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:
042: /**
043: * This generated bean class DomainObject matches the schema element 'domainObject'.
044: * The root bean class is TemplateFamilies
045: *
046: * Generated on Thu Jun 07 12:07:29 PDT 2007
047: * @Generated
048: */package org.netbeans.modules.uml.codegen.dataaccess.xmlbeans;
049:
050: import org.w3c.dom.*;
051: import org.netbeans.modules.schema2beans.*;
052: import java.beans.*;
053: import java.util.*;
054:
055: // BEGIN_NOI18N
056: import javax.swing.table.DefaultTableModel;
057:
058: public class DomainObject extends
059: org.netbeans.modules.schema2beans.BaseBean
060: implements
061: org.netbeans.modules.uml.codegen.dataaccess.xmlbeans.DomainObjectInterface,
062: org.netbeans.modules.uml.codegen.dataaccess.xmlbeans.CommonBean {
063:
064: static Vector comparators = new Vector();
065: private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(
066: 4, 2, 0);
067:
068: static public final String NAME = "Name"; // NOI18N
069: static public final String MODELELEMENT = "ModelElement"; // NOI18N
070: static public final String STEREOTYPE = "Stereotype"; // NOI18N
071: static public final String DESCRIPTION = "Description"; // NOI18N
072: static public final String TEMPLATE = "Template"; // NOI18N
073:
074: public DomainObject() {
075: this (Common.USE_DEFAULT_VALUES);
076: }
077:
078: public DomainObject(int options) {
079: super (comparators, runtimeVersion);
080: // Properties (see root bean comments for the bean graph)
081: initPropertyTables(4);
082: this .createProperty("modelElement", // NOI18N
083: MODELELEMENT, Common.TYPE_1 | Common.TYPE_STRING
084: | Common.TYPE_KEY, java.lang.String.class);
085: this .createProperty("stereotype", // NOI18N
086: STEREOTYPE, Common.TYPE_1 | Common.TYPE_STRING
087: | Common.TYPE_KEY, java.lang.String.class);
088: this .createProperty("description", // NOI18N
089: DESCRIPTION, Common.TYPE_1 | Common.TYPE_STRING
090: | Common.TYPE_KEY, java.lang.String.class);
091: this .createProperty("template", // NOI18N
092: TEMPLATE, Common.TYPE_1_N | Common.TYPE_BEAN
093: | Common.TYPE_KEY, Template.class);
094: this .initialize(options);
095: }
096:
097: // Setting the default values of the properties
098: void initialize(int options) {
099:
100: }
101:
102: // This attribute is optional
103: public void setName(java.lang.String value) {
104: setAttributeValue(NAME, value);
105: }
106:
107: //
108: public java.lang.String getName() {
109: return getAttributeValue(NAME);
110: }
111:
112: // This attribute is mandatory
113: public void setModelElement(java.lang.String value) {
114: this .setValue(MODELELEMENT, value);
115: }
116:
117: //
118: public java.lang.String getModelElement() {
119: return (java.lang.String) this .getValue(MODELELEMENT);
120: }
121:
122: public java.lang.String fetchDefaultModelElement() {
123: return "";
124: }
125:
126: // This attribute is mandatory
127: public void setStereotype(java.lang.String value) {
128: this .setValue(STEREOTYPE, value);
129: }
130:
131: //
132: public java.lang.String getStereotype() {
133: return (java.lang.String) this .getValue(STEREOTYPE);
134: }
135:
136: public java.lang.String fetchDefaultStereotype() {
137: return "";
138: }
139:
140: // This attribute is mandatory
141: public void setDescription(java.lang.String value) {
142: this .setValue(DESCRIPTION, value);
143: }
144:
145: //
146: public java.lang.String getDescription() {
147: return (java.lang.String) this .getValue(DESCRIPTION);
148: }
149:
150: public java.lang.String fetchDefaultDescription() {
151: return "";
152: }
153:
154: // This attribute is an array containing at least one element
155: public void setTemplate(int index, Template value) {
156: this .setValue(TEMPLATE, index, value);
157: }
158:
159: //
160: public Template getTemplate(int index) {
161: return (Template) this .getValue(TEMPLATE, index);
162: }
163:
164: // Return the number of properties
165: public int sizeTemplate() {
166: return this .size(TEMPLATE);
167: }
168:
169: // This attribute is an array containing at least one element
170: public void setTemplate(Template[] value) {
171: this .setValue(TEMPLATE, value);
172: }
173:
174: //
175: public Template[] getTemplate() {
176: return (Template[]) this .getValues(TEMPLATE);
177: }
178:
179: // Add a new element returning its index in the list
180: public int addTemplate(
181: org.netbeans.modules.uml.codegen.dataaccess.xmlbeans.Template value) {
182: int positionOfNewItem = this .addValue(TEMPLATE, value);
183: return positionOfNewItem;
184: }
185:
186: //
187: // Remove an element using its reference
188: // Returns the index the element had in the list
189: //
190: public int removeTemplate(
191: org.netbeans.modules.uml.codegen.dataaccess.xmlbeans.Template value) {
192: return this .removeValue(TEMPLATE, value);
193: }
194:
195: /**
196: * Create a new bean using it's default constructor.
197: * This does not add it to any bean graph.
198: */
199: public Template newTemplate() {
200: return new Template();
201: }
202:
203: //
204: public static void addComparator(
205: org.netbeans.modules.schema2beans.BeanComparator c) {
206: comparators.add(c);
207: }
208:
209: //
210: public static void removeComparator(
211: org.netbeans.modules.schema2beans.BeanComparator c) {
212: comparators.remove(c);
213: }
214:
215: public void validate()
216: throws org.netbeans.modules.schema2beans.ValidateException {
217: }
218:
219: // Dump the content of this bean returning it as a String
220: public void dump(StringBuffer str, String indent) {
221: String s;
222: Object o;
223: org.netbeans.modules.schema2beans.BaseBean n;
224: str.append(indent);
225: str.append("ModelElement"); // NOI18N
226: str.append(indent + "\t"); // NOI18N
227: str.append("<"); // NOI18N
228: o = this .getModelElement();
229: str.append((o == null ? "null" : o.toString().trim())); // NOI18N
230: str.append(">\n"); // NOI18N
231: this .dumpAttributes(MODELELEMENT, 0, str, indent);
232:
233: str.append(indent);
234: str.append("Stereotype"); // NOI18N
235: str.append(indent + "\t"); // NOI18N
236: str.append("<"); // NOI18N
237: o = this .getStereotype();
238: str.append((o == null ? "null" : o.toString().trim())); // NOI18N
239: str.append(">\n"); // NOI18N
240: this .dumpAttributes(STEREOTYPE, 0, str, indent);
241:
242: str.append(indent);
243: str.append("Description"); // NOI18N
244: str.append(indent + "\t"); // NOI18N
245: str.append("<"); // NOI18N
246: o = this .getDescription();
247: str.append((o == null ? "null" : o.toString().trim())); // NOI18N
248: str.append(">\n"); // NOI18N
249: this .dumpAttributes(DESCRIPTION, 0, str, indent);
250:
251: str.append(indent);
252: str.append("Template[" + this .sizeTemplate() + "]"); // NOI18N
253: for (int i = 0; i < this .sizeTemplate(); i++) {
254: str.append(indent + "\t");
255: str.append("#" + i + ":");
256: n = (org.netbeans.modules.schema2beans.BaseBean) this
257: .getTemplate(i);
258: if (n != null)
259: n.dump(str, indent + "\t"); // NOI18N
260: else
261: str.append(indent + "\tnull"); // NOI18N
262: this .dumpAttributes(TEMPLATE, i, str, indent);
263: }
264:
265: }
266:
267: public String dumpBeanNode() {
268: StringBuffer str = new StringBuffer();
269: str.append("DomainObject\n"); // NOI18N
270: this .dump(str, "\n "); // NOI18N
271: return str.toString();
272: }
273:
274: public String[][] getTemplatesTableData() {
275: Template[] templateList = getTemplate();
276: String[][] data = new String[templateList.length][4];
277: int row = 0;
278:
279: for (Template template : templateList) {
280: data[row][0] = template.getFilenameFormat();
281: data[row][1] = template.getFileExtension();
282: data[row][2] = template.getFolderPath();
283: data[row][3] = template.getTemplateFile();
284: row++;
285: }
286:
287: return data;
288: }
289:
290: public void updateTemplates(DefaultTableModel templateTable) {
291: Template[] templates = getTemplate();
292: ArrayList<Template> templateList = new ArrayList(
293: templates.length);
294:
295: for (Template curtemplate : templates)
296: templateList.add(curtemplate);
297:
298: int listSize = templateList.size();
299: int tableSize = templateTable.getRowCount();
300:
301: if (tableSize == 0) {
302: setTemplate(new Template[] {});
303: return;
304: }
305:
306: Template template = null;
307:
308: for (int row = 0; row < tableSize; row++) {
309: if (row < listSize)
310: template = templateList.get(row);
311:
312: else
313: template = new Template();
314:
315: template
316: .setFilenameFormat(templateTable.getValueAt(row, 0) == null ? null
317: : templateTable.getValueAt(row, 0)
318: .toString());
319:
320: template
321: .setFileExtension(templateTable.getValueAt(row, 1) == null ? null
322: : templateTable.getValueAt(row, 1)
323: .toString());
324:
325: template
326: .setFolderPath(templateTable.getValueAt(row, 2) == null ? null
327: : templateTable.getValueAt(row, 2)
328: .toString());
329:
330: template
331: .setTemplateFile(templateTable.getValueAt(row, 3) == null ? null
332: : templateTable.getValueAt(row, 3)
333: .toString());
334:
335: if (row < listSize)
336: templateList.set(row, template);
337:
338: else
339: templateList.add(template);
340: }
341:
342: if (tableSize < listSize)
343: templateList.subList(tableSize, listSize).clear();
344:
345: setTemplate(templateList.toArray(new Template[] {}));
346: }
347:
348: }
349:
350: // END_NOI18N
351:
352: /*
353: The following schema file has been used for generation:
354:
355: <?xml version="1.0" encoding="UTF-8"?>
356:
357: <!--
358: The contents of this file are subject to the terms of the Common Development
359: and Distribution License (the License). You may not use this file except in
360: compliance with the License.
361:
362: You can obtain a copy of the License at http://www.netbeans.org/cddl.html
363: or http://www.netbeans.org/cddl.txt.
364:
365: When distributing Covered Code, include this CDDL Header Notice in each file
366: and include the License file at http://www.netbeans.org/cddl.txt.
367: If applicable, add the following below the CDDL Header, with the fields
368: enclosed by brackets [] replaced by your own identifying information:
369: "Portions Copyrighted [year] [name of copyright owner]"
370:
371: The Original Software is NetBeans. The Initial Developer of the Original
372: Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
373: Microsystems, Inc. All Rights Reserved.
374: -->
375:
376: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
377: <xsd:element name="templateFamilies">
378: <xsd:complexType>
379: <xsd:sequence>
380: <xsd:element name="family" maxOccurs="unbounded">
381: <xsd:complexType>
382: <xsd:sequence>
383: <xsd:element name="domainObject" maxOccurs="unbounded">
384: <xsd:complexType>
385: <xsd:sequence>
386: <xsd:element name="modelElement" type="xsd:string"/>
387: <xsd:element name="stereotype" type="xsd:string"/>
388: <xsd:element name="description" type="xsd:string"/>
389: <xsd:element name="template" maxOccurs="unbounded">
390: <xsd:complexType>
391: <xsd:sequence>
392: <xsd:element name="filenameFormat" type="xsd:string"/>
393: <xsd:element name="fileExtension" type="xsd:string"/>
394: <xsd:element name="folderPath" type="xsd:string"/>
395: <xsd:element name="templateFile" type="xsd:string"/>
396: </xsd:sequence>
397: </xsd:complexType>
398: </xsd:element>
399: </xsd:sequence>
400: <xsd:attribute name="name" type="xsd:string"/>
401: </xsd:complexType>
402: </xsd:element>
403: </xsd:sequence>
404: <xsd:attribute name="name" type="xsd:string"/>
405: <xsd:attribute name="expanded" type="xsd:boolean"/>
406: </xsd:complexType>
407: </xsd:element>
408: </xsd:sequence>
409: </xsd:complexType>
410: </xsd:element>
411: </xsd:schema>
412:
413: */
|