List of usage examples for javafx.scene.control MenuItem setOnAction
public final void setOnAction(EventHandler<ActionEvent> value)
From source file:de.pixida.logtest.designer.automaton.AutomatonEdge.java
@Override ContextMenu createContextMenu() {//from www . ja v a 2s .c o m final ContextMenu cm = new ContextMenu(); final MenuItem mi = new MenuItem("Delete edge"); mi.setGraphic(Icons.getIconGraphics("delete")); mi.setStyle("-fx-text-fill:red"); mi.setOnAction(event -> { final Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirm"); alert.setHeaderText("You are about to delete the edge."); alert.setContentText("Do you want to continue?"); alert.showAndWait().filter(response -> response == ButtonType.OK) .ifPresent(response -> this.removeNodeAndEdges()); }); cm.getItems().add(mi); return cm; }
From source file:com.exalttech.trex.ui.views.PacketTableView.java
/** * Add menu item to table rightclickMenu * * @param action/* w ww . j a v a 2s.c o m*/ */ private void addMenuItem(StreamTableAction action) { MenuItem item = new MenuItem(action.getTitle()); item.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { handleStreamTableAction(action); } }); rightClickMenu.getItems().add(item); }
From source file:pl.baczkowicz.mqttspy.ui.controllers.NewPublicationController.java
/** * Refreshes the list of recent messages shown in the publish button's context menu. */// ww w . j a v a 2 s.c o m private void refreshRecentMessages() { // Remove all elements while (recentMessagesMenu.getItems().size() > 0) { recentMessagesMenu.getItems().remove(0); } while (saveRecentMessagesMenu.getItems().size() > 0) { saveRecentMessagesMenu.getItems().remove(0); } // Add all elements for (final BaseMqttMessage message : recentMessages) { final String topic = message.getTopic(); final String payload = message.getPayload().length() > 10 ? message.getPayload().substring(0, 10) + "..." : message.getPayload(); final String time = TimeUtils.DATE_WITH_SECONDS_SDF.format(message.getDate()); final String messageText = "Topic = '" + topic + "', payload = '" + payload + "', published at " + time; final MenuItem recentMessageItem = new MenuItem(messageText); recentMessageItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { displayMessage(message); } }); recentMessagesMenu.getItems().add(recentMessageItem); final MenuItem saveMessageItem = new MenuItem(messageText); saveMessageItem.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { saveAsScript(message); } }); saveRecentMessagesMenu.getItems().add(saveMessageItem); } recentMessagesMenu.setDisable(recentMessagesMenu.getItems().size() == 0); saveRecentMessagesMenu.setDisable(saveRecentMessagesMenu.getItems().size() == 0); }
From source file:ninja.javafx.smartcsv.fx.SmartCSVController.java
private ContextMenu contextMenuForColumn(String header) { ContextMenu contextMenu = new ContextMenu(); MenuItem editColumnRulesMenuItem = new MenuItem(resourceBundle.getString("context.menu.edit.column.rules")); bindMenuItemsToContentExistence(currentConfigFile, editColumnRulesMenuItem); editColumnRulesMenuItem.setOnAction(e -> showValidationEditor(header)); contextMenu.getItems().addAll(editColumnRulesMenuItem); return contextMenu; }
From source file:View.Visualize.java
private void addColorChangeOnSeries(XYChart.Series series) { final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp);/*from w w w. jav a2 s . c o m*/ contextMenu.getItems().addAll(changeColor, delete); Node d = series.getNode(); d.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { if (series.getChart() instanceof StackedAreaChart) { series.getChart().lookup(".default-color" + series.getNode().getUserData() + ".chart-series-area-fill").setStyle(""); } if (series.getChart() instanceof LineChart) { series.getChart().lookup( ".default-color" + series.getNode().getUserData() + ".chart-series-line") .setStyle(""); } } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); if (series.getChart() instanceof StackedAreaChart) { series.getChart().lookup(".default-color" + series.getNode().getUserData() + ".chart-series-area-fill").setStyle("-fx-fill:" + hex1 + ";"); } if (series.getChart() instanceof LineChart) { series.getChart().lookup( ".default-color" + series.getNode().getUserData() + ".chart-series-line") .setStyle("-fx-stroke:" + hex1 + ";"); } } }); contextMenu.show(d, t.getScreenX(), t.getScreenY()); } } }); }
From source file:View.Visualize.java
private void addColorChangeOnIndividual(ObservableList<XYChart.Data> data) { final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change Color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp);// ww w . j av a2 s . co m contextMenu.getItems().addAll(changeColor, delete); for (XYChart.Data d : data) { d.getNode().setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { d.getNode().setStyle(""); } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); d.getNode().setStyle("-fx-background-color: " + hex1 + ";"); } }); contextMenu.show(d.getNode(), t.getScreenX(), t.getScreenY()); } } }); } }
From source file:View.Visualize.java
public void getPieChartData(Integer nameColumn, Integer valueColumn, Table table, PieChart pieChart, Label lbl, Boolean newSeries, Boolean rowCounter) { data.clear();/*w w w. j av a2 s . c o m*/ if (!newSeries) { pieChart.getData().clear(); } addDataFromTable(table, nameColumn, valueColumn, rowCounter); data.entrySet().stream().map(entry -> new PieChart.Data(entry.getKey(), entry.getValue())) .forEach(pieChart.getData()::add); for (PieChart.Data d : pieChart.getData()) { //deretter legger vi animasjon p piecharten.. d.getNode().setOnMouseClicked(new mouseHooverAnimationPieChart.MouseHoverAnimation(d, pieChart)); final Node n = d.getNode(); Tooltip tooltip = new Tooltip(); String toolTipText = "Value : " + d.getPieValue(); tooltip.setText(toolTipText); Tooltip.install(n, tooltip); n.setOnMouseEntered(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { n.setEffect(glow); } }); n.setOnMouseExited(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { n.setEffect(null); } }); final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change Color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp); contextMenu.getItems().addAll(changeColor, delete); d.getNode().setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { d.getNode().setStyle(""); } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); d.getNode().setStyle("-fx-background-color: " + hex1 + ";"); } }); contextMenu.show(d.getNode(), t.getScreenX(), t.getScreenY()); } } }); } }
From source file:com.neuronrobotics.bowlerstudio.MainController.java
private void setToLoggedIn(final String name) { // new Exception().printStackTrace(); FxTimer.runLater(Duration.ofMillis(100), () -> { logoutGithub.disableProperty().set(false); logoutGithub.setText("Log out " + name); new Thread() { public void run() { GitHub github = ScriptingEngine.getGithub(); while (github == null) { github = ScriptingEngine.getGithub(); ThreadUtil.wait(20); }/*from w ww. j a v a 2 s . com*/ try { GHMyself myself = github.getMyself(); PagedIterable<GHGist> gists = myself.listGists(); Platform.runLater(() -> { myGists.getItems().clear(); }); ThreadUtil.wait(20); for (GHGist gist : gists) { String desc = gist.getDescription(); if (desc == null || desc.length() == 0) { desc = gist.getFiles().keySet().toArray()[0].toString(); } Menu tmpGist = new Menu(desc); MenuItem loadWebGist = new MenuItem("Show Web Gist..."); loadWebGist.setOnAction(event -> { String webURL = gist.getHtmlUrl(); try { BowlerStudio.openUrlInNewTab(new URL(webURL)); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }); MenuItem addFile = new MenuItem("Add file to Gist..."); addFile.setOnAction(event -> { new Thread() { public void run() { } }.start(); }); Platform.runLater(() -> { tmpGist.getItems().addAll(addFile, loadWebGist); }); EventHandler<Event> loadFiles = new EventHandler<Event>() { @Override public void handle(Event ev) { // for(ScriptingEngine.) new Thread() { public void run() { System.out.println("Loading files"); ArrayList<String> listofFiles = ScriptingEngine .filesInGit(gist.getGitPushUrl(), "master", null); for (String s : listofFiles) { MenuItem tmp = new MenuItem(s); tmp.setOnAction(event -> { new Thread() { public void run() { try { File fileSelected = ScriptingEngine .fileFromGit(gist.getGitPushUrl(), s); BowlerStudio.createFileTab(fileSelected); } catch (Exception e) { // TODO // Auto-generated // catch block e.printStackTrace(); } } }.start(); }); Platform.runLater(() -> { tmpGist.getItems().add(tmp); tmpGist.setOnShowing(null); }); } Platform.runLater(() -> { tmpGist.hide(); Platform.runLater(() -> { tmpGist.show(); }); }); } }.start(); } }; tmpGist.setOnShowing(loadFiles); Platform.runLater(() -> { myGists.getItems().add(tmpGist); }); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }.start(); }); }
From source file:org.sleuthkit.autopsy.imagegallery.gui.GroupPane.java
private MenuItem createGrpTagMenuItem(final TagName tn) { final MenuItem menuItem = new MenuItem(tn.getDisplayName(), new ImageView(DrawableAttribute.TAGS.getIcon())); menuItem.setOnAction(new EventHandler<ActionEvent>() { @Override//ww w.ja va 2 s . c om public void handle(ActionEvent t) { Set<Long> fileIdSet = new HashSet<>(getGrouping().fileIds()); AddDrawableTagAction.getInstance().addTagsToFiles(tn, "", fileIdSet); grpTagSplitMenu.setText(tn.getDisplayName()); grpTagSplitMenu.setOnAction(this); } }); return menuItem; }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.GroupPane.java
private MenuItem createGrpTagMenuItem(final TagName tn) { final MenuItem menuItem = new MenuItem(tn.getDisplayName(), new ImageView(DrawableAttribute.TAGS.getIcon())); menuItem.setOnAction(new EventHandler<ActionEvent>() { @Override//w w w .j a v a 2 s. c o m public void handle(ActionEvent t) { selectAllFiles(); AddDrawableTagAction.getInstance().addTag(tn, ""); grpTagSplitMenu.setText(tn.getDisplayName()); grpTagSplitMenu.setOnAction(this); } }); return menuItem; }