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

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


    @Test (dependsOnMethods = { "testConstructor" })
    public void testNonNullContexts() {
        File testOutputFile = new File("testImageExport.png");
        File testOutputFile2 = new File("testImageExport2.png");
        ActionContextImpl context = Mockito.mock(ActionContextImpl.class);
        Mockito.when(context.getTargetHousing()).thenReturn(housing);
        Mockito.when(context.getSelectedManifestations()).thenReturn(Collections.singleton(aView));
        Mockito.when(fileChooser.showSaveDialog(aView)).thenReturn(JFileChooser.APPROVE_OPTION);
        Mockito.when(fileChooser.getSelectedFile()).thenReturn(testOutputFile);
        exportViewAction.setFileChooser(fileChooser);
        exportWindowAction.setFileChooser(fileChooser);
        Mockito.when(housing.getInspectionArea()).thenReturn(inspectionArea);
        Mockito.when(inspectionArea.getHousedViewManifestation()).thenReturn(aView);
        Mockito.when(aView.getWidth()).thenReturn(10);
        Mockito.when(aView.getHeight()).thenReturn(10);
       
        context.setTargetHousing(housing);
        Mockito.when(context.getSelectedManifestations()).thenReturn(Collections.singleton(aView));
        ActionContextImpl context2 = Mockito.mock(ActionContextImpl.class);
        Mockito.when(context2.getTargetHousing()).thenReturn(housing);
        Mockito.when(context2.getWindowManifestation()).thenReturn(aView);

       
        assertTrue(exportViewAction.canHandle(context));
        assertTrue(exportViewAction.isEnabled());
       
View Full Code Here


  public void actionPerformed(ActionEvent e) {
  }

  @Override
  public boolean canHandle(ActionContext context) {
      ActionContextImpl actionContext = (ActionContextImpl) context;
        AbstractComponent component = actionContext.getTargetComponent();
       
        if (component == null)
          return false;

        if ("My Model B".equals(component.getDisplayName())) {
View Full Code Here

    public void actionPerformed(ActionEvent e) {
    }

    @Override
    public boolean canHandle(ActionContext context) {
        ActionContextImpl actionContext = (ActionContextImpl) context;
        MCTHousing targetHousing = actionContext.getTargetHousing();
        if (targetHousing == null)
            return false;
       
        AbstractComponent rootComponent = targetHousing.getWindowComponent();       
        if (rootComponent == null)
View Full Code Here

        if ( !(viewManifestation instanceof ViewProvider)) {
            logger.error("JComponent object needs to implement ViewManifestationProvider interface");
            return;
        }
        // Set action context.
        ActionContextImpl context = new ActionContextImpl();
        context.setTargetComponent(component);
        context.addTargetViewComponent(viewManifestation);
        context.setTargetHousing(UserEnvironmentRegistry.getActiveHousing());

        JPopupMenu popupMenu = MenuFactory.createIconPopupMenu(context);
        viewManifestation.setComponentPopupMenu(popupMenu);
        popupMenu.show(viewManifestation, e.getX(), e.getY());
    }
View Full Code Here

        private void showPopupMenu(MouseEvent e) {
            if (getSelectedNode() == null)
                return;

            // Set action context.
            ActionContextImpl context = new ActionContextImpl();
            MCTHousing parentHousing = (MCTHousing) SwingUtilities.getAncestorOfClass(MCTHousing.class, e.getComponent());
            context.setTargetHousing(parentHousing);
            DefaultMutableTreeNode[] selectedNodes = getSelectedNodes();
            if (selectedNodes != null && selectedNodes.length > 0) {
                for (DefaultMutableTreeNode node : selectedNodes) {
                    context.addTargetViewComponent((JComponent) node.getUserObject());
                }
                context.setTargetComponent(((View) context.getTargetViewComponent()).getManifestedComponent());
                JPopupMenu popupMenu = MenuFactory.createUserObjectPopupMenu(context);
                popupMenu.show((JComponent) e.getSource(), e.getX(), e.getY());
            }

        }
View Full Code Here

        if (e.isPopupTrigger() || e.getButton() == MouseEvent.BUTTON3)
            showPopupMenu(e);
    }

    private void showPopupMenu(MouseEvent e) {
        ActionContextImpl context = new ActionContextImpl();
        context.setTargetComponent(component);
        // Set the context's housing field. Look for a non-null housing in one of the manifestations.
        Iterator<View> iter = multiViewManifestations.iterator();
        while (iter.hasNext()) {
            MCTHousing currentHousing = (MCTHousing) SwingUtilities.getAncestorOfClass(MCTAbstractHousing.class, iter.next());
            if (currentHousing != null) {
                context.setTargetHousing(currentHousing);
                break;
            }
        }

        for (View viewManifestation: multiViewManifestations) {
            context.addTargetViewComponent(viewManifestation);
        }
           
        JPopupMenu popupMenu = generatePopupMenu(context);
        if (popupMenu == null) {
            logger.error("Could not create popup menu using menu factory");
View Full Code Here

        MockHousing housing = new MockHousing(0, 0, 0, MCTHousingFactory.CONTENT_AREA_ENABLE, new MCTHousingViewManifestation(componentC,new ViewInfo(MCTHousingViewManifestation.class,"",ViewType.LAYOUT)));
        MCTStandardHousingMenuBar standardMenuBar = new MCTStandardHousingMenuBar(housing);
        Assert.assertEquals(standardMenuBar.getMenuCount(), 6);

        ActionContextImpl context = new ActionContextImpl();
        context.setTargetHousing(housing);
        context.addTargetViewComponent(housing.getHousedViewManifestation());
        List<ContextAwareMenu> userObjectMenus = standardMenuBar.getUserObjectMenus(context);
        Assert.assertEquals(userObjectMenus.size(), 1);
        Assert.assertTrue(userObjectMenus.get(0) instanceof ObjectsMenu);
    }
View Full Code Here

        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);
       
        // Check menu and action registration
        Assert.assertTrue(ActionManager.getMenu("VIEW_MENU", context) instanceof ViewMenu);
       
        JPopupMenu viewPopupMenu = MenuExtensionManager.getInstance().getViewPopupMenu(manifestation);
View Full Code Here

  @Test(enabled=true, dependsOnMethods = { "testRegisteredActions" })
  public void testPopupMenu() {
        if (GraphicsEnvironment.isHeadless()) {
            return;
        }
    ActionContextImpl context = new ActionContextImpl();
    context.setTargetComponent(null);
   
    popupMenus.add(testMenu);
   
    JPopupMenu popupMenu = MenuFactory.createPopupMenu(context, popupMenus);
    Assert.assertNotNull(popupMenu);
View Full Code Here

  @Test(enabled=true, dependsOnMethods = { "testPopupMenu" })
  public void testTargetContextPopup() {
        if (GraphicsEnvironment.isHeadless()) {
            return;
        }
    ActionContextImpl context = new ActionContextImpl();
    context.setTargetComponent(componentA);
   
    JPopupMenu popupMenu = MenuFactory.createPopupMenu(context, popupMenus);
    Assert.assertNotNull(popupMenu);
   
    Assert.assertEquals(popupMenu.getComponentCount(), 4);
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.