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);
}
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);
}
});
}
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();
});
}
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();
}
}
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);
}
}
Aggregations