Java Code Examples for org.openide.nodes.PropertySupport#ReadWrite

The following examples show how to use org.openide.nodes.PropertySupport#ReadWrite . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationTypesNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Create PropertySupport for given property name and class */
private PropertySupport createProperty(final String name, final Class clazz) {
    return new PropertySupport.ReadWrite(name, clazz,
        getBundleString("PROP_" + name),    //NOI18N
        getBundleString("HINT_" + name)) {  //NOI18N
        public Object getValue() {
            return getProperty(name);
        }
        public void setValue(Object value) {
            setProperty(name, value);
        }
        public boolean supportsDefaultValue() {
            return false;
        }
    };
}
 
Example 2
Source File: JmeParticleEmitter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Property createButtonProperty() {
    return new PropertySupport.ReadWrite<Object>("emit", Object.class, "Emit all particles", "Click here to emit all particles of this emitter ") {

        JmeParticleEmitterButtonProperty pe;

        @Override
        public Object getValue() throws IllegalAccessException, InvocationTargetException {
            return "";
        }

        @Override
        public PropertyEditor getPropertyEditor() {
            if (pe == null) {
                pe = new JmeParticleEmitterButtonProperty(JmeParticleEmitter.this);
                pe.attachEnv(pe.env);
            }
            return pe;
        }

        @Override
        public void setValue(Object t) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        }
    };
}
 
Example 3
Source File: PinWatchValueProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({"# {0} - the watched expression", "PropEditDisplayName=Value of {0}"})
private Action getPropertyEditorAction(final PropertyEditor pe,
                                       final ObjectVariable var,
                                       final ValueListeners vl,
                                       final String expression) {
    Property property = new PropertySupport.ReadWrite(expression, null,
                                                      Bundle.PropEditDisplayName(expression),
                                                      Bundle.PropEditDisplayName(expression)) {
        @Override
        public Object getValue() throws IllegalAccessException, InvocationTargetException {
            return var;
        }
        @Override
        public void setValue(final Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
            RP.post(new Runnable() {
                @Override
                public void run() {
                    try {
                        vl.watchEv.setFromMirrorObject(val);
                        vl.watchEv.setEvaluated(null);
                        updateValueFrom(vl.watchEv);
                    } catch (InvalidObjectException ex) {
                        NotifyDescriptor msg = new NotifyDescriptor.Message(ex.getLocalizedMessage(), NotifyDescriptor.ERROR_MESSAGE);
                        DialogDisplayer.getDefault().notifyLater(msg);
                    }
                }
            });
            vl.value = getEvaluatingText();
            vl.valueOnly = null;

        }
        @Override
        public PropertyEditor getPropertyEditor() {
            return pe;
        }
    };
    PropertyPanel pp = new PropertyPanel(property);
    return pp.getActionMap().get("invokeCustomEditor");                     // NOI18N
}
 
Example 4
Source File: OnePropNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected Sheet createSheet() {
    Sheet sheet = super.createSheet();
    Sheet.Set props = sheet.get(Sheet.PROPERTIES);
    if (props == null) {
        props = Sheet.createPropertiesSet();
        sheet.put(props);
    }
    props.put(new PropertySupport.Name(this));
    class ValueProp extends PropertySupport.ReadWrite {
        public ValueProp() {
            super("value", String.class,
                    bundle.getString("PROP_value"), bundle.getString("HINT_value"));
        }
        public Object getValue() {
            return System.getProperty(key);
        }
        public void setValue(Object nue) {
            System.setProperty(key, (String) nue);
            PropertiesNotifier.changed();
        }
        
    }
    
    props.put(new ValueProp());
    PropertiesNotifier.addChangeListener(listener = new
            ChangeListener() {
        public void stateChanged(ChangeEvent ev) {
            firePropertyChange("value", null, null);
        }
    });
    return sheet;
}
 
Example 5
Source File: JavaNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Node.Property createNameProperty () {
    Node.Property p = new PropertySupport.ReadWrite<String> (
            DataObject.PROP_NAME,
            String.class,
            getMessage (DataObject.class, "PROP_name"),
            getMessage (DataObject.class, "HINT_name")
            ) {
        public String getValue () {
            return JavaNode.this.getName();
        }
        @Override
        public Object getValue(String key) {
            if ("suppressCustomEditor".equals (key)) { //NOI18N
                return Boolean.TRUE;
            } else {
                return super.getValue (key);
            }
        }
        public void setValue(String val) throws IllegalAccessException,
                IllegalArgumentException, InvocationTargetException {
            if (!canWrite())
                throw new IllegalAccessException();
            JavaNode.this.setName(val);
        }
        @Override
        public boolean canWrite() {
            return JavaNode.this.canRename();
        }
        
    };
    
    return p;
}
 
Example 6
Source File: PersistenceManagerBeanDataNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void createProperties(Object bean, java.beans.BeanInfo info) {
        BeanNode.Descriptor d = BeanNode.computeProperties(bean, info);
        Node.Property p = new PropertySupport.ReadWrite(
        "extraParams", PersistenceManagerBeanDataNode.class,  //NOI18N
        NbBundle.getMessage(PersistenceManagerBeanDataNode.class,"LBL_ExtParams"), //NOI18N
        NbBundle.getMessage(PersistenceManagerBeanDataNode.class,"DSC_ExtParams") //NOI18N
        ) {
            public Object getValue() {
                return resource.getExtraParams();
            }
            
            public void setValue(Object val){
                if (val instanceof Object[])
                    resource.setExtraParams((Object[])val);
            }
            
            public PropertyEditor getPropertyEditor(){
                return new NameValuePairsPropertyEditor(resource.getExtraParams());
            }
        };
        
        Sheet sets = getSheet();
        Sheet.Set pset = Sheet.createPropertiesSet();
        pset.put(d.property);
        pset.put(p);
//        pset.setValue("helpID", "AS_Res_PMF_Props"); //NOI18N
        sets.put(pset);
    }
 
Example 7
Source File: DataSourceBeanDataNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void createProperties(Object bean, java.beans.BeanInfo info) {
    BeanNode.Descriptor d = BeanNode.computeProperties(bean, info);
    Node.Property p = new PropertySupport.ReadWrite(
            "extraParams", DataSourceBeanDataNode.class, //NOI18N
            NbBundle.getMessage(DataSourceBeanDataNode.class,"LBL_ExtParams"), //NOI18N
            NbBundle.getMessage(DataSourceBeanDataNode.class,"DSC_ExtParams") //NOI18N
            ) {
        public Object getValue() {
            return resource.getExtraParams();
        }
        
        public void setValue(Object val){
            if (val instanceof Object[])
                resource.setExtraParams((Object[])val);
        }
        
        public PropertyEditor getPropertyEditor(){
            return new NameValuePairsPropertyEditor(resource.getExtraParams());
        }
    };
    
    Sheet sets = getSheet();
    Sheet.Set pset = Sheet.createPropertiesSet();
    pset.put(d.property);
    pset.put(p);
    //pset.setValue("propertiesHelpID", "AS_Res_DataSource_Props"); //NOI18N
    sets.put(pset);
}
 
Example 8
Source File: JMSBeanDataNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void createProperties(Object bean, java.beans.BeanInfo info) {
        BeanNode.Descriptor d = BeanNode.computeProperties(bean, info);
        Node.Property p = new PropertySupport.ReadWrite(
        "extraParams", JMSBeanDataNode.class, //NOI18N
        NbBundle.getMessage(JMSBeanDataNode.class,"LBL_ExtParams"), //NOI18N
        NbBundle.getMessage(JMSBeanDataNode.class,"DSC_ExtParams") //NOI18N
        ) {
            public Object getValue() {
                return resource.getExtraParams();
            }
            
            public void setValue(Object val){
                if (val instanceof Object[])
                    resource.setExtraParams((Object[])val);
            }
            
            public PropertyEditor getPropertyEditor(){
                return new NameValuePairsPropertyEditor(resource.getExtraParams());
            }
        };
        
        Sheet sets = getSheet();
        Sheet.Set pset = Sheet.createPropertiesSet();
        pset.put(d.property);
        pset.put(p);
//        pset.setValue("helpID", "AS_Res_JMS_Props"); //NOI18N
        sets.put(pset);
    }
 
Example 9
Source File: JavaMailSessionBeanDataNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void createProperties(Object bean, java.beans.BeanInfo info) {
        BeanNode.Descriptor d = BeanNode.computeProperties(bean, info);
        Node.Property p = new PropertySupport.ReadWrite(
        "extraParams", JavaMailSessionBeanDataNode.class, //NOI18N
        NbBundle.getMessage(JavaMailSessionBeanDataNode.class,"LBL_ExtParams"), //NOI18N
        NbBundle.getMessage(JavaMailSessionBeanDataNode.class,"DSC_ExtParams") //NOI18N
        ) {
            public Object getValue() {
                return resource.getExtraParams();
            }
            
            public void setValue(Object val){
                if (val instanceof Object[])
                    resource.setExtraParams((Object[])val);
            }
            
            public PropertyEditor getPropertyEditor(){
                return new NameValuePairsPropertyEditor(resource.getExtraParams());
            }
        };
        
        Sheet sets = getSheet();
        Sheet.Set pset = Sheet.createPropertiesSet();
        pset.put(d.property);
        pset.put(p);
//        pset.setValue("helpID", "AS_Res_Mail_Props"); //NOI18N
        sets.put(pset);
    }
 
Example 10
Source File: ConnPoolBeanDataNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void createProperties(Object bean, java.beans.BeanInfo info) {
        BeanNode.Descriptor d = BeanNode.computeProperties(bean, info);
        Node.Property p = new PropertySupport.ReadWrite(
        "extraParams", ConnPoolBeanDataNode.class, //NOI18N
        NbBundle.getMessage(ConnPoolBeanDataNode.class,"LBL_ExtParams"), //NOI18N
        NbBundle.getMessage(ConnPoolBeanDataNode.class,"DSC_ExtParams") //NOI18N
        ) {
            public Object getValue() {
                return resource.getExtraParams();
            }
            
            public void setValue(Object val){
                if (val instanceof Object[])
                    resource.setExtraParams((Object[])val);
            }
            
            public PropertyEditor getPropertyEditor(){
                return new NameValuePairsPropertyEditor(resource.getExtraParams());
            }
        };
        
        Sheet sets = getSheet();
        Sheet.Set pset = Sheet.createPropertiesSet();
        pset.put(d.property);
        pset.put(p);
//        pset.setValue("helpID", "AS_Res_ConnectionPool_Props"); //NOI18N
        sets.put(pset);
     }
 
Example 11
Source File: EjbJarMultiViewDataNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected Sheet createSheet() {
    Sheet s = super.createSheet();
    Sheet.Set ss = new Sheet.Set();
    ss.setName(DEPLOYMENT);
    ss.setDisplayName(NbBundle.getMessage(EjbJarMultiViewDataNode.class, "PROP_deploymentSet"));
    ss.setShortDescription(NbBundle.getMessage(EjbJarMultiViewDataNode.class, "HINT_deploymentSet"));
    ss.setValue("helpID", "TBD---Ludo ejbjar node");   // NOI18N
    
    Property p = new PropertySupport.ReadWrite(PROPERTY_DOCUMENT_TYPE,
            String.class,
            NbBundle.getBundle(EjbJarMultiViewDataNode.class).getString("PROP_documentDTD"),
            NbBundle.getBundle(EjbJarMultiViewDataNode.class).getString("HINT_documentDTD")) {
        public Object getValue() {
            java.math.BigDecimal version = dataObject.getEjbJar().getVersion();
            return (version == null ? "" : version.toString());
        }
        
        public void setValue(Object value) {
            String val = (String) value;
            if (EjbJar.VERSION_2_1.equals(val) && !val.equals(dataObject.getEjbJar().getVersion().toString())) {
                dataObject.getEjbJar().setVersion(new java.math.BigDecimal(val));
                dataObject.modelUpdatedFromUI();
            }
        }
    };
    ss.put(p);
    s.put(ss);
    
    return s;
}
 
Example 12
Source File: AntCustomizer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public AntCustomizer() {
    initComponents();
    bAntHome.addActionListener (this);
    ((DefaultComboBoxModel) cbVerbosity.getModel()).removeAllElements(); // just have prototype for form editor
    cbVerbosity.addItem(NbBundle.getMessage(AntCustomizer.class, "LBL_verbosity_warn"));
    cbVerbosity.addItem(NbBundle.getMessage(AntCustomizer.class, "LBL_verbosity_info"));
    cbVerbosity.addItem(NbBundle.getMessage(AntCustomizer.class, "LBL_verbosity_verbose"));
    cbVerbosity.addItem(NbBundle.getMessage(AntCustomizer.class, "LBL_verbosity_debug"));
    cbSaveFiles.addActionListener (this);
    cbReuseOutput.addActionListener (this);
    cbAlwaysShowOutput.addActionListener (this);
    cbVerbosity.addActionListener (this);
    classpathProperty = new PropertySupport.ReadWrite<NbClassPath>("classpath", NbClassPath.class, null, null) {
        public NbClassPath getValue() throws IllegalAccessException, InvocationTargetException {
            return new NbClassPath(classpath.toArray(new File[classpath.size()]));
        }
        public void setValue(NbClassPath val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
            String cp = val.getClassPath();
            if (cp.startsWith("\"") && cp.endsWith("\"")) {
                // *@%!* NbClassPath.getClassPath semantics.
                cp = cp.substring(1, cp.length() - 1);
            }
            classpath = new ArrayList<File>();
            for (String f : cp.split(Pattern.quote(File.pathSeparator))) {
                if(!f.trim().isEmpty()) {
                    classpath.add(new File(f));
                }
            }
            fireChanged();
        }
    };
    propertiesProperty = new PropertySupport.ReadWrite<Properties>("properties", Properties.class, null, null) {
        public Properties getValue() throws IllegalAccessException, InvocationTargetException {
            Properties p = new Properties();
            p.putAll(properties);
            return p;
        }
        public void setValue(Properties val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
            properties = NbCollections.checkedMapByCopy(val, String.class, String.class, true);
            fireChanged();
        }
    };
    setUpPropertyPanels();
}
 
Example 13
Source File: WildflyManagerNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public Sheet createSheet() {
    Sheet sheet = super.createSheet();
    Sheet.Set properties = sheet.get(Sheet.PROPERTIES);
    if (properties == null) {
        properties = Sheet.createPropertiesSet();
        sheet.put(properties);
    }
    final InstanceProperties ip = getDeploymentManager().getInstanceProperties();

    Node.Property property = new PropertySupport.ReadWrite(
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_DISPLAY_NAME"), //NOI18N
            String.class,
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_DISPLAY_NAME"), NbBundle.getMessage(WildflyManagerNode.class, "HINT_DISPLAY_NAME")) {
        @Override
                public Object getValue() {
                    return ip.getProperty(WildflyPluginProperties.PROPERTY_DISPLAY_NAME);
                }

        @Override
                public void setValue(Object val) {
                    ip.setProperty(WildflyPluginProperties.PROPERTY_DISPLAY_NAME, (String) val);
                }
            };

    properties.put(property);

    // servewr name
    property = new PropertySupport.ReadOnly(
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_SERVER_NAME"), //NOI18N
            String.class,
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_SERVER_NAME"), NbBundle.getMessage(WildflyManagerNode.class, "HINT_SERVER_NAME")) {
        @Override
                public Object getValue() {
                    return ip.getProperty(WildflyPluginProperties.PROPERTY_SERVER);
                }
            };
    properties.put(property);

    //server location
    property = new PropertySupport.ReadOnly(
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_SERVER_PATH"), //NOI18N
            String.class,
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_SERVER_PATH"), NbBundle.getMessage(WildflyManagerNode.class, "HINT_SERVER_PATH")) {
        @Override
                public Object getValue() {
                    return ip.getProperty(WildflyPluginProperties.PROPERTY_SERVER_DIR);
                }
            };
    properties.put(property);

    //host
    property = new PropertySupport.ReadOnly(
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_HOST"), //NOI18N
            String.class,
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_HOST"), NbBundle.getMessage(WildflyManagerNode.class, "HINT_HOST")) {
        @Override
                public Object getValue() {
                    return ip.getProperty(WildflyPluginProperties.PROPERTY_HOST);
                }
            };
    properties.put(property);

    //port
    property = new PropertySupport.ReadOnly(
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_PORT"), //NOI18N
            Integer.TYPE,
            NbBundle.getMessage(WildflyManagerNode.class, "LBL_PORT"), NbBundle.getMessage(WildflyManagerNode.class, "HINT_PORT")) {
        @Override
                public Object getValue() {
                    return new Integer(ip.getProperty(WildflyPluginProperties.PROPERTY_PORT));
                }
            };
    properties.put(property);

    return sheet;
}
 
Example 14
Source File: KeyNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Initializes sheet of properties. Overrides superclass method.
 * @return default sheet to use
 */
protected Sheet createSheet () {
    Sheet sheet = Sheet.createDefault ();
    Sheet.Set sheetSet = sheet.get (Sheet.PROPERTIES);

    Node.Property property;

    // Key property.
    property = new PropertySupport.ReadWrite<String>(
            PROP_NAME,
            String.class,
            NbBundle.getBundle(KeyNode.class).getString("PROP_item_key"),
            NbBundle.getBundle(KeyNode.class).getString("HINT_item_key")
        ) {
            public String getValue() {
                return itemKey;
            }

            public void setValue(String val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
                KeyNode.this.setName(val);
            }
        };
    property.setName(Element.ItemElem.PROP_ITEM_KEY);
    sheetSet.put (property);

    // Value property
    property = new PropertySupport.ReadWrite<String>(
            Element.ItemElem.PROP_ITEM_VALUE,
            String.class,
            NbBundle.getBundle(KeyNode.class).getString("PROP_item_value"),
            NbBundle.getBundle(KeyNode.class).getString("HINT_item_value")
        ) {
            public String getValue() {
                return getItem().getValue();
            }

            public void setValue(String val) throws IllegalAccessException,
                IllegalArgumentException, InvocationTargetException {
                getItem().setValue(val);
            }
        };
    property.setName(Element.ItemElem.PROP_ITEM_VALUE);
    sheetSet.put (property);

    // Comment property
    property = new PropertySupport.ReadWrite<String>(
            Element.ItemElem.PROP_ITEM_COMMENT,
            String.class,
            NbBundle.getBundle(KeyNode.class).getString("PROP_item_comment"),
            NbBundle.getBundle(KeyNode.class).getString("HINT_item_comment")
        ) {
            public String getValue() {
                return getItem().getComment();
            }

            public void setValue(String val) throws IllegalAccessException,
                IllegalArgumentException, InvocationTargetException {
                getItem().setComment(val);
            }
        };
    property.setName(Element.ItemElem.PROP_ITEM_COMMENT);
    sheetSet.put (property);

    return sheet;
}