use of com.exalttech.trex.ui.views.services.CountdownService 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")));
duplicateProfileBtn.setGraphic(new ImageView(new Image("/icons/clone_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);
duplicateProfileBtn.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);
addMenuItem(rightClickPortMenu, "Enable Service Mode", ContextMenuClickType.ENABLE_SERVICE, false);
addMenuItem(rightClickPortMenu, "Disable Service Mode", ContextMenuClickType.DISABLE_SERVICE, 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());
// 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();
}
});
devicesTree.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
@Override
public void changed(ObservableValue observable, Object oldValue, Object newValue) {
handleTreeItemSelectionChanged();
}
});
}
Aggregations