1 19 20 package org.netbeans.modules.j2ee.dd.impl.application; 21 22 import java.math.BigDecimal ; 23 import org.netbeans.modules.j2ee.dd.api.application.Application; 24 25 28 public class ApplicationProxy implements Application { 29 private Application app; 30 private String version; 31 private java.util.List listeners; 32 public boolean writing=false; 33 private OutputProvider outputProvider; 34 private org.xml.sax.SAXParseException error; 35 private int ddStatus; 36 37 39 40 public ApplicationProxy(Application app, String version) { 41 this.app = app; 42 this.version = version; 43 listeners = new java.util.ArrayList (); 44 } 45 46 public void setOriginal(Application app) { 47 if (this.app != app) { 48 for (int i=0;i<listeners.size();i++) { 49 java.beans.PropertyChangeListener pcl = 50 (java.beans.PropertyChangeListener )listeners.get(i); 51 if (this.app != null) this.app.removePropertyChangeListener(pcl); 52 if (app != null) app.addPropertyChangeListener(pcl); 53 54 } 55 this.app = app; 56 if (app != null) setProxyVersion(app.getVersion().toString()); 57 } 58 } 59 60 public Application getOriginal() { 61 return app; 62 } 63 64 public void setProxyVersion(java.lang.String value) { 65 if ((version==null && value!=null) || (version != null && !version.equals(value))) { 66 java.beans.PropertyChangeEvent evt = 67 new java.beans.PropertyChangeEvent (this, PROPERTY_VERSION, version, value); 68 version=value; 69 for (int i=0;i<listeners.size();i++) { 70 ((java.beans.PropertyChangeListener )listeners.get(i)).propertyChange(evt); 71 } 72 } 73 } 74 75 76 public org.netbeans.modules.j2ee.dd.api.common.CommonDDBean addBean(String beanName) throws ClassNotFoundException { 77 return app==null?null:app.addBean(beanName); 78 } 79 80 public org.netbeans.modules.j2ee.dd.api.common.CommonDDBean addBean(String beanName, String [] propertyNames, Object [] propertyValues, String keyProperty) throws ClassNotFoundException , org.netbeans.modules.j2ee.dd.api.common.NameAlreadyUsedException { 81 return app==null?null:app.addBean(beanName, propertyNames, propertyValues, keyProperty); 82 } 83 84 public int addIcon(org.netbeans.modules.j2ee.dd.api.common.Icon value) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 85 return app==null?-1:app.addIcon(value); 86 } 87 88 public int addModule(org.netbeans.modules.j2ee.dd.api.application.Module value) { 89 return app==null?-1:app.addModule(value); 90 } 91 92 public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl) { 93 if (app != null) app.addPropertyChangeListener(pcl); 94 listeners.add(pcl); 95 } 96 97 public int addSecurityRole(org.netbeans.modules.j2ee.dd.api.common.SecurityRole value) { 98 return app==null?-1:app.addSecurityRole(value); 99 } 100 101 public org.netbeans.modules.j2ee.dd.api.common.CommonDDBean createBean(String beanName) throws ClassNotFoundException { 102 return app==null?null:app.createBean(beanName); 103 } 104 105 public org.netbeans.modules.j2ee.dd.api.common.CommonDDBean findBeanByName(String beanName, String propertyName, String value) { 106 return app==null?null:app.findBeanByName(beanName, propertyName, value); 107 } 108 109 public java.util.Map getAllDescriptions() { 110 return app==null?new java.util.HashMap ():app.getAllDescriptions(); 111 } 112 113 public java.util.Map getAllDisplayNames() { 114 return app==null?new java.util.HashMap ():app.getAllDisplayNames(); 115 } 116 117 public java.util.Map getAllIcons() { 118 return app==null?new java.util.HashMap ():app.getAllIcons(); 119 } 120 121 public String getDefaultDescription() { 122 return app==null?null:app.getDefaultDescription(); 123 } 124 125 public String getDefaultDisplayName() { 126 return app==null?null:app.getDefaultDisplayName(); 127 } 128 129 public org.netbeans.modules.j2ee.dd.api.common.Icon getDefaultIcon() { 130 return app==null?null:app.getDefaultIcon(); 131 } 132 133 public String getDescription(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 134 return app==null?null:app.getDescription(locale); 135 } 136 137 public String getDisplayName(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 138 return app==null?null:app.getDisplayName(locale); 139 } 140 141 public org.xml.sax.SAXParseException getError() { 142 return error; 143 } 144 145 public void setError(org.xml.sax.SAXParseException error) { 146 this.error=error; 147 } 148 149 public org.netbeans.modules.j2ee.dd.api.common.Icon getIcon(int index) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 150 return app==null?null:app.getIcon(index); 151 } 152 153 public String getId() { 154 return app==null?null:app.getId(); 155 } 156 157 public String getLargeIcon() { 158 return app==null?null:app.getLargeIcon(); 159 } 160 161 public String getLargeIcon(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 162 return app==null?null:app.getLargeIcon(locale); 163 } 164 165 public org.netbeans.modules.j2ee.dd.api.application.Module[] getModule() { 166 return app==null?null:app.getModule(); 167 } 168 169 public org.netbeans.modules.j2ee.dd.api.application.Module getModule(int index) { 170 return app==null?null:app.getModule(index); 171 } 172 173 public org.netbeans.modules.j2ee.dd.api.common.SecurityRole[] getSecurityRole() { 174 return app==null?null:app.getSecurityRole(); 175 } 176 177 public org.netbeans.modules.j2ee.dd.api.common.SecurityRole getSecurityRole(int index) { 178 return app==null?null:app.getSecurityRole(index); 179 } 180 181 public String getSmallIcon() { 182 return app==null?null:app.getSmallIcon(); 183 } 184 185 public String getSmallIcon(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 186 return app==null?null:app.getSmallIcon(locale); 187 } 188 189 public int getStatus() { 190 return ddStatus; 191 } 192 193 public void setStatus(int value) { 194 if (ddStatus!=value) { 195 java.beans.PropertyChangeEvent evt = 196 new java.beans.PropertyChangeEvent (this, PROPERTY_STATUS, new Integer (ddStatus), new Integer (value)); 197 ddStatus=value; 198 for (int i=0;i<listeners.size();i++) { 199 ((java.beans.PropertyChangeListener )listeners.get(i)).propertyChange(evt); 200 } 201 } 202 } 203 204 public Object getValue(String propertyName) { 205 return app==null?null:app.getValue(propertyName); 206 } 207 208 public BigDecimal getVersion() { 209 return version == null ? BigDecimal.ZERO : new BigDecimal (version); 210 } 211 212 public void merge(org.netbeans.modules.j2ee.dd.api.common.RootInterface root, int mode) { 213 if (app!=null) { 214 if (root instanceof ApplicationProxy) 215 app.merge(((ApplicationProxy)root).getOriginal(), mode); 216 else app.merge(root, mode); 217 } 218 } 219 220 public org.netbeans.modules.j2ee.dd.api.common.Icon newIcon() { 221 return app==null?null:app.newIcon(); 222 } 223 224 public org.netbeans.modules.j2ee.dd.api.application.Module newModule() { 225 return app==null?null:app.newModule(); 226 } 227 228 public org.netbeans.modules.j2ee.dd.api.common.SecurityRole newSecurityRole() { 229 return app==null?null:app.newSecurityRole(); 230 } 231 232 public void removeAllDescriptions() { 233 if (app!=null) app.removeAllDescriptions(); 234 } 235 236 public void removeAllDisplayNames() { 237 if (app!=null) app.removeAllDisplayNames(); 238 } 239 240 public void removeAllIcons() { 241 if (app!=null) app.removeAllIcons(); 242 } 243 244 public void removeDescription() { 245 if (app!=null) app.removeDescription(); 246 } 247 248 public void removeDescriptionForLocale(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 249 if (app!=null) app.removeDescriptionForLocale(locale); 250 } 251 252 public void removeDisplayName() { 253 if (app!=null) app.removeDisplayName(); 254 } 255 256 public void removeDisplayNameForLocale(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 257 if (app!=null) app.removeDisplayNameForLocale(locale); 258 } 259 260 public void removeIcon() { 261 if (app!=null) app.removeIcon(); 262 } 263 264 public int removeIcon(org.netbeans.modules.j2ee.dd.api.common.Icon value) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 265 return app==null?-1:app.removeIcon(value); 266 } 267 268 public void removeIcon(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 269 if (app!=null) app.removeIcon(locale); 270 } 271 272 public void removeLargeIcon() { 273 if (app!=null) app.removeLargeIcon(); 274 } 275 276 public void removeLargeIcon(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 277 if (app!=null) app.removeLargeIcon(locale); 278 } 279 280 public int removeModule(org.netbeans.modules.j2ee.dd.api.application.Module value) { 281 return app==null?-1:app.removeModule(value); 282 } 283 284 public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl) { 285 if (app != null) app.removePropertyChangeListener(pcl); 286 listeners.remove(pcl); 287 } 288 289 public int removeSecurityRole(org.netbeans.modules.j2ee.dd.api.common.SecurityRole value) { 290 return app==null?-1:app.removeSecurityRole(value); 291 } 292 293 public void removeSmallIcon() { 294 if (app != null) app.removeSmallIcon(); 295 } 296 297 public void removeSmallIcon(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 298 if (app != null) app.removeSmallIcon(locale); 299 } 300 301 public void setAllDescriptions(java.util.Map descriptions) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 302 if (app != null) app.setAllDescriptions(descriptions); 303 } 304 305 public void setAllDisplayNames(java.util.Map displayNames) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 306 if (app != null) app.setAllDisplayNames(displayNames); 307 } 308 309 public void setAllIcons(String [] locales, String [] smallIcons, String [] largeIcons) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 310 if (app != null) app.setAllIcons(locales, smallIcons, largeIcons); 311 } 312 313 public void setDescription(String description) { 314 if (app != null) app.setDescription(description); 315 } 316 317 public void setDescription(String locale, String description) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 318 if (app != null) app.setDescription(locale, description); 319 } 320 321 public void setDisplayName(String displayName) { 322 if (app != null) app.setDisplayName(displayName); 323 } 324 325 public void setDisplayName(String locale, String displayName) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 326 if (app != null) app.setDisplayName(locale, displayName); 327 } 328 329 public void setIcon(org.netbeans.modules.j2ee.dd.api.common.Icon[] value) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 330 if (app != null) app.setIcon(value); 331 } 332 333 public void setIcon(org.netbeans.modules.j2ee.dd.api.common.Icon icon) { 334 if (app != null) app.setIcon(icon); 335 } 336 337 public void setIcon(int index, org.netbeans.modules.j2ee.dd.api.common.Icon value) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 338 if (app != null) app.setIcon(index, value); 339 } 340 341 public void setId(String value) { 342 if (app != null) app.setId(value); 343 } 344 345 public void setLargeIcon(String icon) { 346 if (app != null) app.setLargeIcon(icon); 347 } 348 349 public void setLargeIcon(String locale, String icon) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 350 if (app != null) app.setLargeIcon(locale, icon); 351 } 352 353 public void setModule(org.netbeans.modules.j2ee.dd.api.application.Module[] value) { 354 if (app != null) app.setModule(value); 355 } 356 357 public void setModule(int index, org.netbeans.modules.j2ee.dd.api.application.Module value) { 358 if (app != null) app.setModule(index, value); 359 } 360 361 public void setSecurityRole(org.netbeans.modules.j2ee.dd.api.common.SecurityRole[] value) { 362 if (app != null) app.setSecurityRole(value); 363 } 364 365 public void setSecurityRole(int index, org.netbeans.modules.j2ee.dd.api.common.SecurityRole value) { 366 if (app != null) app.setSecurityRole(index, value); 367 } 368 369 public void setSmallIcon(String icon) { 370 if (app != null) app.setSmallIcon(icon); 371 } 372 373 public void setSmallIcon(String locale, String icon) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 374 if (app != null) app.setSmallIcon(locale, icon); 375 } 376 377 public int sizeIcon() throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 378 return app==null?0:app.sizeIcon(); 379 } 380 381 public int sizeModule() { 382 return app==null?0:app.sizeModule(); 383 } 384 385 public int sizeSecurityRole() { 386 return app==null?0:app.sizeSecurityRole(); 387 } 388 389 public void write(org.openide.filesystems.FileObject fo) throws java.io.IOException { 390 if (app != null) { 391 try { 392 org.openide.filesystems.FileLock lock = fo.lock(); 393 try { 394 java.io.OutputStream os = fo.getOutputStream(lock); 395 try { 396 writing=true; 397 write(os); 398 } finally { 399 os.close(); 400 } 401 } 402 finally { 403 lock.releaseLock(); 404 } 405 } catch (org.openide.filesystems.FileAlreadyLockedException ex) { 406 org.openide.loaders.DataObject dobj = org.openide.loaders.DataObject.find(fo); 408 if (dobj!=null && dobj instanceof ApplicationProxy.OutputProvider) 409 ((ApplicationProxy.OutputProvider)dobj).write(this); 410 else throw ex; 411 } 412 } 413 } 414 415 public void write(java.io.OutputStream os) throws java.io.IOException { 416 if (app != null) { 417 writing=true; 418 app.write(os); 419 } 420 } 421 422 public Object clone() { 423 ApplicationProxy proxy = null; 424 if (app == null) 425 proxy = new ApplicationProxy(null,version); 426 else { 427 ApplicationProxy clonedApp=(ApplicationProxy)app.clone(); 428 proxy = new ApplicationProxy(clonedApp, version); 429 } 430 proxy.setError(error); 431 proxy.setStatus(ddStatus); 432 return proxy; 433 } 434 435 public boolean isWriting() { 436 return writing; 437 } 438 439 public void setWriting(boolean writing) { 440 this.writing=writing; 441 } 442 443 public void setOutputProvider(OutputProvider iop) { 444 this.outputProvider=iop; 445 } 446 447 450 public static interface OutputProvider { 451 public void write(Application app) throws java.io.IOException ; 452 public org.openide.filesystems.FileObject getTarget(); 453 } 454 } 455 | Popular Tags |