Fill table in bsqTxView after resize window

This commit is contained in:
Manfred Karrer 2017-04-12 12:53:35 -05:00
parent 7312d258f5
commit cd33a623e8
5 changed files with 52 additions and 7 deletions

View file

@ -33,7 +33,10 @@ import io.bisq.gui.main.dao.wallet.BsqBalanceUtil;
import io.bisq.gui.main.overlays.popups.Popup;
import io.bisq.gui.util.BsqFormatter;
import io.bisq.gui.util.GUIUtil;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
@ -41,6 +44,7 @@ import javafx.collections.transformation.SortedList;
import javafx.geometry.Insets;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.util.Callback;
import org.bitcoinj.core.Transaction;
@ -65,6 +69,10 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
private ListChangeListener<Transaction> walletBsqTransactionsListener;
private final ObservableList<BsqTxListItem> observableList = FXCollections.observableArrayList();
private final SortedList<BsqTxListItem> sortedList = new SortedList<>(observableList);
private ChangeListener<Number> parentHeightListener;
private Pane rootParent;
// Need to be DoubleProperty as we pass it as reference
private DoubleProperty initialOccupiedHeight = new SimpleDoubleProperty(-1);
///////////////////////////////////////////////////////////////////////////////////////////
@ -104,6 +112,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
addConfidenceColumn();
walletBsqTransactionsListener = change -> updateList();
parentHeightListener = (observable, oldValue, newValue) -> layout();
}
@Override
@ -115,6 +124,12 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
tableView.setItems(sortedList);
updateList();
if (root.getParent() instanceof Pane) {
rootParent = (Pane) root.getParent();
rootParent.heightProperty().addListener(parentHeightListener);
}
layout();
}
@Override
@ -123,6 +138,8 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
sortedList.comparatorProperty().unbind();
bsqWalletService.getWalletTransactions().removeListener(walletBsqTransactionsListener);
observableList.forEach(BsqTxListItem::cleanup);
if (rootParent != null)
((Pane) root.getParent()).heightProperty().removeListener(parentHeightListener);
}
private void updateList() {
@ -161,6 +178,10 @@ public class BsqTxView extends ActivatableView<GridPane, Void> {
}
}
private void layout() {
GUIUtil.fillAvailableHeight(root, tableView, initialOccupiedHeight);
}
private void addDateColumn() {
TableColumn<BsqTxListItem, BsqTxListItem> column = new TableColumn<>(Res.get("shared.dateTime"));
column.setCellValueFactory(item -> new ReadOnlyObjectWrapper<>(item.getValue()));

View file

@ -93,6 +93,7 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
private Subscription currencySelectionSubscriber;
private HBox toolBox;
private ChangeListener<Number> parentHeightListener;
private Pane rootParent;
///////////////////////////////////////////////////////////////////////////////////////////
@ -219,8 +220,10 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
UserThread.runAfter(this::updateChartData, 100, TimeUnit.MILLISECONDS);
if (root.getParent() instanceof Pane)
((Pane) root.getParent()).heightProperty().addListener(parentHeightListener);
if (root.getParent() instanceof Pane) {
rootParent = (Pane) root.getParent();
rootParent.heightProperty().addListener(parentHeightListener);
}
layout();
}
@ -246,8 +249,8 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
priceSeries.getData().clear();
priceChart.getData().clear();
if (root.getParent() instanceof Pane)
((Pane) root.getParent()).heightProperty().removeListener(parentHeightListener);
if (rootParent != null)
rootParent.heightProperty().removeListener(parentHeightListener);
}

View file

@ -391,7 +391,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
if (paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.CLEAR_X_CHANGE_ID) &&
!clearXchangeWarningDisplayed) {
clearXchangeWarningDisplayed = true;
UserThread.runAfter(() -> GUIUtil.showClearXchangeWarning(preferences),
UserThread.runAfter(() -> GUIUtil.showClearXchangeWarning(),
500, TimeUnit.MILLISECONDS);
}
}

View file

@ -212,7 +212,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
if (model.getPaymentMethod().getId().equals(PaymentMethod.CLEAR_X_CHANGE_ID) &&
!clearXchangeWarningDisplayed) {
clearXchangeWarningDisplayed = true;
UserThread.runAfter(() -> GUIUtil.showClearXchangeWarning(preferences),
UserThread.runAfter(() -> GUIUtil.showClearXchangeWarning(),
500, TimeUnit.MILLISECONDS);
}
}

View file

@ -22,6 +22,7 @@ import com.googlecode.jcsv.CSVStrategy;
import com.googlecode.jcsv.writer.CSVEntryConverter;
import com.googlecode.jcsv.writer.CSVWriter;
import com.googlecode.jcsv.writer.internal.CSVWriterBuilder;
import io.bisq.common.UserThread;
import io.bisq.common.app.DevEnv;
import io.bisq.common.locale.CurrencyUtil;
import io.bisq.common.locale.Res;
@ -34,11 +35,14 @@ import io.bisq.core.user.Preferences;
import io.bisq.core.user.User;
import io.bisq.gui.components.indicator.TxConfidenceIndicator;
import io.bisq.gui.main.overlays.popups.Popup;
import javafx.beans.property.DoubleProperty;
import javafx.collections.ObservableList;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Region;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
@ -58,6 +62,7 @@ import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
public class GUIUtil {
@ -349,7 +354,7 @@ public class GUIUtil {
return parent != null ? (T) parent : null;
}
public static void showClearXchangeWarning(Preferences preferences) {
public static void showClearXchangeWarning() {
String key = "confirmClearXchangeRequirements";
new Popup().information(Res.get("payment.clearXchange.selected") + "\n" + Res.get("payment.clearXchange.info"))
.width(900)
@ -357,4 +362,20 @@ public class GUIUtil {
.dontShowAgainId(key)
.show();
}
public static void fillAvailableHeight(Pane container, Region component, DoubleProperty initialOccupiedHeight) {
UserThread.runAfter(() -> {
double available;
if (container.getParent() instanceof Pane)
available = ((Pane) container.getParent()).getHeight();
else
available = container.getHeight();
if (initialOccupiedHeight.get() == -1 && component.getHeight() > 0) {
initialOccupiedHeight.set(available - component.getHeight());
}
component.setPrefHeight(available - initialOccupiedHeight.get());
}, 100, TimeUnit.MILLISECONDS);
}
}