use of javafx.beans.value.ChangeListener in project bitsquare by bitsquare.
the class TraderDisputeView method onSelectDispute.
private void onSelectDispute(Dispute dispute) {
removeListenersOnSelectDispute();
if (dispute == null) {
if (root.getChildren().size() > 2)
root.getChildren().remove(2);
selectedDispute = null;
} else if (selectedDispute != dispute) {
this.selectedDispute = dispute;
boolean isTrader = disputeManager.isTrader(selectedDispute);
tableGroupHeadline = new TableGroupHeadline();
tableGroupHeadline.setText("Messages");
AnchorPane.setTopAnchor(tableGroupHeadline, 10d);
AnchorPane.setRightAnchor(tableGroupHeadline, 0d);
AnchorPane.setBottomAnchor(tableGroupHeadline, 0d);
AnchorPane.setLeftAnchor(tableGroupHeadline, 0d);
disputeCommunicationMessages = selectedDispute.getDisputeCommunicationMessagesAsObservableList();
SortedList<DisputeCommunicationMessage> sortedList = new SortedList<>(disputeCommunicationMessages);
sortedList.setComparator((o1, o2) -> o1.getDate().compareTo(o2.getDate()));
messageListView = new ListView<>(sortedList);
messageListView.setId("message-list-view");
messageListView.setMinHeight(150);
AnchorPane.setTopAnchor(messageListView, 30d);
AnchorPane.setRightAnchor(messageListView, 0d);
AnchorPane.setLeftAnchor(messageListView, 0d);
messagesAnchorPane = new AnchorPane();
VBox.setVgrow(messagesAnchorPane, Priority.ALWAYS);
inputTextArea = new TextArea();
inputTextArea.setPrefHeight(70);
inputTextArea.setWrapText(true);
sendButton = new Button("Send");
sendButton.setDefaultButton(true);
sendButton.setOnAction(e -> {
if (p2PService.isBootstrapped()) {
String text = inputTextArea.getText();
if (!text.isEmpty())
onSendMessage(text, selectedDispute);
} else {
new Popup().information("You need to wait until you are fully connected to the network.\n" + "That might take up to about 2 minutes at startup.").show();
}
});
inputTextAreaTextSubscription = EasyBind.subscribe(inputTextArea.textProperty(), t -> sendButton.setDisable(t.isEmpty()));
Button uploadButton = new Button("Add attachments");
uploadButton.setOnAction(e -> onRequestUpload());
sendMsgInfoLabel = new Label();
sendMsgInfoLabel.setVisible(false);
sendMsgInfoLabel.setManaged(false);
sendMsgInfoLabel.setPadding(new Insets(5, 0, 0, 0));
sendMsgBusyAnimation = new BusyAnimation(false);
if (!selectedDispute.isClosed()) {
HBox buttonBox = new HBox();
buttonBox.setSpacing(10);
buttonBox.getChildren().addAll(sendButton, uploadButton, sendMsgBusyAnimation, sendMsgInfoLabel);
if (!isTrader) {
Button closeDisputeButton = new Button("Close ticket");
closeDisputeButton.setOnAction(e -> onCloseDispute(selectedDispute));
closeDisputeButton.setDefaultButton(true);
Pane spacer = new Pane();
HBox.setHgrow(spacer, Priority.ALWAYS);
buttonBox.getChildren().addAll(spacer, closeDisputeButton);
}
messagesInputBox = new VBox();
messagesInputBox.setSpacing(10);
messagesInputBox.getChildren().addAll(inputTextArea, buttonBox);
VBox.setVgrow(buttonBox, Priority.ALWAYS);
AnchorPane.setRightAnchor(messagesInputBox, 0d);
AnchorPane.setBottomAnchor(messagesInputBox, 5d);
AnchorPane.setLeftAnchor(messagesInputBox, 0d);
AnchorPane.setBottomAnchor(messageListView, 120d);
messagesAnchorPane.getChildren().addAll(tableGroupHeadline, messageListView, messagesInputBox);
} else {
AnchorPane.setBottomAnchor(messageListView, 0d);
messagesAnchorPane.getChildren().addAll(tableGroupHeadline, messageListView);
}
messageListView.setCellFactory(new Callback<ListView<DisputeCommunicationMessage>, ListCell<DisputeCommunicationMessage>>() {
@Override
public ListCell<DisputeCommunicationMessage> call(ListView<DisputeCommunicationMessage> list) {
return new ListCell<DisputeCommunicationMessage>() {
public ChangeListener<Boolean> sendMsgBusyAnimationListener;
final Pane bg = new Pane();
final ImageView arrow = new ImageView();
final Label headerLabel = new Label();
final Label messageLabel = new Label();
final Label copyIcon = new Label();
final HBox attachmentsBox = new HBox();
final AnchorPane messageAnchorPane = new AnchorPane();
final Label statusIcon = new Label();
final double arrowWidth = 15d;
final double attachmentsBoxHeight = 20d;
final double border = 10d;
final double bottomBorder = 25d;
final double padding = border + 10d;
final double msgLabelPaddingRight = padding + 20d;
{
bg.setMinHeight(30);
messageLabel.setWrapText(true);
headerLabel.setTextAlignment(TextAlignment.CENTER);
attachmentsBox.setSpacing(5);
statusIcon.setStyle("-fx-font-size: 10;");
Tooltip.install(copyIcon, new Tooltip("Copy to clipboard"));
messageAnchorPane.getChildren().addAll(bg, arrow, headerLabel, messageLabel, copyIcon, attachmentsBox, statusIcon);
}
@Override
public void updateItem(final DisputeCommunicationMessage item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
copyIcon.setOnMouseClicked(e -> Utilities.copyToClipboard(messageLabel.getText()));
/* messageAnchorPane.prefWidthProperty().bind(EasyBind.map(messageListView.widthProperty(),
w -> (double) w - padding - GUIUtil.getScrollbarWidth(messageListView)));*/
if (!messageAnchorPane.prefWidthProperty().isBound())
messageAnchorPane.prefWidthProperty().bind(messageListView.widthProperty().subtract(padding + GUIUtil.getScrollbarWidth(messageListView)));
AnchorPane.setTopAnchor(bg, 15d);
AnchorPane.setBottomAnchor(bg, bottomBorder);
AnchorPane.setTopAnchor(headerLabel, 0d);
AnchorPane.setBottomAnchor(arrow, bottomBorder + 5d);
AnchorPane.setTopAnchor(messageLabel, 25d);
AnchorPane.setTopAnchor(copyIcon, 25d);
AnchorPane.setBottomAnchor(attachmentsBox, bottomBorder + 10);
boolean senderIsTrader = item.isSenderIsTrader();
boolean isMyMsg = isTrader ? senderIsTrader : !senderIsTrader;
arrow.setVisible(!item.isSystemMessage());
arrow.setManaged(!item.isSystemMessage());
statusIcon.setVisible(false);
if (item.isSystemMessage()) {
headerLabel.setStyle("-fx-text-fill: -bs-green; -fx-font-size: 11;");
bg.setId("message-bubble-green");
messageLabel.setStyle("-fx-text-fill: white;");
copyIcon.setStyle("-fx-text-fill: white;");
} else if (isMyMsg) {
headerLabel.setStyle("-fx-text-fill: -fx-accent; -fx-font-size: 11;");
bg.setId("message-bubble-blue");
messageLabel.setStyle("-fx-text-fill: white;");
copyIcon.setStyle("-fx-text-fill: white;");
if (isTrader)
arrow.setId("bubble_arrow_blue_left");
else
arrow.setId("bubble_arrow_blue_right");
if (sendMsgBusyAnimationListener != null)
sendMsgBusyAnimation.isRunningProperty().removeListener(sendMsgBusyAnimationListener);
sendMsgBusyAnimationListener = (observable, oldValue, newValue) -> {
if (!newValue) {
if (item.arrivedProperty().get())
showArrivedIcon();
else if (item.storedInMailboxProperty().get())
showMailboxIcon();
}
};
sendMsgBusyAnimation.isRunningProperty().addListener(sendMsgBusyAnimationListener);
if (item.arrivedProperty().get())
showArrivedIcon();
else if (item.storedInMailboxProperty().get())
showMailboxIcon();
//TODO show that icon on error
/*else if (sendMsgProgressIndicator.getProgress() == 0)
showNotArrivedIcon();*/
} else {
headerLabel.setStyle("-fx-text-fill: -bs-light-grey; -fx-font-size: 11;");
bg.setId("message-bubble-grey");
messageLabel.setStyle("-fx-text-fill: black;");
copyIcon.setStyle("-fx-text-fill: black;");
if (isTrader)
arrow.setId("bubble_arrow_grey_right");
else
arrow.setId("bubble_arrow_grey_left");
}
if (item.isSystemMessage()) {
AnchorPane.setLeftAnchor(headerLabel, padding);
AnchorPane.setRightAnchor(headerLabel, padding);
AnchorPane.setLeftAnchor(bg, border);
AnchorPane.setRightAnchor(bg, border);
AnchorPane.setLeftAnchor(messageLabel, padding);
AnchorPane.setRightAnchor(messageLabel, msgLabelPaddingRight);
AnchorPane.setRightAnchor(copyIcon, padding);
AnchorPane.setLeftAnchor(attachmentsBox, padding);
AnchorPane.setRightAnchor(attachmentsBox, padding);
} else if (senderIsTrader) {
AnchorPane.setLeftAnchor(headerLabel, padding + arrowWidth);
AnchorPane.setLeftAnchor(bg, border + arrowWidth);
AnchorPane.setRightAnchor(bg, border);
AnchorPane.setLeftAnchor(arrow, border);
AnchorPane.setLeftAnchor(messageLabel, padding + arrowWidth);
AnchorPane.setRightAnchor(messageLabel, msgLabelPaddingRight);
AnchorPane.setRightAnchor(copyIcon, padding);
AnchorPane.setLeftAnchor(attachmentsBox, padding + arrowWidth);
AnchorPane.setRightAnchor(attachmentsBox, padding);
AnchorPane.setRightAnchor(statusIcon, padding);
} else {
AnchorPane.setRightAnchor(headerLabel, padding + arrowWidth);
AnchorPane.setLeftAnchor(bg, border);
AnchorPane.setRightAnchor(bg, border + arrowWidth);
AnchorPane.setRightAnchor(arrow, border);
AnchorPane.setLeftAnchor(messageLabel, padding);
AnchorPane.setRightAnchor(messageLabel, msgLabelPaddingRight + arrowWidth);
AnchorPane.setRightAnchor(copyIcon, padding + arrowWidth);
AnchorPane.setLeftAnchor(attachmentsBox, padding);
AnchorPane.setRightAnchor(attachmentsBox, padding + arrowWidth);
AnchorPane.setLeftAnchor(statusIcon, padding);
}
AnchorPane.setBottomAnchor(statusIcon, 7d);
headerLabel.setText(formatter.formatDateTime(item.getDate()));
messageLabel.setText(item.getMessage());
attachmentsBox.getChildren().clear();
if (item.getAttachments().size() > 0) {
AnchorPane.setBottomAnchor(messageLabel, bottomBorder + attachmentsBoxHeight + 10);
attachmentsBox.getChildren().add(new Label("Attachments: ") {
{
setPadding(new Insets(0, 0, 3, 0));
if (isMyMsg)
setStyle("-fx-text-fill: white;");
else
setStyle("-fx-text-fill: black;");
}
});
item.getAttachments().stream().forEach(attachment -> {
final Label icon = new Label();
setPadding(new Insets(0, 0, 3, 0));
if (isMyMsg)
icon.getStyleClass().add("attachment-icon");
else
icon.getStyleClass().add("attachment-icon-black");
AwesomeDude.setIcon(icon, AwesomeIcon.FILE_TEXT);
icon.setPadding(new Insets(-2, 0, 0, 0));
icon.setTooltip(new Tooltip(attachment.getFileName()));
icon.setOnMouseClicked(event -> onOpenAttachment(attachment));
attachmentsBox.getChildren().add(icon);
});
} else {
AnchorPane.setBottomAnchor(messageLabel, bottomBorder + 10);
}
// Need to set it here otherwise style is not correct
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY, "16.0");
copyIcon.getStyleClass().add("copy-icon-disputes");
// TODO There are still some cell rendering issues on updates
setGraphic(messageAnchorPane);
} else {
if (sendMsgBusyAnimation != null && sendMsgBusyAnimationListener != null)
sendMsgBusyAnimation.isRunningProperty().removeListener(sendMsgBusyAnimationListener);
messageAnchorPane.prefWidthProperty().unbind();
AnchorPane.clearConstraints(bg);
AnchorPane.clearConstraints(headerLabel);
AnchorPane.clearConstraints(arrow);
AnchorPane.clearConstraints(messageLabel);
AnchorPane.clearConstraints(copyIcon);
AnchorPane.clearConstraints(statusIcon);
AnchorPane.clearConstraints(attachmentsBox);
copyIcon.setOnMouseClicked(null);
setGraphic(null);
}
}
/* private void showNotArrivedIcon() {
statusIcon.setVisible(true);
AwesomeDude.setIcon(statusIcon, AwesomeIcon.WARNING_SIGN, "14");
Tooltip.install(statusIcon, new Tooltip("Message did not arrive. Please try to send again."));
statusIcon.setTextFill(Paint.valueOf("#dd0000"));
}*/
private void showMailboxIcon() {
statusIcon.setVisible(true);
AwesomeDude.setIcon(statusIcon, AwesomeIcon.ENVELOPE_ALT, "14");
Tooltip.install(statusIcon, new Tooltip("Message saved in receiver's mailbox"));
statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
}
private void showArrivedIcon() {
statusIcon.setVisible(true);
AwesomeDude.setIcon(statusIcon, AwesomeIcon.OK, "14");
Tooltip.install(statusIcon, new Tooltip("Message arrived at receiver"));
statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
}
};
}
});
if (root.getChildren().size() > 2)
root.getChildren().remove(2);
root.getChildren().add(2, messagesAnchorPane);
scrollToBottom();
}
addListenersOnSelectDispute();
}
use of javafx.beans.value.ChangeListener in project bitsquare by bitsquare.
the class TraderDisputeView method getStateColumn.
private TableColumn<Dispute, Dispute> getStateColumn() {
TableColumn<Dispute, Dispute> column = new TableColumn<Dispute, Dispute>("State") {
{
setMinWidth(50);
}
};
column.setCellValueFactory((dispute) -> new ReadOnlyObjectWrapper<>(dispute.getValue()));
column.setCellFactory(new Callback<TableColumn<Dispute, Dispute>, TableCell<Dispute, Dispute>>() {
@Override
public TableCell<Dispute, Dispute> call(TableColumn<Dispute, Dispute> column) {
return new TableCell<Dispute, Dispute>() {
public ReadOnlyBooleanProperty closedProperty;
public ChangeListener<Boolean> listener;
@Override
public void updateItem(final Dispute item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
listener = (observable, oldValue, newValue) -> {
setText(newValue ? "Closed" : "Open");
getTableRow().setOpacity(newValue ? 0.4 : 1);
};
closedProperty = item.isClosedProperty();
closedProperty.addListener(listener);
boolean isClosed = item.isClosed();
setText(isClosed ? "Closed" : "Open");
getTableRow().setOpacity(isClosed ? 0.4 : 1);
} else {
if (closedProperty != null) {
closedProperty.removeListener(listener);
closedProperty = null;
}
setText("");
}
}
};
}
});
return column;
}
use of javafx.beans.value.ChangeListener in project bitsquare by bitsquare.
the class OfferBookChartView method activate.
@Override
protected void activate() {
// root.getParent() is null at initialize
tabPaneSelectionModel = GUIUtil.getParentOfType(root, TabPane.class).getSelectionModel();
selectedTabIndexListener = (observable, oldValue, newValue) -> model.setSelectedTabIndex((int) newValue);
model.setSelectedTabIndex(tabPaneSelectionModel.getSelectedIndex());
tabPaneSelectionModel.selectedIndexProperty().addListener(selectedTabIndexListener);
currencyComboBox.setItems(model.getCurrencyListItems());
currencyComboBox.setVisibleRowCount(25);
if (model.getSelectedCurrencyListItem().isPresent())
currencyComboBox.getSelectionModel().select(model.getSelectedCurrencyListItem().get());
currencyComboBox.setOnAction(e -> {
CurrencyListItem selectedItem = currencyComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
model.onSetTradeCurrency(selectedItem.tradeCurrency);
updateChartData();
}
});
model.currencyListItems.addListener(currencyListItemsListener);
model.getOfferBookListItems().addListener(changeListener);
tradeCurrencySubscriber = EasyBind.subscribe(model.selectedTradeCurrencyProperty, tradeCurrency -> {
String code = tradeCurrency.getCode();
areaChart.setTitle("Offer book for " + formatter.getCurrencyNameAndCurrencyPair(code));
volumeColumnLabel.set("Amount in " + code);
xAxis.setTickLabelFormatter(new StringConverter<Number>() {
@Override
public String toString(Number object) {
final double doubleValue = (double) object;
if (CurrencyUtil.isCryptoCurrency(model.getCurrencyCode())) {
final String withPrecision3 = formatter.formatRoundedDoubleWithPrecision(doubleValue, 3);
if (withPrecision3.equals("0.000"))
return formatter.formatRoundedDoubleWithPrecision(doubleValue, 8);
else
return withPrecision3;
} else {
return formatter.formatRoundedDoubleWithPrecision(doubleValue, 2);
}
}
@Override
public Number fromString(String string) {
return null;
}
});
if (CurrencyUtil.isCryptoCurrency(code)) {
if (bottomHBox.getChildren().size() == 2 && bottomHBox.getChildren().get(0).getUserData().equals("BUY")) {
bottomHBox.getChildren().get(0).toFront();
reverseTableColumns();
}
buyOfferHeaderLabel.setText("Offers to sell " + code + " for BTC");
buyOfferButton.setText("I want to buy " + code + " (sell BTC)");
sellOfferHeaderLabel.setText("Offers to buy " + code + " with BTC");
sellOfferButton.setText("I want to sell " + code + " (buy BTC)");
priceColumnLabel.set("Price in BTC");
} else {
if (bottomHBox.getChildren().size() == 2 && bottomHBox.getChildren().get(0).getUserData().equals("SELL")) {
bottomHBox.getChildren().get(0).toFront();
reverseTableColumns();
}
buyOfferHeaderLabel.setText("Offers to buy BTC with " + code);
buyOfferButton.setText("I want to sell BTC for " + code);
sellOfferHeaderLabel.setText("Offers to sell BTC for " + code);
sellOfferButton.setText("I want to buy BTC with " + code);
priceColumnLabel.set("Price in " + code);
}
xAxis.setLabel(formatter.getPriceWithCurrencyCode(code));
seriesBuy.setName(buyOfferHeaderLabel.getText() + " ");
seriesSell.setName(sellOfferHeaderLabel.getText());
});
buyOfferTableView.setItems(model.getTopBuyOfferList());
sellOfferTableView.setItems(model.getTopSellOfferList());
buyTableRowSelectionListener = (observable, oldValue, newValue) -> {
model.preferences.setSellScreenCurrencyCode(model.getCurrencyCode());
navigation.navigateTo(MainView.class, SellOfferView.class);
};
sellTableRowSelectionListener = (observable, oldValue, newValue) -> {
model.preferences.setBuyScreenCurrencyCode(model.getCurrencyCode());
navigation.navigateTo(MainView.class, BuyOfferView.class);
};
buyOfferTableView.getSelectionModel().selectedItemProperty().addListener(buyTableRowSelectionListener);
sellOfferTableView.getSelectionModel().selectedItemProperty().addListener(sellTableRowSelectionListener);
updateChartData();
}
use of javafx.beans.value.ChangeListener in project jgnash by ccavanaugh.
the class ReconcileDialogController method configureTableView.
private void configureTableView(final TableView<RecTransaction> tableView, final TableViewManager<RecTransaction> tableViewManager) {
tableView.setTableMenuButtonVisible(false);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
final TableColumn<RecTransaction, String> reconciledColumn = new TableColumn<>(resources.getString("Column.Clr"));
reconciledColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getReconciledState().toString()));
tableView.getColumns().add(reconciledColumn);
final TableColumn<RecTransaction, LocalDate> dateColumn = new TableColumn<>(resources.getString("Column.Date"));
dateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDate()));
dateColumn.setCellFactory(param -> new ShortDateTableCell<>());
tableView.getColumns().add(dateColumn);
final TableColumn<RecTransaction, String> numberColumn = new TableColumn<>(resources.getString("Column.Num"));
numberColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getNumber()));
tableView.getColumns().add(numberColumn);
final TableColumn<RecTransaction, String> payeeColumn = new TableColumn<>(resources.getString("Column.Payee"));
payeeColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getPayee()));
tableView.getColumns().add(payeeColumn);
final TableColumn<RecTransaction, BigDecimal> amountColumn = new TableColumn<>(resources.getString("Column.Amount"));
amountColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(AccountBalanceDisplayManager.convertToSelectedBalanceMode(account.getAccountType(), param.getValue().getAmount(account))));
amountColumn.setCellFactory(param -> new BigDecimalTableCell<>(CommodityFormat.getShortNumberFormat(account.getCurrencyNode())));
tableView.getColumns().add(amountColumn);
// hide the horizontal scrollbar
tableView.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS);
tableViewManager.setColumnFormatFactory(param -> {
if (param == amountColumn && account != null) {
return CommodityFormat.getShortNumberFormat(account.getCurrencyNode());
}
return null;
});
final ChangeListener<Number> widthListener = new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if (newValue != null && newValue.doubleValue() > 0) {
JavaFXUtils.runLater(tableViewManager::restoreLayout);
JavaFXUtils.runLater(tableViewManager::packTable);
tableView.widthProperty().removeListener(this);
}
}
};
tableView.widthProperty().addListener(widthListener);
}
use of javafx.beans.value.ChangeListener in project trex-stateless-gui by cisco-system-traffic-generator.
the class MainViewController method initializeInlineComponent.
/**
* Initialize in-line built component
*/
private void initializeInlineComponent() {
updateBtn.setGraphic(new ImageView(new Image("/icons/apply.png")));
newProfileBtn.setGraphic(new ImageView(new Image("/icons/add_profile.png")));
stopUpdateBtn.setGraphic(new ImageView(new Image("/icons/stop_update.png")));
devicesTreeArrowContainer.setImage(leftArrow);
// mapped profiles enabling with property
profileListBox.disableProperty().bind(disableProfileProperty);
newProfileBtn.disableProperty().bind(disableProfileProperty);
profileDetailLabel.disableProperty().bind(disableProfileProperty);
profileListBox.getItems().clear();
profileListBox.setItems(FXCollections.observableArrayList(getProfilesNameList()));
profileListBox.valueProperty().addListener(new UpdateProfileListener<>(profileListBox.getSelectionModel()));
updateProfileListProperty.bind(ProfileManager.getInstance().getUpdatedProperty());
updateProfileListProperty.addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
List<String> profiles = getProfilesNameList();
profileListBox.setItems(FXCollections.observableArrayList(profiles));
if (!profiles.contains(currentSelectedProfile)) {
tableView.reset();
profileDetailContainer.setVisible(false);
}
});
tableView = new PacketTableView(230, this, true);
profileTableViewContainer.getChildren().add(tableView);
serverStatusIcon.setImage(new Image("/icons/offline.png"));
// initialize right click menu
rightClickPortMenu = new ContextMenu();
addMenuItem(rightClickPortMenu, "Acquire", ContextMenuClickType.ACQUIRE, false);
addMenuItem(rightClickPortMenu, "Force Acquire", ContextMenuClickType.FORCE_ACQUIRE, false);
addMenuItem(rightClickPortMenu, "Release Acquire", ContextMenuClickType.RELEASE_ACQUIRE, false);
rightClickProfileMenu = new ContextMenu();
addMenuItem(rightClickProfileMenu, "Play", ContextMenuClickType.PLAY, false);
addMenuItem(rightClickProfileMenu, "Pause", ContextMenuClickType.PAUSE, false);
addMenuItem(rightClickProfileMenu, "Stop", ContextMenuClickType.STOP, false);
rightClickGlobalMenu = new ContextMenu();
addMenuItem(rightClickGlobalMenu, "Release All Ports", ContextMenuClickType.RELEASE_ALL, false);
addMenuItem(rightClickGlobalMenu, "Acquire All Ports", ContextMenuClickType.ACQUIRE_ALL, false);
addMenuItem(rightClickGlobalMenu, "Force Acquire All Ports", ContextMenuClickType.FORCE_ACQUIRE_ALL, false);
addMenuItem(rightClickGlobalMenu, "Re-Acquire my Ports", ContextMenuClickType.ACQUIRE_MY_PORT, false);
// initialize multiplexer
multiplierView = new MultiplierView(this);
multiplierOptionContainer.getChildren().add(multiplierView);
notificationPanel = new NotificationPanel();
notificationPanel.setNotificationMsg(DISABLED_MULTIPLIER_MSG);
notificationPanelHolder.getChildren().add(notificationPanel);
// add close
TrexApp.getPrimaryStage().setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
// handle aplpication close
DialogManager.getInstance().closeAll();
handleAppClose();
}
});
TrexApp.getPrimaryStage().setOnShown(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
TrexApp.getPrimaryStage().focusedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
if (newValue && tableView.isStreamEditingWindowOpen()) {
tableView.setStreamEditingWindowOpen(false);
streamTableUpdated();
}
});
}
});
TrexApp.getPrimaryStage().setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
System.exit(0);
}
});
logContainer.getChildren().add(LogsController.getInstance().getView());
consoleLogContainer.getChildren().add(LogsController.getInstance().getConsoleLogView());
// initialize countdown service
countdownService = new CountdownService();
countdownService.setPeriod(Duration.seconds(Constants.REFRESH_ONE_INTERVAL_SECONDS));
countdownService.setRestartOnFailure(false);
countdownService.setOnSucceeded((WorkerStateEvent event) -> {
int count = (int) event.getSource().getValue();
countdownValue.setText(String.valueOf(count) + " Sec");
if (count == 0) {
doUpdateAssignedProfile(getSelectedPortIndex());
}
});
devicesTree.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
handleTreeItemSelectionChanged();
}
});
}
Aggregations