Package gov.nasa.arc.mct.gui

Examples of gov.nasa.arc.mct.gui.View$GlassPanel


                    ));
        }
       
        @Override
        public boolean canHandle(ActionContext context) {  
            View view = context.getWindowManifestation();
            return view != null &&
                   isWritable(view.getManifestedComponent()) &&
                   super.canHandle(context);
        }
View Full Code Here


                return result.getStatus();
            }

            @Override
            protected Transferable createTransferable(JComponent c) {
                View v = context.getWindowManifestation();
                Container container = v.getTopLevelAncestor();
                if (container instanceof MCTStandardHousing) {
                    MCTStandardHousing housing = (MCTStandardHousing) container;
                    MCTContentArea contentArea = housing.getContentArea();
                    if (contentArea != null) {
                        v = contentArea.getHousedViewManifestation();
View Full Code Here

        // But staleness in this view is not detected for some reason
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        View housedView = isHousing ?
                housing.getContentArea().getHousedViewManifestation() :
                view.getHousedViewManifestation();
       
        // Should not be null per canHandle, but check for safety
        if (housedView != null) {
            boolean doRefresh = true;
           
            // Give the user an opportunity to cancel the refresh if it would
            // overwrite unsaved changes.
            if (housedView.getManifestedComponent().isDirty()) {
                Map<String, Object> hints = new HashMap<String, Object>();
                hints.put(WindowManagerImpl.MESSAGE_TYPE, OptionBox.WARNING_MESSAGE);
                hints.put(WindowManagerImpl.OPTION_TYPE, OptionBox.YES_NO_OPTION);
                hints.put(WindowManagerImpl.PARENT_COMPONENT, housing);

                String ok = BUNDLE.getString("RefreshAction.ok"); //NOI18N
                String cancel = BUNDLE.getString("RefreshAction.cancel"); //NOI18N
               
                String input = PlatformAccess.getPlatform().getWindowManager().showInputDialog(
                        BUNDLE.getString("RefreshAction.title"), //NOI18N
                        BUNDLE.getString("RefreshAction.warning"), //NOI18N
                        new String[]{ok, cancel},
                        ok,
                        hints);
                doRefresh = ok.equals(input);
            }
          
            // Perform the refresh by re-creating view
            if (doRefresh) {
                // Update component from persistence
                AbstractComponent comp = housedView.getManifestedComponent();
                comp = PlatformAccess.getPlatform().getPersistenceProvider().getComponent(comp.getComponentId());
                housedView.setManifestedComponent(comp);               
               
                // Re-create view
                ViewInfo vi = housedView.getInfo();
                if (isHousing) {
                    View newView = vi.createView(comp);
                    housing.getContentArea().setOwnerComponentCanvasManifestation(newView);
                } else {
                    housedView.setManifestedComponent(comp);
                    view.setHousedViewManifestation(vi);
                }
View Full Code Here

   
    private static void logMenuDiagnostics(ActionContextImpl context) {
        Set<JComponent> views = context.getAllTargetViewComponent();
        StringBuffer supplementInfo = new StringBuffer();
        for (JComponent view : views) {
            View viewManif = (View) view;
            AbstractComponent comp = viewManif.getManifestedComponent();
            supplementInfo.append("Component name = " + comp.getDisplayName() + ", id = "
                    + comp.getId() + ".  ");
        }
        if (context.getTargetHousing() == null) {
            supplementInfo.append("\n\n --- Context's housing object is NULL.");
View Full Code Here

   
    @BeforeMethod
    public void beforeMethod() {
        MockitoAnnotations.initMocks(this);
       
        @SuppressWarnings("serial")
        View view = new View(mockComponent, mockViewInfo1) {};
        Mockito.when(mockViewProvider.getHousedViewManifestation())
            .thenReturn(view);
       
        // Enforce desired test order of view infos, such that mockViewInfo1 is selected by default
        Set<ViewInfo> mockViewInfos = new TreeSet<ViewInfo>(new Comparator<ViewInfo>() {
View Full Code Here

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

    }
   
    @Test (dataProvider = "generateSwitcherTests")
    public void testSwitcher(boolean addGUI, boolean doChange, boolean acceptChange) {
        // Create the test object
        View switcherView = SwitcherView.VIEW_INFO.createView(mockComponent);
       
        // Act as though the view provider has/hasn't accepted the view switch
        Mockito.when(mockViewProvider.setHousedViewManifestation(mockViewInfo2))
            .thenReturn(acceptChange);
       
        // Attach view provider to gui, if this test iteration says we should
        if (addGUI) {
            switcherView.addMonitoredGUI(mockViewProvider);
        }
       
        // Find combo box so we can change selection
        @SuppressWarnings("rawtypes")
        JComboBox comboBox = findComponent(switcherView, JComboBox.class);
View Full Code Here

        // Multiple views -> Combo box
        // One view       -> Label
        // No views       -> Neither
       
        // Create the test object
        View switcherView = SwitcherView.VIEW_INFO.createView(mockComponent);
       
        // During normal initialization, should have two view infos.
        // A Combo Box should be found.
        Assert.assertNotNull(findComponent(switcherView, JComboBox.class));
       
View Full Code Here

    public void testBadInput() {
        // Make sure that view does not break for unexpected input
        // (verify that null checks are present.)
       
        // Create the test object
        View switcherView = SwitcherView.VIEW_INFO.createView(mockComponent);
       
        // Add monitored GUI can take a variety of object types
        // Make sure an unexpected object type does not trigger an exception
        switcherView.addMonitoredGUI(null);
        switcherView.addMonitoredGUI("hello");       
        Mockito.when(mockViewProvider.getHousedViewManifestation())
            .thenReturn(null);
        switcherView.addMonitoredGUI(mockViewProvider);
    }
View Full Code Here

        super.setForeground(fg);
    }
   
    private void resetSelection() {
        if (managedView != null) {
            View housedView = managedView.getHousedViewManifestation();
            if (housedView != null) {
                ViewInfo vi = housedView.getInfo();
                if (comboBox != null) {
                    comboBox.removeItemListener(itemListener); // Avoid triggering listener
                    comboBox.setSelectedItem(vi);
                    comboBox.addItemListener(itemListener);
                }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.gui.View$GlassPanel

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.