use of javafx.beans.value.ChangeListener in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketTableView method buildUI.
/**
* Build component UI
*/
private void buildUI(boolean addExportToYamlBtn) {
setTopAnchor(this, 0d);
setLeftAnchor(this, 0d);
setBottomAnchor(this, 0d);
setRightAnchor(this, 0d);
// build btn bar
HBox buttonContainer = new HBox();
buttonContainer.setSpacing(5);
// add build stream btn
buildPacketBtn = new StreamTableButton(StreamTableAction.BUILD);
buildPacketBtn.setId("buildStreamBtn");
initializeStreamButtons(buildPacketBtn, false);
buttonContainer.getChildren().add(buildPacketBtn);
editPacketBtn = new StreamTableButton(StreamTableAction.EDIT);
editPacketBtn.setId("editStreanBtn");
initializeStreamButtons(editPacketBtn, true);
buttonContainer.getChildren().add(editPacketBtn);
deleteButtonBtn = new StreamTableButton(StreamTableAction.DELETE);
initializeStreamButtons(deleteButtonBtn, true);
buttonContainer.getChildren().add(deleteButtonBtn);
importPcapButton = new StreamTableButton(StreamTableAction.IMPORT_PCAP);
initializeStreamButtons(importPcapButton, false);
buttonContainer.getChildren().add(importPcapButton);
exportPcapButton = new StreamTableButton(StreamTableAction.EXPORT_TO_PCAP);
initializeStreamButtons(exportPcapButton, true);
buttonContainer.getChildren().add(exportPcapButton);
if (addExportToYamlBtn) {
exportToYaml = new StreamTableButton(StreamTableAction.EXPORT_TO_YAML);
initializeStreamButtons(exportToYaml, false);
buttonContainer.getChildren().add(exportToYaml);
}
getChildren().add(buttonContainer);
setTopAnchor(buttonContainer, 5d);
rightClickMenu = new ContextMenu();
addMenuItem(StreamTableAction.EDIT);
addMenuItem(StreamTableAction.DELETE);
addMenuItem(StreamTableAction.EXPORT_TO_PCAP);
addMenuItem(StreamTableAction.EXPORT_TO_YAML);
// add table view
streamPacketTableView = new TableView<>();
streamPacketTableView.setId("streamTableView");
streamPacketTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
streamPacketTableView.setFixedCellSize(32);
streamPacketTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
streamPacketTableView.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
handleTableRowClick(event);
}
});
streamPacketTableView.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends TableProfileStream> observable, TableProfileStream oldValue, TableProfileStream newValue) -> {
boolean notSelected = !(newValue != null);
exportPcapButton.setDisable(notSelected);
editPacketBtn.setDisable(notSelected);
deleteButtonBtn.setDisable(notSelected);
});
streamPacketTableView.addEventFilter(KeyEvent.KEY_RELEASED, (KeyEvent event) -> {
if (copyCombination.match(event)) {
selectedProfile = tabledata.getProfiles().get(streamPacketTableView.getSelectionModel().getSelectedIndex());
} else if (pasteCombination.match(event)) {
handleDuplicateStream();
} else if (event.getCode() == KeyCode.DELETE) {
handleDeletePacket();
}
});
streamPacketTableView.setEditable(true);
initializeTableColumn();
// disable table reordering
streamPacketTableView.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> source, Number oldWidth, Number newWidth) {
TableHeaderRow header = (TableHeaderRow) streamPacketTableView.lookup("TableHeaderRow");
header.reorderingProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
header.setReordering(false);
}
});
}
});
getChildren().add(streamPacketTableView);
setTopAnchor(streamPacketTableView, 35d);
setBottomAnchor(streamPacketTableView, 5d);
setLeftAnchor(streamPacketTableView, 0d);
setRightAnchor(streamPacketTableView, 0d);
}
use of javafx.beans.value.ChangeListener in project Smartcity-Smarthouse by TechnionYP5777.
the class MessageViewController method initialize.
@Override
public void initialize(final URL location, final ResourceBundle __) {
mainPane.setAlignment(Pos.TOP_LEFT);
mainPane.setHgap(10);
mainPane.setVgap(10);
mainPane.setPadding(new Insets(0, 25, 25, 0));
sendButton.setOnAction(e -> buildMessage());
switchModeButton.selectedProperty().addListener((ChangeListener<Boolean>) (b, oldValue, newValue) -> {
if (newValue.booleanValue()) {
buildStreamModePane();
mainPane.getChildren().setAll(streamMode.getChildren());
} else {
buildSingleModePane();
mainPane.getChildren().setAll(singleMode.getChildren());
}
});
}
use of javafx.beans.value.ChangeListener in project SmartCity-Market by TechnionYP5777.
the class CustomerMainScreen method initialize.
@Override
public void initialize(URL location, ResourceBundle __) {
AbstractApplicationScreen.fadeTransition(customerMainScreenPane);
barcodeEventHandler.register(this);
customer = TempCustomerPassingData.customer;
filteredProductList = new FilteredList<>(productsObservableList, s -> true);
searchField.textProperty().addListener(obs -> {
String filter = searchField.getText();
filteredProductList.setPredicate((filter == null || filter.length() == 0) ? s -> true : s -> s.getCatalogProduct().getName().contains(filter));
});
productsListView.setItems(filteredProductList);
productsListView.setCellFactory(new Callback<ListView<CartProduct>, ListCell<CartProduct>>() {
@Override
public ListCell<CartProduct> call(ListView<CartProduct> __) {
return new CustomerProductCellFormat();
}
});
productsListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<CartProduct>() {
@Override
public void changed(ObservableValue<? extends CartProduct> __, CartProduct oldValue, CartProduct newValue) {
updateProductInfoPaine(newValue.getCatalogProduct(), newValue.getTotalAmount(), ProductInfoPaneVisibleMode.PRESSED_PRODUCT);
}
});
productsListView.depthProperty().set(1);
productsListView.setExpanded(true);
setAbilityAndVisibilityOfProductInfoPane(false);
}
use of javafx.beans.value.ChangeListener in project bitsquare by bitsquare.
the class MainView method initialize.
@Override
protected void initialize() {
MainView.rootContainer = this.root;
ToggleButton marketButton = new NavButton(MarketView.class, "Market");
ToggleButton buyButton = new NavButton(BuyOfferView.class, "Buy BTC");
ToggleButton sellButton = new NavButton(SellOfferView.class, "Sell BTC");
ToggleButton portfolioButton = new NavButton(PortfolioView.class, "Portfolio");
ToggleButton fundsButton = new NavButton(FundsView.class, "Funds");
ToggleButton disputesButton = new NavButton(DisputesView.class, "Support");
ToggleButton settingsButton = new NavButton(SettingsView.class, "Settings");
ToggleButton accountButton = new NavButton(AccountView.class, "Account");
Pane portfolioButtonHolder = new Pane(portfolioButton);
Pane disputesButtonHolder = new Pane(disputesButton);
HBox leftNavPane = new HBox(marketButton, buyButton, sellButton, portfolioButtonHolder, fundsButton, disputesButtonHolder) {
{
setLeftAnchor(this, 10d);
setTopAnchor(this, 0d);
}
};
Tuple3<ComboBox<PriceFeedComboBoxItem>, Label, VBox> marketPriceBox = getMarketPriceBox("Market price");
ComboBox<PriceFeedComboBoxItem> priceComboBox = marketPriceBox.first;
priceComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
model.setPriceFeedComboBoxItem(newValue);
});
ChangeListener<PriceFeedComboBoxItem> selectedPriceFeedItemListender = (observable, oldValue, newValue) -> {
if (newValue != null)
priceComboBox.getSelectionModel().select(newValue);
};
model.selectedPriceFeedComboBoxItemProperty.addListener(selectedPriceFeedItemListender);
priceComboBox.setItems(model.priceFeedComboBoxItems);
marketPriceBox.second.textProperty().bind(createStringBinding(() -> {
PriceFeedService.Type type = model.typeProperty.get();
return type != null ? "Market price (" + type.name + ")" : "";
}, model.marketPriceCurrencyCode, model.typeProperty));
HBox.setMargin(marketPriceBox.third, new Insets(0, 0, 0, 0));
Tuple2<TextField, VBox> availableBalanceBox = getBalanceBox("Available balance");
availableBalanceBox.first.textProperty().bind(model.availableBalance);
Tuple2<TextField, VBox> reservedBalanceBox = getBalanceBox("Reserved in offers");
reservedBalanceBox.first.textProperty().bind(model.reservedBalance);
Tuple2<TextField, VBox> lockedBalanceBox = getBalanceBox("Locked in trades");
lockedBalanceBox.first.textProperty().bind(model.lockedBalance);
HBox rightNavPane = new HBox(marketPriceBox.third, availableBalanceBox.second, reservedBalanceBox.second, lockedBalanceBox.second, settingsButton, accountButton) {
{
setRightAnchor(this, 10d);
setTopAnchor(this, 0d);
}
};
root.widthProperty().addListener((observable, oldValue, newValue) -> {
double w = (double) newValue;
if (w > 0) {
leftNavPane.setSpacing(w >= 1080 ? 10 : 5);
rightNavPane.setSpacing(w >= 1080 ? 10 : 5);
}
});
AnchorPane contentContainer = new AnchorPane() {
{
setId("content-pane");
setLeftAnchor(this, 0d);
setRightAnchor(this, 0d);
setTopAnchor(this, 60d);
setBottomAnchor(this, 10d);
}
};
AnchorPane applicationContainer = new AnchorPane(leftNavPane, rightNavPane, contentContainer) {
{
setId("content-pane");
}
};
BorderPane baseApplicationContainer = new BorderPane(applicationContainer) {
{
setId("base-content-container");
}
};
baseApplicationContainer.setBottom(createFooter());
setupNotificationIcon(portfolioButtonHolder);
setupDisputesIcon(disputesButtonHolder);
navigation.addListener(viewPath -> {
if (viewPath.size() != 2 || viewPath.indexOf(MainView.class) != 0)
return;
Class<? extends View> viewClass = viewPath.tip();
View view = viewLoader.load(viewClass);
contentContainer.getChildren().setAll(view.getRoot());
navButtons.getToggles().stream().filter(toggle -> toggle instanceof NavButton).filter(button -> viewClass == ((NavButton) button).viewClass).findFirst().orElseThrow(() -> new BitsquareException("No button matching %s found", viewClass)).setSelected(true);
});
VBox splashScreen = createSplashScreen();
root.getChildren().addAll(baseApplicationContainer, splashScreen);
model.showAppScreen.addListener((ov, oldValue, newValue) -> {
if (newValue) {
navigation.navigateToPreviousVisitedView();
if (!persistedFilesCorrupted.isEmpty()) {
if (persistedFilesCorrupted.size() > 1 || !persistedFilesCorrupted.get(0).equals("Navigation")) {
// show warning that some files has been corrupted
new Popup().warning("We detected incompatible data base files!\n\n" + "Those database file(s) are not compatible with our current code base:" + "\n" + persistedFilesCorrupted.toString() + "\n\nWe made a backup of the corrupted file(s) and applied the default values to a new " + "database version." + "\n\nThe backup is located at:\n[you local app data directory]/db/backup_of_corrupted_data.\n\n" + "Please check if you have the latest version of Bitsquare installed.\n" + "You can download it at:\nhttps://github.com/bitsquare/bitsquare/releases\n\n" + "Please restart the application.").closeButtonText("Shut down").onClose(BitsquareApp.shutDownHandler::run).show();
} else {
log.debug("We detected incompatible data base file for Navigation. That is a minor issue happening with refactoring of UI classes " + "and we don't display a warning popup to the user.");
}
}
transitions.fadeOutAndRemove(splashScreen, 1500, actionEvent -> disposeSplashScreen());
}
});
// Delay a bit to give time for rendering the splash screen
UserThread.execute(model::start);
}
use of javafx.beans.value.ChangeListener in project bitsquare by bitsquare.
the class MainViewModel method start.
///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////
public void start() {
// TODO need more though how to improve privacy without annoying first time users.
/* String key = "showAddBitcoinNodesWindowKey";
if (preferences.showAgain(key))
addBitcoinNodesWindow.dontShowAgainId(key, preferences)
.onClose(() -> {
preferences.dontShowAgain(key, true);
initializeAllServices();
})
.onAction(() -> {
preferences.dontShowAgain(key, true);
initializeAllServices();
})
.show();
else
initializeAllServices();
}
private void initializeAllServices() {*/
Log.traceCall();
UserThread.runAfter(tacWindow::showIfNeeded, 2);
ChangeListener<Boolean> walletInitializedListener = (observable, oldValue, newValue) -> {
if (newValue && !p2pNetWorkReady.get())
showStartupTimeoutPopup();
};
Timer startupTimeout = UserThread.runAfter(() -> {
log.warn("startupTimeout called");
Wallet wallet = walletService.getWallet();
if (wallet != null && wallet.isEncrypted())
walletInitialized.addListener(walletInitializedListener);
else
showStartupTimeoutPopup();
}, 4, TimeUnit.MINUTES);
p2pNetWorkReady = initP2PNetwork();
initBitcoinWallet();
// need to store it to not get garbage collected
allServicesDone = EasyBind.combine(walletInitialized, p2pNetWorkReady, (a, b) -> a && b);
allServicesDone.subscribe((observable, oldValue, newValue) -> {
if (newValue) {
startupTimeout.stop();
walletInitialized.removeListener(walletInitializedListener);
onAllServicesInitialized();
if (startupTimeoutPopup != null)
startupTimeoutPopup.hide();
}
});
}
Aggregations