use of se.light.assembly64.model.PlaylistInfo 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);
}
}
use of se.light.assembly64.model.PlaylistInfo 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 se.light.assembly64.model.PlaylistInfo in project assembly64fx by freabemania.
the class SidifyExportPlaylistController method export.
public void export() throws Exception {
int idx = locations.getSelectionModel().getSelectedIndex();
List<String> exportLocations = new ArrayList<>();
if (idx != 0) {
exportLocations.addAll(Collections.singletonList(locations.getSelectionModel().getSelectedItem()));
} else {
exportLocations.addAll(locations.getItems().stream().filter(item -> !item.equals(ALL_LOCATIONS)).collect(Collectors.toList()));
}
int items = playlists.stream().map(item -> playlistService.getSongsForPlaylist(item)).map(item -> item.size()).mapToInt(i -> i.intValue()).sum() * exportLocations.size();
CancelableTask cancelTask = CancelableTask.of();
ProgressDBController controller = GuiUtils.showDialogOwnerNoWait("progressBarDbUpdate.fxml", "Progress", true, NullWindowOwner.of(), new Object[] { items, cancelTask, exportLocations.get(0) + MUSIC_SIDIFY, "Playlist exported to <location>/Music/Sidify" });
NonReturningTask t = () -> {
try {
for (PlaylistInfo playlist : playlists) {
List<PlaylistEntry> songsForPlaylist = playlistService.getSongsForPlaylist(playlist);
int padding = Integer.valueOf(String.valueOf(songsForPlaylist.size()).length());
for (String dir : exportLocations) {
File exportDir = new File(dir + MUSIC_SIDIFY + playlist.getName());
FileUtils.deleteQuietly(exportDir);
FileUtils.forceMkdir(exportDir);
int ctr = 1;
for (PlaylistEntry entry : playlistService.getSongsForPlaylist(playlist)) {
String pos = String.format("%0" + padding + "d", ctr);
try {
controller.increaseProgress();
controller.setProgressLabel("Exporting " + entry.getNameMasked());
FileUtils.copyFile(downloadService.getSid(entry), new File(exportDir + "/" + pos + "_" + entry.getNameMasked() + ".sid"));
ctr++;
} catch (Exception e) {
e.printStackTrace();
}
if (cancelTask.isCancelled()) {
FileUtils.deleteQuietly(exportDir);
break;
}
}
}
if (cancelTask.isCancelled()) {
break;
}
}
} finally {
controller.progressDone();
}
};
ExecutorUtil.executeAsync(t);
}
use of se.light.assembly64.model.PlaylistInfo 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 se.light.assembly64.model.PlaylistInfo in project assembly64fx by freabemania.
the class SidifyViewPublicPlaylistsController method populateList.
private void populateList() {
items.clear();
Set<String> myLists = playListService.myPlaylistIds();
for (PlaylistInfo item : playListService.getPublicPlaylists()) {
if (!myLists.contains(item.getId())) {
if (filter.getText().length() == 0 || (filter.getText().length() > 0 && item.getName().toLowerCase().startsWith(filter.getText().toLowerCase()))) {
items.add(item);
}
}
}
publicLists.setItems(items);
if (myLists.size() > 0) {
publicLists.getSelectionModel().select(0);
publicLists.getFocusModel().focus(0);
}
}
Aggregations