use of com.frostwire.gui.theme.SkinMenuItem in project frostwire by frostwire.
the class LibraryPlaylists method addExportActionsToPopupMenu.
private void addExportActionsToPopupMenu(SkinPopupMenu playlistPopup, boolean playlistEmpty) {
if (!playlistEmpty) {
playlistPopup.addSeparator();
playlistPopup.add(new SkinMenuItem(actions[COPY_PLAYLIST_FILES_ACTION]));
playlistPopup.add(new SkinMenuItem(actions[EXPORT_PLAYLIST_ACTION]));
playlistPopup.addSeparator();
if (OSUtils.isWindows() || OSUtils.isMacOSX()) {
playlistPopup.add(new SkinMenuItem(actions[EXPORT_TO_ITUNES_ACTION]));
}
}
}
use of com.frostwire.gui.theme.SkinMenuItem in project frostwire by frostwire.
the class LibraryFilesTableMediator method createSearchSubMenu.
private JMenu createSearchSubMenu(LibraryFilesTableDataLine dl) {
SkinMenu menu = new SkinMenu(I18n.tr("Search"));
if (dl != null) {
File f = dl.getInitializeObject();
String keywords = QueryUtils.createQueryString(f.getName());
if (keywords.length() > 0)
menu.add(new SkinMenuItem(new SearchAction(keywords)));
}
if (menu.getItemCount() == 0)
menu.setEnabled(false);
return menu;
}
use of com.frostwire.gui.theme.SkinMenuItem in project frostwire by frostwire.
the class SearchResultMediator method createSearchAgainMenu.
/**
* Returns a menu with a 'repeat search' and 'repeat search no clear' action.
*/
private JMenu createSearchAgainMenu(SearchResultDataLine line) {
JMenu menu = new SkinMenu(tr("Search More"));
menu.add(new SkinMenuItem(new RepeatSearchAction()));
if (line == null) {
menu.setEnabled(isRepeatSearchEnabled());
return menu;
}
menu.addSeparator();
String keywords = QueryUtils.createQueryString(line.getFilename());
SearchInformation info = SearchInformation.createKeywordSearch(keywords, null, MediaType.getAnyTypeMediaType());
if (SearchMediator.validateInfo(info) == SearchMediator.QUERY_VALID) {
SeasonalContentSearchSuggestion.attemptToAddSeasonalContentSearchSuggestion(menu, null, searchTokens);
menu.add(new SkinMenuItem(new SearchAction(info, tr("Search for Keywords: {0}"))));
}
return menu;
}
use of com.frostwire.gui.theme.SkinMenuItem in project frostwire by frostwire.
the class BTDownloadMediatorAdvancedMenuFactory method addSpeedMenu.
private static void addSpeedMenu(SkinMenu menuAdvanced, boolean isTorrentContext, boolean hasSelection, boolean downSpeedDisabled, boolean downSpeedUnlimited, long totalDownSpeed, long downSpeedSetMax, long maxDownload, boolean upSpeedDisabled, boolean upSpeedUnlimited, long totalUpSpeed, long upSpeedSetMax, long maxUpload, final int num_entries, final SpeedAdapter adapter) {
// advanced > Download Speed Menu //
final SkinMenu menuDownSpeed = new SkinMenu(I18n.tr("Set Down Speed"));
menuAdvanced.add(menuDownSpeed);
final SkinMenuItem itemCurrentDownSpeed = new SkinMenuItem();
itemCurrentDownSpeed.setEnabled(false);
StringBuffer speedText = new StringBuffer();
String separator = "";
// itemDownSpeed.
if (downSpeedDisabled) {
speedText.append(I18n.tr("Disabled"));
separator = " / ";
}
if (downSpeedUnlimited) {
speedText.append(separator);
speedText.append(I18n.tr("Unlimited"));
separator = " / ";
}
if (totalDownSpeed > 0) {
speedText.append(separator);
speedText.append(DisplayFormatters.formatByteCountToKiBEtcPerSec(totalDownSpeed));
}
itemCurrentDownSpeed.setText(speedText.toString());
menuDownSpeed.add(itemCurrentDownSpeed);
menuDownSpeed.addSeparator();
final SkinMenuItem[] itemsDownSpeed = new SkinMenuItem[12];
ActionListener itemsDownSpeedListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() != null && e.getSource() instanceof SkinMenuItem) {
SkinMenuItem item = (SkinMenuItem) e.getSource();
int speed = item.getClientProperty("maxdl") == null ? 0 : ((Integer) item.getClientProperty("maxdl")).intValue();
adapter.setDownSpeed(speed);
}
}
};
itemsDownSpeed[1] = new SkinMenuItem();
itemsDownSpeed[1].setText(I18n.tr("No limit"));
itemsDownSpeed[1].putClientProperty("maxdl", new Integer(0));
itemsDownSpeed[1].addActionListener(itemsDownSpeedListener);
menuDownSpeed.add(itemsDownSpeed[1]);
if (hasSelection) {
// using 200KiB/s as the default limit when no limit set.
if (maxDownload == 0) {
if (downSpeedSetMax == 0) {
maxDownload = 200 * 1024;
} else {
maxDownload = 4 * (downSpeedSetMax / 1024) * 1024;
}
}
for (int i = 2; i < 12; i++) {
itemsDownSpeed[i] = new SkinMenuItem();
itemsDownSpeed[i].addActionListener(itemsDownSpeedListener);
// dms.length has to be > 0 when hasSelection
int limit = (int) (maxDownload / (10 * num_entries) * (12 - i));
StringBuffer speed = new StringBuffer();
speed.append(DisplayFormatters.formatByteCountToKiBEtcPerSec(limit * num_entries));
// if (num_entries > 1) {
// speed.append(" ");
// speed.append(MessageText
// .getString("MyTorrentsView.menu.setSpeed.in"));
// speed.append(" ");
// speed.append(num_entries);
// speed.append(" ");
// speed.append(MessageText
// .getString("MyTorrentsView.menu.setSpeed.slots"));
// speed.append(" ");
// speed
// .append(DisplayFormatters.formatByteCountToKiBEtcPerSec(limit));
// }
itemsDownSpeed[i].setText(speed.toString());
itemsDownSpeed[i].putClientProperty("maxdl", new Integer(limit));
menuDownSpeed.add(itemsDownSpeed[i]);
}
}
// ---
// menuDownSpeed.addSeparator();
//
// final SkinMenuItem itemDownSpeedManualSingle = new SkinMenuItem();
// itemDownSpeedManualSingle.setText(I18n.tr("Manual..."));
// itemDownSpeedManualSingle.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// //int speed_value = getManualSpeedValue(shell, true);
// //if (speed_value > 0) {adapter.setDownSpeed(speed_value);}
// }
// });
// menuDownSpeed.add(itemDownSpeedManualSingle);
// if (num_entries > 1) {
// final MenuItem itemDownSpeedManualShared = new MenuItem(menuDownSpeed, SWT.PUSH);
// Messages.setLanguageText(itemDownSpeedManualShared, isTorrentContext?"MyTorrentsView.menu.manual.shared_torrents":"MyTorrentsView.menu.manual.shared_peers");
// itemDownSpeedManualShared.addSelectionListener(new SelectionAdapter() {
// public void widgetSelected(SelectionEvent e) {
// int speed_value = getManualSharedSpeedValue(shell, true, num_entries);
// if (speed_value > 0) {adapter.setDownSpeed(speed_value);}
// }
// });
// }
// advanced >Upload Speed Menu //
final SkinMenu menuUpSpeed = new SkinMenu(I18n.tr("Set Up Speed"));
menuAdvanced.add(menuUpSpeed);
final SkinMenuItem itemCurrentUpSpeed = new SkinMenuItem();
itemCurrentUpSpeed.setEnabled(false);
separator = "";
speedText = new StringBuffer();
// itemUpSpeed.
if (upSpeedDisabled) {
speedText.append(I18n.tr("Disabled"));
separator = " / ";
}
if (upSpeedUnlimited) {
speedText.append(separator);
speedText.append(I18n.tr("Unlimited"));
separator = " / ";
}
if (totalUpSpeed > 0) {
speedText.append(separator);
speedText.append(DisplayFormatters.formatByteCountToKiBEtcPerSec(totalUpSpeed));
}
itemCurrentUpSpeed.setText(speedText.toString());
menuUpSpeed.add(itemCurrentUpSpeed);
// ---
menuUpSpeed.addSeparator();
final SkinMenuItem[] itemsUpSpeed = new SkinMenuItem[12];
ActionListener itemsUpSpeedListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() != null && e.getSource() instanceof SkinMenuItem) {
SkinMenuItem item = (SkinMenuItem) e.getSource();
int speed = item.getClientProperty("maxul") == null ? 0 : ((Integer) item.getClientProperty("maxul")).intValue();
adapter.setUpSpeed(speed);
}
}
};
itemsUpSpeed[1] = new SkinMenuItem();
itemsUpSpeed[1].setText(I18n.tr("No limit"));
itemsUpSpeed[1].putClientProperty("maxul", new Integer(0));
itemsUpSpeed[1].addActionListener(itemsUpSpeedListener);
menuUpSpeed.add(itemsUpSpeed[1]);
if (hasSelection) {
// using 75KiB/s as the default limit when no limit set.
if (maxUpload == 0) {
maxUpload = 75 * 1024;
} else {
if (upSpeedSetMax == 0) {
maxUpload = 200 * 1024;
} else {
maxUpload = 4 * (upSpeedSetMax / 1024) * 1024;
}
}
for (int i = 2; i < 12; i++) {
itemsUpSpeed[i] = new SkinMenuItem();
itemsUpSpeed[i].addActionListener(itemsUpSpeedListener);
int limit = (int) (maxUpload / (10 * num_entries) * (12 - i));
StringBuffer speed = new StringBuffer();
speed.append(DisplayFormatters.formatByteCountToKiBEtcPerSec(limit * num_entries));
// if (num_entries > 1) {
// speed.append(" ");
// speed.append(MessageText
// .getString("MyTorrentsView.menu.setSpeed.in"));
// speed.append(" ");
// speed.append(num_entries);
// speed.append(" ");
// speed.append(MessageText
// .getString("MyTorrentsView.menu.setSpeed.slots"));
// speed.append(" ");
// speed
// .append(DisplayFormatters.formatByteCountToKiBEtcPerSec(limit));
// }
itemsUpSpeed[i].setText(speed.toString());
itemsUpSpeed[i].putClientProperty("maxul", new Integer(limit));
menuUpSpeed.add(itemsUpSpeed[i]);
}
}
// menuUpSpeed.addSeparator();
//
// final SkinMenuItem itemUpSpeedManualSingle = new SkinMenuItem();
// itemUpSpeedManualSingle.setText(I18n.tr("Manual..."));
// itemUpSpeedManualSingle.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// //int speed_value = getManualSpeedValue(shell, false);
// //if (speed_value > 0) {adapter.setUpSpeed(speed_value);}
// }
// });
// menuUpSpeed.add(itemUpSpeedManualSingle);
// if (num_entries > 1) {
// final MenuItem itemUpSpeedManualShared = new MenuItem(menuUpSpeed, SWT.PUSH);
// Messages.setLanguageText(itemUpSpeedManualShared, isTorrentContext?"MyTorrentsView.menu.manual.shared_torrents":"MyTorrentsView.menu.manual.shared_peers" );
// itemUpSpeedManualShared.addSelectionListener(new SelectionAdapter() {
// public void widgetSelected(SelectionEvent e) {
// int speed_value = getManualSharedSpeedValue(shell, false, num_entries);
// if (speed_value > 0) {adapter.setUpSpeed(speed_value);}
// }
// });
// }
}
use of com.frostwire.gui.theme.SkinMenuItem in project frostwire by frostwire.
the class BTDownloadMediatorAdvancedMenuFactory method createAddToPlaylistSubMenu.
public static SkinMenu createAddToPlaylistSubMenu() {
BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders();
if (downloaders.length == 0) {
return null;
}
for (BTDownload dler : downloaders) {
if (!dler.isCompleted()) {
return null;
}
File saveLocation = dler.getSaveLocation();
if (saveLocation.isDirectory()) {
// If the file(s) is(are) inside a folder
if (!LibraryUtils.directoryContainsAudio(saveLocation)) {
return null;
}
} else if (!MediaPlayer.isPlayableFile(saveLocation)) {
return null;
}
}
SkinMenu menu = new SkinMenu(I18n.tr("Add to playlist"));
menu.add(new SkinMenuItem(new CreateNewPlaylistAction()));
Library library = LibraryMediator.getLibrary();
List<Playlist> playlists = library.getPlaylists();
if (playlists.size() > 0) {
menu.addSeparator();
for (Playlist playlist : library.getPlaylists()) {
menu.add(new SkinMenuItem(new AddToPlaylistAction(playlist)));
}
}
return menu;
}
Aggregations