1 19 package org.netbeans.modules.j2ee.sun.ide.avk.actions; 20 21 import java.net.URL ; 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.text.MessageFormat ; 25 import java.util.ResourceBundle ; 26 27 import org.openide.nodes.Node; 28 import org.openide.util.HelpCtx; 29 import org.openide.ErrorManager; 30 import org.openide.NotifyDescriptor; 31 import org.openide.awt.StatusDisplayer; 32 import org.openide.util.RequestProcessor; 33 import org.openide.util.actions.CookieAction; 34 35 import javax.enterprise.deploy.spi.DeploymentManager ; 36 import org.netbeans.modules.j2ee.sun.ide.j2ee.ui.Util; 37 import org.netbeans.modules.j2ee.sun.ide.j2ee.LogViewerSupport; 38 import org.netbeans.modules.j2ee.sun.ide.j2ee.runtime.nodes.ManagerNode; 39 import org.netbeans.modules.j2ee.sun.ide.j2ee.DeploymentManagerProperties; 40 import org.netbeans.modules.j2ee.sun.api.SunDeploymentManagerInterface; 41 42 import org.openide.awt.HtmlBrowser.URLDisplayer; 43 44 import org.netbeans.modules.j2ee.sun.ide.avk.AVKSupport; 45 46 50 public class GenerateReportAction extends CookieAction { 51 52 protected static final ResourceBundle bundle = ResourceBundle.getBundle("org.netbeans.modules.j2ee.sun.ide.avk.actions.Bundle"); private static RequestProcessor uninstrumentProc = new RequestProcessor("uninstrument"); 55 protected Class [] cookieClasses() { 56 return new Class [] {}; 57 } 58 59 protected int mode() { 60 return MODE_EXACTLY_ONE; 61 } 62 63 protected void performAction(Node[] nodes) { 64 if(nodes[0].getLookup().lookup(ManagerNode.class) != null){ 65 try{ 66 ManagerNode node = (ManagerNode)nodes[0].getLookup().lookup(ManagerNode.class); 67 SunDeploymentManagerInterface sdm = node.getDeploymentManager(); 68 final AVKSupport support = new AVKSupport(sdm); 69 final DeploymentManagerProperties dmProps = new DeploymentManagerProperties((DeploymentManager ) sdm); 70 final SunDeploymentManagerInterface currentDm = sdm; 71 uninstrumentProc.post(new Runnable () { 72 public void run() { 73 boolean generate = true; 74 try{ 75 if(currentDm.isRunning()){ 76 Object val = Util.showWarning(bundle.getString("Msg_StopServer")); if(val == NotifyDescriptor.OK_OPTION){ 78 StatusDisplayer.getDefault().setStatusText(bundle.getString("MSG_Stopping")); support.stopServer(dmProps, currentDm); 80 support.setAVK(false); 81 }else{ 82 generate=false; 83 } 84 }else{ 85 support.setAVK(false); 86 } 87 }catch(Exception ex){ 88 Util.showError(bundle.getString("Err_StopServer")); ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 90 return; 91 } 92 if(generate){ 93 dmProps.setAVKOn(false); 94 support.generateReport(); 95 dmProps.getInstanceProperties().refreshServerInstance(); 96 } 97 } 98 }); 99 } catch (Exception e){ 100 } 102 } 103 } 104 105 public String getName() { 106 return bundle.getString("LBL_Generate"); } 108 109 protected String iconResource() { 110 return "org/netbeans/modules/j2ee/sun/ide/resources/AddInstanceActionIcon.gif"; } 112 113 public HelpCtx getHelpCtx() { 114 return new HelpCtx("AVKGenerateReport"); 115 } 116 117 protected boolean enable(Node[] nodes) { 118 if( (nodes == null) || (nodes.length < 1) ) 119 return false; 120 121 if(nodes[0].getLookup().lookup(ManagerNode.class) != null){ 122 try{ 123 ManagerNode node = (ManagerNode)nodes[0].getLookup().lookup(ManagerNode.class); 124 SunDeploymentManagerInterface sdm = node.getDeploymentManager(); 125 DeploymentManagerProperties dmProps = new DeploymentManagerProperties((DeploymentManager ) sdm); 126 return (sdm.isLocal() && dmProps.getAVKOn()); 127 } catch (Exception e){ 128 } 130 } 131 return false; 132 } 133 134 protected boolean asynchronous() { 135 return false; 136 } 137 138 } 139 | Popular Tags |