Package gov.nasa.arc.mct.gui.impl

Examples of gov.nasa.arc.mct.gui.impl.ActionContextImpl


            }
           
            @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();
                for (int index = 0; index < sections.size(); index++) {
View Full Code Here


                PlatformAccess.getPlatform().getPersistenceProvider().getComponent(
                        view.getManifestedComponent().getComponentId());
        if (committedComponent == null)
            return true;
       
        ActionContextImpl context = new ActionContextImpl();
        context.setTargetComponent(view.getManifestedComponent());
        context.addTargetViewComponent(view);
        context.setTargetHousing((MCTHousing) SwingUtilities.getAncestorOfClass(MCTHousing.class, view));
        if (!action.canHandle(context) || !action.isEnabled()) {
            return true; // Can't save anyway, so don't bother
        }
       
        String save = action.getValue(ContextAwareAction.NAME).toString();       
View Full Code Here

    }

    @Override
    public boolean canHandle(ActionContext context) {
       
        ActionContextImpl actionContext = (ActionContextImpl) context;
          
        if (actionContext.getWindowManifestation().getManifestedComponent() == null) {
            logger.warn("THIS Object ActionContext.getWindowManifestation().getManifestedComponent() is null!");
            return false;
        }
       
        return (DetectGraphicsDevices.getInstance().getNumberGraphicsDevices() > DetectGraphicsDevices.MINIMUM_MONITOR_CHECK);
View Full Code Here

    }

    @Override
    public boolean canHandle(ActionContext context) {
       
        ActionContextImpl actionContext = (ActionContextImpl) context;
        if (actionContext.getSelectedManifestations() == null) {
            logger.warn("ActionContext.getSelectedManifestations() is null!");
            return false;
        }
        return ((actionContext.getSelectedManifestations().size() == 1) &&
                DetectGraphicsDevices.getInstance().getNumberGraphicsDevices() > DetectGraphicsDevices.MINIMUM_MONITOR_CHECK ? true : false);      
    }
View Full Code Here

        super("Create");
    }

    @Override
    public boolean canHandle(ActionContext context) {
        ActionContextImpl actionContext = (ActionContextImpl) context;
        // For now, this New submenu should only appear when there are external bundles
        ExternalComponentRegistryImpl extCompRegistry = ExternalComponentRegistryImpl.getInstance();
        Collection<ExtendedComponentTypeInfo> componentInfos = extCompRegistry.getComponentInfos();
        if (componentInfos.isEmpty())
            return false;

        AbstractComponent targetComponent = actionContext.getTargetComponent();
        PolicyContext policyContext = new PolicyContext();
        policyContext.setProperty(PolicyContext.PropertyName.TARGET_COMPONENT.getName(), targetComponent);
        policyContext.setProperty(PolicyContext.PropertyName.ACTION.getName(), 'w');
        String compositionKey = PolicyInfo.CategoryType.COMPOSITION_POLICY_CATEGORY.getKey();
        return PolicyManagerImpl.getInstance().execute(compositionKey, policyContext).getStatus();
View Full Code Here

   
    public MCTStandardHousingMenuBar(MCTStandardHousing parentHousing) {
        if (parentHousing == null)
            throw new IllegalStateException("Should associate menu bar with a non-null MCTAbstractHousing.");
        instrumentNames();
        ActionContextImpl context = new ActionContextImpl();
        context.setTargetHousing(parentHousing);
        context.setTargetComponent(parentHousing.getWindowComponent());
        context.addTargetViewComponent(parentHousing.getHousedViewManifestation());
       
        List<String> list = new LinkedList<String>();
        list.add("ICON_MENU");
        list.add("THIS_MENU");
        list.add("OBJECTS_MENU");
View Full Code Here

        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

        Mockito.when(componentWithExternalKey.getExternalKey()).thenReturn("key");
        AbstractComponent componentWithoutExternalKey = Mockito.mock(AbstractComponent.class);
       
        Field f = DuplicateAction.class.getDeclaredField("actionContext");
        f.setAccessible(true);
        ActionContextImpl actionContext = new ActionContextImpl();
        f.set(action, actionContext);
       
        actionContext.setTargetComponent(componentWithoutExternalKey);
        Assert.assertTrue(action.isEnabled());
        actionContext.setTargetComponent(componentWithExternalKey);
        Assert.assertFalse(action.isEnabled());
    }
View Full Code Here

        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));
View Full Code Here

                housings.add(housing3);
                return housings;
            }
        };

        ActionContextImpl context = new ActionContextImpl();
        context.setTargetHousing(housing1);
        Assert.assertTrue(action.canHandle(context));
        RadioAction[] radioActions = action.getActions();
        Assert.assertEquals(radioActions.length, 3);
        Assert.assertSame(radioActions[0].getValue(Action.NAME), "A");
        Assert.assertSame(radioActions[1].getValue(Action.NAME), "A");
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.gui.impl.ActionContextImpl

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.