001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019: package org.netbeans.modules.soa.ui.axinodes;
020:
021: import java.awt.Image;
022: import org.netbeans.modules.soa.ui.axinodes.NodeType.BadgeModificator;
023: import org.netbeans.modules.soa.ui.nodes.InstanceRef;
024: import org.netbeans.modules.soa.ui.nodes.NodeTypeHolder;
025: import org.netbeans.modules.xml.axi.AXIComponent;
026: import org.openide.nodes.AbstractNode;
027: import org.openide.nodes.Children;
028: import org.openide.util.HelpCtx;
029: import org.openide.util.Lookup;
030:
031: /**
032: * This class represents the base class for BPEL related nodes.
033: * <p>
034: * The PropertyNodeFactory class is implied that the derived nodes has
035: * at least one constructor with the specific parameters.
036: *
037: * @author nk160297
038: */
039: public abstract class AxiomNode<T extends AXIComponent> extends
040: AbstractNode implements InstanceRef<T>,
041: NodeTypeHolder<NodeType> {
042: //
043: private Object reference;
044:
045: public AxiomNode(T ref, Lookup lookup) {
046: this (ref, Children.LEAF, lookup);
047: }
048:
049: public AxiomNode(T ref, Children children, Lookup lookup) {
050: super (children, lookup);
051: setReference(ref);
052: }
053:
054: /**
055: * The reference to an object which the node represents.
056: */
057: public T getReference() {
058: T ref = (T) reference;
059: return ref;
060: }
061:
062: public Object getAlternativeReference() {
063: return null;
064: }
065:
066: public Image getIcon(int type) {
067: return getNodeType().getImage(BadgeModificator.SINGLE);
068: }
069:
070: public Image getOpenedIcon(int type) {
071: return getIcon(type);
072: }
073:
074: protected void setReference(T newRef) {
075: this .reference = newRef;
076: }
077:
078: public abstract NodeType getNodeType();
079:
080: public String getDisplayName() {
081: String instanceName = getName();
082: return ((instanceName == null || instanceName.length() == 0) ? ""
083: : instanceName + " ")
084: + "[" + getNodeType().getDisplayName() + "]"; // NOI18N
085: }
086:
087: public synchronized String getShortDescription() {
088: return getDisplayName();
089: }
090:
091: public boolean equals(Object obj) {
092: if (super .equals(obj)) {
093: return true;
094: }
095:
096: //
097: if (obj instanceof AxiomNode) {
098: return this .getNodeType().equals(
099: ((AxiomNode) obj).getNodeType())
100: && this .reference
101: .equals(((AxiomNode) obj).reference);
102: }
103: //
104: return false;
105: }
106:
107: // /**
108: // * Looks for the Properties Set by the Group enum.
109: // * If the group isn't
110: // */
111: // protected Sheet.Set getPropertySet(
112: // Sheet sheet, Constants.PropertiesGroups group) {
113: // Sheet.Set propSet = sheet.get(group.getDisplayName());
114: // if (propSet == null) {
115: // propSet = new Sheet.Set();
116: // propSet.setName(group.getDisplayName());
117: // sheet.put(propSet);
118: // }
119: // //
120: // return propSet;
121: // }
122:
123: public String getHelpId() {
124: return null;
125: }
126:
127: public HelpCtx getHelpCtx() {
128: return getHelpId() == null ? null : new HelpCtx(getHelpId());
129: }
130:
131: }
|