Package gov.nasa.arc.mct.gui

Examples of gov.nasa.arc.mct.gui.ContextAwareMenu.canHandle()


            menu.initialize();

            if (menuIndex > 0)
                popupMenu.addSeparator();
           
            if (menu.canHandle(context)) {
                int lastPopulatedIndex = -1;
                List<MenuSection> sections = menu.getMenuSections();
                for (int sectionIndex = 0; sectionIndex < sections.size(); sectionIndex++) {
                    MenuSection section = sections.get(sectionIndex);
                    List<MenuItemInfo> menuItemInfoList = section.getMenuItemInfoList();
View Full Code Here


        List<Class<? extends ContextAwareMenu>> menuList = commandMenuMap.get(commandKey);
        if (menuList != null) {
            for (Class<? extends ContextAwareMenu> menuClass : menuList) {
                try {
                    ContextAwareMenu menu = menuClass.newInstance();
                    if (menu.canHandle(context)) {
                        menu.addMenuListener(MenuFactory.createMenuListener(menu));
                        // Populate built-in menus and/or menu items
                        menu.initialize();
                        // Populate extended menus and/or menu items
                        MenuExtensionManager manager = MenuExtensionManager.getInstance();
View Full Code Here

        Assert.assertEquals(thisMenu.getText(), "Export");
        Assert.assertEquals(objsMenu.getText(), "Export");
       
        // Should always return true to canHandle
        Assert.assertTrue(thisMenu.canHandle(null));
        Assert.assertTrue(objsMenu.canHandle(null));
       
        // Verify that expected extension points are published
        String[] thisExts = thisMenu.getExtensionMenubarPaths();
        String[] objsExts = objsMenu.getExtensionMenubarPaths();
        Assert.assertEquals(thisExts[0], "/this/export.ext");
View Full Code Here

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

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

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

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

        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

TOP
Copyright © 2018 www.massapi.com. 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.