Package gov.nasa.arc.mct.gui

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


     * Creates a new instance of this for the selected view type.
     * @param component to use to attach view to
     * @return new instance of view
     */
    public View createView(final AbstractComponent component) {
        View v;
        /* Try to build under MCT's color model */
        try {
            v = LookAndFeelSettings.getColorProperties().getColorSchemeFor(getViewClass().getSimpleName()).callUnderColorScheme( new Callable<View>() {
                public View call() throws Exception {
                    return newView(component);               
View Full Code Here


        return c;
    }
   
    private View newView(AbstractComponent ac) {
        View v = null;
        try {
            v = viewConstructor.newInstance(ac, this);
        } catch (IllegalArgumentException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
View Full Code Here

        return true;
    }

    @Override
    public boolean isEnabled() {
        View embeddedView = housingManifestation.getContentArea().getHousedViewManifestation();
        return embeddedView.getManifestedComponent().isStale();
           
    }
View Full Code Here

    }

    @Override
    public void actionPerformed(ActionEvent e) {
        PersistenceProvider persistenceProvider = PlatformAccess.getPlatform().getPersistenceProvider();
        View embeddedView = housingManifestation.getContentArea().getHousedViewManifestation();
        AbstractComponent updatedComponent = persistenceProvider.getComponent(housingManifestation.getContentArea().getOwnerComponent().getComponentId());       
        housingManifestation.getContentArea().setOwnerComponentCanvasManifestation(embeddedView.getInfo().createView(updatedComponent));
        housingManifestation.setManifestedComponent(updatedComponent);
    }
View Full Code Here

    public void testAppearance() {
        // Exercise custom ComboBoxUI
        // Mostly visual, so not much to verify
       
        // Create the test object
        View switcherView = SwitcherView.VIEW_INFO.createView(mockComponent);
       
        // Find combo box so we can test its UI object
        @SuppressWarnings("rawtypes")
        JComboBox comboBox = findComponent(switcherView, JComboBox.class);       
        ComboBoxUI ui = comboBox.getUI();
View Full Code Here

            completeWorkUnit();
            if (c != null){
                newComponentId = c.getComponentId();
            }
           
            View directoryAreaView = actionContext.getTargetHousing().getDirectoryArea();
            // Select new component (only if it is not null), selection is currently tied to the directory area
            // this implementation should be changed to make the selection support generic (added to the SelectionManager API)
            // to remove this dependency
            if (!(directoryAreaView instanceof MCTDirectoryArea)) {
                MCTLogger.getLogger(NewObjectAction.class).warn(
                        "new object not selected in directory as only MCTDirectoryArea instances are supported " + directoryAreaView.getClass().getName());
            }
           
            if (newComponentId != null && directoryAreaView instanceof MCTDirectoryArea) {
                MCTDirectoryArea directoryArea = MCTDirectoryArea.class.cast(directoryAreaView);
                JTree activeTree = directoryArea.getActiveTree();

                // Identify the currently selected node in the directory area.
                MCTMutableTreeNode initiallySelectedNode = directoryArea.getSelectedNode();   

                if (initiallySelectedNode == null) {
                    // set the root of the tree as the initially selected node.
                    initiallySelectedNode = (MCTMutableTreeNode) activeTree.getModel().getRoot();
                }
                assert initiallySelectedNode!=null : "Selected node must not be null by this point";

                // Check to see if children have been loaded. If not fire are tree expansion event to force them to be loaded.
                if (initiallySelectedNode.isProxy()) {
                    // Force children to be loaded.
                    DefaultTreeModel treeModel = (DefaultTreeModel) activeTree.getModel();
                    TreePath path = new TreePath(treeModel.getPathToRoot(initiallySelectedNode));

                    if (path!=null) {
                        View initiallySelectedManifestation = directoryArea.getSelectedManifestations().iterator().next()
                        initiallySelectedManifestation.getViewListener().actionPerformed(new TreeExpansionEvent(activeTree, path));
                    }

                }
               
                // Find the child that corresponds to our new component.
                for(int i=0; i< initiallySelectedNode.getChildCount(); i++) {
                    MCTMutableTreeNode childNode = (MCTMutableTreeNode) initiallySelectedNode.getChildAt(i);
                    if(childNode.getUserObject() instanceof View) {
                        View man = (View) childNode.getUserObject();
                        if (man.getManifestedComponent().getId().equalsIgnoreCase(newComponentId)) {
                            // Found the child that corresponds to our new component. Set it as selected.
                            directoryArea.setSelectedNode(childNode);
                            PropertyChangeEvent pce = new PropertyChangeEvent(man.getManifestedComponent());
                            pce.setProperty(PropertyChangeEvent.DISPLAY_NAME, PropertyChangeEvent.DISPLAY_NAME);
                            man.updateMonitoredGUI(pce);
                            break;
                        }
                    }           
                }
            }
View Full Code Here

                    ViewInfo nextViewInfo = nodeViews.iterator().next();
                   
                    // Children are only allowed if the component is not a leaf or the component is another users drop box
                    boolean allowsChildren =!childComponent.isLeaf();
                   
                    View childNodeView = nextViewInfo.createView(childComponent);
                    MCTMutableTreeNode childNode = new MCTMutableTreeNode(childNodeView, tree, allowsChildren);

                    if (allowsChildren){
                        MCTMutableTreeNode grandChildNode = new MCTMutableTreeNode(View.NULL_VIEW_MANIFESTATION, tree);
                        childNode.add(grandChildNode);
                        childNode.setProxy(true);
                    }
                    selectedNode.add(childNode);
                    childNodeView.addPropertyChangeListener(VIEW_STALE_PROPERTY, objectStaleListener);
                }
            }
            treeModel.reload(selectedNode);
           
            timer.stopInterval();
View Full Code Here

    private DefaultTreeModel model;

    @BeforeMethod
    public void setup() {
        MockitoAnnotations.initMocks(this);
        mockViewManifestation = new View() {
            private static final long serialVersionUID = -3939874904884082433L;
        };

        when(mockComponent.getDisplayName()).thenReturn("XXX");
        when(mockComponent.getExtendedDisplayName()).thenReturn("XXX");
        // Set up JTree for updateMonitoredGUI() calls
        rootNode = new MCTMutableTreeNode(new View() {
            private static final long serialVersionUID = 3318467817844246495L;
           
        });
        model = new DefaultTreeModel(rootNode);
        tree = new JTree(model);
View Full Code Here

      nodeViewManifestation.addMonitoredGUI(treeNode);     

        nodeViewManifestation.updateMonitoredGUI();
        for (int index = 0; index < mockComponent.getComponents().size(); index++) {
            String expected = mockComponent.getComponents().get(index).getComponentId();
            View   childView = (View) ((MCTMutableTreeNode) treeNode.getChildAt(index)).getUserObject();
            Assert.assertEquals(childView.getManifestedComponent().getComponentId(), expected);
        }

      Mockito.when(mockComponent.getComponents()).thenReturn(Arrays.asList(comp1, comp3, comp2));

        nodeViewManifestation.updateMonitoredGUI();
        for (int index = 0; index < mockComponent.getComponents().size(); index++) {
            String expected = mockComponent.getComponents().get(index).getComponentId();
            View   childView = (View) ((MCTMutableTreeNode) treeNode.getChildAt(index)).getUserObject();
            Assert.assertEquals(childView.getManifestedComponent().getComponentId(), expected);
        }
    }
View Full Code Here

    @Test
    public void testGetParentView() {
        MCTMutableTreeNode mockTreeNode = Mockito.mock(MCTMutableTreeNode.class);
        MCTMutableTreeNode mockParentNode = Mockito.mock(MCTMutableTreeNode.class);
        View mockView = Mockito.mock(View.class);
        Mockito.when(mockTreeNode.getParent()).thenReturn(mockParentNode);
        Mockito.when(mockParentNode.getUserObject()).thenReturn(mockView);
        nodeViewManifestation.addMonitoredGUI(mockTreeNode);
       
        // Should not matter whether or not node is a proxy
View Full Code Here

TOP

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

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.