1 19 20 package org.netbeans.modules.websvc.registry.nodes; 21 22 26 27 import org.openide.nodes.AbstractNode; 28 import org.openide.nodes.Sheet; 29 import org.openide.nodes.Node.Cookie; 30 import org.openide.nodes.PropertySupport.Reflection; 31 import org.openide.nodes.Sheet.Set; 32 import org.openide.util.HelpCtx; 33 import org.openide.util.NbBundle; 34 import org.openide.util.Utilities; 35 import org.openide.util.actions.SystemAction; 36 import org.openide.util.datatransfer.ExTransferable; 37 import org.openide.util.datatransfer.ExTransferable.Single; 38 39 import org.netbeans.modules.websvc.registry.actions.DeleteWebServiceAction; 41 import org.netbeans.modules.websvc.registry.model.WebServiceData; 42 import org.netbeans.modules.websvc.registry.model.WebServiceListModel; 43 import java.awt.Image ; 44 import java.awt.datatransfer.DataFlavor ; 45 import java.awt.datatransfer.Transferable ; 46 import java.io.File ; 47 import java.io.IOException ; 48 import javax.swing.Action ; 49 51 52 53 60 public class WebServicesNode extends AbstractNode implements WebServicesCookie { 62 private WebServiceData websvcData; 63 64 66 public WebServicesNode() { 67 this(null); 68 } 69 70 public WebServiceData getWebServiceData() { 71 return websvcData; 72 } 73 74 public WebServicesNode(WebServiceData wsData) { 75 super(new WebServicesNodeChildren(wsData)); 76 websvcData = wsData; 77 setName(wsData.getDisplayName()); 78 setIconBaseWithExtension("org/netbeans/modules/websvc/registry/resources/webservice.png"); 79 setShortDescription(wsData.getWSDescription()); 80 getCookieSet().add(this); 81 } 82 83 91 public Action[] getActions(boolean context) { 92 return new SystemAction[] { 93 SystemAction.get(DeleteWebServiceAction.class) 95 }; 96 } 97 98 public HelpCtx getHelpCtx() { 99 return HelpCtx.DEFAULT_HELP; 100 } 101 102 106 protected Sheet createSheet() { 107 Sheet sheet = super.createSheet(); 108 Set ss = sheet.get("data"); 110 if (ss == null) { 111 ss = new Set(); 112 ss.setName("data"); ss.setDisplayName(NbBundle.getMessage(WebServicesNode.class, "WS_INFO")); 114 ss.setShortDescription(NbBundle.getMessage(WebServicesNode.class, "WS_INFO")); 115 sheet.put(ss); 116 } 117 118 try { 119 Reflection p; 120 121 p = new Reflection(websvcData, String .class, "getName", null); p.setName("name"); p.setDisplayName(NbBundle.getMessage(WebServicesNode.class, "WS_NAME")); 124 p.setShortDescription(NbBundle.getMessage(WebServicesNode.class, "WS_NAME")); 125 ss.put(p); 126 127 p = new Reflection(websvcData, Integer .class, "getWebServicePort", null); p.setName("port"); p.setDisplayName(NbBundle.getMessage(WebServicesNode.class, "WS_PORT")); 130 p.setShortDescription(NbBundle.getMessage(WebServicesNode.class, "WS_PORT")); 131 ss.put(p); 132 133 p = new Reflection(websvcData, String .class, "getURL", null); p.setName("URL"); p.setDisplayName(NbBundle.getMessage(WebServicesNode.class, "WS_URL")); 136 p.setShortDescription(NbBundle.getMessage(WebServicesNode.class, "WS_URL")); 137 ss.put(p); 138 139 p = new Reflection(websvcData, String .class, "getWebServiceAddress", null); p.setName("Web Service Address"); p.setDisplayName(NbBundle.getMessage(WebServicesNode.class, "WS_ADDRESS")); 142 p.setShortDescription(NbBundle.getMessage(WebServicesNode.class, "WS_ADDRESS")); 143 ss.put(p); 144 } catch (NoSuchMethodException nsme) { 145 nsme.printStackTrace(); 146 } 147 148 return sheet; 149 } 150 151 public boolean canDestroy() { 152 return true; 153 } 154 155 public void destroy() throws IOException { 156 WebServiceListModel wsListModel = WebServiceListModel.getInstance(); 157 wsListModel.removeWebService(websvcData.getId()); 158 167 if(null != websvcData.getProxyJarFileName()) { 168 String jarFileName = websvcData.getProxyJarFileName(); 169 File wsJarFile = new File (jarFileName); 171 if(wsJarFile.getParentFile() == null || !wsJarFile.exists()) { 172 wsJarFile = new File (new File (System.getProperty("netbeans.user"), "websvc/"), wsJarFile.getName()); 173 } 174 wsJarFile.delete(); 175 } 176 177 super.destroy(); 178 } 179 180 public boolean canCopy() { 182 return true; 183 } 184 185 public boolean canCut() { 186 return true; 187 } 188 189 public Transferable clipboardCopy() { 190 try { 192 ExTransferable et = ExTransferable.create(super.clipboardCopy()); 193 205 206 return et; 207 } catch (IOException ioe) { 208 System.err.println("WSLeaf.clipboardCopy: Error"); 209 ioe.printStackTrace(); 210 return null; 211 } 212 } 213 214 215 224 225 236 237 public Cookie getCookie (Class type) { 238 248 return super.getCookie(type); 249 } 250 } 251 252 253 | Popular Tags |