Search in sources :

Example 31 with MenuItem

use of javafx.scene.control.MenuItem in project blue by kunstmusik.

the class SoundEditor method jbInit.

private void jbInit() throws Exception {
    this.setLayout(new BorderLayout());
    this.add(editor);
    editor.setLabelText("[ Sound ]");
    JFXPanel jfxPanel = new JFXPanel();
    CountDownLatch latch = new CountDownLatch(1);
    JFXPanel jfxCommentPanel = new JFXPanel();
    BlueFX.runOnFXThread(() -> {
        try {
            MenuButton btn = new MenuButton("Automations");
            BorderPane mainPane = new BorderPane();
            lineView = new ParameterLineView(lineList);
            lineSelector = new LineSelector(lineList);
            lineView.widthProperty().bind(mainPane.widthProperty());
            lineView.heightProperty().bind(mainPane.heightProperty().subtract(lineSelector.heightProperty()));
            lineSelector.getChildren().add(0, btn);
            lineSelector.setSpacing(5.0);
            lineView.selectedLineProperty().bind(lineSelector.selectedLineProperty());
            TimeBar tb = new TimeBar();
            tb.startTimeProperty().bind(lineView.startTimeProperty());
            tb.durationProperty().bind(lineView.durationProperty());
            Pane p = new Pane(lineView, tb);
            p.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
            lineView.widthProperty().bind(p.widthProperty().subtract(20));
            lineView.heightProperty().bind(p.heightProperty().subtract(40));
            lineView.setLayoutX(10);
            lineView.setLayoutY(30);
            tb.widthProperty().bind(lineView.widthProperty());
            tb.setHeight(20);
            tb.setLayoutX(10);
            tb.setLayoutY(10);
            mainPane.setCenter(p);
            mainPane.setTop(lineSelector);
            btn.showingProperty().addListener((obs, old, newVal) -> {
                if (newVal) {
                    if (sObj != null) {
                        sObj.getBlueSynthBuilder().getParameterList().sorted().forEach((param) -> {
                            MenuItem m = new MenuItem(param.getName());
                            m.setOnAction(e -> {
                                param.setAutomationEnabled(!param.isAutomationEnabled());
                                if (param.isAutomationEnabled()) {
                                    Line line = param.getLine();
                                    line.setVarName(param.getName());
                                    List<LinePoint> points = line.getObservableList();
                                    if (points.size() < 2) {
                                        LinePoint lp = new LinePoint();
                                        lp.setLocation(1.0, points.get(0).getY());
                                        points.add(lp);
                                    }
                                    lineList.add(line);
                                } else {
                                    lineList.remove(param.getLine());
                                }
                                int colorCount = 0;
                                for (Line line : lineList) {
                                    line.setColor(LineColors.getColor(colorCount++));
                                }
                            });
                            if (param.isAutomationEnabled()) {
                                m.setStyle("-fx-text-fill: green;");
                            }
                            btn.getItems().add(m);
                        });
                    }
                } else {
                    btn.getItems().clear();
                }
            });
            final Scene scene = new Scene(mainPane);
            BlueFX.style(scene);
            jfxPanel.setScene(scene);
            commentTextArea = new TextArea();
            commentTextArea.setWrapText(true);
            final Scene scene2 = new Scene(commentTextArea);
            BlueFX.style(scene2);
            jfxCommentPanel.setScene(scene2);
        } finally {
            latch.countDown();
        }
    });
    try {
        latch.await();
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
    editor.getTabs().insertTab("Automation", null, jfxPanel, "", 1);
    editor.getTabs().addTab("Comments", jfxCommentPanel);
}
Also used : TimeBar(blue.soundObject.editor.sound.TimeBar) JFXPanel(javafx.embed.swing.JFXPanel) BorderPane(javafx.scene.layout.BorderPane) ParameterLineView(blue.soundObject.editor.sound.ParameterLineView) Background(javafx.scene.layout.Background) TextArea(javafx.scene.control.TextArea) BackgroundFill(javafx.scene.layout.BackgroundFill) MenuButton(javafx.scene.control.MenuButton) LineSelector(blue.orchestra.editor.blueSynthBuilder.jfx.LineSelector) MenuItem(javafx.scene.control.MenuItem) CountDownLatch(java.util.concurrent.CountDownLatch) Scene(javafx.scene.Scene) Pane(javafx.scene.layout.Pane) BorderPane(javafx.scene.layout.BorderPane) LinePoint(blue.components.lines.LinePoint) Line(blue.components.lines.Line) LinePoint(blue.components.lines.LinePoint) BorderLayout(java.awt.BorderLayout)

Example 32 with MenuItem

use of javafx.scene.control.MenuItem in project honest-profiler by jvm-profiling-tools.

the class ProfileRootController method refreshContextMenu.

/**
 * Add profiles available for comparison to the specified {@link ContextMenu}.
 * <p>
 *
 * @param menu the {@link ContextMenu} to which available profiles will be added
 */
private void refreshContextMenu(ContextMenu menu) {
    menu.getItems().clear();
    // Only compare against profiles which have actually been opened
    List<String> profileNames = appCtx().getOpenProfileNames();
    profileNames.forEach(name -> {
        // Don't compare a profile against itself
        if (!name.equals(profileContext.getName())) {
            MenuItem item = new MenuItem(name);
            item.setOnAction(event -> appCtx().createDiffView(profileContext.getName(), name));
            menu.getItems().add(item);
        }
    });
}
Also used : MenuItem(javafx.scene.control.MenuItem)

Example 33 with MenuItem

use of javafx.scene.control.MenuItem in project completable-reactor by ru-fix.

the class GraphViewPane method initializePopupMenu.

void initializePopupMenu() {
    ContextMenu contextMenu = new ContextMenu();
    MenuItem buildGraphMenuItem = new MenuItem("Graph build location");
    buildGraphMenuItem.setOnAction(event -> actionListener.goToSource(this.graphModel.buildGraphSource));
    contextMenu.getItems().add(buildGraphMenuItem);
    MenuItem coordinatesMenuItem = new MenuItem("Coordinates location");
    coordinatesMenuItem.setOnAction(event -> actionListener.goToSource(this.graphModel.coordinatesSource));
    contextMenu.getItems().add(coordinatesMenuItem);
    MenuItem serializationMenuItem = new MenuItem();
    serializationMenuItem.setOnAction(event -> actionListener.goToSource(this.graphModel.serializationPointSource));
    contextMenu.getItems().add(serializationMenuItem);
    pane.setOnContextMenuRequested(contextMenuEvent -> {
        val serializationMenuText = new StringBuilder("Graph serialization location");
        shortcutProvider.apply(ShortcutType.GOTO_SERIALIZATION_POINT).ifPresent(shortcut -> serializationMenuText.append(" (" + shortcut.getTitle() + ")"));
        serializationMenuItem.setText(serializationMenuText.toString());
        contextMenu.show(pane, contextMenuEvent.getScreenX(), contextMenuEvent.getScreenY());
        contextMenuEvent.consume();
    });
    this.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
        contextMenu.hide();
    });
}
Also used : lombok.val(lombok.val) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem)

Example 34 with MenuItem

use of javafx.scene.control.MenuItem in project assembly64fx by freabemania.

the class SearchController method handleMouseClicked.

// first stage
private void handleMouseClicked(MouseEvent event) {
    // user either rightclicks
    if (event.getButton() == MouseButton.SECONDARY || event.isControlDown()) {
        final ContextMenu contextMenu = new ContextMenu();
        List<SearchResultItem> selectedItems = table.getSelectionModel().getSelectedItems();
        MenuItem view = new MenuItem("Download to installbase");
        view.setOnAction((ActionEvent event2) -> {
            Analytics.sendEvent("search", "installfiles");
            if (userService.getPrimaryInstallation().exists()) {
                downloadFiles(selectedItems, userService.resolveDownloadFolderAsString());
            } else {
                GenericMessageDialogController.withErrorProps("Ooops..", "No valid downloadlocation is present").showAndWait();
            }
        });
        MenuItem downloadTo = new MenuItem("Download to...");
        downloadTo.setOnAction((ActionEvent event2) -> {
            File tmp = new DirectoryChooser().showDialog(getStage());
            Analytics.sendEvent("search", "installfilecustompath");
            if (tmp != null) {
                downloadFiles(selectedItems, Support.getAndfixPathAsString(tmp));
            }
        });
        if (userService.isLocationSelectedAndExisting()) {
            contextMenu.getItems().add(view);
        }
        contextMenu.getItems().add(downloadTo);
        table.setContextMenu(contextMenu);
        Analytics.sendEvent("search", "installfolder");
    // or jumps straight to the files
    } else if (event.getClickCount() == 2) {
        openFiles();
    }
}
Also used : ActionEvent(javafx.event.ActionEvent) SearchResultItem(se.light.assembly64.model.SearchResultItem) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) File(java.io.File) DirectoryChooser(javafx.stage.DirectoryChooser)

Example 35 with MenuItem

use of javafx.scene.control.MenuItem in project assembly64fx by freabemania.

the class SearchViewFilesController method handleMouseClicked.

private void handleMouseClicked(MouseEvent event) {
    if (event.getButton() == MouseButton.SECONDARY || event.isControlDown()) {
        final ContextMenu contextMenu = new ContextMenu();
        List<ContentEntry> selectedItems = table.getSelectionModel().getSelectedItems();
        // do not show downloadbuttons if we're coming from treeview
        if (fromSearch) {
            MenuItem view = new MenuItem("Download to installbase");
            view.setOnAction((ActionEvent event2) -> {
                if (userService.getPrimaryInstallation().exists()) {
                    downloadFilesAsync(selectedItems, UserService.getInstance().resolveDownloadFolderAsString());
                } else {
                    GenericMessageDialogController.withErrorProps("Ooops..", "No valid downloadlocation is present").showAndWait();
                }
            });
            if (userService.isLocationSelectedAndExisting()) {
                contextMenu.getItems().add(view);
            }
            MenuItem downloadTo = new MenuItem("Download to...");
            downloadTo.setOnAction((ActionEvent event2) -> {
                File tmp = new DirectoryChooser().showDialog(getStage());
                Analytics.sendEvent("search", "installfilecustompath");
                if (tmp != null) {
                    downloadFilesAsync(selectedItems, Support.getAndfixPathAsString(tmp));
                }
            });
            contextMenu.getItems().add(downloadTo);
        }
        MenuItem openBrowser = new MenuItem("Open browser");
        openBrowser.setOnAction((ActionEvent event2) -> {
            openFile(true);
        });
        contextMenu.getItems().add(openBrowser);
        MenuItem loadStar = new MenuItem("LOAD \"*\",8,1");
        loadStar.setOnAction((ActionEvent event2) -> {
            openFile(false, true);
        });
        contextMenu.getItems().add(loadStar);
        if (selectedItems.size() == 1) {
            MenuItem browseAction = new MenuItem("Browse image");
            browseAction.setOnAction((ActionEvent event2) -> {
                openFile(true);
            });
            if (selectedItems.size() == 1) {
                ContentEntry selectedItem = selectedItems.get(0);
                if (selectedItem.getName().toLowerCase().endsWith(".sid")) {
                    Menu addToPlaylist = new Menu("Add to playlist");
                    for (PlaylistInfo plist : playlistService.getPlaylistInfo()) {
                        PlaylistMenuItem mItem = new PlaylistMenuItem(plist);
                        mItem.setOnAction((ActionEvent event2) -> {
                            PlaylistMenuItem item = (PlaylistMenuItem) event2.getSource();
                            PlaylistEntry song = new PlaylistEntry(searchedItem.getId(), searchedItem.getCategory(), selectedItem.getId(), selectedItem.getName());
                            selectedItem.setFullPlaylistInfo(song);
                            playlistService.addSong(item.getPlaylist(), selectedItem);
                        });
                        addToPlaylist.getItems().add(mItem);
                    }
                    contextMenu.getItems().add(addToPlaylist);
                }
            }
            contextMenu.getItems().add(browseAction);
        }
        table.setContextMenu(contextMenu);
        Analytics.sendEvent("search", "installfile");
    } else if (event.getClickCount() == 2) {
        openFile(false);
    }
}
Also used : PlaylistMenuItem(se.light.assembly64.model.PlaylistMenuItem) ContentEntry(se.light.assembly64.model.ContentEntry) ActionEvent(javafx.event.ActionEvent) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) PlaylistMenuItem(se.light.assembly64.model.PlaylistMenuItem) ContextMenu(javafx.scene.control.ContextMenu) Menu(javafx.scene.control.Menu) PlaylistInfo(se.light.assembly64.model.PlaylistInfo) PlaylistEntry(se.light.assembly64.model.PlaylistEntry) File(java.io.File) DirectoryChooser(javafx.stage.DirectoryChooser)

Aggregations

MenuItem (javafx.scene.control.MenuItem)133 ContextMenu (javafx.scene.control.ContextMenu)72 Menu (javafx.scene.control.Menu)41 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)41 ActionEvent (javafx.event.ActionEvent)30 File (java.io.File)23 VBox (javafx.scene.layout.VBox)21 List (java.util.List)20 Scene (javafx.scene.Scene)20 ArrayList (java.util.ArrayList)19 Label (javafx.scene.control.Label)19 Collectors (java.util.stream.Collectors)16 MenuBar (javafx.scene.control.MenuBar)15 ObservableList (javafx.collections.ObservableList)13 IOException (java.io.IOException)12 EventHandler (javafx.event.EventHandler)12 Button (javafx.scene.control.Button)12 FXCollections (javafx.collections.FXCollections)11 ImageView (javafx.scene.image.ImageView)11 KeyCodeCombination (javafx.scene.input.KeyCodeCombination)11