Package gov.nasa.arc.mct.gui

Examples of gov.nasa.arc.mct.gui.MCTMutableTreeNode


            if (newComponentId != null && directoryAreaView instanceof MCTDirectoryArea) {
                MCTDirectoryArea directoryArea = MCTDirectoryArea.class.cast(directoryAreaView);
                JTree activeTree = directoryArea.getActiveTree();

                // Identify the currently selected node in the directory area.
                MCTMutableTreeNode initiallySelectedNode = directoryArea.getSelectedNode();   

                if (initiallySelectedNode == null) {
                    // set the root of the tree as the initially selected node.
                    initiallySelectedNode = (MCTMutableTreeNode) activeTree.getModel().getRoot();
                }
                assert initiallySelectedNode!=null : "Selected node must not be null by this point";

                // Check to see if children have been loaded. If not fire are tree expansion event to force them to be loaded.
                if (initiallySelectedNode.isProxy()) {
                    // Force children to be loaded.
                    DefaultTreeModel treeModel = (DefaultTreeModel) activeTree.getModel();
                    TreePath path = new TreePath(treeModel.getPathToRoot(initiallySelectedNode));

                    if (path!=null) {
                        View initiallySelectedManifestation = directoryArea.getSelectedManifestations().iterator().next()
                        initiallySelectedManifestation.getViewListener().actionPerformed(new TreeExpansionEvent(activeTree, path));
                    }

                }
               
                // Find the child that corresponds to our new component.
                for(int i=0; i< initiallySelectedNode.getChildCount(); i++) {
                    MCTMutableTreeNode childNode = (MCTMutableTreeNode) initiallySelectedNode.getChildAt(i);
                    if(childNode.getUserObject() instanceof View) {
                        View man = (View) childNode.getUserObject();
                        if (man.getManifestedComponent().getId().equalsIgnoreCase(newComponentId)) {
                            // Found the child that corresponds to our new component. Set it as selected.
                            directoryArea.setSelectedNode(childNode);
                            PropertyChangeEvent pce = new PropertyChangeEvent(man.getManifestedComponent());
                            pce.setProperty(PropertyChangeEvent.DISPLAY_NAME, PropertyChangeEvent.DISPLAY_NAME);
View Full Code Here


        if (!(activeHousing.getDirectoryArea() instanceof MCTDirectoryArea)) {
            return false;
        }
       
        MCTDirectoryArea directory = MCTDirectoryArea.class.cast(activeHousing.getDirectoryArea());
        MCTMutableTreeNode firstSelectedNode = directory.getSelectedDirectoryNode();
       
        if (firstSelectedNode == null)
            return false;
       
        JTree tree = firstSelectedNode.getParentTree();
        selectedTreePaths = tree.getSelectionPaths();
        return selectedTreePaths != null && selectedTreePaths.length > 0;
    }
View Full Code Here

    @Override
    public void actionPerformed(ActionEvent e) {
        Map<String, AbstractComponent> toDelete = new HashMap<String, AbstractComponent>();
        Map<String, AbstractComponent> toRemove = new HashMap<String, AbstractComponent>();
        for (TreePath path : selectedTreePaths) {
            MCTMutableTreeNode selectedNode = (MCTMutableTreeNode) path.getLastPathComponent();           
            AbstractComponent selectedComponent = ((View) selectedNode.getUserObject()).getManifestedComponent();
            categorizeDescendants(selectedComponent, toDelete, toRemove);
        }
        Set<AbstractComponent> cannotRemove = findNonRemovableComponents(toDelete, toRemove);
        handleWarnings(toDelete.values(), toRemove.values(), cannotRemove);
    }
View Full Code Here

        warning.add(scrollPane2);
        return warning;
    }
   
    private boolean isRemovable(TreePath path) {
        MCTMutableTreeNode lastPathComponent = (MCTMutableTreeNode) path.getLastPathComponent();
        AbstractComponent selectedComponent = View.class.cast(lastPathComponent.getUserObject()).getManifestedComponent();

        MCTMutableTreeNode parentNode = (MCTMutableTreeNode) lastPathComponent.getParent();
        if (parentNode == null)
            return false;

        AbstractComponent parentComponent = ((View) parentNode.getUserObject()).getManifestedComponent();       
        if (!selectedComponent.canBeDeleted()) {
            return false;
        }
       
       
View Full Code Here

            timer.startInterval();
           
            JTree tree = (JTree) event.getSource();
            final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel();

            final MCTMutableTreeNode selectedNode = node;

            AbstractComponent component = getManifestedComponent();

            for (AbstractComponent childComponent : component.getComponents()) {
                Set<ViewInfo> nodeViews = childComponent.getViewInfos(ViewType.NODE);
                if (!nodeViews.isEmpty()) {
                    ViewInfo nextViewInfo = nodeViews.iterator().next();
                   
                    // Children are only allowed if the component is not a leaf or the component is another users drop box
                    boolean allowsChildren =!childComponent.isLeaf();
                   
                    View childNodeView = nextViewInfo.createView(childComponent);
                    MCTMutableTreeNode childNode = new MCTMutableTreeNode(childNodeView, tree, allowsChildren);

                    if (allowsChildren){
                        MCTMutableTreeNode grandChildNode = new MCTMutableTreeNode(View.NULL_VIEW_MANIFESTATION, tree);
                        childNode.add(grandChildNode);
                        childNode.setProxy(true);
                    }
                    selectedNode.add(childNode);
                    childNodeView.addPropertyChangeListener(VIEW_STALE_PROPERTY, objectStaleListener);
View Full Code Here

        };

        when(mockComponent.getDisplayName()).thenReturn("XXX");
        when(mockComponent.getExtendedDisplayName()).thenReturn("XXX");
        // Set up JTree for updateMonitoredGUI() calls
        rootNode = new MCTMutableTreeNode(new View() {
            private static final long serialVersionUID = 3318467817844246495L;
           
        });
        model = new DefaultTreeModel(rootNode);
        tree = new JTree(model);
View Full Code Here

        Assert.assertNotNull(nodeViewManifestation);
    }

    @Test
    public void testAddMonitoredGUI() {
        MCTMutableTreeNode treeNode = new MCTMutableTreeNode();
        treeNode.setAllowsChildren(false);
        nodeViewManifestation.addMonitoredGUI(treeNode);
        MCTMutableTreeNode retrievedNode = ((NodeViewManifestation) nodeViewManifestation).getMCTMutableTreeNode();
        Assert.assertFalse(retrievedNode.getAllowsChildren());

        nodeViewManifestation.addMonitoredGUI(Mockito.mock(MCTMutableTreeNode.class));
        Assert.assertNotNull(((NodeViewManifestation) nodeViewManifestation).getMCTMutableTreeNode());
    }
View Full Code Here

        Mockito.when(comp1.getComponentId()).thenReturn("COMP1_ID");
        Mockito.when(comp2.getComponentId()).thenReturn("COMP2_ID");
        Mockito.when(comp3.getComponentId()).thenReturn("COMP3_ID");
      Mockito.when(mockComponent.getComponents()).thenReturn(Arrays.asList(comp1, comp2, comp3));
        MCTMutableTreeNode treeNode = new MCTMutableTreeNode();
        treeNode.setParentTree(new JTree());
       
        MCTMutableTreeNode node1 = new MCTMutableTreeNode(view1, false);
        MCTMutableTreeNode node2 = new MCTMutableTreeNode(view2, false);
        MCTMutableTreeNode node3 = new MCTMutableTreeNode(view3, false);
      treeNode.add(node1);
      treeNode.add(node2);
      treeNode.add(node3);
     
      nodeViewManifestation.addMonitoredGUI(treeNode);     
View Full Code Here

        JLabel label = (JLabel) field.get(nodeViewManifestation);// get label field of View under test
        String fixedName = "outdatedView";
        label.setText(fixedName);// outdate the label of the view under test
        Assert.assertFalse(label.getText().equals(mockComponent.getExtendedDisplayName()));
      
        MCTMutableTreeNode mockTreeNode = Mockito.mock(MCTMutableTreeNode.class);
        JTree mockTree = Mockito.mock(JTree.class);
        DefaultTreeModel mockModel = Mockito.mock(DefaultTreeModel.class);
       
        Mockito.when(mockTreeNode.getParentTree()).thenReturn(mockTree);
        Mockito.when(mockTree.getModel()).thenReturn(mockModel);
        Mockito.when(mockComponent.getComponents()).thenReturn(Collections.<AbstractComponent>emptyList());
        PlatformAccess access = new PlatformAccess();
        access.setPlatform(new MockPlatform());
       
View Full Code Here

        PropertyChangeEvent event = new PropertyChangeEvent(mockComponent);
        String fixedString = "YYY";
        event.setProperty(PropertyChangeEvent.DISPLAY_NAME, fixedString);
        Mockito.when(mockComponent.getExtendedDisplayName()).thenReturn(fixedString);

        MCTMutableTreeNode mockTreeNode = Mockito.mock(MCTMutableTreeNode.class);
        JTree mockTree = Mockito.mock(JTree.class);
        Mockito.when(mockTreeNode.getParentTree()).thenReturn(mockTree);
        DefaultTreeModel mockModel = Mockito.mock(DefaultTreeModel.class);
        Mockito.when(mockTree.getModel()).thenReturn(mockModel);
        nodeViewManifestation.addMonitoredGUI(mockTreeNode);
        nodeViewManifestation.updateMonitoredGUI(event);
        Assert.assertTrue(label.getText().equals(fixedString));
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.gui.MCTMutableTreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.