Package gov.nasa.arc.mct.gui

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


    private void addToSelectionCollection(List<View> manifestations) {
        for (Panel panel : selectedPanels)
            manifestations.add(panel.getWrappedManifestation());
        for (Entry<Integer, Panel> entry : renderedPanels.entrySet()) {
            Panel panel = entry.getValue();
            View wrappedManifestation = panel.getWrappedManifestation();
            if (wrappedManifestation instanceof CanvasManifestation) {
                ((CanvasManifestation) wrappedManifestation).addToSelectionCollection(manifestations);
            }
        }
    }
View Full Code Here


        if (!selectedPanels.isEmpty()) {
            return true;
        } // end if
        for (Entry<Integer, Panel> entry : renderedPanels.entrySet()) {
            Panel panel = entry.getValue();
            View wrappedManifestation = panel.getWrappedManifestation();           
            if (wrappedManifestation instanceof CanvasManifestation) {
                if (((CanvasManifestation) wrappedManifestation).hasSelectedManifestations()) {
                    return true;
                } // end if
            } else {
                if (!wrappedManifestation.getSelectionProvider().getSelectedManifestations().isEmpty()) {
                    return true;
                } // end if
            } // end if
        } // end for
        return false;
View Full Code Here

       
        // Set up mocks
        ActionContext mockContext = Mockito.mock(ActionContext.class);
        PolicyManager mockPolicy = Mockito.mock(PolicyManager.class);
        AbstractComponent mockComponent = Mockito.mock(AbstractComponent.class);
        View mockView = Mockito.mock(View.class);
        String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey();
       
        Mockito.when(mockPlatform.getPolicyManager()).thenReturn(mockPolicy);
       
        // First, This's Import menu
        // No window active - should disallow
        Mockito.when(mockContext.getWindowManifestation()).thenReturn(null);
        Assert.assertFalse(thisMenu.canHandle(mockContext));
       
        // Active window but component is null - should disallow
        Mockito.when(mockContext.getWindowManifestation()).thenReturn(mockView);
        Mockito.when(mockView.getManifestedComponent()).thenReturn(null);
        Assert.assertFalse(thisMenu.canHandle(mockContext));
       
        // Has a window, but policy says no - should disallow
        Mockito.when(mockContext.getWindowManifestation()).thenReturn(mockView);
        Mockito.when(mockView.getManifestedComponent()).thenReturn(mockComponent);
        Mockito.when(mockPolicy.execute(Mockito.eq(compositionKey), Mockito.<PolicyContext>any()))
            .thenReturn(new ExecutionResult(null, false, ""));
        Assert.assertFalse(thisMenu.canHandle(mockContext));
       
        // If policy allows, then canHandle should be true
        Mockito.when(mockPolicy.execute(Mockito.eq(compositionKey), Mockito.<PolicyContext>any()))
            .thenReturn(new ExecutionResult(null, true, ""));
        Assert.assertTrue(thisMenu.canHandle(mockContext));
       
       
        // Second, Objects's Import menu
        // Null selections - should disallow
        Mockito.when(mockContext.getSelectedManifestations()).thenReturn(null);
        Assert.assertFalse(objsMenu.canHandle(mockContext));

        // Empty selections - should disallow
        Mockito.when(mockContext.getSelectedManifestations())
            .thenReturn(Collections.<View>emptyList());
        Assert.assertFalse(objsMenu.canHandle(mockContext));
       
        // One selection but policy says no - should disallow
        Mockito.when(mockContext.getSelectedManifestations())
            .thenReturn(Arrays.asList(mockView));
        Mockito.when(mockView.getManifestedComponent()).thenReturn(mockComponent);       
        Mockito.when(mockPolicy.execute(Mockito.eq(compositionKey), Mockito.<PolicyContext>any()))
            .thenReturn(new ExecutionResult(null, false, ""));              
        Assert.assertFalse(objsMenu.canHandle(mockContext));
       
        // One selection but policy says yes - should allow!
        Mockito.when(mockContext.getSelectedManifestations())
            .thenReturn(Arrays.asList(mockView));
        Mockito.when(mockView.getManifestedComponent()).thenReturn(mockComponent);       
        Mockito.when(mockPolicy.execute(Mockito.eq(compositionKey), Mockito.<PolicyContext>any()))
            .thenReturn(new ExecutionResult(null, true, ""));              
        Assert.assertTrue(objsMenu.canHandle(mockContext));
       
        // Multiple selections, even though policy says yes - should disallow
        Mockito.when(mockContext.getSelectedManifestations())
            .thenReturn(Arrays.asList(mockView, mockView));
        Mockito.when(mockView.getManifestedComponent()).thenReturn(mockComponent);       
        Mockito.when(mockPolicy.execute(Mockito.eq(compositionKey), Mockito.<PolicyContext>any()))
            .thenReturn(new ExecutionResult(null, true, ""));              
        Assert.assertFalse(objsMenu.canHandle(mockContext));

    }
View Full Code Here

            // selected, so we need to ensure that both 1) the tree has a selection,
            // and 2) we've recognized the selection as an MCT view manifestation.
            if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
                logger.debug("Tree detected a double click");
                if (dirTree.getSelectionPath()!=null && getSelectedNode()!=null) {
                    View gui = (View) getSelectedNode().getUserObject();
                   
                    if (gui != null) {
                        gui.getManifestedComponent().open();
                    }
                }
            }
        }
View Full Code Here

            public void mousePressed(MouseEvent e) {
                Collection<View> selectedManifestations = getSelectedManifestations();
                if (selectedManifestations.isEmpty())
                    return;
               
                View manifestation = selectedManifestations.iterator().next();
                if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
                    manifestation.getManifestedComponent().open();
                    return;
                }
            }
        });
        list.setDragEnabled(true);
View Full Code Here

                public void propertyChange(PropertyChangeEvent evt) {
                    refreshFromCenterPaneViewChange();
                }
            });

            View housedViewManifestation = contentArea.getHousedViewManifestation();
            List<? extends JComponent> statusWidgets = housedViewManifestation.getStatusWidgets();
            for (JComponent widget : statusWidgets) {
                dynamicStatusWidgets.add(widget);
                statusArea.addToLeft(widget);
            }
        }
View Full Code Here

         *    Panel child = Mockito.mock(Panel.class);
         *    Mockito.when(child.getBounds()).thenReturn(new Rectangle(2,2,1,1));
         *    rootPanel.add(child);
         * But now we have the following:
         */
        View v = new View(){};
        v.putClientProperty(CanvasManifestation.MANIFEST_INFO, new MCTViewManifestationInfoImpl() );
       
        panelManifestation = new MockManifestation(mockComponent, new ViewInfo(CanvasManifestation.class, "", ViewType.OBJECT));
        MCTViewManifestationInfoImpl info = new MCTViewManifestationInfoImpl();
        panelManifestation.putClientProperty(CanvasManifestation.MANIFEST_INFO, info);
       
View Full Code Here

        }
        return rootNode;
    }
   
    private void mockComponent(AbstractComponent mockedComponent, AbstractComponent child) {
        View mockView = Mockito.mock(View.class);
        Mockito.when(mockView.getManifestedComponent()).thenReturn(mockedComponent);
        Mockito.when(mockedComponent.getViewInfos(ViewType.NODE)).thenReturn(Collections.singleton(new ViewInfo(NodeViewManifestation.class, "", ViewType.NODE)));
        Mockito.when(mockedComponent.getComponents()).thenReturn(child == null ? Collections.<AbstractComponent>emptyList() : Collections.<AbstractComponent>singletonList(child));
        Mockito.when(mockedComponent.isLeaf()).thenReturn(child == null);
       
    }
View Full Code Here

    public void test() {
        // Register the View menu
        ActionManager.registerMenu(ViewMenu.class, "VIEW_MENU");
       
        // Setup manifestation for the action context
        View manifestation = Mockito.mock(View.class);
        AbstractComponent component = Mockito.mock(AbstractComponent.class);
        MCTAbstractHousing housing = Mockito.mock(MCTAbstractHousing.class);
       
        Mockito.when(manifestation.getManifestedComponent()).thenReturn(component);
        Mockito.when(manifestation.getParent()).thenReturn(housing);

        ActionContextImpl context = new ActionContextImpl();
        context.setTargetComponent(component);
        context.setTargetHousing(housing);
       
View Full Code Here

               
        Mockito.when(mockTarget.getManifestedComponent()).thenReturn(pseudoTargetComponent);
        Mockito.when(mockNonTarget.getManifestedComponent()).thenReturn(pseudoNonTargetComponent);
       
        for (int i = 0; i < 3; i++) {
            View mockView = Mockito.mock(View.class);
            final AbstractComponent pseudoComponentClone = new PseudoComponent();
            AbstractComponent pseudoComponent = new PseudoComponent() {
                @Override
                public AbstractComponent clone() {
                    return pseudoComponentClone;
                }
            };
           
            Mockito.when(mockView.getManifestedComponent()).thenReturn(pseudoComponent);
            Mockito.when(mockView.getParentView()).thenReturn(mockNonTarget);
           
            mockSelections.add(mockView);
            pseudoComponents.add(pseudoComponent);
            pseudoClones.add(pseudoComponentClone);
        }
View Full Code Here

TOP

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

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.