1 19 20 package org.netbeans.modules.tasklist.bugs; 21 22 import java.awt.Dialog ; 23 import java.awt.Dimension ; 24 import org.netbeans.modules.tasklist.core.TaskListView; 25 26 import org.openide.DialogDescriptor; 27 import org.openide.NotifyDescriptor; 28 import org.openide.DialogDisplayer; 29 import org.openide.cookies.EditorCookie; 30 import org.openide.filesystems.FileObject; 31 import org.openide.filesystems.FileUtil; 32 import org.openide.loaders.DataObject; 33 import org.openide.nodes.Node; 34 import org.openide.text.CloneableEditorSupport; 35 import org.openide.text.NbDocument; 36 import org.openide.util.HelpCtx; 37 import org.openide.util.NbBundle; 38 import org.openide.util.actions.NodeAction; 39 import org.openide.windows.Mode; 40 import org.openide.windows.TopComponent; 41 import org.openide.windows.WindowManager; 42 43 44 49 public class NewQueryAction extends NodeAction { 50 51 private static final long serialVersionUID = 1; 52 53 protected boolean enable(Node[] node) { 54 return true; 55 } 56 57 60 private static Node[] getEditorNodes() { 61 Node[] nodes = null; 69 WindowManager wm = WindowManager.getDefault(); 70 71 Mode mode = wm.findMode(CloneableEditorSupport.EDITOR_MODE); 76 if (mode == null) { 77 return null; 78 } 79 TopComponent [] tcs = mode.getTopComponents(); 80 for (int j = 0; j < tcs.length; j++) { 81 TopComponent tc = tcs[j]; 82 if (tc instanceof org.openide.text.EditorSupport.Editor) { 83 if (tcs[j].isShowing()) { 85 nodes = tcs[j].getActivatedNodes(); 86 break; 87 } 88 } 89 } 90 return nodes; 91 } 92 93 protected void performAction(Node[] node) { 94 BugQuery query = new BugQuery(); 95 EditQueryPanel panel = new EditQueryPanel(query, false); 96 97 DialogDescriptor d = new DialogDescriptor(panel, 98 NbBundle.getMessage(NewQueryAction.class, 99 "TITLE_NEW_QUERY")); d.setModal(true); 101 d.setHelpCtx(new HelpCtx("NewQuery")); d.setMessageType(NotifyDescriptor.PLAIN_MESSAGE); 103 d.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION); 104 Dialog dlg = DialogDisplayer.getDefault().createDialog(d); 105 dlg.pack(); 106 dlg.show(); 107 108 if (d.getValue() == NotifyDescriptor.OK_OPTION) { 109 String bugEngine = panel.getBugEngine(); 111 String queryString = panel.getQueryString(); 112 query = panel.getQuery(); 113 System.out.println("bugEngine = " + bugEngine + "\nqueryString = " + queryString); 114 115 TaskListView tv = new BugsView(query); 116 tv.showInMode(); 117 } 118 } 119 120 protected boolean asynchronous() { 121 return false; 122 } 123 130 202 public String getName() { 203 return "New Query"; } 205 206 protected String iconResource() { 207 return "org/netbeans/modules/tasklist/bugs/bugsView.gif"; } 211 212 public HelpCtx getHelpCtx() { 213 return HelpCtx.DEFAULT_HELP; 214 } 217 218 } 219 | Popular Tags |