use of javafx.beans.value.ObservableValue 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);
duplicatePacketBtn = new StreamTableButton(StreamTableAction.DUPLICATE);
initializeStreamButtons(duplicatePacketBtn, true);
buttonContainer.getChildren().add(duplicatePacketBtn);
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.DUPLICATE);
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);
duplicatePacketBtn.setDisable(notSelected);
deleteButtonBtn.setDisable(notSelected);
});
streamPacketTableView.addEventFilter(KeyEvent.KEY_RELEASED, (KeyEvent event) -> {
if (isEditingCell()) {
return;
}
if (copyCombination.match(event)) {
copiedProfiles = getSelectedProfiles();
} else if (pasteCombination.match(event) && !copiedProfiles.isEmpty()) {
handlePasteStreams(copiedProfiles);
} 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.ObservableValue in project intellij-plugins by StepicOrg.
the class AuthDialog method makeProgressBarWithListener.
@NotNull
private ProgressBar makeProgressBarWithListener() {
final ProgressBar progress = new ProgressBar();
Worker<Void> loadWorker = engine.getLoadWorker();
progress.progressProperty().bind(loadWorker.progressProperty());
loadWorker.stateProperty().addListener(new ChangeListener<Worker.State>() {
@Override
public void changed(ObservableValue<? extends Worker.State> ov, Worker.State oldState, Worker.State newState) {
if (newState == Worker.State.CANCELLED) {
return;
}
if (newState == Worker.State.FAILED) {
Map<String, Object> map = new HashMap<>();
map.put("url", engine.getLocation());
String content = Templater.processTemplate("error", map);
engine.loadContent(content);
return;
}
String location = engine.getLocation();
if (location != null) {
if (location.startsWith(Urls.STEPIK_URL + "/#")) {
String paramString = location.split("#")[1];
String[] params = paramString.split("&");
map.clear();
Arrays.stream(params).forEach(param -> {
String[] entry = param.split("=");
String value = "";
if (entry.length > 1) {
value = entry[1];
}
map.put(entry[0], value);
});
hide();
return;
} else if ((Urls.STEPIK_URL + "/?error=access_denied").equals(location)) {
map.put("error", "access_denied");
hide();
return;
}
}
progressBar.setVisible(newState == Worker.State.RUNNING);
if (newState == Worker.State.SUCCEEDED) {
AuthDialog.this.setTitle(engine.getTitle());
}
}
private void hide() {
loadWorker.cancel();
setVisible(false);
}
});
return progress;
}
use of javafx.beans.value.ObservableValue in project jmeter by apache.
the class RenderInBrowser method createScene.
private void createScene(final String htmlContent) {
Platform.setImplicitExit(false);
Platform.runLater(() -> {
WebView view = new WebView();
engine = view.getEngine();
engine.setOnStatusChanged(event -> SwingUtilities.invokeLater(() -> lblStatus.setText(event.getData())));
engine.getLoadWorker().workDoneProperty().addListener((ChangeListener<Number>) (observableValue, oldValue, newValue) -> SwingUtilities.invokeLater(() -> progressBar.setValue(newValue.intValue())));
engine.getLoadWorker().exceptionProperty().addListener((ObservableValue<? extends Throwable> o, Throwable old, final Throwable value) -> {
if (engine.getLoadWorker().getState() == State.FAILED) {
SwingUtilities.invokeLater(() -> JOptionPane.showMessageDialog(resultsScrollPane, (value != null) ? engine.getLocation() + "\n" + value.getMessage() : engine.getLocation() + "\nUnexpected error.", "Loading error...", JOptionPane.ERROR_MESSAGE));
}
});
jfxPanel.setScene(new Scene(view));
});
}
use of javafx.beans.value.ObservableValue in project ETUmulator by kasirgalabs.
the class ArrowFunction method apply.
@Override
public Node apply(int lineNumber) {
Polygon triangle = new Polygon(0.0, 0.0, 10.0, 5.0, 0.0, 10.0);
triangle.setFill(Color.GREEN);
ObservableValue<Boolean> visible = Val.map(shownLine, sl -> sl == lineNumber);
triangle.visibleProperty().bind(Val.flatMap(triangle.sceneProperty(), scene -> {
return scene != null ? visible : Val.constant(false);
}));
return triangle;
}
use of javafx.beans.value.ObservableValue in project azure-tools-for-java by Microsoft.
the class JobViewPanel method init.
private void init(final JFXPanel panel) {
String url = rootPath + "/com.microsoft.hdinsight/hdinsight/job/html/index.html";
url = url.replace("\\", "/");
final String queryString = "?projectid=" + id + "&engintype=javafx";
final String weburl = "file:///" + url + queryString;
Platform.setImplicitExit(false);
Platform.runLater(() -> {
webView = new WebView();
webEngine = webView.getEngine();
webEngine.setJavaScriptEnabled(true);
webEngine.getLoadWorker().stateProperty().addListener((ObservableValue<? extends Worker.State> ov, Worker.State oldState, Worker.State newState) -> {
if (newState == Worker.State.SUCCEEDED) {
JSObject win = (JSObject) webEngine.executeScript("window");
win.setMember("JobUtils", jobUtil);
}
});
panel.setScene(new Scene(webView));
if (!alreadyLoad) {
webEngine.load(weburl);
alreadyLoad = true;
}
});
}
Aggregations