Package gov.nasa.arc.mct.gui

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


       
        // Setup selected nodes, including a parent
        int nodes = Math.max(canCompose.length, canDelete.length);
        selectedTreePaths = new TreePath[nodes];
        AbstractComponent mockParent = mockComponent(canDeleteParent, canComposeParent);
        MCTMutableTreeNode mockParentNode = Mockito.mock(MCTMutableTreeNode.class);
        View mockParentView = mockView(mockParent, ViewType.NODE);
        Mockito.when(mockParentNode.getUserObject()).thenReturn(mockParentView);

        for (int i = 0; i < nodes; i++) {
            AbstractComponent mockChild =
                    mockComponent(canDelete [i % canDelete.length ],
                                  canCompose[i % canCompose.length]);
           
            TreePath mockPath = Mockito.mock(TreePath.class);
            MCTMutableTreeNode mockTreeNode = Mockito.mock(MCTMutableTreeNode.class);
            Mockito.when(mockPath.getLastPathComponent()).thenReturn(mockTreeNode);
            View mockView = mockView(mockChild, ViewType.NODE);           
            Mockito.when(mockTreeNode.getUserObject()).thenReturn(mockView);
            Mockito.when(mockTreeNode.getParent()).thenReturn(mockParentNode);
            selectedTreePaths[i] = mockPath;
        }
       
        // Verify precondition; obey ContextAwareAction life cycle
        Assert.assertTrue(deleteAll.canHandle(mockContext));
View Full Code Here


            .thenReturn(mockWindowing);
   
        // Setup selected nodes, including a parent       
        selectedTreePaths = new TreePath[selected.size()];
        AbstractComponent mockParent = mockComponent(false, true);
        MCTMutableTreeNode mockParentNode = Mockito.mock(MCTMutableTreeNode.class);
        View mockParentView = mockView(mockParent, ViewType.NODE);
        Mockito.when(mockParentNode.getUserObject()).thenReturn(mockParentView);

        int i = 0;
        for (AbstractComponent component : selected) {
            TreePath mockPath = Mockito.mock(TreePath.class);
            MCTMutableTreeNode mockTreeNode = Mockito.mock(MCTMutableTreeNode.class);
            Mockito.when(mockPath.getLastPathComponent()).thenReturn(mockTreeNode);
            View mockView = mockView(component, ViewType.NODE);           
            Mockito.when(mockTreeNode.getUserObject()).thenReturn(mockView);
            Mockito.when(mockTreeNode.getParent()).thenReturn(mockParentNode);
            selectedTreePaths[i++] = mockPath;
        }
       
        // Ensure dialog choice
        Mockito.when(mockWindowing.<Object>showInputDialog(
View Full Code Here

    @Override
    public void actionPerformed(ActionEvent e) {       
        for (TreePath path : selectedTreePaths) {
           
            MCTMutableTreeNode selectedNode = (MCTMutableTreeNode) path.getLastPathComponent();
            MCTMutableTreeNode parentNode = (MCTMutableTreeNode) selectedNode.getParent();
       
            AbstractComponent parentComponent = ((View) parentNode.getUserObject()).getManifestedComponent();
            AbstractComponent selectedComponent = ((View) selectedNode.getUserObject()).getManifestedComponent();
       
            if (selectedComponent == null) {
                OptionBox.showMessageDialog(null, "Unable to create duplicate of this object!", "Error creating duplicate.", OptionBox.ERROR_MESSAGE);
                return;
View Full Code Here

       
        // This action works only for selected items in the directory area.
        if (selectedManifestationsInDirectory == null || selectedManifestationsInDirectory.isEmpty())
            return false;
       
        MCTMutableTreeNode firstSelectedNode = directoryArea.getSelectedDirectoryNode();
        if (firstSelectedNode == null)
            return false;
       
        if (!isComponentCreatable(actionContext.getTargetComponent())) {
            return false;
        }
       
        JTree tree = firstSelectedNode.getParentTree();
        selectedTreePaths = tree.getSelectionPaths();
       
        if (selectedTreePaths.length > 1)
            return false;
       
       
        MCTMutableTreeNode selectedNode = (MCTMutableTreeNode) selectedTreePaths[0].getLastPathComponent();
        MCTMutableTreeNode parentNode = (MCTMutableTreeNode) selectedNode.getParent();
        AbstractComponent parentComponent = ((View) parentNode.getUserObject()).getManifestedComponent();

        return isParentComponentModifiable(parentComponent);
    }
View Full Code Here

            for (TreePath path : selectionPaths) {
                // Only add nodes that are components - this should always be the
                // case, but we check just to make sure, so that we don't try to
                // drag dummy nodes such as MessageTreeNode.
                if (path.getLastPathComponent() instanceof MCTMutableTreeNode) {
                    MCTMutableTreeNode node = (MCTMutableTreeNode) path.getLastPathComponent();
                    View gui = (View) node.getUserObject();
                    dragComponents.add(gui.getManifestedComponent());
                }
            }
           
            PolicyContext context = new PolicyContext();
View Full Code Here

            for (TreePath path : selectionPaths) {
                // Only add nodes that are components - this should always be the
                // case, but we check just to make sure, so that we don't try to
                // drag dummy nodes such as MessageTreeNode.
                if (path.getLastPathComponent() instanceof MCTMutableTreeNode) {
                    MCTMutableTreeNode node = (MCTMutableTreeNode) path.getLastPathComponent();
                    View gui = (View) node.getUserObject();
                    views.add(gui);
                }
            }

            // If we didn't find any applicable roles, just return null so that we
View Full Code Here

        @Override
        public boolean importData(TransferSupport support) {
            JTree.DropLocation location = (JTree.DropLocation) support.getDropLocation();
            TreePath dropPath = location.getPath();
            MCTMutableTreeNode parent; // The parent node under which we perform the drop.
            if (dropPath != null) {
                parent = (MCTMutableTreeNode) dropPath.getLastPathComponent();
            } else {
                parent = (MCTMutableTreeNode) theModel.getRoot();
            }
View Full Code Here

               
                // Update selection in the target window to be the set of dragged components.
                // This is consistent with the usability requirement of feeding back the results of user actions.               
                if (path != null) {
                    // The target tree is not empty, set selection     
                    MCTMutableTreeNode selectedNode = (MCTMutableTreeNode) path.getLastPathComponent();
                    View selectedNodeGUIComponent = (View) selectedNode.getUserObject();
                    selectedNodeGUIComponent.updateMonitoredGUI(new FocusEvent(directoryArea, handler.getDroppedComponents()));
                }               
            } else {
                // Action was not permitted
                final String message = handler.getMessage();
View Full Code Here

    private static final class DirectoryTreeExpansionListener implements TreeExpansionListener {
        @Override
        public void treeCollapsed(TreeExpansionEvent event) {
            logger.debug("Tree detected a collapse event.");
            TreePath path = event.getPath();
            MCTMutableTreeNode selectedNode = (MCTMutableTreeNode) path.getLastPathComponent();
            JTree tree = (JTree) event.getSource();
            // if the node has already been initialized then remove the nodes
            // and add back in the placeholder node. This will signal the node upon
            // expansion that the real children need to be created.
            if (!selectedNode.isProxy() && selectedNode != tree.getModel().getRoot()) {
                MCTMutableTreeNode childNode = new MCTMutableTreeNode(View.NULL_VIEW_MANIFESTATION, (JTree) event.getSource());
                selectedNode.removeAllChildren();
                selectedNode.add(childNode);
                selectedNode.setProxy(true);
                // fire this event to ensure the cache has been updated. Changes to
                // the node itself do not fire events that the nodes have changed
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

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.