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-2007 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: package org.netbeans.modules.uml.codegen.ui;
042:
043: import javax.swing.Icon;
044:
045: /**
046: *
047: * @author Craig Conover, craig.conover@sun.com
048: */
049: public class DomainTreeNode {
050: public final static int NODE_ROOT = 0;
051: public final static int NODE_FAMILY = 1;
052: public final static int NODE_DOMAIN = 2;
053:
054: private String displayName = null;
055: private String familyName = null;
056: private String domainName = null;
057: private boolean checked = false;
058: private Icon icon = null;
059:
060: public DomainTreeNode(String displayName) {
061: this (displayName, false, null, null, null);
062: }
063:
064: public DomainTreeNode(String displayName, boolean checked) {
065: this (displayName, checked, null, null, null);
066: }
067:
068: public DomainTreeNode(String displayName, boolean checked,
069: String familyName, String domainName) {
070: this (displayName, checked, familyName, domainName, null);
071: }
072:
073: public DomainTreeNode(String displayName, boolean checked,
074: String familyName, String domainName, Icon icon) {
075: setDisplayName(displayName);
076: setChecked(checked);
077: setFamilyName(familyName);
078: setDomainName(domainName);
079: setIcon(icon);
080: }
081:
082: public void setDisplayName(String value) {
083: displayName = value;
084: }
085:
086: public String getDisplayName() {
087: return displayName;
088: }
089:
090: public void setChecked(boolean value) {
091: checked = value;
092: }
093:
094: public boolean isChecked() {
095: // TODO Auto-generated method stub
096: return checked;
097: }
098:
099: public void setFamilyName(String value) {
100: familyName = value;
101: }
102:
103: public String getFamilyName() {
104: return familyName;
105: }
106:
107: public void setDomainName(String value) {
108: domainName = value;
109: }
110:
111: public String getDomainName() {
112: return domainName;
113: }
114:
115: public Icon getIcon() {
116: return icon;
117: }
118:
119: public void setIcon(Icon value) {
120: icon = value;
121: }
122:
123: public int getNodeType() {
124: if (getDomainName() != null)
125: return NODE_DOMAIN;
126:
127: else if (getFamilyName() != null)
128: return NODE_FAMILY;
129:
130: else
131: return NODE_ROOT;
132: }
133:
134: public boolean isRoot() {
135: return getNodeType() == NODE_ROOT;
136: }
137:
138: public boolean isFamily() {
139: return getNodeType() == NODE_FAMILY;
140: }
141:
142: public boolean isDomain() {
143: return getNodeType() == NODE_DOMAIN;
144: }
145:
146: public String toString() {
147: return getDisplayName();
148: }
149: }
|