Package gov.nasa.arc.mct.gui

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


        Map<String,Integer> numberOfParents = new HashMap<String,Integer>();
        Set<String> lastManifestationComponents = new HashSet<String>();
        List<Map<MCTMutableTreeNode, MCTMutableTreeNode>> okToRemoveManifestations = new ArrayList<Map<MCTMutableTreeNode, MCTMutableTreeNode>>();
       
        for (TreePath path : selectedTreePaths) {
            MCTMutableTreeNode selectedNode = (MCTMutableTreeNode) path.getLastPathComponent();           
            MCTMutableTreeNode parentNode = (MCTMutableTreeNode) selectedNode.getParent();
           
            AbstractComponent selectedComponent = ((View) selectedNode.getUserObject()).getManifestedComponent();

            if (!numberOfParents.containsKey(selectedComponent.getComponentId()))  {
                numberOfParents.put(selectedComponent.getComponentId(), Integer.valueOf(selectedComponent.getReferencingComponents().size()));
View Full Code Here


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

        PolicyContext context = new PolicyContext();
        context.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), parentComponent);
        context.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        context.setProperty(PolicyContext.PropertyName.SOURCE_COMPONENTS.getName(), Collections.singleton(selectedComponent));
        context.setProperty(PolicyContext.PropertyName.VIEW_MANIFESTATION_PROVIDER.getName(), parentNode.getUserObject());
       
        String canRemoveManifestationKey = PolicyInfo.CategoryType.CAN_REMOVE_MANIFESTATION_CATEGORY.getKey();
        boolean canRemoveManifestation = PolicyManagerImpl.getInstance().execute(canRemoveManifestationKey, context).getStatus();
       
        if (canRemoveManifestation) {
View Full Code Here

        @Override
        public void treeExpanded(final TreeExpansionEvent event) {
            logger.debug("Tree detected an expansion event.");
            final JTree tree = (JTree) event.getSource();
            TreePath path = event.getPath();
            final MCTMutableTreeNode selectedNode = (MCTMutableTreeNode) path.getLastPathComponent();
            if (selectedNode.isProxy()) {
                // Insert a dummy node to alert the user that the expansion may take a while.
                final MutableTreeNode newChild = new MessageTreeNode(bundle.getString("PLACEHOLDER_NODE_TEXT"));
               
                // only add the node after the timer has expired to avoid flashing
                // 200 ms is the threshold that users can perceive a delay
                final Timer t = new Timer(150, new ActionListener() {
                   
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        // if the node has been closed before the action has run
                        // but before this action has been canceled then do not
                        // insert the please wait node
                        if (!selectedNode.isProxy()) {
                            ((DefaultTreeModel) tree.getModel()).insertNodeInto(newChild, selectedNode, 0);
                        }
                    }
                });
                t.setRepeats(false);
                // signal that initialization has occurred
                selectedNode.setProxy(false);
                t.start();
               
                // Load the actual children in a background thread. The dummy node will be
                // removed, and the tree redisplayed with the actual children, when the
                // child components are loaded from the database.
                (new SwingWorker<Object,Object>() {
                   
                    @Override
                    protected Object doInBackground() throws Exception {
                        View gui = (View) selectedNode.getUserObject();
                        AbstractComponent component = gui.getManifestedComponent();                       
                        return component.getComponents();
                    }
                   
                    @Override
                    protected void done() {
                        // this runs in the AWT Thread
                        t.stop();
                        // this is true if the node has been collapsed
                        if (selectedNode.isProxy()) {
                            return;
                        }
                        // Let the node know it needs to refresh itself
                        View gui = (View) selectedNode.getUserObject();
                        gui.updateMonitoredGUI();
                    }
                }).execute();
            }
        }
View Full Code Here

    }
   
    @Test
    public void testLazyLoading() {
        // Clone subtree of component A
        MCTMutableTreeNode clonedTreeNode = GUIUtil.cloneTreeNode(componentA, new ViewInfo(NodeViewTest.class, "", ViewType.NODE));
        Assert.assertNotNull(clonedTreeNode);
        Assert.assertEquals(clonedTreeNode.getChildCount(), 1);
        Assert.assertTrue(clonedTreeNode.isProxy());
    }
View Full Code Here

            // node.
            if (value instanceof MessageTreeNode) {
                return new JLabel(value.toString());
            }
           
            MCTMutableTreeNode node = (MCTMutableTreeNode) value;
            WeakReference<View> viewRef = renderedComponent.get(node);
            View view = viewRef == null ? null : viewRef.get();
            if (view == null) {
                view = (View) node.getUserObject();
                view.addMonitoredGUI(node);
                renderedComponent.put(node, new WeakReference<View>(view));
            }

            // We highlight the tree node if either it's selected or it's
View Full Code Here

    /**
     * Taken from BookmarkTest
     */
    private static MCTMutableTreeNode createMCTMutableTreeStructure(AbstractComponent root) {
        JTree tree = new JTree();
        MCTMutableTreeNode rootNode = new MCTMutableTreeNode(root.getViewInfos(ViewType.NODE).iterator().next().createView(root), tree);

        // Populate the tree
        for (AbstractComponent childComponent : root.getComponents()) {
            Set<ViewInfo> setViewInfos = childComponent.getViewInfos(ViewType.NODE);
            ViewInfo viewRole = setViewInfos.iterator().next();
            MCTMutableTreeNode childNode = new MCTMutableTreeNode(viewRole.createView(childComponent), tree);
            rootNode.add(childNode);
            if (!childComponent.getComponents().isEmpty()) {
                childNode.setProxy(true);
                MCTMutableTreeNode grandChildNode = new MCTMutableTreeNode(View.NULL_VIEW_MANIFESTATION);
                childNode.add(grandChildNode);
            }
        }
        return rootNode;
    }
View Full Code Here

        assertEquals(selectedNodes.length, 0);
    }
   
    @Test
    public void testGetSelectedDirectoryNode() {
        MCTMutableTreeNode selectedDirectoryNode = dirArea.getSelectedDirectoryNode();
        assertNotNull(selectedDirectoryNode);
    }
View Full Code Here

        Field f = JTree.class.getDeclaredField("dropLocation");
        f.setAccessible(true);
        f.set(tree, loc);
       
        View view = mock(View.class);
        MCTMutableTreeNode node = new MCTMutableTreeNode();
        node.setUserObject(view);

        View renderView = (View) renderer.getTreeCellRendererComponent(tree, node, sel, false, false, row, false);
       
        assertSame(renderView, view);
       
View Full Code Here

   
    @DataProvider(name="createTransferableTests")
    public Object[][] getCreateTransferableTests() {
       View p1View = mock(View.class);
         View cView = mock(View.class);
         MCTMutableTreeNode g = createMockNode(null);
         MCTMutableTreeNode p1 = createMockNode(p1View);
         MCTMutableTreeNode p2 = createMockNode(null);
         MCTMutableTreeNode c = createMockNode(cView);
        
         TreePath path1 = new TreePath(new Object[]{g, p1});
         TreePath path2 = new TreePath(new Object[]{g, p2, c});
        
         return new Object[][] {
View Full Code Here

                 new Object[] { new TreePath[] { path1, path2 }, new View[] { p1View, cView } }
         };
    }
   
    private MCTMutableTreeNode createMockNode(View view) {
        MCTMutableTreeNode node = new MCTMutableTreeNode();
        if (view != null) {
            node.setUserObject(view);
        }
        return node;
    }
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.