Package gov.nasa.arc.mct.gui.housing

Examples of gov.nasa.arc.mct.gui.housing.MCTHousing


    public static class ThisSaveAction extends SaveAction {
        private static final long serialVersionUID = -8750182309057992525L;

        @Override
        protected AbstractComponent getTargetComponent(ActionContextImpl actionContext)  {
            MCTHousing housing = actionContext.getTargetHousing();
            MCTContentArea contentArea = housing.getContentArea();
            return contentArea == null ? null : contentArea.getHousedViewManifestation().getManifestedComponent();
        }       
View Full Code Here


    @Override
    public boolean isEnabled() {
        boolean checkTargetComponent =  false;
        boolean checkTargetHousing = false;
       
        MCTHousing targetHousing = actionContext.getTargetHousing();
        checkTargetHousing = (targetHousing == null) ? false : true;
       
        AbstractComponent targetComponent = actionContext.getTargetComponent();
        checkTargetComponent = (targetComponent == null) ? false : true;
       
        if (targetComponent.equals(targetHousing.getWindowComponent()))
            checkTargetComponent = false;
        
        return (checkTargetComponent && checkTargetHousing &&
                (DetectGraphicsDevices.getInstance().getNumberGraphicsDevices() > DetectGraphicsDevices.MINIMUM_MONITOR_CHECK));
    }
View Full Code Here

    }
   
    @Override
    public boolean canHandle(ActionContext context) {
        actionContext = (ActionContextImpl) context;
        MCTHousing activeHousing = actionContext.getTargetHousing();
        if (activeHousing == null)
            return false;


        Collection<View> selection =
            activeHousing.getSelectionProvider().getSelectedManifestations();
       
        if (selection.isEmpty()) {
            return false;
        }
       
        ViewInfo vi = selection.iterator().next().getInfo();
       
        if (!(vi != null && vi.getViewType() == ViewType.NODE)){
            return false;
        }

        if (!(activeHousing.getDirectoryArea() instanceof MCTDirectoryArea)) {
            return false;
        }
       
        MCTDirectoryArea directory = MCTDirectoryArea.class.cast(activeHousing.getDirectoryArea());
        MCTMutableTreeNode firstSelectedNode = directory.getSelectedDirectoryNode();
       
        if (firstSelectedNode == null)
            return false;
       
View Full Code Here

    }
   
    @Override
    public boolean canHandle(ActionContext context) {
        actionContext = (ActionContextImpl) context;
        MCTHousing activeHousing = actionContext.getTargetHousing();
        if (activeHousing == null)
            return false;


        Collection<View> selection =
            activeHousing.getSelectionProvider().getSelectedManifestations();
       
        if (selection.isEmpty()) {
            return false;
        }
       
        ViewInfo vi = selection.iterator().next().getInfo();
       
        if (!(vi != null && vi.getViewType() == ViewType.NODE)){
            return false;
        }

        if (!(activeHousing.getDirectoryArea() instanceof MCTDirectoryArea)) {
            return false;
        }
       
        MCTDirectoryArea directory = MCTDirectoryArea.class.cast(activeHousing.getDirectoryArea());
        MCTMutableTreeNode firstSelectedNode = directory.getSelectedDirectoryNode();
       
        if (firstSelectedNode == null)
            return false;
       
View Full Code Here

        return new MCTStandardHousingMenuBar(parentHousing);
    }
   
    public static JPopupMenu createUserObjectPopupMenu(ActionContextImpl context) {
       
        MCTHousing activeHousing = context.getTargetHousing();
        if (activeHousing == null) {
            logMenuDiagnostics(context);
            return null;
        }
        MCTStandardHousingMenuBar mBar = createStandardHousingMenuBar((MCTStandardHousing) activeHousing);
View Full Code Here

           
            @Override
            public void menuSelected(MenuEvent e) {
                // Set action context.
                ActionContextImpl context = new ActionContextImpl();
                MCTHousing activeHousing = (MCTHousing) SwingUtilities.getAncestorOfClass(MCTHousing.class, menu);               
                if (activeHousing != null) {
                    // An active housing may be missing in headless mode.
                    View currentActiveManifestation = activeHousing.getCurrentManifestation();                   
                    context.setTargetComponent(currentActiveManifestation.getManifestedComponent());
                    context.setTargetHousing(activeHousing);
                   
                    // Add all selected manifestations to context.
                    for (View manifestation : activeHousing.getSelectionProvider().getSelectedManifestations())
                        context.addTargetViewComponent(manifestation);   
                }

                lastPopulatedIndex = -1;
                List<MenuSection> sections = menu.getMenuSections();
View Full Code Here

        };       
    };
   
    @Test
    public void testHandleNoSelectionInDirectory() {
        MCTHousing mockHousing = Mockito.mock(MCTHousing.class);
        MCTDirectoryArea mockDirectoryArea = Mockito.mock(MCTDirectoryArea.class);
        Mockito.when(mockHousing.getDirectoryArea()).thenReturn(mockDirectoryArea);
        Mockito.when(mockDirectoryArea.getSelectedManifestations()).thenReturn(Collections.<View>emptySet());
       
        ActionContextImpl context = new ActionContextImpl();       
        context.setTargetHousing(mockHousing);
        Assert.assertFalse(action.canHandle(context));
View Full Code Here

    }
   
    @Test
    public void cannotHandle() {
        PolicyManagerImpl.getInstance().refreshExtendedPolicies(Collections.<ExtendedComponentProvider>singletonList(new ExtendedComponentProviderTest()));
        MCTHousing housing = Mockito.mock(MCTHousing.class);
        MCTDirectoryArea directoryArea = Mockito.mock(MCTDirectoryArea.class);
        MCTMutableTreeNode selectedNode = Mockito.mock(MCTMutableTreeNode.class);
        MCTMutableTreeNode parentNode = Mockito.mock(MCTMutableTreeNode.class);
        AbstractComponent ac = Mockito.mock(AbstractComponent.class);
        AbstractComponent parent = Mockito.mock(AbstractComponent.class);
        JTree tree = Mockito.mock(JTree.class);
        TreePath treePath = Mockito.mock(TreePath.class);
       
        ActionContextImpl actionContext = Mockito.mock(ActionContextImpl.class);
        NodeViewManifestation selectedNodeView = Mockito.mock(NodeViewManifestation.class);       
        NodeViewManifestation parentNodeView = Mockito.mock(NodeViewManifestation.class);       
        Mockito.when(actionContext.getTargetHousing()).thenReturn(housing);
        Mockito.when(actionContext.getTargetComponent()).thenReturn(ac);
        Mockito.when(housing.getDirectoryArea()).thenReturn(directoryArea);
        Mockito.when(directoryArea.getSelectedManifestations()).thenReturn(Collections.<View>singleton(selectedNodeView));
        Mockito.when(directoryArea.getSelectedDirectoryNode()).thenReturn(selectedNode);
        Mockito.when(selectedNode.getParentTree()).thenReturn(tree);
        Mockito.when(tree.getSelectionPaths()).thenReturn(Arrays.array(treePath));
        Mockito.when(treePath.getLastPathComponent()).thenReturn(selectedNode);
View Full Code Here

    }

    @Test (dependsOnMethods = { "testConstructor" })
    public void testNonNullContext() {
        ActionContextImpl context = new ActionContextImpl();
        MCTHousing housing = Mockito.mock(MCTHousing.class);
        context.setTargetHousing(housing);
       
        assertTrue(controlArea.canHandle(context));
        assertTrue(controlArea.isEnabled());
       
View Full Code Here

        // Set up parent/child component such that SaveAll should be available
        final AbstractComponent child = generateComponent(true, true, true, null);
        final AbstractComponent comp = generateComponent(true, isDirty, true, child);

        // Elaborate mocking to simulate context menu activation
        MCTHousing mockHousing = Mockito.mock(MCTHousing.class);
        MCTContentArea mockContentArea = Mockito.mock(MCTContentArea.class);
        View mockView = Mockito.mock(View.class);
        ActionContextImpl mockContext = Mockito.mock(ActionContextImpl.class);

        Mockito.when(mockContext.getInspectorComponent()).thenReturn(comp);
        Mockito.when(mockContext.getTargetComponent()).thenReturn(comp);
        Mockito.when(mockContext.getTargetHousing()).thenReturn(mockHousing);
        Mockito.when(mockHousing.getContentArea()).thenReturn(mockContentArea);
        Mockito.when(mockContentArea.getHousedViewManifestation()).thenReturn(mockView);
        Mockito.when(mockView.getManifestedComponent()).thenReturn(comp);

        // Generate a new persistence provider each time
        PersistenceProvider persistence = Mockito.mock(PersistenceProvider.class);
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.gui.housing.MCTHousing

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.