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

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


   
   
    @Test (dataProvider="generateTestCases")
    public void testSaveAllEnabled(ContextAwareAction action, AbstractComponent comp, boolean shouldHandle, boolean shouldBeEnabled) {
        // 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);
       
        // Verify that enabled/disabled states match expectations
        Assert.assertEquals(action.canHandle(mockContext), shouldHandle);
View Full Code Here


    }
   
    @Test (dataProvider="generateWarningDialogCases")
    public void testWarningDialog(ContextAwareAction action, AbstractComponent comp, boolean confirm, boolean prompt, final Set<AbstractComponent> expect) {
        // 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

       
        AbstractComponent component = actionContext.getTargetComponent();       
        if (component == null)
            return false;

        MCTHousing targetHousing = actionContext.getTargetHousing();
        if (targetHousing == null || targetHousing.getContentArea() == null)
            return false;

        putValue(Action.SELECTED_KEY, targetHousing.getContentArea().isTitleBarShowing());
        return true;       
    }
View Full Code Here

    @Override
    public void actionPerformed(ActionEvent e) {

        // get the current active housing
        MCTHousing housing = getHousing();
       
        if (housing == null) {
            // no housing, so no controls to show
            return;
        }
       
        boolean currentControlVisibilityState = housing.isControlAreaVisible();
        housing.setControlAreaVisible(!currentControlVisibilityState);
        housing.toggleControlAreas(!currentControlVisibilityState);
    }
View Full Code Here

    }
   
    @Override
    public boolean canHandle(ActionContext context) {
        actionContext = (ActionContextImpl) context;
        MCTHousing activeHousing = actionContext.getTargetHousing();
        if (activeHousing == null)
            return false;
       
        if (!(activeHousing.getDirectoryArea() instanceof MCTDirectoryArea)) {
            return false;
        }
       
        directoryArea = MCTDirectoryArea.class.cast(activeHousing.getDirectoryArea());
        Collection<View> selectedManifestationsInDirectory = directoryArea.getSelectedManifestations();
       
        // This action works only for selected items in the directory area.
        if (selectedManifestationsInDirectory == null || selectedManifestationsInDirectory.isEmpty())
            return false;
View Full Code Here

    }

    @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)
            return false;
       
        if (PlatformAccess.getPlatform().getRootComponent() == rootComponent)
            return false;
View Full Code Here

        return true;
    }

    @Override
    public boolean isEnabled() {
        MCTHousing targetHousing = actionContext.getTargetHousing();
        if (targetHousing == null)
            return false;
       
        AbstractComponent targetComponent = actionContext.getTargetComponent();
        if (targetComponent == null)
            return false;
       
        if (targetComponent.equals(targetHousing.getWindowComponent()))
            return false;
       
        return true;
    }
View Full Code Here

     *            the component to open in the window
     */
    protected void openInWindow(String displayName, ViewInfo nodeView, Window activeWindow, double horizontalScale,
            double verticalScale, AbstractComponent component) {

        MCTHousing housing = null;
        if (component instanceof RootComponent) {

            // THIS Object menu open new user environment
            housing = MCTHousingFactory.newUserEnvironment();            
           
        } else if (component.isLeaf()) {
            Set<ViewInfo> possibleViews = new LinkedHashSet<ViewInfo>(component.getViewInfos(ViewType.CENTER));
            possibleViews.addAll(component.getViewInfos(ViewType.OBJECT));
            housing = MCTHousingFactory.newHousing(displayName,
                    (byte) (MCTHousingFactory.CONTROL_AREA_ENABLE
                            | MCTHousingFactory.CONTENT_AREA_ENABLE | MCTHousingFactory.STATUS_AREA_ENABLE),
                    JFrame.DO_NOTHING_ON_CLOSE, possibleViews.iterator().next().createView(component),
                    horizontalScale, verticalScale, activeWindow);
        } else {
            housing = MCTHousingFactory.newHousing(displayName, MCTHousingFactory.ENABLE_ALL_AREA,
                    JFrame.DO_NOTHING_ON_CLOSE, GUIUtil.cloneTreeNode(component, nodeView), false, horizontalScale, verticalScale,
                    activeWindow);
        }
        ((MCTAbstractHousing) housing).setJMenuBar(MenuFactory.createStandardHousingMenuBar((MCTStandardHousing) housing));
        new StatusBarContentProvider(housing);
        if (housing.getContentArea() != null && !housing.getContentArea().isAreaEmpty()) {
            // use preferred size since the content area is going to be the dominate focus
            MCTAbstractHousing abstractHousing = ((MCTAbstractHousing) housing);
            abstractHousing.pack();
            Rectangle maximumWindowBounds = abstractHousing.getGraphicsConfiguration() != null ? abstractHousing.getGraphicsConfiguration().getBounds() :
                                            GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
            abstractHousing.setSize(Math.min((int) (maximumWindowBounds.width*MAX_SCALE_FACTOR), abstractHousing.getSize().width),
                            Math.min((int) (maximumWindowBounds.height*MAX_SCALE_FACTOR), abstractHousing.getSize().height));
            housing.getContentArea().getHousedViewManifestation().requestFocusInWindow();
       
        }
       
        if (activeWindow != null) {
            Rectangle activeWindowGraphicsConfigBound = activeWindow.getGraphicsConfiguration().getBounds();
View Full Code Here

        ((MCTAbstractHousing) housing).setVisible(true);
    }

    @Override
    public AbstractComponent getWindowRootComponent(Component component) {
        MCTHousing housing = (MCTHousing) SwingUtilities.getAncestorOfClass(MCTHousing.class, component);
        if (housing != null) {
            return housing.getWindowComponent();
        }
        return null;
    }
View Full Code Here

        return null;
    }

    @Override
    public View getWindowRootManifestation(Component component) {
        MCTHousing housing = (MCTHousing) SwingUtilities.getAncestorOfClass(MCTHousing.class, component);
        if (housing != null) {
            return housing.getHousedViewManifestation();
        }
        return null;
    }
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.