1 19 20 package org.netbeans.modules.web.core; 21 22 import java.io.IOException ; 23 import org.netbeans.modules.web.core.jsploader.JspLoader; 24 import org.netbeans.modules.web.core.jsploader.JspDataObject; 25 26 import org.openide.util.HelpCtx; 27 import org.openide.util.NbBundle; 28 import org.openide.util.actions.CookieAction; 29 import org.openide.nodes.Node; 30 import org.openide.loaders.DataObject; 31 import org.openide.NotifyDescriptor; 32 33 import org.openide.DialogDisplayer; 34 import org.openide.ErrorManager; 35 36 41 public class EditQueryStringAction extends CookieAction { 42 43 static final long serialVersionUID = -8487176709444303658L; 44 45 48 public void performAction (final Node[] activatedNodes) { 49 if (activatedNodes.length == 0) { 50 return; 51 } 52 DataObject dObj = (DataObject)(activatedNodes[0]).getCookie(DataObject.class); 53 QueryStringCookie qsc = (QueryStringCookie)activatedNodes[0].getCookie(QueryStringCookie.class); 54 55 NotifyDescriptor.InputLine dlg = new NotifyDescriptor.InputLine( 56 NbBundle.getBundle(EditQueryStringAction.class).getString("CTL_QueryStringLabel"), 57 NbBundle.getBundle(EditQueryStringAction.class).getString("CTL_QueryStringTitle")); 58 59 dlg.setInputText(WebExecSupport.getQueryString(dObj.getPrimaryFile())); 60 61 if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(dlg))) { 62 try { 63 qsc.setQueryString (dlg.getInputText()); 65 } 66 catch (IOException e) { 67 ErrorManager.getDefault().notify(e); 68 } 69 } 70 } 71 72 75 protected int mode () { 76 return MODE_EXACTLY_ONE; 77 } 78 79 protected boolean enable (Node[] activatedNodes){ 80 if (activatedNodes.length == 0) { 81 return false; 82 } 83 for (int i = 0; i < activatedNodes.length; i++){ 84 DataObject dObj = (DataObject)(activatedNodes[i]).getCookie(DataObject.class); 85 QueryStringCookie qsc = (QueryStringCookie)activatedNodes[i].getCookie(QueryStringCookie.class); 86 87 if (qsc == null || dObj == null) 88 return false; 89 90 if (dObj instanceof JspDataObject){ 91 String ext = dObj.getPrimaryFile().getExt(); 92 if (ext.equals(JspLoader.TAGF_FILE_EXTENSION) 93 || ext.equals(JspLoader.TAGX_FILE_EXTENSION) 94 || ext.equals(JspLoader.TAG_FILE_EXTENSION)) 95 return false; 96 } 97 } 98 return true; 99 } 100 103 protected Class [] cookieClasses () { 104 return new Class [] { 105 QueryStringCookie.class 107 }; 108 } 109 110 111 public String getName() { 112 return NbBundle.getBundle (EditQueryStringAction.class).getString ("LBL_EditQueryString"); 113 } 114 115 116 public HelpCtx getHelpCtx() { 117 return new HelpCtx (EditQueryStringAction.class); 118 } 119 } 120 121 | Popular Tags |