From: Gregorio R. <bla...@us...> - 2005-10-23 22:01:28
|
Update of /cvsroot/limewire/gui/com/limegroup/gnutella/gui/download In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29313/com/limegroup/gnutella/gui/download Modified Files: DownloadMediator.java DownloadDataLine.java Log Message: update from limecvs Index: DownloadDataLine.java =================================================================== RCS file: /cvsroot/limewire/gui/com/limegroup/gnutella/gui/download/DownloadDataLine.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** DownloadDataLine.java 3 Aug 2005 20:09:07 -0000 1.62 --- DownloadDataLine.java 23 Oct 2005 22:01:20 -0000 1.63 *************** *** 623,626 **** --- 623,634 ---- /** + * Returns name of the file being downloaded. + * @return name of the downloaded file. + */ + public String getFileName() { + return _fileName; + } + + /** * Returns whether or not the <tt>Downloader</tt> for this download * is equal to the one passed in. Index: DownloadMediator.java =================================================================== RCS file: /cvsroot/limewire/gui/com/limegroup/gnutella/gui/download/DownloadMediator.java,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** DownloadMediator.java 15 Jul 2005 15:30:38 -0000 1.64 --- DownloadMediator.java 23 Oct 2005 22:01:20 -0000 1.65 *************** *** 7,10 **** --- 7,11 ---- import java.util.Arrays; import java.util.Comparator; + import java.util.Map; import javax.swing.AbstractAction; *************** *** 35,40 **** --- 36,43 ---- import com.limegroup.gnutella.gui.actions.CopyMagnetLinkToClipboardAction; import com.limegroup.gnutella.gui.actions.LimeAction; + import com.limegroup.gnutella.gui.actions.SearchAction; import com.limegroup.gnutella.gui.options.OptionsMediator; import com.limegroup.gnutella.gui.playlist.PlaylistMediator; + import com.limegroup.gnutella.gui.search.SearchInformation; import com.limegroup.gnutella.gui.search.SearchMediator; import com.limegroup.gnutella.gui.tables.AbstractTableMediator; *************** *** 51,56 **** --- 54,62 ---- import com.limegroup.gnutella.settings.QuestionsHandler; import com.limegroup.gnutella.settings.SharingSettings; + import com.limegroup.gnutella.settings.SearchSettings; import com.limegroup.gnutella.util.CommonUtils; + import com.limegroup.gnutella.util.FileUtils; import com.limegroup.gnutella.util.ProcessingQueue; + import com.limegroup.gnutella.util.StringUtils; /** *************** *** 106,109 **** --- 112,116 ---- private Action magnetAction; private Action bitziAction; + private Action exploreAction; /** The actual download buttons instance. *************** *** 146,149 **** --- 153,157 ---- editLocationAction = new EditLocationAction(); magnetAction = new CopyMagnetLinkToClipboardAction(this); + exploreAction = new ExploreAction(); bitziAction = new BitziLookupAction(this); } *************** *** 154,161 **** */ public Action[] getActions() { ! return new Action[] { priorityUpAction, priorityDownAction, ! removeAction, resumeAction, pauseAction, launchAction, ! clearAction, }; } --- 162,175 ---- */ public Action[] getActions() { ! Action[] actions; ! if(CommonUtils.isWindows()||CommonUtils.isMacOSX()) ! actions = new Action[] { priorityUpAction, priorityDownAction, ! removeAction, resumeAction, pauseAction, launchAction, ! exploreAction,clearAction}; ! else ! actions = new Action[] { priorityUpAction, priorityDownAction, ! removeAction, resumeAction, pauseAction, launchAction,clearAction }; + return actions; } *************** *** 262,265 **** --- 276,280 ---- priorityUpAction.setEnabled(inactive && pausable); priorityDownAction.setEnabled(inactive && pausable); + exploreAction.setEnabled(dataLine.getDownloader().isCompleted()); } *************** *** 423,426 **** --- 438,468 ---- ((Downloader)lines[i].getInitializeObject()).pause(); } + + /** + * Launches explorer + */ + void launchExplorer() { + final DataLine[] lines = TABLE.getSelectedDataLines(); + final Downloader dl = (Downloader)lines[lines.length-1].getInitializeObject(); + File toExplore = dl.getFile(); + if (toExplore == null) + return; + + String explorePath = toExplore.getPath(); + try { + explorePath = toExplore.getCanonicalPath(); + } catch(IOException ioe) { } + + try { + if (CommonUtils.isWindows()) + //launches explorer and highlights the file + Runtime.getRuntime().exec(new String[] {"explorer","/select,", explorePath }); + else if (CommonUtils.isMacOSX()) { + if(toExplore.isFile())explorePath = toExplore.getParent(); + Runtime.getRuntime().exec(new String[] { "open", explorePath }); + } + } catch(SecurityException se) { + } catch(IOException ieo) { } + } /** *************** *** 566,572 **** --- 608,617 ---- menu.add(new JMenuItem(pauseAction)); menu.add(new JMenuItem(launchAction)); + if(CommonUtils.isWindows()||CommonUtils.isMacOSX()) + menu.add(new JMenuItem(exploreAction)); menu.addSeparator(); menu.add(new JMenuItem(clearAction)); menu.addSeparator(); + menu.add(createSearchMenu()); menu.add(new JMenuItem(chatAction)); menu.add(new JMenuItem(browseAction)); *************** *** 578,581 **** --- 623,659 ---- } + private JMenu createSearchMenu() { + JMenu menu = new JMenu(GUIMediator.getStringResource("DOWNLOAD_SEARCH_MENU")); + DataLine[] lines = TABLE.getSelectedDataLines(); + if ( lines.length == 0 ) { // is there any file selected ? + menu.setEnabled(false); + return menu; + } + //-- make perform orginal query -- + // get orginal query + Downloader downloader = ((DownloadDataLine) lines[0]).getDownloader(); + Map searchInfoMap = (Map) downloader.getAttribute( + SearchMediator.SEARCH_INFORMATION_KEY ); + if ( searchInfoMap != null ) { + SearchInformation searchInfo = SearchInformation.createFromMap( searchInfoMap ); + menu.add(new JMenuItem( new SearchAction( searchInfo ) )); + } + + //-- make search for filename action -- + // get name of the file + java.lang.String filename = ((DownloadDataLine) lines[0]).getFileName(); + // remove extension - searches searches filename not in specified format + int dotPos = filename.lastIndexOf('.'); + if ( dotPos > 0 ) + filename = filename.substring( 0, dotPos ); + filename = StringUtils.removeIllegalChars( filename ); + // cut the file name if necessary + if ( filename.length() > SearchSettings.MAX_QUERY_LENGTH.getValue() ) + filename = filename.substring(0, SearchSettings.MAX_QUERY_LENGTH.getValue()); + menu.add(new JMenuItem( new SearchAction( filename ) )); + + return menu; + } + private JMenu createAdvancedSubMenu() { JMenu menu = new JMenu(GUIMediator.getStringResource *************** *** 634,637 **** --- 712,716 ---- launchAction.putValue(Action.SHORT_DESCRIPTION, GUIMediator.getStringResource("DOWNLOAD_LAUNCH_BUTTON_COMPLETED_TIP")); + exploreAction.setEnabled(TABLE.getSelectedRowCount() == 1); } else { removeAction.putValue(Action.NAME, GUIMediator.getStringResource *************** *** 647,650 **** --- 726,730 ---- launchAction.putValue(Action.SHORT_DESCRIPTION, GUIMediator.getStringResource("DOWNLOAD_LAUNCH_BUTTON_TIP")); + exploreAction.setEnabled(false); } *************** *** 680,683 **** --- 760,764 ---- magnetAction.setEnabled(false); bitziAction.setEnabled(false); + exploreAction.setEnabled(false); } *************** *** 792,795 **** --- 873,891 ---- } + private class ExploreAction extends AbstractAction { + public ExploreAction() { + putValue(Action.NAME, + GUIMediator.getStringResource("LIBRARY_EXPLORE_BUTTON_LABEL")); + putValue(LimeAction.SHORT_NAME, + GUIMediator.getStringResource("LIBRARY_EXPLORE_BUTTON_LABEL")); + putValue(Action.SHORT_DESCRIPTION, + GUIMediator.getStringResource("DOWNLOAD_EXPLORE_BUTTON_TIP")); + putValue(LimeAction.ICON_NAME, "LIBRARY_EXPLORE"); + } + + public void actionPerformed(ActionEvent e) { + launchExplorer(); + } + } private class PriorityUpAction extends AbstractAction { |