List of usage examples for javafx.scene.control ToolBar ToolBar
public ToolBar()
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setWidth(300);/*from w ww .j a v a 2s . co m*/ stage.setHeight(150); ToolBar toolBar = new ToolBar(); toolBar.getItems().add(new Button("New")); toolBar.getItems().add(new Button("Open")); toolBar.getItems().add(new Button("Save")); toolBar.getItems().add(new Separator()); toolBar.getItems().add(new Button("Clean")); toolBar.getItems().add(new Button("Compile")); toolBar.getItems().add(new Button("Run")); toolBar.getItems().add(new Separator()); toolBar.getItems().add(new Button("Debug")); toolBar.getItems().add(new Button("Profile")); toolBar.setOrientation(Orientation.HORIZONTAL); System.out.println(toolBar.orientationProperty()); ((Group) scene.getRoot()).getChildren().add(toolBar); stage.setScene(scene); stage.show(); }
From source file:be.makercafe.apps.makerbench.editors.TextEditor.java
/** * Creates the toolBar for the editor./*from w w w . j a v a2 s . c om*/ * * @return */ private ToolBar createToolBar() { ToolBar toolBar = new ToolBar(); toolBar.setOrientation(Orientation.HORIZONTAL); Button btnSave = GlyphsDude.createIconButton(MaterialDesignIcon.FLOPPY, "Save"); btnSave.setOnAction(this::handleSaveButton); toolBar.getItems().add(btnSave); return toolBar; }
From source file:be.makercafe.apps.makerbench.editors.JFXMillEditor.java
/** * Creates the toolBar for the editor./* w w w . ja v a 2 s. co m*/ * * @return */ private ToolBar createToolBar() { ToolBar toolBar = new ToolBar(); toolBar.setOrientation(Orientation.HORIZONTAL); Button btnSave = GlyphsDude.createIconButton(MaterialDesignIcon.FLOPPY, "Save"); btnSave.setOnAction(this::handleSaveButton); Button btnExportSTL = GlyphsDude.createIconButton(MaterialDesignIcon.EXPORT, "Export GCODE"); btnExportSTL.setOnAction(this::handleExportAsGCodeFile); Button btnExportPNG = GlyphsDude.createIconButton(MaterialDesignIcon.CAMERA, "Export PNG"); btnExportPNG.setOnAction(this::handleExportAsPngFile); Button btnRun = GlyphsDude.createIconButton(MaterialDesignIcon.RUN, "Run"); btnRun.setOnAction(this::handleCompileAndRun); ToggleButton btnAutoCompile = GlyphsDude.createIconToggleButton(MaterialDesignIcon.AUTO_FIX, "Automatic run", null, ContentDisplay.LEFT); btnAutoCompile.setOnAction(this::handleAutoCompile); btnAutoCompile.setSelected(false); ToggleButton btn3DNav = GlyphsDude.createIconToggleButton(MaterialDesignIcon.ROTATE_3D, "3D Navigation ", null, ContentDisplay.LEFT); btn3DNav.setSelected(false); ComboBox cbxSourceExamples = new ComboBox(); cbxSourceExamples.getItems().addAll("TestCut"); this.cbxSourceExamples = cbxSourceExamples; // TODO: maybe cleaner way // to do this ? Button btnPasteSource = GlyphsDude.createIconButton(MaterialDesignIcon.CONTENT_PASTE, "Paste source"); btnPasteSource.setOnAction(this::handlePasteSource); toolBar.getItems().addAll(btnSave, btnExportSTL, btnExportPNG, new Separator(), btnRun, new Separator(), btnAutoCompile, new Separator(), cbxSourceExamples, btnPasteSource); return toolBar; }
From source file:eu.over9000.skadi.ui.MainWindow.java
private void setupToolbar(final Stage stage) { this.add = GlyphsDude.createIconButton(FontAwesomeIcons.PLUS); this.addName = new TextField(); this.addName.setOnAction(event -> this.add.fire()); this.add.setOnAction(event -> { final String name = this.addName.getText().trim(); if (name.isEmpty()) { return; }//from w w w . j a v a2s . c o m final boolean result = this.channelHandler.addChannel(name, this.sb); if (result) { this.addName.clear(); } }); this.imprt = GlyphsDude.createIconButton(FontAwesomeIcons.DOWNLOAD); this.imprt.setOnAction(event -> { final TextInputDialog dialog = new TextInputDialog(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(stage); dialog.setTitle("Import followed channels"); dialog.setHeaderText("Import followed channels from Twitch"); dialog.setGraphic(null); dialog.setContentText("Twitch username:"); dialog.showAndWait().ifPresent(name -> { final ImportFollowedService ifs = new ImportFollowedService(this.channelHandler, name, this.sb); ifs.start(); }); }); this.details = GlyphsDude.createIconButton(FontAwesomeIcons.INFO); this.details.setDisable(true); this.details.setOnAction(event -> { this.detailChannel.set(this.table.getSelectionModel().getSelectedItem()); if (!this.sp.getItems().contains(this.detailPane)) { this.sp.getItems().add(this.detailPane); this.doDetailSlide(true); } }); this.details.setTooltip(new Tooltip("Show channel information")); this.remove = GlyphsDude.createIconButton(FontAwesomeIcons.TRASH); this.remove.setDisable(true); this.remove.setOnAction(event -> { final Channel candidate = this.table.getSelectionModel().getSelectedItem(); final Alert alert = new Alert(AlertType.CONFIRMATION); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(stage); alert.setTitle("Delete channel"); alert.setHeaderText("Delete " + candidate.getName()); alert.setContentText("Do you really want to delete " + candidate.getName() + "?"); final Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { this.channelHandler.getChannels().remove(candidate); this.sb.setText("Removed channel " + candidate.getName()); } }); this.refresh = GlyphsDude.createIconButton(FontAwesomeIcons.REFRESH); this.refresh.setTooltip(new Tooltip("Refresh all channels")); this.refresh.setOnAction(event -> { this.refresh.setDisable(true); final ForcedChannelUpdateService service = new ForcedChannelUpdateService(this.channelHandler, this.sb, this.refresh); service.start(); }); this.settings = GlyphsDude.createIconButton(FontAwesomeIcons.COG); this.settings.setTooltip(new Tooltip("Settings")); this.settings.setOnAction(event -> { final SettingsDialog dialog = new SettingsDialog(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(stage); final Optional<StateContainer> result = dialog.showAndWait(); if (result.isPresent()) { this.persistenceHandler.saveState(result.get()); } }); this.onlineOnly = new ToggleButton("Live", GlyphsDude.createIcon(FontAwesomeIcons.FILTER)); this.onlineOnly.setSelected(this.currentState.isOnlineFilterActive()); this.onlineOnly.setOnAction(event -> { this.currentState.setOnlineFilterActive(this.onlineOnly.isSelected()); this.persistenceHandler.saveState(this.currentState); this.updateFilterPredicate(); }); // TODO re-enable if 8u60 is released this.onlineOnly.setDisable(true); this.filterText = new TextField(); this.filterText.textProperty().addListener((obs, oldV, newV) -> this.updateFilterPredicate()); this.filterText.setTooltip(new Tooltip("Filter channels by name, status and game")); // TODO re-enable if 8u60 is released this.filterText.setDisable(true); this.tb = new ToolBar(); this.tb.getItems().addAll(this.addName, this.add, this.imprt, new Separator(), this.refresh, this.settings, new Separator(), this.onlineOnly, this.filterText, new Separator(), this.details, this.remove); this.chatAndStreamButton = new HandlerControlButton(this.chatHandler, this.streamHandler, this.table, this.tb, this.sb); this.updateFilterPredicate(); }
From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java
/** * Creates the toolBar for the editor./*from w w w . j a v a 2s. co m*/ * * @return */ private ToolBar createToolBar() { ToolBar toolBar = new ToolBar(); toolBar.setOrientation(Orientation.HORIZONTAL); Button btnSave = GlyphsDude.createIconButton(MaterialDesignIcon.FLOPPY, "Save"); btnSave.setOnAction(this::handleSaveButton); Button btnExportSTL = GlyphsDude.createIconButton(MaterialDesignIcon.EXPORT, "Export STL"); btnExportSTL.setOnAction(this::handleExportAsStlFile); Button btnExportPNG = GlyphsDude.createIconButton(MaterialDesignIcon.CAMERA, "Export PNG"); btnExportPNG.setOnAction(this::handleExportAsPngFile); Button btnRun = GlyphsDude.createIconButton(MaterialDesignIcon.RUN, "Run"); btnRun.setOnAction(this::handleCompileAndRun); ToggleButton btnAutoCompile = GlyphsDude.createIconToggleButton(MaterialDesignIcon.AUTO_FIX, "Automatic run", null, ContentDisplay.LEFT); btnAutoCompile.setSelected(false); ToggleButton btn3DNav = GlyphsDude.createIconToggleButton(MaterialDesignIcon.ROTATE_3D, "3D Navigation ", null, ContentDisplay.LEFT); btn3DNav.setSelected(false); ComboBox cbxSourceExamples = new ComboBox(); cbxSourceExamples.getItems().addAll("BatteryHolder", "BoardMount", "BreadBoardConnector", "ServoMount", "Wheel"); this.cbxSourceExamples = cbxSourceExamples; // TODO: maybe cleaner way // to do this ? Button btnPasteSource = GlyphsDude.createIconButton(MaterialDesignIcon.CONTENT_PASTE, "Paste source"); btnPasteSource.setOnAction(this::handlePasteSource); toolBar.getItems().addAll(btnSave, btnExportSTL, btnExportPNG, new Separator(), btnRun, new Separator(), btnAutoCompile, new Separator(), cbxSourceExamples, btnPasteSource); return toolBar; }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private void initialize() { model = new TMATableModel(); groupByIDProperty.addListener((v, o, n) -> refreshTableData()); MenuBar menuBar = new MenuBar(); Menu menuFile = new Menu("File"); MenuItem miOpen = new MenuItem("Open..."); miOpen.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN)); miOpen.setOnAction(e -> {//from www. ja va 2 s . c o m File file = QuPathGUI.getDialogHelper(stage).promptForFile(null, null, "TMA data files", new String[] { "qptma" }); if (file == null) return; setInputFile(file); }); MenuItem miSave = new MenuItem("Save As..."); miSave.setAccelerator( new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); miSave.setOnAction( e -> SummaryMeasurementTableCommand.saveTableModel(model, null, Collections.emptyList())); MenuItem miImportFromImage = new MenuItem("Import from current image..."); miImportFromImage.setAccelerator( new KeyCodeCombination(KeyCode.I, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); miImportFromImage.setOnAction(e -> setTMAEntriesFromOpenImage()); MenuItem miImportFromProject = new MenuItem("Import from current project... (experimental)"); miImportFromProject.setAccelerator( new KeyCodeCombination(KeyCode.P, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); miImportFromProject.setOnAction(e -> setTMAEntriesFromOpenProject()); MenuItem miImportClipboard = new MenuItem("Import from clipboard..."); miImportClipboard.setOnAction(e -> { String text = Clipboard.getSystemClipboard().getString(); if (text == null) { DisplayHelpers.showErrorMessage("Import scores", "Clipboard is empty!"); return; } int n = importScores(text); if (n > 0) { setTMAEntries(new ArrayList<>(entriesBase)); } DisplayHelpers.showMessageDialog("Import scores", "Number of scores imported: " + n); }); Menu menuEdit = new Menu("Edit"); MenuItem miCopy = new MenuItem("Copy table to clipboard"); miCopy.setOnAction(e -> { SummaryMeasurementTableCommand.copyTableContentsToClipboard(model, Collections.emptyList()); }); combinedPredicate.addListener((v, o, n) -> { // We want any other changes triggered by this to have happened, // so that the data has already been updated Platform.runLater(() -> handleTableContentChange()); }); // Reset the scores for missing cores - this ensures they will be NaN and not influence subsequent results MenuItem miResetMissingScores = new MenuItem("Reset scores for missing cores"); miResetMissingScores.setOnAction(e -> { int changes = 0; for (TMAEntry entry : entriesBase) { if (!entry.isMissing()) continue; boolean changed = false; for (String m : entry.getMeasurementNames().toArray(new String[0])) { if (!TMASummaryEntry.isSurvivalColumn(m) && !Double.isNaN(entry.getMeasurementAsDouble(m))) { entry.putMeasurement(m, null); changed = true; } } if (changed) changes++; } if (changes == 0) { logger.info("No changes made when resetting scores for missing cores!"); return; } logger.info("{} change(s) made when resetting scores for missing cores!", changes); table.refresh(); updateSurvivalCurves(); if (scatterPane != null) scatterPane.updateChart(); if (histogramDisplay != null) histogramDisplay.refreshHistogram(); }); menuEdit.getItems().add(miResetMissingScores); QuPathGUI.addMenuItems(menuFile, miOpen, miSave, null, miImportClipboard, null, miImportFromImage, miImportFromProject); menuBar.getMenus().add(menuFile); menuEdit.getItems().add(miCopy); menuBar.getMenus().add(menuEdit); menuFile.setOnShowing(e -> { boolean imageDataAvailable = QuPathGUI.getInstance() != null && QuPathGUI.getInstance().getImageData() != null && QuPathGUI.getInstance().getImageData().getHierarchy().getTMAGrid() != null; miImportFromImage.setDisable(!imageDataAvailable); boolean projectAvailable = QuPathGUI.getInstance() != null && QuPathGUI.getInstance().getProject() != null && !QuPathGUI.getInstance().getProject().getImageList().isEmpty(); miImportFromProject.setDisable(!projectAvailable); }); // Double-clicking previously used for comments... but conflicts with tree table expansion // table.setOnMouseClicked(e -> { // if (!e.isPopupTrigger() && e.getClickCount() > 1) // promptForComment(); // }); table.setPlaceholder(new Text("Drag TMA data folder onto window, or choose File -> Open")); table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); BorderPane pane = new BorderPane(); pane.setTop(menuBar); menuBar.setUseSystemMenuBar(true); // Create options ToolBar toolbar = new ToolBar(); Label labelMeasurementMethod = new Label("Combination method"); labelMeasurementMethod.setLabelFor(comboMeasurementMethod); labelMeasurementMethod .setTooltip(new Tooltip("Method whereby measurements for multiple cores with the same " + TMACoreObject.KEY_UNIQUE_ID + " will be combined")); CheckBox cbHidePane = new CheckBox("Hide pane"); cbHidePane.setSelected(hidePaneProperty.get()); cbHidePane.selectedProperty().bindBidirectional(hidePaneProperty); CheckBox cbGroupByID = new CheckBox("Group by ID"); entriesBase.addListener((Change<? extends TMAEntry> event) -> { if (!event.getList().stream().anyMatch(e -> e.getMetadataValue(TMACoreObject.KEY_UNIQUE_ID) != null)) { cbGroupByID.setSelected(false); cbGroupByID.setDisable(true); } else { cbGroupByID.setDisable(false); } }); cbGroupByID.setSelected(groupByIDProperty.get()); cbGroupByID.selectedProperty().bindBidirectional(groupByIDProperty); CheckBox cbUseSelected = new CheckBox("Use selection only"); cbUseSelected.selectedProperty().bindBidirectional(useSelectedProperty); CheckBox cbSkipMissing = new CheckBox("Hide missing cores"); cbSkipMissing.selectedProperty().bindBidirectional(skipMissingCoresProperty); skipMissingCoresProperty.addListener((v, o, n) -> { table.refresh(); updateSurvivalCurves(); if (histogramDisplay != null) histogramDisplay.refreshHistogram(); updateSurvivalCurves(); if (scatterPane != null) scatterPane.updateChart(); }); toolbar.getItems().addAll(labelMeasurementMethod, comboMeasurementMethod, new Separator(Orientation.VERTICAL), cbHidePane, new Separator(Orientation.VERTICAL), cbGroupByID, new Separator(Orientation.VERTICAL), cbUseSelected, new Separator(Orientation.VERTICAL), cbSkipMissing); comboMeasurementMethod.getItems().addAll(MeasurementCombinationMethod.values()); comboMeasurementMethod.getSelectionModel().select(MeasurementCombinationMethod.MEDIAN); selectedMeasurementCombinationProperty.addListener((v, o, n) -> table.refresh()); ContextMenu popup = new ContextMenu(); MenuItem miSetMissing = new MenuItem("Set missing"); miSetMissing.setOnAction(e -> setSelectedMissingStatus(true)); MenuItem miSetAvailable = new MenuItem("Set available"); miSetAvailable.setOnAction(e -> setSelectedMissingStatus(false)); MenuItem miExpand = new MenuItem("Expand all"); miExpand.setOnAction(e -> { if (table.getRoot() == null) return; for (TreeItem<?> item : table.getRoot().getChildren()) { item.setExpanded(true); } }); MenuItem miCollapse = new MenuItem("Collapse all"); miCollapse.setOnAction(e -> { if (table.getRoot() == null) return; for (TreeItem<?> item : table.getRoot().getChildren()) { item.setExpanded(false); } }); popup.getItems().addAll(miSetMissing, miSetAvailable, new SeparatorMenuItem(), miExpand, miCollapse); table.setContextMenu(popup); table.setRowFactory(e -> { TreeTableRow<TMAEntry> row = new TreeTableRow<>(); // // Make rows invisible if they don't pass the predicate // row.visibleProperty().bind(Bindings.createBooleanBinding(() -> { // TMAEntry entry = row.getItem(); // if (entry == null || (entry.isMissing() && skipMissingCoresProperty.get())) // return false; // return entries.getPredicate() == null || entries.getPredicate().test(entry); // }, // skipMissingCoresProperty, // entries.predicateProperty())); // Style rows according to what they contain row.styleProperty().bind(Bindings.createStringBinding(() -> { if (row.isSelected()) return ""; TMAEntry entry = row.getItem(); if (entry == null || entry instanceof TMASummaryEntry) return ""; else if (entry.isMissing()) return "-fx-background-color:rgb(225,225,232)"; else return "-fx-background-color:rgb(240,240,245)"; }, row.itemProperty(), row.selectedProperty())); // row.itemProperty().addListener((v, o, n) -> { // if (n == null || n instanceof TMASummaryEntry || row.isSelected()) // row.setStyle(""); // else if (n.isMissing()) // row.setStyle("-fx-background-color:rgb(225,225,232)"); // else // row.setStyle("-fx-background-color:rgb(240,240,245)"); // }); return row; }); BorderPane paneTable = new BorderPane(); paneTable.setTop(toolbar); paneTable.setCenter(table); MasterDetailPane mdTablePane = new MasterDetailPane(Side.RIGHT, paneTable, createSidePane(), true); mdTablePane.showDetailNodeProperty().bind(Bindings.createBooleanBinding( () -> !hidePaneProperty.get() && !entriesBase.isEmpty(), hidePaneProperty, entriesBase)); mdTablePane.setDividerPosition(2.0 / 3.0); pane.setCenter(mdTablePane); model.getEntries().addListener(new ListChangeListener<TMAEntry>() { @Override public void onChanged(ListChangeListener.Change<? extends TMAEntry> c) { if (histogramDisplay != null) histogramDisplay.refreshHistogram(); updateSurvivalCurves(); if (scatterPane != null) scatterPane.updateChart(); } }); Label labelPredicate = new Label(); labelPredicate.setPadding(new Insets(5, 5, 5, 5)); labelPredicate.setAlignment(Pos.CENTER); // labelPredicate.setStyle("-fx-background-color: rgba(20, 120, 20, 0.15);"); labelPredicate.setStyle("-fx-background-color: rgba(120, 20, 20, 0.15);"); labelPredicate.textProperty().addListener((v, o, n) -> { if (n.trim().length() > 0) pane.setBottom(labelPredicate); else pane.setBottom(null); }); labelPredicate.setMaxWidth(Double.MAX_VALUE); labelPredicate.setMaxHeight(labelPredicate.getPrefHeight()); labelPredicate.setTextAlignment(TextAlignment.CENTER); predicateMeasurements.addListener((v, o, n) -> { if (n == null) labelPredicate.setText(""); else if (n instanceof TablePredicate) { TablePredicate tp = (TablePredicate) n; if (tp.getOriginalCommand().trim().isEmpty()) labelPredicate.setText(""); else labelPredicate.setText("Predicate: " + tp.getOriginalCommand()); } else labelPredicate.setText("Predicate: " + n.toString()); }); // predicate.set(new TablePredicate("\"Tumor\" > 100")); scene = new Scene(pane); scene.addEventHandler(KeyEvent.KEY_PRESSED, e -> { KeyCode code = e.getCode(); if ((code == KeyCode.SPACE || code == KeyCode.ENTER) && entrySelected != null) { promptForComment(); return; } }); }
From source file:tachyon.view.Viewer.java
public Viewer(Resource scr, Project pro) { super(scr, pro); getCenter().setCenter(new ScrollPane(view = new ImageView(image = readFromFile(scr.getFile())))); controls = new ToolBar(); controls.setPadding(new Insets(5, 10, 5, 10)); getCenter().setTop(controls);//from w ww. ja v a 2s . c om controls.getItems().addAll(zIn = new Button("Zoom In"), zOut = new Button("Zoom Out"), new Separator(), rotate = new Button("Rotate"), new Separator(), revert = new Button("Revert")); zIn.setOnAction((e) -> { if (zoom.get() < 2.0) { zoom.set(zoom.get() + 0.1); } }); zOut.setOnAction((e) -> { if (zoom.get() > 0.2) { zoom.set(zoom.get() - 0.1); } }); zoom.addListener((ob, older, newer) -> { view.setFitHeight(newer.doubleValue() * image.getHeight()); view.setFitWidth(newer.doubleValue() * image.getWidth()); }); rotate.setOnAction((e) -> { view.setRotate(view.getRotate() + 90); }); revert.setOnAction((e) -> { zoom.set(1.0); view.setRotate(0); }); }