1 19 20 package org.netbeans.modules.j2ee.sun.share.config; 21 22 import java.lang.reflect.InvocationTargetException ; 23 24 import javax.enterprise.deploy.spi.exceptions.ConfigurationException ; 25 26 import org.openide.ErrorManager; 27 import org.openide.cookies.OpenCookie; 28 import org.openide.cookies.EditCookie; 29 import org.openide.loaders.DataNode; 30 import org.openide.nodes.Children; 31 import org.openide.nodes.PropertySupport; 32 import org.openide.nodes.Sheet; 33 import org.openide.util.NbBundle; 34 35 import org.netbeans.modules.j2ee.sun.share.configbean.ASDDVersion; 36 import org.netbeans.modules.j2ee.sun.share.configbean.SunONEDeploymentConfiguration; 37 38 39 42 public class ConfigDataNode extends DataNode { 43 44 private ConfigDataObject dataObject; 45 46 public ConfigDataNode (ConfigDataObject obj) { 47 this (obj, Children.LEAF); 48 this.dataObject = obj; 49 } 50 51 public ConfigDataNode (ConfigDataObject obj, Children ch) { 52 super (obj, ch); 53 setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/share/config/ui/resources/ConfigFile.gif"); } 55 56 57 public void destroy() throws java.io.IOException { 58 this.dataObject = null; 59 super.destroy(); 60 } 61 62 protected org.openide.nodes.Sheet createSheet() { 64 Sheet sheet = super.createSheet(); 65 Sheet.Set ss = new Sheet.Set(); 66 67 ss.setName("deploymentdescriptor"); ss.setDisplayName(NbBundle.getBundle(ConfigDataNode.class).getString("LBL_ConfigPropertiesName")); ss.setShortDescription(NbBundle.getBundle(ConfigDataNode.class).getString("LBL_ConfigPropertiesDescription")); ss.put(new VersionProperty()); 71 72 sheet.put(ss); 73 return sheet; 74 } 75 76 79 private final class VersionProperty extends PropertySupport { 80 81 public VersionProperty() { 82 super("DDVersion" , VersionEditor.class, 83 NbBundle.getBundle(ConfigDataNode.class).getString("LBL_ConfigVersionPropertyName"), NbBundle.getBundle(ConfigDataNode.class).getString("LBL_ConfigVersionPropertyDescription"), true, false); 86 } 87 88 public Object getValue() throws IllegalAccessException , InvocationTargetException { 89 String result = ASDDVersion.SUN_APPSERVER_8_1.toString(); 90 91 try { 92 SunONEDeploymentConfiguration config = dataObject.getDeploymentConfiguration(); 93 result = config.getAppServerVersion().toString(); 94 } catch(ConfigurationException ex) { 95 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 96 } 97 98 return result; 99 } 100 101 public void setValue(Object val) throws IllegalAccessException , IllegalArgumentException , InvocationTargetException { 102 if(val instanceof String ) { 103 try { 104 ASDDVersion asDDVersion = ASDDVersion.getASDDVersion((String ) val); 105 SunONEDeploymentConfiguration config = dataObject.getDeploymentConfiguration(); 106 config.setAppServerVersion(asDDVersion); 107 } catch(ConfigurationException ex) { 108 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 109 } 110 } else { 111 throw new IllegalArgumentException ("value must be non null and type String"); } 113 } 114 115 public java.beans.PropertyEditor getPropertyEditor() { 116 VersionEditor result = null; 117 118 try { 119 SunONEDeploymentConfiguration config = dataObject.getDeploymentConfiguration(); 120 int minAS = VersionEditor.fromASDDVersion(config.getMinASVersion()); 121 int maxAS = VersionEditor.fromASDDVersion(config.getMaxASVersion()); 122 result = new VersionEditor(minAS, maxAS); 123 } catch (ConfigurationException ex) { 124 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 125 } 126 127 return result; 128 } 129 130 public boolean canWrite() { 131 return dataObject.getCookie(OpenCookie.class) != null && 135 dataObject.getCookie(EditCookie.class) != null; 136 } 137 138 public boolean canRead() { 139 return true; 140 } 141 142 } 143 } 144 | Popular Tags |