|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ /* * InstanceTargetNode.java * * Created on December 7, 2003, 9:11 PM */ package org.netbeans.modules.j2ee.deployment.impl.ui; import org.netbeans.modules.j2ee.deployment.impl.ui.actions.SetAsDefaultServerAction; import org.netbeans.modules.j2ee.deployment.impl.ServerInstance; import org.netbeans.modules.j2ee.deployment.impl.ServerTarget; import org.openide.util.HelpCtx; import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.util.actions.SystemAction; /** * A node for an admin instance that is also a target server. * * @author nn136682 */ public class InstanceTargetNode extends InstanceNode { ServerTarget instanceTarget; TargetNode delegateTargetNode; /** Creates a new instance of InstanceTargetNode */ public InstanceTargetNode(ServerInstance instance) { super(instance); this.setChildren(new InstanceTargetChildren(instance)); } private ServerTarget getServerTarget() { if (instanceTarget != null) return instanceTarget; instanceTarget = instance.getCoTarget(); return instanceTarget; } private TargetNode getDelegateTargetNode() { if (delegateTargetNode != null) return delegateTargetNode; ServerTarget st = getServerTarget(); if (st == null) return null; delegateTargetNode = new TargetNode(st); return delegateTargetNode; } public static class InstanceTargetChildren extends TargetNode.TargetChildren { ServerInstance instance; public InstanceTargetChildren(ServerInstance instance) { this.instance = instance; } protected void addNotify() { updateKeys(); } public void updateKeys() { if (isFurtherExpandable()) { target = instance.getCoTarget(); if (target == null) setKeys(java.util.Collections.EMPTY_SET); else setKeys(TargetNode.getMQueries(target)); } else { setKeys(java.util.Collections.EMPTY_SET); } } protected org.openide.nodes.Node[] createNodes(Object obj) { TargetNode.MQueries queries = (TargetNode.MQueries) obj; if (target == null) target = instance.getCoTarget(); org.openide.nodes.Node childNode = new MFolderNode(target, queries.queries, queries.name); return new org.openide.nodes.Node[] { childNode }; } private boolean isFurtherExpandable() { ServerRegistryNode root = ServerRegistryNode.getServerRegistryNode(); if (root != null) return root.isExpandablePassTargetNode(); return true; } } public javax.swing.Action[] getActions(boolean context) { java.util.List l = java.util.Arrays.asList(super.getActions(context)); java.util.List actions = new java.util.ArrayList(l); if (instance.isRunning()) { actions.addAll(java.util.Arrays.asList(getDelegateTargetNode().getActions(context))); } else { actions.add(SystemAction.get(SetAsDefaultServerAction.class)); } return (javax.swing.Action[]) actions.toArray(new javax.swing.Action[actions.size()]); } public org.openide.nodes.Sheet createSheet() { if (! instance.isRunning() && instance.getStartServer().needsStartForAdminConfig() ) return org.openide.nodes.Sheet.createDefault(); return getDelegateTargetNode().createSheet(); } public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; //PENDING } public org.openide.nodes.Node.Cookie getCookie(Class type) { TargetNode tn = getDelegateTargetNode(); org.openide.nodes.Node.Cookie c = null; if (tn != null) c = tn.getCookie(type); if (c == null) c = super.getCookie(type); return c; } public void handleRefresh() { Children old = getChildren(); Children replacing = new InstanceTargetChildren(instance); //PENDING: traverse old subtree to remove listener. setChildren(replacing); } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.