org.openide.nodes.BeanNode Java Examples

The following examples show how to use org.openide.nodes.BeanNode. 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: IndexedPropertyEditorTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testGetJavaInitializationString() throws Exception {
    ExPropertyEditor editor = new IndexedPropertyEditor();
    PropertyEnv env = new PropertyEnv();
    Node.Property<?> prop = null;
    Bean bean = new Bean();
    bean.setStuff(new Stuff[] {new Stuff(1), new Stuff(2)});
    for (Node.PropertySet s : new BeanNode<Bean>(bean).getPropertySets()) {
        for (Node.Property<?> p : s.getProperties()) {
            if (p.getName().equals("stuff")) {
                prop = p;
                break;
            }
        }
    }
    assertNotNull(prop);
    assertTrue(prop instanceof Node.IndexedProperty<?,?>);
    editor.setValue(bean.getStuff());
    env.setFeatureDescriptor(prop);
    editor.attachEnv(env);
    String n = Stuff.class.getCanonicalName();
    assertEquals("new" + n + "[]{new" + n + "(1),new" + n + "(2)}", editor.getJavaInitializationString().replaceAll("\\s+", ""));
}
 
Example #2
Source File: SerialDataNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** try to register PropertyChangeListener to instance to fire its changes.
 * @param bean     */
private void initPList (Object bean, BeanInfo bInfo, BeanNode.Descriptor descr) {
    EventSetDescriptor[] descs  = bInfo.getEventSetDescriptors();
    try {
        Method setter = null;
        for (int i = 0; descs != null && i < descs.length; i++) {
            setter = descs[i].getAddListenerMethod();
            if (setter != null && setter.getName().equals("addPropertyChangeListener")) { // NOI18N                    
                propertyChangeListener = new PropL(createSupportedPropertyNames(descr));
                setter.invoke(bean, new Object[] {WeakListeners.propertyChange(propertyChangeListener, bean)});
                setSettingsInstance(bean);
            }
        }
    } catch (Exception ex) {
        // ignore
    }
}
 
Example #3
Source File: ProxyNodeTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testClashInNameProperties() throws Exception {
    NBean nb = new NBean();
    BeanNode n = new BeanNode(nb);
    ProxyNode pn = new ProxyNode(n);
    
    Property<?> prop = findProperty(pn, "name");
    assertEquals("Name", "name", prop.getName());
    assertEquals("Value", 1, prop.getValue());
    
    nb.setName(10);
    
    assertEquals("Value", 10, prop.getValue());
}
 
Example #4
Source File: SerialDataNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Sheet.Set createExpertSet(BeanNode.Descriptor descr, BeanDescriptor bd) {
    Sheet.Set p = Sheet.createExpertSet();
    convertProps (p, descr.expert, this);
    if (bd != null) {
        Object helpID = bd.getValue("expertHelpID"); // NOI18N
        if (helpID != null && helpID instanceof String) {
            p.setValue("helpID", helpID); // NOI18N
        }
    }
    return p;
}
 
Example #5
Source File: SerialDataNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Sheet.Set createPropertiesSet(BeanNode.Descriptor descr, BeanDescriptor bd) {
    Sheet.Set props;
    props = Sheet.createPropertiesSet();
    if (descr.property != null) {
        convertProps (props, descr.property, this);
    }
    if (bd != null) {
        // #29550: help from the beaninfo on property tabs
        Object helpID = bd.getValue("propertiesHelpID"); // NOI18N
        if (helpID != null && helpID instanceof String) {
            props.setValue("helpID", helpID); // NOI18N
        }
    }
    return props;
}
 
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: DerbyOptions.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static BeanNode createViewNode() throws java.beans.IntrospectionException {
    return new BeanNode<DerbyOptions>(DerbyOptions.getDefault());
}
 
Example #12
Source File: MainFrame.java    From procamcalib with GNU General Public License v2.0 4 votes vote down vote up
void buildSettingsView() throws IntrospectionException, PropertyVetoException {
        HashMap<String, Class<? extends PropertyEditor>> editors =
                new HashMap<String, Class<? extends PropertyEditor>>();
        editors.put("frameGrabber", FrameGrabber.PropertyEditor.class);

        // hide settings we do not need from the user...
        editors.put("triggerMode", null);
        editors.put("imageMode", null);
        editors.put("timeout", null);
        editors.put("deviceFilename", null);
        editors.put("useOpenGL", null);
//        editors.put("nominalDistance", null);

        if (cameraSettings == null) {
            cameraSettings = new CameraSettings();
            cameraSettings.setFrameGrabber(FrameGrabber.getDefault());
            cameraSettings.setQuantity(1);
        }
        cameraSettings.addPropertyChangeListener(this);
        BeanNode cameraNode = new CleanBeanNode<CameraSettings>
                (cameraSettings, editors, "Cameras");

        if (projectorSettings == null) {
            projectorSettings = new ProjectorSettings();
            projectorSettings.setQuantity(1);
        }
        projectorSettings.addPropertyChangeListener(this);
        BeanNode projectorNode = new CleanBeanNode<ProjectorSettings>
                (projectorSettings, editors, "Projectors");

        if (markerSettings == null) {
            markerSettings = new Marker.ArraySettings();
        }
        markerSettings.addPropertyChangeListener(this);
        BeanNode markerNode = new CleanBeanNode<Marker.ArraySettings>
                (markerSettings, null, "MarkerPatterns");

        if (markerDetectorSettings == null) {
            markerDetectorSettings = new MarkerDetector.Settings();
        }
        BeanNode detectorNode = new CleanBeanNode<MarkerDetector.Settings>
                (markerDetectorSettings, null, "MarkerDetector");

        if (geometricCalibratorSettings == null) {
            geometricCalibratorSettings = new CalibrationWorker.GeometricSettings();
        }
        BeanNode geometricCalibratorNode = new CleanBeanNode<CalibrationWorker.GeometricSettings>
                (geometricCalibratorSettings, null, "GeometricCalibrator");

        if (colorCalibratorSettings == null) {
            colorCalibratorSettings = new CalibrationWorker.ColorSettings();
        }
        colorCalibratorSettings.addPropertyChangeListener(this);
        BeanNode colorCalibratorNode = new CleanBeanNode<CalibrationWorker.ColorSettings>
                (colorCalibratorSettings, null, "ColorCalibrator");

        Children children = new Children.Array();
        children.add(new Node[] { cameraNode, projectorNode, markerNode, detectorNode, 
                geometricCalibratorNode, colorCalibratorNode });

        Node root = new AbstractNode(children);
        root.setName("Settings");
        manager.setRootContext(root);
    }
 
Example #13
Source File: MainFrame.java    From procamtracker with GNU General Public License v2.0 4 votes vote down vote up
void buildSettingsView() throws IntrospectionException, PropertyVetoException {
    HashMap<String, Class<? extends PropertyEditor>> editors =
            new HashMap<String, Class<? extends PropertyEditor>>();
    editors.put("frameGrabber", FrameGrabber.PropertyEditor.class);

    // hide settings we do not need from the user...
    editors.put("triggerMode", null);
    editors.put("imageMode", null);
    editors.put("timeout", null);
    editors.put("parametersFilename", null);
    editors.put("deviceFilename", null);
    editors.put("useOpenGL", null);
    editors.put("objectImage", null);
    editors.put("gammaTgamma", null);
    editors.put("outputVideoFilename", null);
    editors.put("textureImageFilename", null);
    editors.put("projectorImageFilename", null);
    editors.put("projectorVideoFilename", null);
    editors.put("initialRoiPts", null);
    editors.put("initialPosition", null);

    if (cameraSettings == null) {
        cameraSettings = new CameraDevice.CalibratedSettings();
        cameraSettings.setFrameGrabber(FrameGrabber.getDefault());
    }
    cameraSettings.addPropertyChangeListener(this);
    BeanNode cameraNode = new CleanBeanNode<CameraDevice.Settings>
            (cameraSettings, editors, "Camera");

    if (projectorSettings == null) {
        projectorSettings = new ProjectorDevice.CalibratedSettings();
    }
    projectorSettings.addPropertyChangeListener(this);
    BeanNode projectorNode = new CleanBeanNode<ProjectorDevice.Settings>
            (projectorSettings, editors, "Projector");

    if (objectFinderSettings == null) {
        objectFinderSettings = new ObjectFinder.Settings();
    }
    objectFinderSettings.addPropertyChangeListener(this);
    BeanNode objectFinderNode = new CleanBeanNode<ObjectFinder.Settings>
            (objectFinderSettings, editors, "ObjectFinder");

    if (markerDetectorSettings == null) {
        markerDetectorSettings = new MarkerDetector.Settings();
    }
    markerDetectorSettings.addPropertyChangeListener(this);
    BeanNode markerDetectorNode = new CleanBeanNode<MarkerDetector.Settings>
            (markerDetectorSettings, editors, "MarkerDetector");

    if (alignerSettings == null) {
        alignerSettings = new GNImageAligner.Settings();
    }
    BeanNode alignerNode = new CleanBeanNode<GNImageAligner.Settings>
            (alignerSettings, editors, "GNImageAligner");

    if (handMouseSettings == null) {
        handMouseSettings = new HandMouse.Settings();
    }
    BeanNode handMouseNode = new CleanBeanNode<HandMouse.Settings>
            (handMouseSettings, editors, "HandMouse");

    if (virtualBallSettings == null) {
        virtualBallSettings = new VirtualBall.Settings();
    }
    BeanNode virtualBallNode = new CleanBeanNode<VirtualBall.Settings>
            (virtualBallSettings, editors, "VirtualBall");

    if (realityAugmentorSettings == null) {
        realityAugmentorSettings = new RealityAugmentor.Settings();
        RealityAugmentor.ObjectSettings os = new RealityAugmentor.ObjectSettings();
        RealityAugmentor.VirtualSettings vs = new RealityAugmentor.VirtualSettings();
        os.add(vs);
        realityAugmentorSettings.add(os);
    }
    BeanNode realityAugmentorNode = new CleanBeanNode<RealityAugmentor.Settings>
            (realityAugmentorSettings, editors, "RealityAugmentor");

    if (trackingSettings == null) {
        trackingSettings = new TrackingWorker.Settings();
    }
    BeanNode trackingNode = new CleanBeanNode<TrackingWorker.Settings>
            (trackingSettings, editors, "TrackingWorker");

    Children children = new Children.Array();
    children.add(new Node[] { cameraNode, projectorNode, objectFinderNode,
            markerDetectorNode, alignerNode, handMouseNode, virtualBallNode,
            realityAugmentorNode, trackingNode });

    Node root = new AbstractNode(children);
    root.setName("Settings");
    manager.setRootContext(root);
}