KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > ui > nodes > schema > SequenceNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.schema.ui.nodes.schema;
21
22 import org.netbeans.modules.xml.schema.model.Cardinality;
23 import org.netbeans.modules.xml.schema.ui.basic.editors.MaxOccursEditor;
24 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.BaseSchemaProperty;
25 import org.openide.nodes.Children;
26 import org.openide.nodes.Node.Property;
27 import org.openide.nodes.Sheet;
28 import org.openide.util.NbBundle;
29
30 import org.netbeans.modules.xml.schema.model.Sequence;
31 import org.netbeans.modules.xml.schema.model.SchemaComponentReference;
32 import org.netbeans.modules.xml.schema.ui.nodes.SchemaComponentNode;
33 import org.netbeans.modules.xml.schema.ui.nodes.SchemaModelFlushWrapper;
34 import org.netbeans.modules.xml.schema.ui.nodes.SchemaUIContext;
35 import org.netbeans.modules.xml.schema.ui.nodes.schema.properties.NonNegativeIntegerProperty;
36
37 /**
38  *
39  * @author Todd Fast, todd.fast@sun.com
40  * @author Jeri Lockhart
41  */

42 public class SequenceNode extends SchemaComponentNode<Sequence>
43 {
44     /**
45      *
46      *
47      */

48     public SequenceNode(SchemaUIContext context,
49     SchemaComponentReference<Sequence> reference,
50     Children children) {
51     super(context,reference,children);
52     setIconBaseWithExtension(
53         "org/netbeans/modules/xml/schema/ui/nodes/resources/sequence.png");
54     
55     setDefaultExpanded(true);
56     }
57     
58     
59     /**
60      *
61      *
62      */

63     @Override JavaDoc
64     public String JavaDoc getTypeDisplayName() {
65     return NbBundle.getMessage(SequenceNode.class,
66         "LBL_SequenceNode_TypeDisplayName"); // NOI18N
67
}
68     
69     
70     
71     @Override JavaDoc
72     protected Sheet createSheet() {
73     Sheet sheet = null;
74     try {
75         sheet = super.createSheet();
76         Sheet.Set props = sheet.get(Sheet.PROPERTIES);
77         if (props == null) {
78         props = Sheet.createPropertiesSet();
79         sheet.put(props);
80         }
81         
82         Cardinality choiceCardinality = getReference().get().getCardinality();
83         
84         if (choiceCardinality != null) {
85         // minOccurs
86
Property minOccursProp = new NonNegativeIntegerProperty(
87             getReference().get(), // schema component
88
Sequence.MIN_OCCURS_PROPERTY,
89             NbBundle.getMessage(SequenceNode.class,"PROP_MinOccurs_DisplayName"), // display name
90
NbBundle.getMessage(SequenceNode.class,"PROP_MinOccurs_ShortDescription") // descr
91
);
92         props.put(new SchemaModelFlushWrapper(getReference().get(), minOccursProp));
93         
94         // maxOccurs
95
Property maxOccursProp = new BaseSchemaProperty(
96             getReference().get(), // schema component
97
String JavaDoc.class,
98             Sequence.MAX_OCCURS_PROPERTY,
99             NbBundle.getMessage(SequenceNode.class,"PROP_MaxOccurs_DisplayName"), // display name
100
NbBundle.getMessage(SequenceNode.class,"PROP_MaxOccurs_ShortDescription"), // descr
101
MaxOccursEditor.class
102             );
103         props.put(new SchemaModelFlushWrapper(getReference().get(), maxOccursProp));
104         }
105     } catch (NoSuchMethodException JavaDoc ex) {
106         assert false : "properties should be defined";
107     }
108     return sheet;
109     }
110 }
111
Popular Tags