01: /*
02: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03: *
04: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
05: *
06: * The contents of this file are subject to the terms of either the GNU
07: * General Public License Version 2 only ("GPL") or the Common
08: * Development and Distribution License("CDDL") (collectively, the
09: * "License"). You may not use this file except in compliance with the
10: * License. You can obtain a copy of the License at
11: * http://www.netbeans.org/cddl-gplv2.html
12: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13: * specific language governing permissions and limitations under the
14: * License. When distributing the software, include this License Header
15: * Notice in each file and include the License file at
16: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17: * particular file as subject to the "Classpath" exception as provided
18: * by Sun in the GPL Version 2 section of the License file that
19: * accompanied this code. If applicable, add the following below the
20: * License Header, with the fields enclosed by brackets [] replaced by
21: * your own identifying information:
22: * "Portions Copyrighted [year] [name of copyright owner]"
23: *
24: * Contributor(s):
25: *
26: * Portions Copyrighted 2007 Sun Microsystems, Inc.
27: */
28: package org.netbeans.modules.php.rt.providers.impl.nodes;
29:
30: import org.netbeans.modules.php.rt.providers.impl.ftp.nodes.*;
31: import javax.swing.Action;
32: import org.netbeans.modules.php.rt.providers.impl.HostImpl;
33: import org.netbeans.modules.php.rt.resources.ResourceMarker;
34: import org.openide.actions.CustomizeAction;
35: import org.openide.nodes.Children;
36: import org.openide.nodes.Node;
37: import org.openide.util.Lookup;
38: import org.openide.util.actions.SystemAction;
39: import org.openide.util.lookup.Lookups;
40:
41: /**
42: *
43: * @author avk
44: */
45: public abstract class AbstractWebInfoNode extends AbstractInfoNode {
46:
47: public AbstractWebInfoNode(HostImpl host) {
48: this (Children.LEAF, host);
49: }
50:
51: public AbstractWebInfoNode(Children children, HostImpl host) {
52: super (children, createLookup(host));
53:
54: setDisplayName(getNodeName(host));
55: setName(getDisplayName());
56: setIconBaseWithExtension(ResourceMarker.getLocation()
57: + ResourceMarker.SERVER_WEB_ICON);
58: setShortDescription(getNodeDescription(host));
59: }
60:
61: private String getNodeName(HostImpl host) {
62: return truncateName(getNodeDescription(host));
63: }
64:
65: private String getNodeDescription(HostImpl host) {
66: String name = HostImpl.Helper.getHttpUrl(host);
67: if (name == null) {
68: name = HostImpl.Helper.noHttpMessage();
69: }
70: return name;
71: }
72:
73: @Override
74: public boolean hasCustomizer() {
75: Node parent = getParentNode();
76: if (parent != null) {
77: return parent.hasCustomizer();
78: }
79: return false;
80: }
81:
82: @Override
83: public Action[] getActions(boolean context) {
84: if (hasCustomizer()) {
85: return new Action[] { SystemAction
86: .get(CustomizeAction.class) };
87: }
88: return new Action[] {};
89: }
90:
91: static Lookup createLookup(HostImpl host) {
92: if (host != null) {
93: return Lookups.fixed(new Object[] { host });
94: } else {
95: return null;
96: }
97: }
98:
99: }
|