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-2006 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.xml.wizard;
042:
043: import java.beans.PropertyChangeSupport;
044: import java.beans.PropertyChangeListener;
045: import java.net.URL;
046: import java.util.ArrayList;
047: import java.util.Iterator;
048: import java.util.List;
049: import java.util.Set;
050: import java.util.TreeSet;
051: import org.openide.nodes.Node;
052:
053: /**
054: * Holds state of new document wizard.
055: *
056: * @author Petr Kuzel
057: */
058: public final class DocumentModel {
059:
060: public static final int NONE = 0;
061:
062: public static final int DTD = 1;
063:
064: public static final int SCHEMA = 2;
065:
066: public static final int OTHER = 3;
067:
068: private String name;
069:
070: private String namespace;
071:
072: private String publicID;
073:
074: private String systemID;
075:
076: private String root;
077:
078: // input property describing wizard invocation context
079: private URL targetFolderURL;
080:
081: public static final String PROP_TYPE = "type";
082:
083: private int type;
084:
085: private PropertyChangeSupport support;
086:
087: private List schemaNodes;
088:
089: private String prefix;
090:
091: private XMLContentAttributes contentAttr;
092:
093: private String primarySchemaFileName;
094:
095: /** Creates new SchemaWizardModel */
096: public DocumentModel(URL targetFolderURL) {
097: type = NONE;
098: this .targetFolderURL = targetFolderURL;
099: }
100:
101: public String getName() {
102: return name;
103: }
104:
105: public void setName(String value) {
106: name = value;
107: }
108:
109: public String getNamespace() {
110: return this .namespace;
111: }
112:
113: public void setNamespace(String namespace) {
114: this .namespace = namespace;
115: }
116:
117: public String getPublicID() {
118: if (publicID != null && publicID.trim().equals(""))
119: return null;
120: return this .publicID;
121: }
122:
123: public void setPublicID(String publicID) {
124: this .publicID = publicID;
125: }
126:
127: public String getSystemID() {
128: return this .systemID;
129: }
130:
131: public void setSystemID(String systemID) {
132: this .systemID = systemID;
133: }
134:
135: public String getRoot() {
136: if (root != null && root.trim().equals(""))
137: return null;
138: return this .root;
139: }
140:
141: public void setRoot(String root) {
142: this .root = root;
143: }
144:
145: public int getType() {
146: return this .type;
147: }
148:
149: public void setType(int type) {
150: int old = this .type;
151: this .type = type;
152: getSupport().firePropertyChange(PROP_TYPE, old, type);
153: }
154:
155: public URL getTargetFolderURL() {
156: return targetFolderURL;
157: }
158:
159: public void addPropertyChangeListener(PropertyChangeListener l) {
160: getSupport().addPropertyChangeListener(l);
161: }
162:
163: public void removePropertyChangeListener(PropertyChangeListener l) {
164: getSupport().removePropertyChangeListener(l);
165: }
166:
167: private synchronized PropertyChangeSupport getSupport() {
168: if (support == null) {
169: support = new PropertyChangeSupport(this );
170: }
171: return support;
172: }
173:
174: public void setSchemaNodes(List schemaNodes) {
175: this .schemaNodes = schemaNodes;
176: }
177:
178: public List getSchemaNodes() {
179: return schemaNodes;
180:
181: }
182:
183: public void setPrefix(String prefix) {
184: this .prefix = prefix;
185: }
186:
187: public String getPrefix() {
188: return prefix;
189: }
190:
191: public void setXMLContentAttributes(XMLContentAttributes attr) {
192: this .contentAttr = attr;
193: }
194:
195: public XMLContentAttributes getXMLContentAttributes() {
196: return contentAttr;
197: }
198:
199: public void setPrimarySchema(String fileName) {
200: this .primarySchemaFileName = fileName;
201: }
202:
203: public String getPrimarySchema() {
204: return primarySchemaFileName;
205: }
206:
207: }
|