1 19 20 package org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.actions; 21 22 import org.netbeans.modules.j2ee.sun.ide.j2ee.PluginProperties; 23 import org.openide.nodes.Node; 24 import org.openide.util.HelpCtx; 25 import org.openide.filesystems.FileObject; 26 import org.openide.filesystems.FileUtil; 27 import org.openide.loaders.DataObject; 28 import org.openide.util.NbBundle; 29 import org.openide.util.RequestProcessor; 30 import org.openide.util.actions.NodeAction; 31 32 33 import org.netbeans.modules.j2ee.sun.ide.j2ee.VerifierSupport; 34 38 public class RunASVerifierAction extends NodeAction { 39 40 protected Class [] cookieClasses() { 41 return new Class [] {}; 42 } 43 44 45 protected void performAction(Node[] nodes) { 46 if(nodes.length==0 || nodes.length>1) { 47 return; 48 }else{ 49 Node node=nodes[0]; 50 DataObject dob = (DataObject) node.getCookie(DataObject.class); 51 if(dob!=null){ 52 FileObject fo=dob.getPrimaryFile(); 54 String ext=fo.getExt(); 55 if("jar".equals(ext) || "war".equals(ext) || "ear".equals(ext) || "rar".equals(ext)){ 57 final String jname = FileUtil.toFile(fo).getAbsolutePath(); 58 RequestProcessor.getDefault().post(new Runnable () { 59 public void run() { 60 launchVerifier(jname); 61 } 62 }); 63 } 64 } 65 66 } 67 } 68 69 public void launchVerifier(String archiveLocation){ 70 java.io.File irf = org.netbeans.modules.j2ee.sun.api.ServerLocationManager.getLatestPlatformLocation(); 71 if (null != irf && irf.exists()) { 72 String installRoot = irf.getAbsolutePath(); System.setProperty("com.sun.aas.configRoot", installRoot+"/config"); 74 System.setProperty("com.sun.aas.verifier.xsl", installRoot+"/lib/verifier"); 75 System.setProperty("server.name", "server"); 76 } 79 try{ 80 VerifierSupport.launchVerifier(archiveLocation,null); 81 } catch (Throwable t) { 82 t.printStackTrace(); 83 } finally { 84 } 86 } 87 88 public String getName() { 89 return NbBundle.getMessage(ShowAdminToolAction.class, "LBL_RunASVeriferAction"); 90 } 91 92 protected String iconResource() { 93 return "org/netbeans/modules/j2ee/sun/ide/resources/ServerInstanceIcon.png"; 94 } 95 96 public HelpCtx getHelpCtx() { 97 return null; } 101 102 protected boolean enable(Node[] nodes) { 103 boolean result=false; 104 if(nodes.length==0 || nodes.length>1) { 105 result=false; 106 }else{ 107 Node node=nodes[0]; 108 DataObject dob = (DataObject) node.getCookie(DataObject.class); 109 if(dob!=null){ 110 FileObject fo=dob.getPrimaryFile(); 112 String ext=fo.getExt(); 113 if("jar".equals(ext) || "war".equals(ext) || "ear".equals(ext) || "rar".equals(ext)){ 115 result=true; 116 } 117 } 118 } 119 return result; 120 } 121 122 protected boolean asynchronous() { 123 return false; 124 } 125 126 127 } 128 | Popular Tags |