Skip to content

Commit

Permalink
Merge pull request #4875 from deusmax/FXC-ext
Browse files Browse the repository at this point in the history
Replace use of Collections to FXCollections in desktop.
  • Loading branch information
ripcurlx authored Dec 4, 2020
2 parents c782f22 + c7290ee commit 0d6b17f
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ObjectProperty;

import javafx.collections.ObservableList;
import javafx.collections.FXCollections;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

// TODO Copied form OpenJFX, check license issues and way how we integrated it
Expand Down Expand Up @@ -261,7 +263,7 @@ public StaticProgressIndicatorSkin(TxConfidenceIndicator control) {
* CssMetaData of its super classes.
*/
@SuppressWarnings("SameReturnValue")
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
public static ObservableList<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() {
return StyleableProperties.STYLEABLES;
}

Expand Down Expand Up @@ -316,7 +318,7 @@ public Paint getProgressColor() {
* {@inheritDoc}
*/
@Override
public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
public ObservableList<CssMetaData<? extends Styleable, ?>> getCssMetaData() {
return getClassCssMetaData();
}

Expand Down Expand Up @@ -691,7 +693,7 @@ protected void layoutChildren() {
*/
@SuppressWarnings({"deprecation", "unchecked", "ConstantConditions"})
private static class StyleableProperties {
static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES;
static final ObservableList<CssMetaData<? extends Styleable, ?>> STYLEABLES;

private static final CssMetaData<TxConfidenceIndicator, Paint> PROGRESS_COLOR =
new CssMetaData<>(
Expand Down Expand Up @@ -746,7 +748,6 @@ public boolean isSettable(TxConfidenceIndicator node) {
return skin.spinEnabled == null || !skin.spinEnabled.isBound();
}


@Override
public StyleableProperty<Boolean> getStyleableProperty(TxConfidenceIndicator node) {
final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) node.getSkin();
Expand All @@ -755,13 +756,12 @@ public StyleableProperty<Boolean> getStyleableProperty(TxConfidenceIndicator nod
};

static {
final List<CssMetaData<? extends Styleable, ?>> styleables =
new ArrayList<>(SkinBase.getClassCssMetaData());
final ObservableList<CssMetaData<? extends Styleable, ?>> styleables =
FXCollections.observableArrayList(SkinBase.getClassCssMetaData());
styleables.add(PROGRESS_COLOR);
styleables.add(INDETERMINATE_SEGMENT_COUNT);
styleables.add(SPIN_ENABLED);
STYLEABLES = Collections.unmodifiableList(styleables);
STYLEABLES = FXCollections.unmodifiableObservableList(styleables);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
import javafx.util.Callback;
import javafx.util.StringConverter;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
Expand Down Expand Up @@ -668,12 +667,12 @@ public void updateItem(final OfferListItem newItem, boolean empty) {
private void reverseTableColumns() {
ObservableList<TableColumn<OfferListItem, ?>> columns = FXCollections.observableArrayList(buyOfferTableView.getColumns());
buyOfferTableView.getColumns().clear();
Collections.reverse(columns);
FXCollections.reverse(columns);
buyOfferTableView.getColumns().addAll(columns);

columns = FXCollections.observableArrayList(sellOfferTableView.getColumns());
sellOfferTableView.getColumns().clear();
Collections.reverse(columns);
FXCollections.reverse(columns);
sellOfferTableView.getColumns().addAll(columns);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import java.time.temporal.ChronoUnit;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
Expand Down Expand Up @@ -292,7 +291,7 @@ CandleData getCandleData(long tick, Set<TradeStatistics3> set) {
long accumulatedVolume = 0;
long accumulatedAmount = 0;
long numTrades = set.size();
List<Long> tradePrices = new ArrayList<>(set.size());
ObservableList<Long> tradePrices = FXCollections.observableArrayList();

for (TradeStatistics3 item : set) {
long tradePriceAsLong = item.getTradePrice().getValue();
Expand All @@ -304,13 +303,14 @@ CandleData getCandleData(long tick, Set<TradeStatistics3> set) {
accumulatedAmount += item.getTradeAmount().getValue();
tradePrices.add(item.getTradePrice().getValue());
}
Collections.sort(tradePrices);
FXCollections.sort(tradePrices);

List<TradeStatistics3> list = new ArrayList<>(set);
list.sort(Comparator.comparingLong(TradeStatistics3::getDateAsLong));
if (list.size() > 0) {
open = list.get(0).getTradePrice().getValue();
close = list.get(list.size() - 1).getTradePrice().getValue();
ObservableList<TradeStatistics3> obsList = FXCollections.observableArrayList(list);
obsList.sort(Comparator.comparingLong(TradeStatistics3::getDateAsLong));
if (obsList.size() > 0) {
open = obsList.get(0).getTradePrice().getValue();
close = obsList.get(obsList.size() - 1).getTradePrice().getValue();
}

long averagePrice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

import org.apache.commons.lang3.StringUtils;

import javafx.collections.FXCollections;

import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
Expand All @@ -50,7 +52,6 @@
import javafx.geometry.Insets;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -294,7 +295,7 @@ private void setupFieldFromPaymentAccountFiltersList(InputTextField field, List<

private List<String> readAsList(InputTextField field) {
if (field.getText().isEmpty()) {
return Collections.emptyList();
return FXCollections.emptyObservableList();
} else {
return Arrays.asList(StringUtils.deleteWhitespace(field.getText()).split(","));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -416,9 +415,9 @@ public TradeCurrency fromString(String string) {
});

preferredTradeCurrencyComboBox.setButtonCell(GUIUtil.getTradeCurrencyButtonCell("", "",
Collections.emptyMap()));
FXCollections.emptyObservableMap()));
preferredTradeCurrencyComboBox.setCellFactory(GUIUtil.getTradeCurrencyCellFactory("", "",
Collections.emptyMap()));
FXCollections.emptyObservableMap()));

Tuple3<Label, ListView<FiatCurrency>, VBox> fiatTuple = addTopLabelListView(root, displayCurrenciesGridRowIndex,
Res.get("setting.preferences.displayFiat"));
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/main/java/bisq/desktop/util/AxisInlierUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.collections.FXCollections;

import java.util.Collections;
import java.util.DoubleSummaryStatistics;
import java.util.List;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -171,7 +171,7 @@ private static List<Double> trim(double percentToTrim, List<Double> numbers) {
return numbers;
}
if (totalPercentTrim == 100) {
return Collections.emptyList();
return FXCollections.emptyObservableList();
}

if (numbers.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import com.google.common.collect.Sets;

import javafx.collections.FXCollections;

import java.util.Collections;
import java.util.Set;

Expand Down Expand Up @@ -61,7 +63,7 @@ public void testUpdateWhenRepositoryIsEmpty() {
.thenReturn(Collections.singleton(mock(Transaction.class)));

TradableRepository tradableRepository = mock(TradableRepository.class);
when(tradableRepository.getAll()).thenReturn(Collections.emptySet());
when(tradableRepository.getAll()).thenReturn(FXCollections.emptyObservableSet());

TransactionListItemFactory transactionListItemFactory = mock(TransactionListItemFactory.class);

Expand Down
Loading

0 comments on commit 0d6b17f

Please sign in to comment.