1 19 24 package org.netbeans.modules.j2ee.sun.ide.sunresources.wizards; 25 26 import java.util.Set ; 27 import java.util.Vector ; 28 import java.util.Hashtable ; 29 import org.openide.util.NbBundle; 30 import org.openide.filesystems.FileObject; 31 import org.openide.loaders.DataFolder; 32 33 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair; 34 35 import org.netbeans.modules.j2ee.sun.sunresources.beans.Wizard; 36 import org.netbeans.modules.j2ee.sun.sunresources.beans.WizardConstants; 37 38 42 public class ResourceConfigData implements WizardConstants { 43 44 private DataFolder targetFolder; 45 private String targetFolderPath; 46 private String targetFile; 47 private FileObject targetFileObject; 48 private ResourceConfigHelperHolder holder; 49 private Hashtable prop_value_map = new Hashtable (); 50 private String resName; 51 52 public static Wizard cpWizard = null; 53 public static Wizard dsWizard = null; 54 public static Wizard jmsWizard = null; 55 public static Wizard mailWizard = null; 56 public static Wizard pmWizard = null; 57 58 public ResourceConfigData() { 59 } 60 61 91 92 public void removeAll() { 93 prop_value_map = new Hashtable (); 94 } 95 96 public String getResourceName() { 97 return resName; 98 } 99 100 public void setResourceName(String name) { 101 resName = name; 102 } 103 104 public String getString(String name) { 105 Object value = prop_value_map.get(name); 106 if (value == null) 107 return new String (); 108 else 109 return (String )value; 110 } 111 112 public void setString(String name, String value) { 113 set(name, value); 114 } 115 116 public Object get(String name) { 117 return prop_value_map.get(name); 118 } 119 120 public void set(String name, Object value) { 121 prop_value_map.put(name, value); 122 } 123 124 public String [] getFieldNames() { 125 Set keySet = prop_value_map.keySet(); 126 String [] fieldNames = new String [keySet.size()]; 127 return (String [])keySet.toArray(fieldNames); 128 } 129 130 public Vector getProperties() { 131 Vector props = (Vector )prop_value_map.get(__Properties); if (props == null) { 133 props = new Vector (); 134 prop_value_map.put(__Properties, props); } 136 return props; 137 } 138 139 public Vector getPropertyNames() { 140 Vector props = getProperties(); 141 Vector vec = new Vector (); 142 for (int i = 0; i < props.size(); i++) { 143 vec.add(((NameValuePair)props.elementAt(i)).getParamName()); 144 } 145 return vec; 146 } 147 148 public String getPropertyValue(String propName) { 149 Vector vec = getProperties(); 150 for (int i = 0; i < vec.size(); i++) { 151 NameValuePair pair = (NameValuePair)vec.elementAt(i); 152 if (pair.getParamName().equals(propName)) 153 return pair.getParamValue(); 154 } 155 return null; 156 } 157 158 public Vector addProperty(NameValuePair pair) { 159 Vector names = getPropertyNames(); 160 if (names.contains(pair.getParamName())) 161 return null; 162 Vector props = getProperties(); 163 props.add(pair); 164 return props; 165 } 166 167 public Vector addProperty(String name, String value) { 168 NameValuePair pair = new NameValuePair(); 169 pair.setParamName(name); 170 pair.setParamValue(value); 171 return addProperty(pair); 172 } 173 174 public void removeProperty(int index) { 175 Vector props = getProperties(); 176 props.removeElementAt(index); 177 } 178 179 public void setProperties(Vector props) { 180 set(__Properties, props); 181 } 182 183 public String toString() { 184 StringBuffer retValue = new StringBuffer (); 185 retValue.append(getResourceName() + "::\n"); String [] fieldNames = getFieldNames(); 187 for (int i = 0; i < fieldNames.length; i++) { 188 if (fieldNames[i].equals(__Properties)) { 189 retValue.append("properties: \n"); Vector props = (Vector )getProperties(); 191 for (int j = 0; j < props.size(); j++) { 192 NameValuePair pair = (NameValuePair)props.elementAt(j); 193 retValue.append(" " + pair.getParamName() + ": " + pair.getParamValue()); } 195 } 196 else 197 retValue.append(fieldNames[i] + ": " + getString(fieldNames[i]) + "\n"); } 199 return retValue.toString(); 200 } 201 202 public void setTargetFolder(DataFolder targetFolder){ 203 this.targetFolder = targetFolder; 204 } 205 206 public DataFolder getTargetFolder(){ 207 return this.targetFolder; 208 } 209 210 public void setTargetFolderPath(String path){ 211 this.targetFolderPath = path; 212 } 213 214 public String getTargetFolderPath(){ 215 return this.targetFolderPath; 216 } 217 218 public void setTargetFile(String targetFile){ 219 this.targetFile = targetFile; 220 } 221 222 public String getTargetFile(){ 223 return this.targetFile; 224 } 225 226 public FileObject getTargetFileObject(){ 227 return this.targetFileObject; 228 } 229 230 public void setTargetFileObject(FileObject targetObject){ 231 this.targetFileObject = targetObject; 232 } 233 234 public ResourceConfigHelperHolder getHolder(){ 235 return this.holder; 236 } 237 238 public void setHolder(ResourceConfigHelperHolder holder){ 239 this.holder = holder; 240 } 241 } 242 | Popular Tags |