KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.swing.Action JavaDoc;
22
23 import java.util.List JavaDoc;
24 import java.util.Arrays JavaDoc;
25 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtLeafNode;
26 import org.netbeans.modules.j2ee.sun.bridge.apis.Removable;
27
28 import org.openide.actions.*;
29 import org.openide.util.actions.SystemAction;
30
31 import org.netbeans.modules.j2ee.sun.ide.runtime.actions.DeleteResourceAction;
32 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtController;
33 import org.netbeans.modules.j2ee.sun.util.NodeTypes;
34
35
36 /**
37  * The parent class for all appserver plugin management leaf nodes. All leaf
38  * nodes for the NetBeans runtime tab J2EE plugin must extend this class for
39  * effectively communicating via AMX API.
40  */

41 public abstract class ResourceLeafNode extends AppserverMgmtLeafNode
42         implements Removable {
43   
44     private String JavaDoc resourceName;
45     
46     
47     /**
48      * Abstract constructor for an AppserverLeafNode called by subclass.
49      *
50      * @param nodeType The type of leaf node to construct (e.g. JVM, etc.)
51      * @param resName The name of the resource.
52      */

53     public ResourceLeafNode(final AppserverMgmtController controller,
54             final String JavaDoc nodeType, final String JavaDoc resName) {
55         super(controller, nodeType);
56         this.resourceName = resName;
57         setDisplayName(resName);
58     }
59     
60     
61     
62   
63     
64     /**
65      * Return the actions associated with the menu drop down seen when
66      * a user right-clicks on a node in the plugin.
67      *
68      * @param boolean true/false
69      * @return An array of Action objects.
70      */

71     public Action JavaDoc[] getActions(boolean flag) {
72         return new SystemAction[] {
73             SystemAction.get(DeleteResourceAction.class),
74             SystemAction.get(PropertiesAction.class)
75         };
76     }
77     
78     
79     /**
80      *
81      */

82     protected String JavaDoc getResourceName() {
83         return this.resourceName;
84     }
85     
86     
87     /**
88      *
89      *
90      */

91     abstract public void remove();
92     
93     protected List JavaDoc getPropertiesToIgnore() {
94         return Arrays.asList(NodeTypes.SERVER_RESOURCE_NODES);
95     }
96     
97     /**
98      * Sets the property as an attribute to the underlying AMX mbeans. It
99      * usually will delegate to the controller object which is responsible for
100      * finding the correct AMX mbean objectname in order to execute a
101      * JMX setAttribute.
102      *
103      * @param props Object array containing updated properties as Attributes
104      * @param oldProps set of old properties
105      */

106     public void updateExtraProperty(Object JavaDoc[] props, java.util.Map JavaDoc oldProps) {
107         getAppserverMgmtController().
108             updateResourceExtraProperty(getResourceName(), getNodeType(), props, oldProps);
109     }
110     
111 }
112
Popular Tags