KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ws7 > nodes > WS70ManagerNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * WS70ManagerNode.java
22  */

23
24 package org.netbeans.modules.j2ee.sun.ws7.nodes;
25
26 import javax.enterprise.deploy.spi.DeploymentManager JavaDoc;
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 JavaDoc;
45
46 import java.util.Collection JavaDoc;
47 import java.io.File JavaDoc;
48 /**
49  *
50  * @author Administrator
51  */

52 public class WS70ManagerNode extends AbstractNode implements Node.Cookie{
53     static java.util.Collection JavaDoc bogusNodes = java.util.Arrays.asList(new Node[] { Node.EMPTY, Node.EMPTY });
54     private WS70SunDeploymentManager manager;
55     /** Creates a new instance of WS70ManagerNode */
56     public WS70ManagerNode(DeploymentManager JavaDoc dm) {
57         super(new MyChildren(bogusNodes));
58         manager = (WS70SunDeploymentManager)dm;
59         setDisplayName(NbBundle.getMessage(WS70ManagerNode.class, "LBL_WS70_MANAGER_NODE_NAME")); //NOI18N
60
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 JavaDoc 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 JavaDoc getCustomizer() {
83         WS70J2eePlatformFactory fact = new WS70J2eePlatformFactory();
84         J2eePlatformImpl platform = fact.getJ2eePlatformImpl(manager);
85         return new WS70Customizer(platform, manager);
86     }
87     public String JavaDoc getAdminURL() {
88         String JavaDoc url = null;
89         WS70SunDeploymentManager cDm= WS70SunDeploymentFactory.getConnectedCachedDeploymentManager(manager.getUri());
90         if(cDm.isAdminOnSSL()){
91             url = "https://";// NOI18N
92
}else{
93             url = "http://";// NOI18N
94
}
95         url = url+cDm.getHost() + ":" + // NOI18N
96
String.valueOf(cDm.getPort());
97         return url;
98     }
99     public boolean isLocalServer(){
100         return manager.isLocalServer();
101     }
102     public void invokeLogViewer(){
103         String JavaDoc uri = manager.getUri();
104         String JavaDoc 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 JavaDoc(location));
109         
110         try{
111             logViewer.showLogViewer(UISupport.getServerIO(uri));
112         }catch(Exception JavaDoc ex){
113             ErrorManager.getDefault().notify(ErrorManager.WARNING, ex);
114         }
115     }
116   
117     public static class MyChildren extends Children.Array {
118         public MyChildren(Collection JavaDoc nodes) {
119             super(nodes);
120         }
121     }
122 }
123
Popular Tags