KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > oc4j > nodes > OC4JInstanceNode


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 package org.netbeans.modules.j2ee.oc4j.nodes;
21
22 import java.awt.Component JavaDoc;
23 import javax.swing.Action JavaDoc;
24 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties;
25 import org.netbeans.modules.j2ee.oc4j.OC4JDeploymentManager;
26 import org.netbeans.modules.j2ee.oc4j.customizer.OC4JCustomizer;
27 import org.netbeans.modules.j2ee.oc4j.customizer.OC4JCustomizerDataSupport;
28 import org.netbeans.modules.j2ee.oc4j.ide.OC4JJ2eePlatformFactory;
29 import org.netbeans.modules.j2ee.oc4j.nodes.actions.ShowAdminToolAction;
30 import org.netbeans.modules.j2ee.oc4j.util.OC4JPluginProperties;
31 import org.openide.nodes.AbstractNode;
32 import org.openide.nodes.Children;
33 import org.openide.nodes.Node;
34 import org.openide.util.Lookup;
35 import org.openide.util.NbBundle;
36 import org.openide.util.actions.SystemAction;
37
38 /**
39  *
40  * @author pblaha
41  */

42 public class OC4JInstanceNode extends AbstractNode implements Node.Cookie {
43     
44     private static String JavaDoc ICON_BASE = "org/netbeans/modules/j2ee/oc4j/resources/16x16.png"; // NOI18N
45
private static final String JavaDoc ADMIN_URL = "/em/"; //NOI18N
46
private static final String JavaDoc HTTP_HEADER = "http://";
47     private Lookup lookup;
48     
49     public OC4JInstanceNode(Lookup lookup) {
50         super(new Children.Array());
51         this.lookup = lookup;
52         getCookieSet().add(this);
53         setIconBaseWithExtension(ICON_BASE);
54     }
55     
56     public String JavaDoc getAdminURL() {
57         InstanceProperties ip = getDeploymentManager().getProperties().getInstanceProperties();
58         String JavaDoc host = ip.getProperty(OC4JPluginProperties.PROPERTY_HOST);
59         String JavaDoc httpPort = ip.getProperty(InstanceProperties.HTTP_PORT_NUMBER);
60         return HTTP_HEADER + host + ":" + httpPort + ADMIN_URL;
61     }
62     
63     public String JavaDoc getDisplayName() {
64         return NbBundle.getMessage(OC4JInstanceNode.class, "TXT_MyInstanceNode");
65     }
66     
67     public javax.swing.Action JavaDoc[] getActions(boolean context) {
68         Action JavaDoc[] actions = new Action JavaDoc[2];
69         actions[0] = null;
70         actions[1] = (SystemAction.get(ShowAdminToolAction.class));
71         return actions;
72     }
73     
74     public boolean hasCustomizer() {
75         return true;
76     }
77     
78     public Component JavaDoc getCustomizer() {
79         OC4JCustomizerDataSupport dataSup = new OC4JCustomizerDataSupport(getDeploymentManager());
80         return new OC4JCustomizer(dataSup, new OC4JJ2eePlatformFactory().getJ2eePlatformImpl(getDeploymentManager()));
81     }
82     
83     public OC4JDeploymentManager getDeploymentManager() {
84         return ((OC4JDeploymentManager) lookup.lookup(OC4JDeploymentManager.class));
85     }
86 }
Popular Tags