1 19 20 package org.netbeans.modules.tasklist.suggestions.ui; 21 22 23 import java.io.IOException ; 24 import javax.swing.text.Document ; 25 import javax.swing.*; 26 27 import org.netbeans.modules.tasklist.client.SuggestionManager; 28 import org.netbeans.modules.tasklist.core.TaskList; 29 import org.netbeans.modules.tasklist.suggestions.ui.SuggestionsView; 30 import org.netbeans.modules.tasklist.suggestions.SuggestionList; 31 import org.netbeans.modules.tasklist.suggestions.SuggestionsScanner; 32 import org.openide.ErrorManager; 33 import org.openide.awt.StatusDisplayer; 34 import org.openide.cookies.EditorCookie; 35 import org.openide.loaders.DataFolder; 36 import org.openide.loaders.DataObject; 37 import org.openide.util.actions.CookieAction; 38 import org.openide.util.Utilities; 39 import org.openide.util.RequestProcessor; 40 import org.openide.nodes.Node; 41 import org.openide.util.HelpCtx; 42 import org.openide.util.NbBundle; 43 44 63 public class ScanSuggestionsAction extends CookieAction { 64 65 private static final long serialVersionUID = 1; 66 67 protected boolean asynchronous() { 68 return true; 69 } 70 71 protected void performAction(final Node[] nodes) { 72 if (nodes == null) { 73 return; 74 } 75 76 final SuggestionsView[] view = new SuggestionsView[] {null}; 77 try { 78 final SuggestionList list = new SuggestionList(); 79 SwingUtilities.invokeLater( new Runnable () { 80 public void run() { 81 view[0] = new SuggestionsView("suggestionsscan", NbBundle.getMessage(ScanSuggestionsAction.class, 90 "ScannedTasks"), list, false, 92 "org/netbeans/modules/tasklist/suggestions/folderscan.gif"); view[0].showInMode(); 94 view[0].setCursor(Utilities.createProgressCursor(view[0])); 95 } 96 }); 97 98 DataObject.Container[] folders = new DataObject.Container[nodes.length]; 99 for (int i = 0; i < nodes.length; i++) { 100 folders[i] = (DataObject.Container) nodes[i].getCookie(DataObject.Container.class); 101 } 102 SuggestionsScanner.getDefault().scan(folders, list, null); 103 104 Integer count = new Integer (list.size()); 105 StatusDisplayer.getDefault ().setStatusText( 106 NbBundle.getMessage(ScanSuggestionsAction.class, 107 "ScanDone", count)); } finally { 109 SwingUtilities.invokeLater( new Runnable () { 110 public void run() { 111 if (view[0] != null) { 112 view[0].setCursor(null); 113 } 114 } 115 }); 116 } 117 } 118 119 public String getName() { 120 return NbBundle.getMessage(ScanSuggestionsAction.class, "ScanDir"); } 122 123 protected String iconResource() { 124 return "org/netbeans/modules/tasklist/suggestions/ui/scanDir.gif"; } 126 127 public HelpCtx getHelpCtx() { 128 return HelpCtx.DEFAULT_HELP; 129 } 130 131 protected int mode() { 132 return MODE_ALL; 133 } 134 135 protected Class [] cookieClasses() { 136 return new Class [] { DataObject.Container.class }; 137 } 138 139 } 140 | Popular Tags |