KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > runtime > nodes > AppClientModuleNode


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.ide.runtime.nodes;
20
21 import java.util.List JavaDoc;
22 import java.util.Arrays JavaDoc;
23
24 import javax.swing.Action JavaDoc;
25 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtLeafNode;
26 import org.openide.util.actions.SystemAction;
27
28 import org.netbeans.modules.j2ee.sun.ide.controllers.AppClientModuleController;
29 import org.netbeans.modules.j2ee.sun.ide.controllers.DeployedItemsController;
30 import org.netbeans.modules.j2ee.sun.util.NodeTypes;
31 import org.netbeans.modules.j2ee.sun.ide.runtime.actions.UndeployAction;
32 import org.netbeans.modules.j2ee.sun.bridge.apis.Undeployable;
33 import org.openide.actions.PropertiesAction;
34
35
36
37
38 /**
39  */

40 public class AppClientModuleNode extends AppserverMgmtLeafNode
41         implements Undeployable {
42         
43     private static String JavaDoc NODE_TYPE = NodeTypes.APP_CLIENT_MODULE;
44     private String JavaDoc appClientName;
45     private boolean isEmbedded;
46             
47
48     
49     
50     /**
51      *
52      *
53      */

54     public AppClientModuleNode(AppClientModuleController controller) {
55         super(controller,NODE_TYPE);
56         this.appClientName = controller.getName();
57         setDisplayName(appClientName);
58     }
59     
60     
61     /**
62      *
63      *
64      */

65     public AppClientModuleNode(final AppClientModuleController controller,
66             final boolean isEmbedded) {
67         super(controller,NODE_TYPE);
68         this.appClientName = controller.getName();
69         this.isEmbedded = isEmbedded;
70         setDisplayName(appClientName);
71
72     }
73     
74     public AppClientModuleNode(final String JavaDoc name) {
75         super(NODE_TYPE);
76         this.isEmbedded = true;
77         setDisplayName(name);
78     }
79     
80     /**
81      * Return the actions associated with the menu drop down seen when
82      * a user right-clicks on an Applications node in the plugin.
83      *
84      * @param boolean true/false
85      * @return An array of Action objects.
86      */

87     public Action JavaDoc[] getActions(boolean flag) {
88         if(!isEmbedded) {
89             return new SystemAction[] {
90                 SystemAction.get(UndeployAction.class),
91                 SystemAction.get(PropertiesAction.class)
92             };
93         } else {
94             return new SystemAction[] {
95                 SystemAction.get(PropertiesAction.class)
96             };
97         }
98     }
99     
100     
101     /**
102      * Return the SheetProperties to be displayed for this Application Client
103      * Module.
104      *
105      * @return A java.util.Map containing all app client module properties.
106      */

107     protected java.util.Map JavaDoc getSheetProperties() {
108        return getController().getProperties(getPropertiesToIgnore());
109     }
110       
111     
112     /**
113      * Sets the property as an attribute to the underlying AMX mbeans. It
114      * usually will delegate to the controller object which is responsible for
115      * finding the correct AMX mbean objectname in order to execute a
116      * JMX setAttribute.
117      *
118      * @param attrName The name of the property to be set.
119      * @param value The value retrieved from the property sheet to be set in the
120      * backend.
121      * @returns the updated Attribute accessed from the Sheet
122      */

123     public javax.management.Attribute JavaDoc setSheetProperty(String JavaDoc attrName, Object JavaDoc value) {
124         return getController().setProperty(attrName, value);
125     }
126     
127     
128     /**
129      *
130      *
131      */

132     public void undeploy() {
133         ((DeployedItemsController)getController()).undeploy();
134     }
135     
136     protected List JavaDoc getPropertiesToIgnore() {
137         return Arrays.asList(NodeTypes.APP_CLIENT_MODULES_NODE);
138     }
139 }
140
Popular Tags