KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > bridge > apis > AppserverMgmtNode


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 package org.netbeans.modules.j2ee.sun.bridge.apis;
20
21 import java.util.logging.Logger JavaDoc;
22 import java.util.logging.Level JavaDoc;
23
24
25 import org.openide.nodes.AbstractNode;
26 import org.openide.nodes.Children;
27 import org.openide.util.NbBundle;
28
29 /**
30  * The parent class for all appserver plugin management nodes. All nodes for
31  * the NetBeans runtime tab J2EE plugin must extend this class for effectively
32  * communicating via AMX API.
33  */

34 public abstract class AppserverMgmtNode extends AbstractNode {
35     
36     private String JavaDoc nodeType;
37     private AppserverMgmtController appsrvrMgmtController;
38     private static Logger JavaDoc logger;
39     
40     static {
41         logger = Logger.getLogger("org.netbeans.modules.j2ee.sun");
42     }
43     
44     
45     /**
46      *
47      */

48     public AppserverMgmtNode(final Children children, final String JavaDoc nodeType) {
49         super(children);
50         setNodeProperties(nodeType);
51         // getAppserverMgmtController();
52
}
53     
54     /**
55      *
56      *
57      */

58     public AppserverMgmtNode(final AppserverMgmtController controller,
59             final Children children, final String JavaDoc nodeType) {
60         super(children);
61         setNodeProperties(nodeType);
62         appsrvrMgmtController = controller;
63     }
64     
65     
66     /**
67      *
68      *
69      */

70     // Shouldn't this be put into the lookup?
71
public AppserverMgmtController getAppserverMgmtController() {
72         try {
73             if(appsrvrMgmtController == null) {
74                 getLogger().log(Level.FINE, "AppserverMgmtController is " +
75                         "null for [" + getNodeType() + "]");
76             }
77         } catch(Exception JavaDoc e) {
78             getLogger().log(Level.FINE, e.getMessage(), e);
79         }
80         return appsrvrMgmtController;
81     }
82     
83     /* reset the controller from the Deployment manager
84      * used when the username of the password known for the connexion is changed
85      * via the IDE for example
86      **/

87     public void setAppserverMgmtController(AppserverMgmtController controller) {
88         appsrvrMgmtController = controller;
89     }
90     /**
91      *
92      *
93      */

94     public String JavaDoc getNodeType(){
95         return nodeType;
96     }
97     
98     
99     /**
100      *
101      */

102     private void setNodeProperties(final String JavaDoc nodeType) {
103         this.nodeType = nodeType;
104         setDisplayName(getNodeDisplayName());
105         setIconBaseWithExtension(getNodeIconPath());
106         setShortDescription(getNodeShortDescription());
107     }
108     
109     /**
110      *
111      */

112     protected String JavaDoc getNodeDisplayName() {
113         String JavaDoc s=nodeType;
114         try{
115             s=NbBundle.getMessage(AppserverMgmtNode.class, nodeType);
116         } catch (Exception JavaDoc e){
117             return s;
118         }
119         return s;
120         
121     }
122     
123     /**
124      *
125      */

126     protected String JavaDoc getNodeIconPath() {
127         String JavaDoc s="org/netbeans/modules/j2ee/sun/ide/resources/ServerInstanceIcon.png";
128         try{
129              s= NbBundle.getMessage(AppserverMgmtNode.class, nodeType + "_ICON");
130         } catch (Exception JavaDoc e){
131             return s;
132             
133         }
134         return s;
135     }
136     
137     /**
138      *
139      */

140     protected String JavaDoc getNodeShortDescription() {
141         String JavaDoc s="missing _SHORT_DESC for " + nodeType;
142         try{
143              s= NbBundle.getMessage(AppserverMgmtNode.class, nodeType + "_SHORT_DESC");
144         } catch (Exception JavaDoc e){
145             
146         }
147         return s;
148     }
149     
150     
151     /**
152      * Returns the logger for all nodes.
153      *
154      * @returns The java.util.logging.Logger impl. for this node.
155      */

156     protected final static Logger JavaDoc getLogger() {
157         if (logger == null) {
158             logger = Logger.getLogger("org.netbeans.modules.j2ee.sun");
159         }
160         return logger;
161     }
162     
163     public boolean isServerLocal(){
164         return appsrvrMgmtController.isDeployMgrLocal();
165     }
166 }
167
Popular Tags