use of javafx.scene.control.MenuItem in project assembly64fx by freabemania.
the class SidifyChooseMultipleSongsController method init.
public void init(List<ContentEntry> contentEntries) {
Analytics.sendEvent("sidify", "choose_multi");
name.setCellValueFactory(new PropertyValueFactory<ContentEntry, String>("name"));
playListService = PlaylistService.getInstance();
sidPlayService = SIDPlayerService.getInstance();
downloadService = DownloadArtifactsService.getInstance();
pathService = PathService.getInstance();
songs.clear();
contentEntries.stream().forEach(songs::add);
songlist.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
songlist.setItems(songs);
songlist.setOnMousePressed(event -> {
List<ContentEntry> selectedItems = songlist.getSelectionModel().getSelectedItems();
if (event.getButton() == MouseButton.SECONDARY || event.isControlDown()) {
final ContextMenu contextMenu = new ContextMenu();
Menu addToPlaylist = new Menu("Add to playlist");
for (PlaylistInfo plist : playListService.getPlaylistInfo()) {
PlaylistMenuItem mItem = new PlaylistMenuItem(plist);
mItem.setOnAction((ActionEvent event2) -> {
playListService.addSongs(plist, selectedItems.stream().map(item -> item.getFullPlaylistInfo()).collect(Collectors.toList()), selectedItems.stream().map(item -> Collections.singletonList(item)).collect(toList()));
songlist.getSelectionModel().clearSelection();
});
addToPlaylist.getItems().add(mItem);
}
MenuItem mItem = new MenuItem("Add to new playlist");
mItem.setOnAction((ActionEvent event2) -> {
SidifyCreatePlaylistController controller = GuiUtils.showDialog("sidifyCreateNewPlaylist.fxml", Boolean.TRUE, "Create new playlist", getStage(), new Object[] { null, true });
PlaylistInfo newPlaylist = controller.getNewlyCreatedPlayList();
if (newPlaylist != null) {
playListService.addSongs(newPlaylist, selectedItems.stream().map(item -> item.getFullPlaylistInfo()).collect(Collectors.toList()), selectedItems.stream().map(item -> Collections.singletonList(item)).collect(toList()));
songlist.getSelectionModel().clearSelection();
}
});
addToPlaylist.getItems().add(mItem);
contextMenu.getItems().add(addToPlaylist);
songlist.setContextMenu(contextMenu);
} else if (event.getClickCount() == 2) {
playSong(new PlaylistEntry(selectedItems.get(0).getFullPlaylistInfo().getId(), selectedItems.get(0).getFullPlaylistInfo().getCategory(), selectedItems.get(0).getId(), selectedItems.get(0).getName()));
}
});
}
use of javafx.scene.control.MenuItem in project assembly64fx by freabemania.
the class SidifyMainContoller method populateLeftList.
private void populateLeftList() {
wordsList.clear();
leftlist.getItems().clear();
String playlistUsage = " (" + playListService.getPlaylistInfo().size() + " of " + MAX_PLAYLISTS + ")";
playlistsHeaderLabel.setText("Playlists " + playlistUsage);
final ContextMenu contextMenu = new ContextMenu();
// Menu addToPlaylist = new Menu("Add to playlist");
MenuItem tmp = new MenuItem("Export all playlists");
tmp.setOnAction((ActionEvent event2) -> {
GuiUtils.showDialog("sidifyExportPlaylist.fxml", Boolean.TRUE, "Playlistinfo", getStage(), new Object[] { null });
});
// addToPlaylist.getItems().add(tmp);
contextMenu.getItems().add(tmp);
playlistsHeaderLabel.setContextMenu(contextMenu);
for (PlaylistInfo list : playListService.getPlaylistInfo()) {
PlayerItem playerItem = null;
boolean availableOffline = list.isAvailableOffline();
boolean isPublic = !Support.isPlaylistMine(list) && Support.isPublicPlaylist(list);
String label = list.getName() + " ";
if (availableOffline || isPublic) {
label += "(";
label += availableOffline ? "*" : "";
label += isPublic ? "P" : "";
label += ")";
}
if (Support.isPlaylistMine(list)) {
playerItem = new PlayerItem(label, MENU_TYPE.PLAYLIST);
} else {
playerItem = new PlayerItem(label, MENU_TYPE.PUBLICLIST);
}
playerItem.setPlaylist(list);
wordsList.add(playerItem);
// leftlist.getItems()
if (activePlaylist != null && activePlaylist.getId().equals(list.getId())) {
leftlist.getSelectionModel().select(playerItem);
}
}
wordsList.add(new PlayerItem("", MENU_TYPE.NONCLICKABLE));
wordsList.add(new PlayerItem("", MENU_TYPE.NONCLICKABLE));
leftlist.setItems(wordsList);
leftlist.refresh();
}
use of javafx.scene.control.MenuItem in project assembly64fx by freabemania.
the class SidifyViewPublicPlaylistsController method init.
public void init(Runnable updateCallback) {
publicLists.setPlaceholder(new Label("No more public lists to follow"));
name.setCellValueFactory(new PropertyValueFactory<PlaylistInfo, String>("name"));
ownerAlias.setCellValueFactory(new PropertyValueFactory<PlaylistInfo, String>("ownerAlias"));
playListService = PlaylistService.getInstance();
populateList();
publicLists.setOnMousePressed(event -> {
PlaylistInfo selectedItem = publicLists.getSelectionModel().getSelectedItem();
if (event.getButton() == MouseButton.SECONDARY || event.isControlDown()) {
final ContextMenu contextMenu = new ContextMenu();
MenuItem infoItem = new MenuItem("Playlistinfo");
infoItem.setOnAction((ActionEvent event2) -> {
GuiUtils.showDialog("sidifyViewPublicPlaylistInfo.fxml", Boolean.TRUE, "Playlistinfo", getStage(), new Object[] { selectedItem });
});
MenuItem mItem = new MenuItem("Subscribe to list");
mItem.setOnAction((ActionEvent event2) -> {
Analytics.sendEvent("sidify", "subscribe_playlist");
playListService.subscribeToPlaylist(selectedItem.getId());
playListService.resetAndGetPublicPlaylists();
populateList();
updateCallback.run();
});
MenuItem mItem2 = new MenuItem("Copy & add to new playlist");
mItem2.setOnAction((ActionEvent event2) -> {
Analytics.sendEvent("sidify", "copyadd_playlist");
SidifyCreatePlaylistController controller = GuiUtils.showDialog("sidifyCreateNewPlaylist.fxml", Boolean.TRUE, "Create new playlist", getStage(), new Object[] { null, true });
playListService.copyPlaylist(selectedItem.getId(), controller.getNewlyCreatedPlayList().getId());
updateCallback.run();
});
Menu mItem3 = new Menu("Copy & add to existing playlist");
for (PlaylistInfo plist : playListService.getPlaylistInfo()) {
Analytics.sendEvent("sidify", "add_to_existing_playlist");
PlaylistMenuItem menuItemPl = new PlaylistMenuItem(plist);
menuItemPl.setOnAction((ActionEvent event2) -> {
playListService.copyPlaylist(selectedItem.getId(), menuItemPl.getPlaylist().getId());
});
mItem3.getItems().add(menuItemPl);
}
contextMenu.getItems().add(infoItem);
contextMenu.getItems().add(mItem);
contextMenu.getItems().add(mItem2);
contextMenu.getItems().add(mItem3);
publicLists.setContextMenu(contextMenu);
} else if (event.getClickCount() == 2) {
GuiUtils.showDialog("sidifyViewPublicPlaylist.fxml", Boolean.TRUE, "Contents of playlist", getStage(), new Object[] { playListService.getSongsForPlaylist(selectedItem) });
}
});
}
use of javafx.scene.control.MenuItem in project assembly64fx by freabemania.
the class C64ImageController method init.
public void init(File file, boolean launchExplorerEvenIfOnlyOneFile, boolean loadStar) throws Exception {
try {
viceService = ViceService.getInstance();
this.diskImage = DiskImage.getDiskImage(file.getAbsolutePath());
this.file = file;
if (loadStar) {
super.setCancelShow(true);
launchVice("*");
return;
}
diskImage.readDirectory();
diskImage.readBAM();
if (!launchExplorerEvenIfOnlyOneFile) {
int ctr = 0;
for (int fileNum = 0; fileNum <= diskImage.getFilenumberMax() - 1; fileNum++) {
CbmFile f = diskImage.getCbmFile(fileNum);
if (getFileTypeString(f.getFileType()).equals("PRG")) {
ctr++;
}
}
if (ctr == 1) {
super.setCancelShow(true);
launchVice("*");
return;
}
}
left.setFont(Font.loadFont(getClass().getResourceAsStream(C64_TTF), 16));
center.setFont(Font.loadFont(getClass().getResourceAsStream(C64_TTF), 16));
right.setFont(Font.loadFont(getClass().getResourceAsStream(C64_TTF), 16));
center.setText(getTextStr("\"" + StringUtils.rightPad(diskImage.getBam().getDiskName(), 16) + "\"" + StringUtils.leftPad(diskImage.getBam().getDiskId(), 6)));
left.setText("0");
left.setDisable(true);
center.setDisable(true);
right.setDisable(true);
List<Text> items2 = new ArrayList<>();
for (int fileNum = 0; fileNum <= diskImage.getFilenumberMax() - 1; fileNum++) {
CbmFile f = diskImage.getCbmFile(fileNum);
String content = StringUtils.rightPad(String.valueOf(f.getSizeInBlocks()), 4);
content += "\"";
content += f.getName() + "\"" + getTabs(f.getName());
content += getFileTypeString(f.getFileType());
items2.add(getText(content));
}
items2.add(getText(diskImage.getBlocksFree() + " BLOCKS FREE."));
ObservableList<Text> tmp = FXCollections.observableArrayList(items2);
items.setItems(tmp);
items.getSelectionModel().select(0);
items.setOnMouseClicked((event) -> {
if (event.getClickCount() == 2) {
launchVice(diskImage.getCbmFile(items.getSelectionModel().getSelectedIndex()).getName());
}
;
});
items.setOnKeyTyped((event) -> launchVice(diskImage.getCbmFile(items.getSelectionModel().getSelectedIndex()).getName()));
items.setOnKeyReleased((event) -> {
if (items.getSelectionModel().getSelectedIndex() == diskImage.getFilenumberMax()) {
items.getSelectionModel().select(diskImage.getFilenumberMax() - 1);
}
});
final ContextMenu contextMenu = new ContextMenu();
MenuItem loadStarMenuItem = new MenuItem("LOAD\"*\",8,1");
loadStarMenuItem.setOnAction((ActionEvent event2) -> {
launchVice("*");
});
contextMenu.getItems().add(loadStarMenuItem);
items.setContextMenu(contextMenu);
Analytics.sendEvent("imagebrowser", "open_image");
} catch (Exception e) {
GenericMessageDialogController.withErrorProps("Error", "Unable to open image").showAndWait();
throw e;
}
}
use of javafx.scene.control.MenuItem in project latexdraw by arnobl.
the class FileLoaderSaver method updateRecentMenuItems.
/**
* Updates the recent menu items.
* @param recentDocs The list of recent documents.
*/
public void updateRecentMenuItems(final List<String> recentDocs) {
// Clean menus before removing them?
recentFilesMenu.getItems().clear();
if (recentDocs != null && !recentDocs.isEmpty()) {
recentDocs.forEach(fileName -> {
final MenuItem item = new MenuItem(new File(fileName).getName());
item.setUserData(fileName);
recentFilesMenu.getItems().add(item);
});
}
recentFilesMenu.setDisable(recentFilesMenu.getItems().isEmpty());
}
Aggregations