001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.identity.server.manager.ui;
043:
044: import javax.swing.Action;
045: import org.netbeans.modules.identity.server.manager.api.ServerInstance;
046: import org.netbeans.modules.identity.server.manager.ui.actions.CustomizerAction;
047: import org.netbeans.modules.identity.server.manager.ui.actions.ViewAdminConsoleAction;
048: import org.openide.nodes.AbstractNode;
049: import org.openide.nodes.Children;
050: import org.openide.nodes.Node;
051: import org.openide.util.HelpCtx;
052: import org.openide.util.NbBundle;
053: import org.openide.util.actions.SystemAction;
054:
055: /**
056: * This class represents a AM server instance node in the Runtime tab.
057: *
058: * Created on June 14, 2006, 12:48 AM
059: *
060: * @author ptliu
061: */
062: public class ServerInstanceNode extends AbstractNode {
063:
064: private static final String SERVER_INSTANCE_ICON = "org/netbeans/modules/identity/server/manager/ui/resources/ServerInstance.png";//NOI18N
065:
066: private static final String HELP_ID = "idmtools_am_ww_am_instances"; //NOI18N
067:
068: private ServerInstance instance;
069:
070: /**
071: * Creates a new instance of ServerInstanceNode
072: *
073: * TODO: use Lookup
074: */
075: public ServerInstanceNode(ServerInstance instance) {
076: super (new ServerInstanceChildren(instance));
077:
078: this .instance = instance;
079:
080: setName(instance.getID());
081: setDisplayName(NbBundle.getMessage(ServerInstanceNode.class,
082: "LBL_ServerInstanceNode"));
083: setIconBaseWithExtension(SERVER_INSTANCE_ICON);
084: setShortDescription(NbBundle.getMessage(
085: ServerInstanceNode.class, "DESC_ServerInstanceNode",
086: instance.getHost()));
087: }
088:
089: public Action[] getActions(boolean context) {
090: Action[] actions = new Action[] {
091: SystemAction.get(ViewAdminConsoleAction.class), null,
092: //SystemAction.get(RemoveServerInstanceAction.class),
093: //null,
094: SystemAction.get(CustomizerAction.class) };
095:
096: return actions;
097: }
098:
099: public ServerInstance getInstance() {
100: return instance;
101: }
102:
103: public String getAdminURL() {
104: return instance.getAdminURL();
105: }
106:
107: public HelpCtx getHelpCtx() {
108: return new HelpCtx(HELP_ID);
109: }
110:
111: private static class ServerInstanceChildren extends Children.Keys {
112: private static final String PROFILES_NODE_KEY = "Profiles"; //NOI18N
113:
114: private ServerInstance instance;
115:
116: public ServerInstanceChildren(ServerInstance instance) {
117: this .instance = instance;
118: }
119:
120: protected void addNotify() {
121: setKeys(new String[] { PROFILES_NODE_KEY });
122: }
123:
124: protected Node[] createNodes(Object key) {
125: if (key.equals(PROFILES_NODE_KEY)) {
126: return new Node[] { new ProfilesNode(instance) };
127: }
128:
129: return null;
130: }
131: }
132: }
|