1 19 20 23 24 package org.netbeans.modules.j2ee.sun.ws7.nodes; 25 26 import javax.enterprise.deploy.spi.DeploymentManager ; 27 import org.openide.nodes.AbstractNode; 28 import org.openide.nodes.Node; 29 import org.openide.nodes.Children; 30 import org.openide.util.NbBundle; 31 import org.openide.ErrorManager; 32 import org.openide.util.actions.SystemAction; 33 import org.netbeans.modules.j2ee.deployment.plugins.api.UISupport; 34 35 import org.netbeans.modules.j2ee.deployment.plugins.api.J2eePlatformImpl; 36 import org.netbeans.modules.j2ee.sun.ws7.nodes.actions.ViewAdminConsoleAction; 37 import org.netbeans.modules.j2ee.sun.ws7.nodes.actions.ViewAdminServerLogAction; 38 import org.netbeans.modules.j2ee.sun.ws7.dm.WS70SunDeploymentManager; 39 import org.netbeans.modules.j2ee.sun.ws7.j2ee.WS70LogViewer; 40 import org.netbeans.modules.j2ee.sun.ws7.dm.WS70SunDeploymentFactory; 41 import org.netbeans.modules.j2ee.sun.ws7.j2ee.WS70J2eePlatformFactory; 42 import org.netbeans.modules.j2ee.sun.ws7.ui.WS70Customizer; 43 44 import javax.swing.Action ; 45 46 import java.util.Collection ; 47 import java.io.File ; 48 52 public class WS70ManagerNode extends AbstractNode implements Node.Cookie{ 53 static java.util.Collection bogusNodes = java.util.Arrays.asList(new Node[] { Node.EMPTY, Node.EMPTY }); 54 private WS70SunDeploymentManager manager; 55 56 public WS70ManagerNode(DeploymentManager dm) { 57 super(new MyChildren(bogusNodes)); 58 manager = (WS70SunDeploymentManager)dm; 59 setDisplayName(NbBundle.getMessage(WS70ManagerNode.class, "LBL_WS70_MANAGER_NODE_NAME")); setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ws7/resources/ServerInstanceIcon.gif"); 61 setShortDescription(manager.getHost()+":"+manager.getPort()); 62 getCookieSet().add(this); 63 } 64 public Node.Cookie getCookie (Class type) { 65 if (WS70ManagerNode.class.isAssignableFrom(type)) { 66 return this; 67 } 68 69 return super.getCookie (type); 70 } 71 public Action[] getActions(boolean context) { 72 return new SystemAction[] { 73 null, 74 SystemAction.get(ViewAdminConsoleAction.class), 75 SystemAction.get(ViewAdminServerLogAction.class), 76 null 77 }; 78 } 79 public boolean hasCustomizer() { 80 return true; 81 } 82 public java.awt.Component getCustomizer() { 83 WS70J2eePlatformFactory fact = new WS70J2eePlatformFactory(); 84 J2eePlatformImpl platform = fact.getJ2eePlatformImpl(manager); 85 return new WS70Customizer(platform, manager); 86 } 87 public String getAdminURL() { 88 String url = null; 89 WS70SunDeploymentManager cDm= WS70SunDeploymentFactory.getConnectedCachedDeploymentManager(manager.getUri()); 90 if(cDm.isAdminOnSSL()){ 91 url = "https://"; }else{ 93 url = "http://"; } 95 url = url+cDm.getHost() + ":" + String.valueOf(cDm.getPort()); 97 return url; 98 } 99 public boolean isLocalServer(){ 100 return manager.isLocalServer(); 101 } 102 public void invokeLogViewer(){ 103 String uri = manager.getUri(); 104 String location = manager.getServerLocation(); 105 location = location+File.separator+"admin-server"+ 106 File.separator+"logs"+File.separator+"errors"; 107 108 WS70LogViewer logViewer = new WS70LogViewer(new File (location)); 109 110 try{ 111 logViewer.showLogViewer(UISupport.getServerIO(uri)); 112 }catch(Exception ex){ 113 ErrorManager.getDefault().notify(ErrorManager.WARNING, ex); 114 } 115 } 116 117 public static class MyChildren extends Children.Array { 118 public MyChildren(Collection nodes) { 119 super(nodes); 120 } 121 } 122 } 123 | Popular Tags |