KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > core > wizard > DocumentModel


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.core.wizard;
20
21 import java.beans.PropertyChangeSupport JavaDoc;
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.net.URL JavaDoc;
24 import java.util.ArrayList JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.Set JavaDoc;
27 import java.util.TreeSet JavaDoc;
28
29 /**
30  * Holds state of new document wizard.
31  *
32  * @author Petr Kuzel
33  */

34 public final class DocumentModel {
35
36     public static final int NONE = 0;
37
38     public static final int DTD = 1;
39
40     public static final int SCHEMA = 2;
41
42     public static final int OTHER = 3;
43
44     private String JavaDoc name;
45     
46     private String JavaDoc namespace;
47     
48     private String JavaDoc publicID;
49     
50     private String JavaDoc systemID;
51         
52     private String JavaDoc root;
53     
54     // input property describing wizard invocation context
55
private URL JavaDoc targetFolderURL;
56     
57     public static final String JavaDoc PROP_TYPE = "type";
58     
59     private int type;
60
61     private PropertyChangeSupport JavaDoc support;
62         
63     /** Creates new SchemaWizardModel */
64     public DocumentModel(URL JavaDoc targetFolderURL) {
65         type = NONE;
66         this.targetFolderURL = targetFolderURL;
67     }
68         
69     public String JavaDoc getName() {
70         return name;
71     }
72     
73     public void setName(String JavaDoc value) {
74         name = value;
75     }
76         
77     public String JavaDoc getNamespace() {
78         return this.namespace;
79     }
80     
81     public void setNamespace(String JavaDoc namespace) {
82         this.namespace = namespace;
83     }
84     
85     public String JavaDoc getPublicID() {
86         if (publicID != null && publicID.trim().equals("")) return null;
87         return this.publicID;
88     }
89     
90     public void setPublicID(String JavaDoc publicID) {
91         this.publicID = publicID;
92     }
93     
94     public String JavaDoc getSystemID() {
95         return this.systemID;
96     }
97     
98     public void setSystemID(String JavaDoc systemID) {
99         this.systemID = systemID;
100     }
101     
102     public String JavaDoc getRoot() {
103         if (root != null && root.trim().equals("")) return null;
104         return this.root;
105     }
106     
107     public void setRoot(String JavaDoc root) {
108         this.root = root;
109     }
110             
111     public int getType() {
112         return this.type;
113     }
114     
115     public void setType(int type) {
116         int old = this.type;
117         this.type = type;
118         getSupport().firePropertyChange(PROP_TYPE, old, type);
119     }
120     
121     public URL JavaDoc getTargetFolderURL() {
122         return targetFolderURL;
123     }
124         
125     public void addPropertyChangeListener(PropertyChangeListener JavaDoc l) {
126         getSupport().addPropertyChangeListener(l);
127     }
128     
129     public void removePropertyChangeListener(PropertyChangeListener JavaDoc l) {
130         getSupport().removePropertyChangeListener(l);
131     }
132     
133     private synchronized PropertyChangeSupport JavaDoc getSupport() {
134         if (support == null) {
135             support = new PropertyChangeSupport JavaDoc(this);
136         }
137         return support;
138     }
139     
140 }
141
Popular Tags