/** * Same as <tt>getInputFile</tt> that takes no arguments, except this allows the caller to specify * the parent component of the chooser. * * @param parent the <tt>Component</tt> that should be the dialog's parent * @return the selected <tt>File</tt> instance, or <tt>null</tt> if a file was not selected * correctly */ public static List<File> getMultiInputFile(Component parent) { return getMultiInputFile( parent, I18nMarker.marktr("Select Folder"), I18nMarker.marktr("Select"), getLastInputDirectory()); }
/** * Same as <tt>getInputFile</tt> that takes no arguments, except this allows the caller to specify * the parent component of the chooser. * * @param parent the <tt>Component</tt> that should be the dialog's parent * @param filter the <tt>FileFilter</tt> instance for customizing the files that are displayed -- * if this is null, no filter is used * @return the selected <tt>File</tt> instance, or <tt>null</tt> if a file was not selected * correctly */ public static File getInputFile(Component parent, FileFilter filter) { return getInputFile( parent, I18nMarker.marktr("Select Folder"), I18nMarker.marktr("Select"), getLastInputDirectory(), filter); }
/** * Runs through all the associations that this manager is handling and checks to see if they can * be enabled. If 'prompt' is true, this will prompt the user (respecting any 'do not ask again' * settings) prior to moving an association to LimeWire from another program. If 'prompt' is * false, this will only change associations that are currently unset. * * @param prompt whether to prompt the user * @return true if all allowed and supported associations are registered to us. (only meaningful * if prompt is false). */ public boolean checkAndGrab(boolean prompt) { boolean ret = true; for (LimeAssociationOption association : associations) { if (association.isAllowed()) { if (association.isAvailable()) // grab all available associations association.setEnabled(true); else if (!association.isEnabled()) ret = false; } } if (!ret && prompt) { DialogOption answer = GUIMediator.showYesNoOtherMessage( I18n.tr( "One or more files or protocols that LimeWire uses are no longer associated with LimeWire. Would you like LimeWire to re-associate them?"), QuestionsHandler.GRAB_ASSOCIATIONS, I18n.tr("Details")); if (answer == DialogOption.YES) { for (LimeAssociationOption association : associations) { if (association.isAllowed() && !association.isEnabled()) association.setEnabled(true); } } else if (answer == DialogOption.OTHER) { new ConfigureOptionsAction(I18nMarker.marktr("File Associations")).actionPerformed(null); } } return ret; }
/** Loads a playlist. */ public void importM3U(Playlist playlist) { File parentFile = FileChooserHandler.getLastInputDirectory(); if (parentFile == null) parentFile = CommonUtils.getCurrentDirectory(); final File selFile = FileChooserHandler.getInputFile( GUIMediator.getAppFrame(), I18nMarker.marktr("Open Playlist (.m3u)"), parentFile, new PlaylistListFileFilter()); // nothing selected? exit. if (selFile == null || !selFile.isFile()) return; String path = selFile.getPath(); try { path = FileUtils.getCanonicalPath(selFile); } catch (IOException ignored) { // LOG.warn("unable to get canonical path for file: " + selFile, ignored); } // create a new thread off of the event queue to process reading the files from // disk loadM3U(playlist, selFile, path); }
/** Saves a playlist. */ public void exportM3U(Playlist playlist) { if (playlist == null) { return; } String suggestedName = CommonUtils.convertFileName(playlist.getName()); // get the user to select a new one.... avoid FrostWire installation folder. File suggested; File suggestedDirectory = FileChooserHandler.getLastInputDirectory(); if (suggestedDirectory.equals(CommonUtils.getCurrentDirectory())) { suggestedDirectory = new File(CommonUtils.getUserHomeDir(), "Desktop"); } suggested = new File(suggestedDirectory, suggestedName + ".m3u"); File selFile = FileChooserHandler.getSaveAsFile( GUIMediator.getAppFrame(), I18nMarker.marktr("Save Playlist As"), suggested, new PlaylistListFileFilter()); // didn't select a file? nothing we can do. if (selFile == null) { return; } // if the file already exists and not the one just opened, ask if it should be // overwritten. // TODO: this should be handled in the jfilechooser if (selFile.exists()) { DialogOption choice = GUIMediator.showYesNoMessage( I18n.tr( "Warning: a file with the name {0} already exists in the folder. Overwrite this file?", selFile.getName()), QuestionsHandler.PLAYLIST_OVERWRITE_OK, DialogOption.NO); if (choice != DialogOption.YES) return; } String path = selFile.getPath(); try { path = FileUtils.getCanonicalPath(selFile); } catch (IOException ignored) { // LOG.warn("unable to get canonical path for file: " + selFile, ignored); } // force m3u on the end. if (!path.toLowerCase().endsWith(".m3u")) path += ".m3u"; // create a new thread to handle saving the playlist to disk saveM3U(playlist, path); }
/** Returns a menu with a 'repeat search' and 'repeat search no clear' action. */ protected final JMenu createSearchAgainMenu(SearchResultDataLine line) { JMenu menu = new SkinMenu(I18n.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) { menu.add( new SkinMenuItem(new SearchAction(info, I18nMarker.marktr("Search for Keywords: {0}")))); } return menu; }
IntentWindow(SetupManager manager) { super(manager, I18nMarker.marktr("State Your Intent"), I18nMarker.marktr("One more thing...")); }
// 2345678|012345678|012345678|012345678|012345678|012345678|012345678|012345678| public final class StatusBarConnectionQualityPaneItem extends AbstractPaneItem { public static final String TITLE = I18n.tr("Connection Quality Indicator"); public static final String LABEL = I18n.tr("You can display a measurement of your connection quality in the status bar."); /** * Constant for the key of the locale-specific <tt>String</tt> for whether the connection quality * status should be displayed in the status bar. */ private final String CHECK_BOX_LABEL = I18nMarker.marktr("Show Connection Quality Indicator:"); private final JCheckBox CHECK_BOX = new JCheckBox(); /** * The constructor constructs all of the elements of this <tt>AbstractPaneItem</tt>. * * @param key the key for this <tt>AbstractPaneItem</tt> that the superclass uses to generate * locale-specific keys */ public StatusBarConnectionQualityPaneItem() { super(TITLE, LABEL); LabeledComponent comp = new LabeledComponent( CHECK_BOX_LABEL, CHECK_BOX, LabeledComponent.LEFT_GLUE, LabeledComponent.LEFT); add(comp.getComponent()); } /** * Defines the abstract method in <tt>AbstractPaneItem</tt>. * * <p>Sets the options for the fields in this <tt>PaneItem</tt> when the window is shown. */ @Override public void initOptions() { CHECK_BOX.setSelected(StatusBarSettings.CONNECTION_QUALITY_DISPLAY_ENABLED.getValue()); } /** * Defines the abstract method in <tt>AbstractPaneItem</tt>. * * <p>Applies the options currently set in this window, displaying an error message to the user if * a setting could not be applied. * * @throws IOException if the options could not be applied for some reason */ @Override public boolean applyOptions() throws IOException { if (!isDirty()) return false; StatusBarSettings.CONNECTION_QUALITY_DISPLAY_ENABLED.setValue(CHECK_BOX.isSelected()); GUIMediator.instance().getStatusLine().refresh(); return false; } public boolean isDirty() { return StatusBarSettings.CONNECTION_QUALITY_DISPLAY_ENABLED.getValue() != CHECK_BOX.isSelected(); } }
@Override public String getServiceName() { return org.limewire.i18n.I18nMarker.marktr("HTTP Request Listening"); }
// 2345678|012345678|012345678|012345678|012345678|012345678|012345678|012345678| public final class AutoClearDownloadsPaneItem extends AbstractPaneItem { public static final String TITLE = I18n.tr("Clear Downloads"); public static final String LABEL = I18n.tr( "You can choose whether or not to automatically clear downloads that have completed."); /** * Constant for the key of the locale-specific <code>String</code> for the download pane check box * label in the options window. */ private final String CHECK_BOX_LABEL = I18nMarker.marktr("Clear Completed Downloads:"); /** * Constant for the check box that specifies whether or not downloads should be automatically * cleared. */ private final JCheckBox CHECK_BOX = new JCheckBox(); /** The stored value to allow rolling back changes. */ private boolean _clearDownloads; /** * The constructor constructs all of the elements of this <tt>AbstractPaneItem</tt>. * * @param key the key for this <tt>AbstractPaneItem</tt> that the superclass uses to generate * locale-specific keys */ public AutoClearDownloadsPaneItem() { super(TITLE, LABEL); LabeledComponent comp = new LabeledComponent( CHECK_BOX_LABEL, CHECK_BOX, LabeledComponent.LEFT_GLUE, LabeledComponent.LEFT); add(comp.getComponent()); } /** * Defines the abstract method in <tt>AbstractPaneItem</tt>. * * <p>Sets the options for the fields in this <tt>PaneItem</tt> when the window is shown. */ @Override public void initOptions() { _clearDownloads = SharingSettings.CLEAR_DOWNLOAD.getValue(); CHECK_BOX.setSelected(_clearDownloads); } /** * Defines the abstract method in <tt>AbstractPaneItem</tt>. * * <p>Applies the options currently set in this window, displaying an error message to the user if * a setting could not be applied. * * @throws IOException if the options could not be applied for some reason */ @Override public boolean applyOptions() throws IOException { final boolean clearDownloads = CHECK_BOX.isSelected(); if (clearDownloads != _clearDownloads) { SharingSettings.CLEAR_DOWNLOAD.setValue(clearDownloads); _clearDownloads = clearDownloads; } return false; } public boolean isDirty() { return SharingSettings.CLEAR_DOWNLOAD.getValue() != CHECK_BOX.isSelected(); } }
/** * Same as <tt>getInputFile</tt> that takes no arguments, except this allows the caller to specify * the parent component of the chooser as well as other options. * * @param parent the <tt>Component</tt> that should be the dialog's parent * @param directory the directory to open the dialog to * @return the selected <tt>File</tt> instance, or <tt>null</tt> if a file was not selected * correctly */ public static File getInputDirectory(Component parent, File directory) { return getInputDirectory( parent, I18nMarker.marktr("Select Folder"), I18nMarker.marktr("Select"), directory); }
@Override public String getServiceName() { return I18nMarker.marktr("Uptime Statistics"); }
public UsagePage() { super( "usagePage", I18nMarker.marktr("Publish License"), I18nMarker.marktr("This tool helps you publish audio under a Creative Commons license.")); }
/** * Same as <tt>getInputFile</tt> that takes no arguments, except this allows the caller to specify * the parent component of the chooser. * * @param parent the <tt>Component</tt> that should be the dialog's parent * @param titleKey the key for the locale-specific string to use for the file dialog title * @param directory the directory to open the dialog to * @return the selected <tt>File</tt> instance, or <tt>null</tt> if a file was not selected * correctly */ public static File getInputFile(Component parent, String titleKey, File directory) { return getInputFile(parent, titleKey, I18nMarker.marktr("Select"), directory); }
/** * Same as <tt>getInputFile</tt> that takes no arguments, except this allows the caller to specify * the parent component of the chooser as well as other options. * * @param parent the <tt>Component</tt> that should be the dialog's parent * @param titleKey the key for the locale-specific string to use for the file dialog title * @param directory the directory to open the dialog to * @param filter the <tt>FileFilter</tt> instance for customizing the files that are displayed -- * if this is null, no filter is used * @return the selected <tt>File</tt> instance, or <tt>null</tt> if a file was not selected * correctly */ public static File getInputDirectory( Component parent, String titleKey, File directory, FileFilter filter) { return getInputDirectory(parent, titleKey, I18nMarker.marktr("Select"), directory, filter); }
public String getServiceName() { return org.limewire.i18n.I18nMarker.marktr("Static Messages"); }
public String getServiceName() { return I18nMarker.marktr("Update Checks"); }
public String getServiceName() { return I18nMarker.marktr("Content Management"); }
/** * Same as <tt>getInputDirectory</tt> that takes no arguments, except this allows the caller to * specify the parent component of the chooser. * * @param parent the <tt>Component</tt> that should be the dialog's parent * @return the selected <tt>File</tt> instance, or <tt>null</tt> if a file was not selected * correctly */ public static File getInputDirectory(Component parent) { return getInputDirectory(parent, I18nMarker.marktr("Select Folder"), getLastInputDirectory()); }
@Override public String getServiceName() { return org.limewire.i18n.I18nMarker.marktr("Magnet Processor"); }
private void copyPlaylistFilesToFolder(Playlist playlist) { if (playlist == null || playlist.getItems().isEmpty()) { return; } File suggestedDirectory = FileChooserHandler.getLastInputDirectory(); if (suggestedDirectory.equals(CommonUtils.getCurrentDirectory())) { suggestedDirectory = new File(CommonUtils.getUserHomeDir(), "Desktop"); } final File selFolder = FileChooserHandler.getSaveAsDir( GUIMediator.getAppFrame(), I18nMarker.marktr("Where do you want the playlist files copied to?"), suggestedDirectory); if (selFolder == null) { return; } // let's make a copy of the list in case the playlist will be modified during the copying. final List<PlaylistItem> playlistItems = new ArrayList<>(playlist.getItems()); BackgroundExecutorService.schedule( new Thread("Library-copy-playlist-files") { @Override public void run() { int n = 0; int total = playlistItems.size(); String targetName = selFolder.getName(); for (PlaylistItem item : playlistItems) { File f = new File(item.getFilePath()); if (f.isFile() && f.exists() && f.canRead()) { try { Path source = f.toPath(); Path target = FileSystems.getDefault().getPath(selFolder.getAbsolutePath(), f.getName()); Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); n++; // invoked on UI thread later String status = String.format("Copied %d of %d to %s", n, total, targetName); LibraryMediator.instance().getLibrarySearch().pushStatus(status); } catch (IOException e) { e.printStackTrace(); } } } GUIMediator.launchExplorer(selFolder); // and clear the output try { Thread.sleep(2000); LibraryMediator.instance().getLibrarySearch().pushStatus(""); } catch (InterruptedException e) { } } }); }
/** * Same as <tt>getInputFile</tt> that takes no arguments, except this allows the caller to specify * the parent component of the chooser. * * @param parent the <tt>Component</tt> that should be the dialog's parent * @param titleKey the key for the locale-specific string to use for the file dialog title * @param directory the directory to open the dialog to * @param filter the <tt>FileFilter</tt> instance for customizing the files that are displayed -- * if this is null, no filter is used * @return the selected <tt>File</tt> instance, or <tt>null</tt> if a file was not selected * correctly */ public static List<File> getMultiInputFile( Component parent, String titleKey, File directory, FileFilter filter) { return getMultiInputFile(parent, titleKey, I18nMarker.marktr("Select"), directory, filter); }
static { errorDescs = new EnumMap<ErrorType, EnumMap<DetailErrorType, String>>(ErrorType.class); for (ErrorType type : ErrorType.values()) errorDescs.put(type, new EnumMap<DetailErrorType, String>(DetailErrorType.class)); errorDescs .get(ErrorType.GENERIC) .put( DetailErrorType.DISK_FULL, I18nMarker.marktr( "LimeWire was unable to write a necessary file because your hard drive is full. To continue using LimeWire you must free up space on your hard drive.")); errorDescs .get(ErrorType.GENERIC) .put( DetailErrorType.FILE_LOCKED, I18nMarker.marktr( "LimeWire was unable to open a necessary file because another program has locked the file. LimeWire may act unexpectedly until this file is released.")); errorDescs .get(ErrorType.GENERIC) .put( DetailErrorType.NO_PRIVS, I18nMarker.marktr( "LimeWire was unable to write a necessary file because you do not have the necessary permissions. Your preferences may not be maintained the next time you start LimeWire, or LimeWire may behave in unexpected ways.")); errorDescs .get(ErrorType.GENERIC) .put( DetailErrorType.BAD_CHARS, I18nMarker.marktr( "LimeWire cannot open a necessary file because the filename contains characters which are not supported by your operating system. LimeWire may behave in unexpected ways.")); errorDescs .get(ErrorType.DOWNLOAD) .put( DetailErrorType.DISK_FULL, I18nMarker.marktr( "LimeWire cannot download the selected file because your hard drive is full. To download more files, you must free up space on your hard drive.")); errorDescs .get(ErrorType.DOWNLOAD) .put( DetailErrorType.FILE_LOCKED, I18nMarker.marktr( "LimeWire was unable to download the selected file because another program is using the file. Please close the other program and retry the download.")); errorDescs .get(ErrorType.DOWNLOAD) .put( DetailErrorType.NO_PRIVS, I18nMarker.marktr( "LimeWire was unable to create or continue writing an incomplete file for the selected download because you do not have permission to write files to the incomplete folder. To continue using LimeWire, please choose a different Save Folder.")); errorDescs .get(ErrorType.DOWNLOAD) .put( DetailErrorType.BAD_CHARS, I18nMarker.marktr( "LimeWire was unable to open the incomplete file for the selected download because the filename contains characters which are not supported by your operating system.")); // just verify it was all setup right. for (ErrorType type : ErrorType.values()) { assert errorDescs.get(type) != null; assert errorDescs.get(type).size() == DetailErrorType.values().length; } }