Today's Page Hits: 1006
<folder name="Services">
<file name="org-netbeans-modules-mymodule-MyModuleSettings.settings" url="MyModuleSettings.xml" />
</folder>
<?xml version="1.0"?>
<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
<settings version="1.0">
<module name="org.netbeans.modules.mymodule"/>
<instanceof class="org.openide.util.SharedClassObject"/>
<instanceof class="org.openide.options.SystemOption"/>
<instanceof class="org.netbeans.modules.mymodule.MyModuleSettings"/>
<instance class="org.netbeans.modules.mymodule.MyModuleSettings"/>
</settings>
public class MyModuleSettings extends SystemOption {
// unique serial number for serialization
static final long serialVersionUID = 34343534534534573L;
// the names of options you'll use
public static final String PROP_HOSTNAME = "hostname";
public static final String PROP_PORT = "port";
// initialization method
protected void initialize () {
// calles SystemOption's initialize
super.initialize();
// default values
putProperty(PROP_HOSTNAME, "localhost", true);
putProperty(PROP_PORT, "4976", true);
}
// this method serializes the options
public void writeExternal (ObjectOutput out) throws IOException {
out.writeObject(getProperty(PROP_HOSTNAME));
out.writeObject(getProperty(PROP_PORT));
}
// this method deserializes the options
private void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
putProperty(PROP_HOSTNAME, in.readObject(), true);
putProperty(PROP_PORT, in.readObject(), true);
}
// readable name of options
public String displayName() {
return "My Module's Options";
}
// help context
public HelpCtx getHelpCtx () {
return new HelpCtx(MyModuleSettings.class);
}
// set Hostname Option
public void setHostname(String hostname) {
putProperty(PROP_HOSTNAME, hostname, true);
}
// get Hostname Option
public String getHostname() {
return (String) getProperty(PROP_HOSTNAME);
}
// set Port Option
public void setPort(Integer port) {
putProperty(PROP_PORT, host, true);
}
// get Port Option
public Integer getPort() {
return (Integer) getProperty(PROP_PORT);
}
}
public class MyModuleSettingsBeanInfo extends SimpleBeanInfo {
public PropertyDescriptor[] getPropertyDescriptors() {
try {
PropertyDescriptor hostname =
new PropertyDescriptor("hostname", MyModuleSettings.class);
hostname.setDisplayName("Hostname");
hostname.setShortDescription("This option sets the hostname.");
PropertyDescriptor port =
new PropertyDescriptor("port", MyModuleSettings.class);
port.setDisplayName("Port");
port.setShortDescription("This option sets the port.");
return new PropertyDescriptor[] {hostname, port};
} catch (IntrospectionException ie) {
System.err.println("Introspection exception thrown: "+ie);
return null;
}
}
public Image getIcon(int type) {
if (type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16) {
return Utilities.loadImage(
"/org/netbeans/modules/mymodule/MyModuleIcon16.gif");
} else {
return null;
}
}
}
<folder name="UI">
<folder name="Services">
<folder name="IDEConfiguration">
<folder name="ServerAndExternalToolSettings">
<file name="org-netbeans-modules-mymodule-MyModuleSettings.shadow">
<attr name="originalFile" stringvalue="Services/org-netbeans-modules-mymodule-MyModuleSettings.settings"/>
</file>
</folder>
</folder>
</folder>
</folder>