Java Code Examples for org.openide.nodes.Node#setName()

The following examples show how to use org.openide.nodes.Node#setName() . 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: RenameGroupAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void performAction(Node[] nodes) {
    if (nodes != null && nodes.length == 1) {
        SaasGroup group = nodes[0].getLookup().lookup(SaasGroup.class);
        if (group == null) {
            return;
        }

        Node n = nodes[0];
        NotifyDescriptor.InputLine dlg = new NotifyDescriptor.InputLine(
                NbBundle.getMessage(RenameAction.class, "CTL_RenameLabel"), // NOI18N
                NbBundle.getMessage(RenameAction.class, "CTL_RenameTitle")); // NOI18N
        dlg.setInputText(n.getName());
        if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(dlg))) {
            String name = dlg.getInputText().trim();
            if (group.getParent().getChildGroup(name) != null) {
                String msg = NbBundle.getMessage(RenameGroupAction.class, "MSG_DuplicateGroupName"); // NOI18N
                DialogDisplayer.getDefault().notify(
                        new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE));
                return;
            }
            SaasServicesModel.getInstance().renameGroup(group, name);
            n.setName(name);
        }
    }
}
 
Example 2
Source File: NamedBeanGroupNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Node findChild(String name) {
    Node result = null;
    Node[] list = getNodes();

    if (list.length > 0 && name != null) {
        Node key = new AbstractNode(Children.LEAF);
        key.setName(name);
        int index = Arrays.binarySearch(list, key, this);
        if(index >= 0) {
            result = list[index];
        }
    }
    
    return result;
}
 
Example 3
Source File: PreventNeedlessChangesOfActionMapTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testChangeOfNodeDoesNotFireChangeInActionMap() {
    ActionMap am = (ActionMap)tc.getLookup().lookup(ActionMap.class);
    assertNotNull(am);
    
    Node m1 = new AbstractNode(Children.LEAF);
    m1.setName("old m1");
    Node m2 = new AbstractNode(Children.LEAF);
    m2.setName("new m2");
    
    tc.setActivatedNodes(new Node[] { m1 });
    assertEquals("No change in ActionMap 1", 0, cnt);
    tc.setActivatedNodes(new Node[] { m2 });
    assertEquals("No change in ActionMap 2", 0, cnt);
    tc.setActivatedNodes(new Node[0]);
    assertEquals("No change in ActionMap 3", 0, cnt);
    tc.setActivatedNodes(null);
    assertEquals("No change in ActionMap 4", 0, cnt);
    
    ActionMap am2 = (ActionMap)tc.getLookup().lookup(ActionMap.class);
    assertEquals("Still the same action map", am, am2);
}
 
Example 4
Source File: DataFolderTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testNameAndRenameWithADot() throws IOException {
    FileObject fo = FileUtil.createMemoryFileSystem().getRoot().createFolder("name-with.dot");
    DataFolder folder = DataFolder.findFolder(fo);
    Node n = folder.getNodeDelegate();
    assertEquals("Full name provided", "name-with.dot", n.getName());
    n.setName("new-name.other");
    assertEquals("New name set", "new-name.other", n.getName());
    assertEquals("New name of dobj too", "new-name.other", folder.getName());
    assertEquals("New name of fo too", "new-name.other", fo.getNameExt());
}
 
Example 5
Source File: NodeFactorySupportTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Test of createCompositeChildren method, of class org.netbeans.spi.project.ui.support.NodeFactorySupport.
 */
public void testCreateCompositeChildren() throws InterruptedException, InvocationTargetException {
    InstanceContent ic = new InstanceContent();
    final Children dels = new TestDelegates(new AbstractLookup(ic));
    final Node node1 = new AbstractNode(Children.LEAF);
    final Node node2 = new AbstractNode(Children.LEAF);
    final Node node3 = new AbstractNode(Children.LEAF);
    final Node node4 = new AbstractNode(Children.LEAF);
    node1.setName("node1");
    node2.setName("node2");
    node3.setName("node3");
    node4.setName("node4");
    NodeFactory fact1 = new TestNodeFactory(node1);
    NodeFactory fact2 = new TestNodeFactory(node2);
    NodeFactory fact3 = new TestNodeFactory(node3);
    NodeFactory fact4 = new TestNodeFactory(node4);
    List<NodeFactory> col = new ArrayList<NodeFactory>();
    col.add(fact1);
    col.add(fact2);
    ic.set(col, null);

    assertEquals(Arrays.asList(node1, node2), Arrays.asList(dels.getNodes(true)));
    
    col.add(0, fact4);
    col.add(fact3);
    col.remove(fact2);
    ic.set(col, null);
    //#115995, caused by fix for #115128
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            Node[] nds = dels.getNodes();
            assertEquals(nds[0], node4);
            assertEquals(nds[1], node1);
            assertEquals(nds[2], node3);
        }
    });
    
}
 
Example 6
Source File: PageFlowController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void changeToAbstractNode(Page oldNode, String displayName) {
    //1. Make Old Node an abstract node
    Node tmpNode = new AbstractNode(Children.LEAF);
    tmpNode.setName(displayName);
    oldNode.replaceWrappedNode(tmpNode); //Does this take care of pageName2Node?
    view.resetNodeWidget(oldNode, true);
}
 
Example 7
Source File: SerialDataNodeTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testDisplayName() throws Exception {
    String res = "Settings/org-netbeans-modules-settings-convertors-testDisplayName.settings";
    FileObject fo = FileUtil.getConfigFile(res);
    assertNotNull(res, fo);
    assertNull("name", fo.getAttribute("name"));
    
    DataObject dobj = DataObject.find (fo);
    Node n = dobj.getNodeDelegate();
    assertNotNull(n);
    assertEquals("I18N", n.getDisplayName());
    
    // property sets have to be initialized otherwise the change name would be
    // propagated to the node after some delay (~2s)
    Object garbage = n.getPropertySets();
    
    InstanceCookie ic = (InstanceCookie) dobj.getCookie(InstanceCookie.class);
    assertNotNull (dobj + " does not contain instance cookie", ic);
    
    FooSetting foo = (FooSetting) ic.instanceCreate();
    String newName = "newName";
    foo.setName(newName);
    assertEquals(n.toString(), newName, n.getDisplayName());
    
    newName = "newNameViaNode";
    n.setName(newName);
    assertEquals(n.toString(), newName, n.getDisplayName());
    assertEquals(n.toString(), newName, foo.getName());
}
 
Example 8
Source File: ViewUtilTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testRenameNormalNode() {
    Node n = new AbstractNode(Children.LEAF) {
        @Override
        public void setName(String s) {
            assertTrue("In AWT", EventQueue.isDispatchThread());
            super.setName(s);
        }
    };
    
    n.setName("newName");
    assertEquals("newName", n.getName());
}
 
Example 9
Source File: ViewUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static void nodeRename(final Node n, final String newStr) {
    // bugfix #21589 don't update name if there is not any change
    if (n.getName().equals(newStr)) {
        return;
    }
    if (EventQueue.isDispatchThread() && Boolean.TRUE.equals(n.getValue("slowRename"))) { // NOI18N
        RP.post(new Runnable() {
            @Override
            public void run() {
                nodeRename(n, newStr);
            }
        });
        return;
    }
    try {
        n.setName(newStr);
    } catch (IllegalArgumentException exc) {
        boolean needToAnnotate = Exceptions.findLocalizedMessage(exc) == null;

        // annotate new localized message only if there is no localized message yet
        if (needToAnnotate) {
            String msg = NbBundle.getMessage(
                    TreeViewCellEditor.class, "RenameFailed", n.getName(), newStr
                );
            Exceptions.attachLocalizedMessage(exc, msg);
        }

        Exceptions.printStackTrace(exc);
    }
}
 
Example 10
Source File: ListViewTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Creates two nodes. Selects one and tries to remove it
 * and replace with the other one (several times).
 */
public void testNodeAddingAndRemoving() {
    final Children c = new Array();
    Node n = new AbstractNode (c);
    final PListView lv = new PListView();
    final ExplorerPanel p = new ExplorerPanel();
    p.add(lv, BorderLayout.CENTER);
    p.getExplorerManager().setRootContext(n);
    p.open();

    final Node c1 = new AbstractNode(Children.LEAF);
    c1.setDisplayName("First");
    c1.setName("First");
    c.add(new Node[] { c1 });
    Node c2 = new AbstractNode(Children.LEAF);
    c2.setDisplayName("Second");
    c2.setName("Second");
    //Thread.sleep(500);

    for (int i = 0; i < 5; i++) {
        c.remove(new Node[] { c1 });
        c.add(new Node[] { c2 });
        
        // Waiting for until the view is updated.
        // This should not be necessary
        try {
            SwingUtilities.invokeAndWait( new EmptyRunnable() );
        } catch (InterruptedException ie) {
            fail ("Caught InterruptedException:" + ie.getMessage ());
        } catch (InvocationTargetException ite) {
            fail ("Caught InvocationTargetException: " + ite.getMessage ());
        }
        
        try {
            p.getExplorerManager().setSelectedNodes(new Node[] {c2} );
        } catch (PropertyVetoException  pve) {
            fail ("Caught the PropertyVetoException when set selected node " + c2.getName ()+ ".");
        }
        
        c.remove(new Node[] { c2 });
        c.add(new Node[] { c1 });
        
        //Thread.sleep(350);
    }
}
 
Example 11
Source File: ListViewTopComponentTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Creates two nodes. Selects one and tries to remove it
 * and replace with the other one (several times).
 */
public void testNodeAddingAndRemoving() {
    final Children c = new Array();
    Node n = new AbstractNode (c);
    final PListView lv = new PListView();
    final ExplorerPanel p = new ExplorerPanel();
    p.add(lv, BorderLayout.CENTER);
    p.getExplorerManager().setRootContext(n);
    p.open();

    final Node c1 = new AbstractNode(Children.LEAF);
    c1.setDisplayName("First");
    c1.setName("First");
    c.add(new Node[] { c1 });
    Node c2 = new AbstractNode(Children.LEAF);
    c2.setDisplayName("Second");
    c2.setName("Second");
    //Thread.sleep(500);

    for (int i = 0; i < 5; i++) {
        c.remove(new Node[] { c1 });
        c.add(new Node[] { c2 });
        
        // Waiting for until the view is updated.
        // This should not be necessary
        try {
            SwingUtilities.invokeAndWait( new EmptyRunnable() );
        } catch (InterruptedException ie) {
            fail ("Caught InterruptedException:" + ie.getMessage ());
        } catch (InvocationTargetException ite) {
            fail ("Caught InvocationTargetException: " + ite.getMessage ());
        }
        
        try {
            p.getExplorerManager().setSelectedNodes(new Node[] {c2} );
        } catch (PropertyVetoException  pve) {
            fail ("Caught the PropertyVetoException when set selected node " + c2.getName ()+ ".");
        }
        
        c.remove(new Node[] { c2 });
        c.add(new Node[] { c1 });
        
        //Thread.sleep(350);
    }
}
 
Example 12
Source File: PackageViewTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@RandomlyFails
   public void testRename() throws Exception {
       assertNull( "source folder should not exist yet", root.getFileObject( "src" ) );
       
       
// Create children
       SourceGroup group = new SimpleSourceGroup( FileUtil.createFolder( root, "src" ) );
       Children ch = PackageView.createPackageView( group ).getChildren();
       
       // Create folder
FileUtil.createFolder( root, "src/a" );
       assertNodes( ch, 
                    new String[] { "a", },
                    new int[] { 0, },
                    true );
       
       Node n = ch.findChild( "a" );                     
       n.setName( "b" );        
       assertNodes( ch, 
                    new String[] { "b", },
                    new int[] { 0, } );
       
       FileUtil.createFolder( root, "src/b/c" );
       assertNodes( ch, 
                    new String[] { "b.c", },
                    new int[] { 0, } );
       
       n = ch.findChild( "b.c" );                     
       n.setName( "b.d" );        
       assertNodes( ch, 
                    new String[] { "b.d", },
                    new int[] { 0, } );
       
       n = ch.findChild( "b.d" );                     
       n.setName( "a.d" );
       assertNodes( ch, 
                    new String[] { "a.d", },
                    new int[] { 0, } );
       
       FileUtil.createFolder( root, "src/a/e" );
       assertNodes( ch, 
                    new String[] { "a.d", "a.e" },
                    new int[] { 0, 0 } );
       
       n = ch.findChild( "a.e" );                     
       n.setName( "a.f" );
       assertNodes( ch, 
                    new String[] { "a.d", "a.f" },
                    new int[] { 0, 0 } );
       
       
       n = ch.findChild( "a.d" );                     
       n.setName( "c.d" );
       assertNodes( ch, 
                    new String[] { "a.f", "c.d"},
                    new int[] { 0, 0 } );
       
       n = ch.findChild( "a.f" );                     
       n.setName( "c.f" );
       assertNodes( ch, 
                    new String[] { "c.d", "c.f" },
                    new int[] { 0, 0 } );
                    
       
       FileUtil.createFolder( root, "src/x/y/z" );
       assertNodes( ch, 
                    new String[] { "c.d", "c.f", "x.y.z" },
                    new int[] { 0, 0, 0 } );
       n = ch.findChild( "x.y.z" );                     
       n.setName( "x.y" );
       assertNodes( ch, 
                    new String[] { "c.d", "c.f", "x.y" },
                    new int[] { 0, 0, 0 } );                                          
       n = ch.findChild( "x.y" );                     
       n.setName( "p.me.tools" );
       assertNodes( ch, 
                    new String[] { "c.d", "c.f", "p.me.tools" },
                    new int[] { 0, 0, 0 } );                     
       n = ch.findChild( "p.me.tools" );
       n.setName( "p.metools" );
       assertNodes( ch, 
                    new String[] { "c.d", "c.f", "p.metools" },
                    new int[] { 0, 0, 0 } );                                          
       n = ch.findChild( "p.metools" );
       n.setName( "p.me.tools" );
       assertNodes( ch, 
                    new String[] { "c.d", "c.f", "p.me.tools" },
                    new int[] { 0, 0, 0 } );                     
       n = ch.findChild( "p.me.tools" );
       n.setName( "p.me.toolsx" );
       assertNodes( ch, 
                    new String[] { "c.d", "c.f", "p.me.toolsx" },
                    new int[] { 0, 0, 0 },
                    true);
       n = ch.findChild( "p.me.toolsx" );
       n.setName( "p.me.tools" );
       assertNodes( ch,
                    new String[] { "c.d", "c.f", "p.me.tools" },
                    new int[] { 0, 0, 0 } );
   }
 
Example 13
Source File: SelectionModeTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Create tree and a selection of nodes for test.
 */
@SuppressWarnings("deprecation")
@Override
protected void setUp () {
    System.setProperty ("org.openide.util.Lookup", Lkp.class.getName());
    
    // create tree:
    // root +--- parent_one +--- one1
    //                      |--- one2
    //      |--- parent_two +--- two1
    //      |--- leaf
    
    final Children parents = new Children.Array ();
    Node root = new AbstractNode (parents);
    root.setName ("root");
    
    tree = new BeanTreeView ();
    //tree = new ContextTreeView ();

    final org.openide.explorer.ExplorerPanel p = new org.openide.explorer.ExplorerPanel();
    p.setName ("SelectionModeTest");
    
    p.add (tree, BorderLayout.CENTER);
    p.getExplorerManager ().setRootContext (root);
    p.open ();

    final Children ones = new Children.Array ();
    Node parent_one = new AbstractNode (ones);
    parent_one.setName ("parent_one");
    final Children twos = new Children.Array ();
    Node parent_two = new AbstractNode (twos);
    parent_two.setName ("parent_two");

    final Node one1 = new AbstractNode (Children.LEAF);
    one1.setName("one1");

    final Node one2 = new AbstractNode (Children.LEAF);
    one2.setName("one2");

    ones.add(new Node[] { one1, one2 });
    
    final Node two1 = new AbstractNode (Children.LEAF);
    two1.setName("two1");

    twos.add (new Node[] { two1 });
    
    parents.add (new Node[] { parent_one, parent_two });
    
    
    // the test selections
    singleSelection = new Node[] {parent_two};
    contiguousSelection = new Node[] {one1, one2};
    discontiguousSelection = new Node[] {one2, two1};
    
    mgr = p.getExplorerManager();
}
 
Example 14
Source File: RenameAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void performAction(final Node[] activatedNodes) {
    if (activatedNodes == null || activatedNodes.length == 0) {
        return;
    }
    Node n = activatedNodes[0]; // we supposed that one node is activated
    
    // for slow FS perform rename out of EDT
    if (EventQueue.isDispatchThread() && Boolean.TRUE.equals(n.getValue("slowRename"))) { // NOI18N
        RP.post(new Runnable() {
            @Override
            public void run() {
                performAction(activatedNodes);
            }
        });
        return;
    }

    NotifyDescriptor.InputLine dlg = new NotifyDescriptor.InputLine(
            NbBundle.getMessage(RenameAction.class, "CTL_RenameLabel"),
            NbBundle.getMessage(RenameAction.class, "CTL_RenameTitle")
        );
    dlg.setInputText(n.getName());

    if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(dlg))) {
        String newname = null;

        try {
            newname = dlg.getInputText();

            if (!newname.equals("")) {
                n.setName(dlg.getInputText()); // NOI18N
            }
        } catch (IllegalArgumentException e) {
            // determine if "printStackTrace"  and  "new annotation" of this exception is needed
            boolean needToAnnotate = Exceptions.findLocalizedMessage(e) == null;

            // annotate new localized message only if there is no localized message yet
            if (needToAnnotate) {
                Exceptions.attachLocalizedMessage(e,
                                                  NbBundle.getMessage(RenameAction.class,
                                                                      "MSG_BadFormat",
                                                                      n.getName(),
                                                                      newname));
            }

            Exceptions.printStackTrace(e);
        }
    }
}
 
Example 15
Source File: ContextTreeViewTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testLeafNodeReallyNotDisplayed() throws Throwable {
    final AbstractNode root = new AbstractNode(new Children.Array());
    root.setName("test root");
    
    
    
    root.getChildren().add(new Node[] {
        createLeaf("kuk"),
        createLeaf("huk"),
    });
    
    class AWTTst implements Runnable {
        public void run() {
            Panel p = new Panel();
            p.getExplorerManager().setRootContext(root);

            ContextTreeView ctv = new ContextTreeView();
            p.add(BorderLayout.CENTER, ctv);

            JFrame f = new JFrame();
            f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
            f.getContentPane().add(BorderLayout.CENTER, p);
            f.setVisible(true);

            final JTree tree = ctv.tree;
    
            // wait a while till the frame is realized and ctv.addNotify called
            Object r = tree.getModel().getRoot();
            assertEquals("There is root", Visualizer.findVisualizer(root), r);
            
            int cnt = tree.getModel().getChildCount(r);
            if (cnt != 0) {
                fail("Should be zero " + cnt + " but there was:  " +
                        tree.getModel().getChild(r, 0) + " and " +
                        tree.getModel().getChild(r, 1)
                        );
            }
            assertEquals("No children as they are leaves", 0, cnt);

            Node n = Visualizer.findNode(r);
            n.setName("Try Rename!");
        }
    }
    AWTTst awt = new AWTTst();
    try {
        SwingUtilities.invokeAndWait(awt);
    } catch (InvocationTargetException ex) {
        throw ex.getTargetException();
    }
}
 
Example 16
Source File: NavigationTreeViewTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testStructureFullOfFormFiles() throws Exception {
    if ((
        Utilities.getOperatingSystem() & 
        (Utilities.OS_SOLARIS | Utilities.OS_SUNOS)
    ) != 0) {
        LOG.log(Level.CONFIG, "Giving up, this test fails too randomly on Solaris");
        return;
    }
    
    Children ch = new Children.Array();
    Node root = new AbstractNode(ch);
    root.setName(getName());

    ch.add(nodeWith("A", "-A", "-B", "B"));
    ch.add(nodeWith("X", "Y", "Z"));

    final Node first = ch.getNodes()[0];

    LOG.log(Level.INFO, "Nodes are ready: {0}", root);
    final ExplorerManager em = testWindow.getExplorerManager();
    em.setRootContext(root);
    LOG.info("setRootContext done");
    em.setSelectedNodes(new Node[] { first });
    LOG.log(Level.INFO, "setSelectedNodes to {0}", first);
    LOG.log(Level.INFO, "Verify setSelectedNodes: {0}", Arrays.asList(em.getSelectedNodes()));

    EventQueue.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            TreePath path = treeView.tree.getSelectionPath();
            LOG.log(Level.INFO, "getSelectionPath {0}", path);
            LOG.log(Level.INFO, "getSelectedNodes {0}", Arrays.toString(em.getSelectedNodes()));
            assertNotNull("Something is selected", path);
            Node node = Visualizer.findNode(path.getLastPathComponent());
            assertEquals("It is the first node", first, node);
        }
    });
    
    sendAction("expand");
    sendAction("selectNext");

    assertEquals("Explored context is N0", first, em.getExploredContext());
    assertEquals("Selected node is A", 1, em.getSelectedNodes().length);
    assertEquals("Selected node is A", "A", em.getSelectedNodes()[0].getName());

    sendAction(enter);

    Keys keys = (Keys)first.getChildren();
    assertEquals("One invocation", 1, keys.actionPerformed);
    assertFalse("No write access", keys.writeAccess);
    assertFalse("No read access", keys.readAccess);
}
 
Example 17
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 18
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);
}