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.sql.framework.ui.editor.property.impl;
042:
043: import java.util.ArrayList;
044: import java.util.Iterator;
045: import java.util.List;
046:
047: import org.netbeans.modules.sql.framework.ui.editor.property.IElement;
048: import org.netbeans.modules.sql.framework.ui.editor.property.INode;
049: import org.netbeans.modules.sql.framework.ui.editor.property.IPropertyGroup;
050: import org.netbeans.modules.sql.framework.ui.editor.property.ITemplate;
051:
052: /**
053: * @author Ritesh Adval
054: * @version $Revision$
055: */
056: public class Template implements ITemplate {
057:
058: private String displayName;
059: private String name;
060: private INode parent;
061: private ArrayList<IPropertyGroup> propertyGroupList = new ArrayList<IPropertyGroup>();
062:
063: private String toolTip;
064:
065: /** Creates a new instance of Template */
066: public Template() {
067: }
068:
069: /**
070: * add a element in the node
071: *
072: * @param element element to add
073: */
074: public void add(IElement element) {
075: element.setParent(this );
076: addPropertyGroup((IPropertyGroup) element);
077: }
078:
079: public void addPropertyGroup(IPropertyGroup propertyG) {
080: propertyGroupList.add(propertyG);
081: }
082:
083: /**
084: * get the count of template in this templte group
085: *
086: * @return child count
087: */
088: public int getChildCount() {
089: return propertyGroupList.size();
090: }
091:
092: /**
093: * get the display name of of element
094: *
095: * @return display name
096: */
097: public String getDisplayName() {
098: return displayName;
099: }
100:
101: public String getName() {
102: return this .name;
103: }
104:
105: /**
106: * get the parent element
107: *
108: * @return parent
109: */
110: public INode getParent() {
111: return parent;
112: }
113:
114: public IPropertyGroup getPropertyGroup(String groupName) {
115: Iterator it = propertyGroupList.iterator();
116: while (it.hasNext()) {
117: IPropertyGroup pg = (IPropertyGroup) it.next();
118: if (pg.getName().equals(groupName)) {
119: return pg;
120: }
121: }
122: return null;
123: }
124:
125: public List<IPropertyGroup> getPropertyGroupList() {
126: return propertyGroupList;
127: }
128:
129: /**
130: * get the tooltip of of element
131: *
132: * @return tooltip
133: */
134: public String getToolTip() {
135: return this .toolTip;
136: }
137:
138: /**
139: * set the display name of the element
140: *
141: * @param dName display name
142: */
143: public void setDisplayName(String dName) {
144: this .displayName = dName;
145: }
146:
147: public void setName(String name) {
148: this .name = name;
149: }
150:
151: /**
152: * set parent parent element
153: */
154: public void setParent(INode parent) {
155: this .parent = parent;
156: }
157:
158: /**
159: * set the tooltip of the element
160: *
161: * @param tTip tool tip
162: */
163: public void setToolTip(String tTip) {
164: this.toolTip = tTip;
165: }
166: }
|