Java Code Examples for org.openide.windows.TopComponent#open()

The following examples show how to use org.openide.windows.TopComponent#open() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MVInnerComponentGetLookupTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Setup component with lookup.
 */
@Override
protected void setUp () {
    final MVElemTopComponent elem1 = new MVElemTopComponent();
    final MVElemTopComponent elem2 = new MVElemTopComponent();
    final MVElemTopComponent elem3 = new MVElemTopComponent();
    desc1 = new MVDesc("desc1", null, 0, elem1);
    desc2 = new MVDesc("desc2", null, 0, elem2);
    desc3 = new MVDesc("desc3", null, 0, elem3);
    MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
    TopComponent mvtop = MultiViewFactory.createMultiView(descs, desc1);
    top = (TopComponent)elem1;
    get = top;
    top2 = (TopComponent)elem2;
    top3 = (TopComponent)elem3;
    lookup = mvtop.getLookup();
    mvtop.open();
    mvtop.requestActive();
    mvtc = mvtop;
}
 
Example 2
Source File: Open.java    From BART with MIT License 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent ev) {
    TopComponent tc = WindowManager.getDefault().findTopComponent(ViewResource.TOP_ID_DependencyViewTopComponent);
    if(tc != null) {
        if(tc.isOpened())  {
            tc.requestActive();
        }else{
            tc.open();
            tc.requestActive();
        }
    }   
      
}
 
Example 3
Source File: ViewManager.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
@Override
public TopComponent show(String name) {
    TopComponent tc = wm.findTopComponent(name);
    if (tc != null) {
        tc.open();
        tc.requestActive();
    }
    return tc;
}
 
Example 4
Source File: SplitAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static void splitWindow(TopComponent tc, int orientation, int splitLocation) {
if (tc instanceof Splitable) {
    TopComponent split = ((Splitable) tc).splitComponent(orientation, splitLocation);
    split.open();
    split.requestActive();
           split.invalidate();
           split.revalidate();
           split.repaint();
           split.requestFocusInWindow();
}
   }
 
Example 5
Source File: DebuggerHeapFragmentWalker.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static TopComponent openComponent (String viewName, boolean activate) {
    TopComponent view = WindowManager.getDefault().findTopComponent(viewName);
    if (view == null) {
        throw new IllegalArgumentException(viewName);
    }
    view.open();
    if (activate) {
        view.requestActive();
    }
    ((InstancesView) view).assureSubViewsVisible();
    return view;
}
 
Example 6
Source File: MultiViewElementTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testUpdateTitle() throws Exception {
    MVElem elem1 = new MVElem();
    MVElem elem2 = new MVElem();
    MVElem elem3 = new MVElem();
    MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
    MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
    MultiViewDescription desc3 = new MVDesc("desc3", null, 0, elem3);
    MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
    TopComponent tc = MultiViewFactory.createMultiView(descs, desc2);

    tc.open();
    assertEquals(null, tc.getDisplayName());
    
    
    elem2.observer.updateTitle("test1");
    assertEquals("test1", tc.getDisplayName());
    
    // switch to desc3 to initilize the element..
    MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);

    // test related hack, easy establishing a  connection from Desc->perspective
    handler.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
    
    elem3.observer.updateTitle("test2");
    assertEquals("test2", tc.getDisplayName());
    
}
 
Example 7
Source File: PerfWatchProjects.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void assertTextDocuments() throws Exception {
    closeTopComponents();
    Thread.sleep(2000);
            TopComponent tc = new TopComponent();
            tc.setLayout(new FlowLayout());
            tc.add(new JTextArea());
            tc.open();
            tc.requestVisible();
            tc.requestActive();
            String jVMversion = System.getProperty("java.specification.version");
            System.out.println("Java.specification.version="+jVMversion);
            if (!("1.8".equals(jVMversion))) {
                try {
                    System.out.println("Cleaning well known static fields");
                    cleanWellKnownStaticFields();
                } catch (Exception ex) {
                    throw new IllegalStateException(ex);
                }
            }
            System.setProperty("assertgc.paths", "0");
            try {
                Thread.sleep(4000);
            } catch (InterruptedException exc) {
                Exceptions.printStackTrace(exc);
            }
            try {
                Log.assertInstances("Are all documents GCed?", "TextDocument");
            } catch (AssertionFailedError afe) {
                throw afe;
            } finally {
                dumpHeap(null);
            }
}
 
Example 8
Source File: MultiViewActionMapTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testActionMapChanges() throws Exception {
    MVElemTopComponent elem1 = new MVElemTopComponent();
    MVElemTopComponent elem2 = new MVElemTopComponent();
    MVElem elem3 = new MVElem();
    MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
    MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
    MultiViewDescription desc3 = new MVDesc("desc3", null, 0, elem3);
    
    MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
    TopComponent tc = MultiViewFactory.createMultiView(descs, desc1);
    // WARNING: as anything else the first element's action map is set only after the tc is opened..
    Lookup.Result result = tc.getLookup().lookup(new Lookup.Template(ActionMap.class));
    LookListener list = new LookListener();
    list.resetCount();
    result.addLookupListener(list);
    result.allItems();
    
    tc.open();
    assertEquals(1, list.getCount());
    
    MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
    // test related hack, easy establishing a  connection from Desc->perspective
    Accessor.DEFAULT.createPerspective(desc2);
    handler.requestVisible(Accessor.DEFAULT.createPerspective(desc2));
    assertEquals(2, list.getCount());
    
    Accessor.DEFAULT.createPerspective(desc3);
    handler.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
    assertEquals(3, list.getCount());
}
 
Example 9
Source File: ShowListenersAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void performAction(Node[] activatedNodes) {
    for (Node n : activatedNodes) {
        JavaComponentInfo ci = n.getLookup().lookup(JavaComponentInfo.class);
        if (ci != null) {
            TopComponent tc = WindowManager.getDefault().findTopComponent("eventsView");
            if (tc == null) {
                throw new IllegalArgumentException("eventsView");
            }
            tc.open();
            tc.requestActive();
        }
    }
}
 
Example 10
Source File: MultiViewProcessorTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testMultiViewsCreate() {
       TopComponent mvc = MultiViews.createMultiView("text/figaro", new LP(Lookup.EMPTY));
       assertNotNull("MultiViewComponent created", mvc);
       mvc.open();
       mvc.requestActive();
       
       MultiViewHandler handler = MultiViews.findMultiViewHandler(mvc);
       assertNotNull("Handler found", handler);
       MultiViewPerspective[] arr = handler.getPerspectives();
       assertEquals("Two perspetives found", 2, arr.length);
       assertEquals("Figaro", arr[0].getDisplayName());
       assertEquals("Figaro", arr[1].getDisplayName());
MultiViewDescription description = Accessor.DEFAULT.extractDescription(arr[0]);
assertTrue(description instanceof ContextAwareDescription);
       assertFalse("First one is not for split", ((ContextAwareDescription)description).isSplitDescription());
description = Accessor.DEFAULT.extractDescription(arr[1]);
assertTrue(description instanceof ContextAwareDescription);
       assertTrue("Second one is for split", ((ContextAwareDescription)description).isSplitDescription());

       CloseH.retValue = true;
       MVE.closeState = MultiViewFactory.createUnsafeCloseState("warn", new AbstractAction() {

           @Override
           public void actionPerformed( ActionEvent e ) {
               MVE.closeState = null;
           }
       }, null);
       assertTrue("Closed OK", mvc.close());
       assertNotNull(CloseH.globalElements);
       assertEquals("One handle", 1, CloseH.globalElements.length);
       assertEquals("states are the same", MVE.closeState, CloseH.globalElements[0]);
   }
 
Example 11
Source File: ShowInDOMAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Activates the DOM Tree view.
 */
void activateDOMView() {
    TopComponent tc = WindowManager.getDefault().findTopComponent(DomTC.ID);
    tc.open();
    tc.requestActive();
}
 
Example 12
Source File: MultiViewElementTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testRequestVisible() throws Exception {
    MVElem elem1 = new MVElem();
    MVElem elem2 = new MVElem();
    MVElem elem3 = new MVElem();
    MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
    MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
    MultiViewDescription desc3 = new MVDesc("desc3", null, 0, elem3);
    
    MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2, desc3 };
    TopComponent tc = MultiViewFactory.createMultiView(descs, desc1);
    
    // NOT OPENED YET.
    assertEquals("",elem1.getLog());
    assertEquals("",elem2.getLog());
    
    tc.open();
    assertEquals("componentOpened-componentShowing-", elem1.getLog());
    assertEquals("",elem2.getLog());

    // initilize the elements..
    MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
    
    // test related hack, easy establishing a  connection from Desc->perspective
    Accessor.DEFAULT.createPerspective(desc2);
    handler.requestVisible(Accessor.DEFAULT.createPerspective(desc2));
    handler.requestVisible(Accessor.DEFAULT.createPerspective(desc3));
    handler.requestVisible(Accessor.DEFAULT.createPerspective(desc1));
    elem1.resetLog();
    elem2.resetLog();
    elem3.resetLog();
    
    elem2.doRequestVisible();
    assertEquals("componentHidden-", elem1.getLog());
    assertEquals("componentShowing-", elem2.getLog());
    assertEquals("", elem3.getLog());
    
    elem3.doRequestVisible();
    assertEquals("componentHidden-", elem1.getLog());
    assertEquals("componentShowing-componentHidden-", elem2.getLog());
    assertEquals("componentShowing-", elem3.getLog());
    
    elem1.doRequestVisible();
    assertEquals("componentShowing-componentHidden-", elem3.getLog());
    assertEquals("componentHidden-componentShowing-", elem1.getLog());
    
}
 
Example 13
Source File: ControlFlowAction.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
    TopComponent win = ControlFlowTopComponent.findInstance();
    win.open();
    win.requestActive();
}
 
Example 14
Source File: LoggerAction.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
   TopComponent win = LoggerTopComponent.findInstance();
   win.open();
   win.requestActive();
}
 
Example 15
Source File: OutlineAction.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
    TopComponent win = OutlineTopComponent.findInstance();
    win.open();
    win.requestActive();
}
 
Example 16
Source File: ControlFlowAction.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
    TopComponent win = ControlFlowTopComponent.findInstance();
    win.open();
    win.requestActive();
}
 
Example 17
Source File: FilterAction.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
    TopComponent win = FilterTopComponent.findInstance();
    win.open();
    win.requestActive();
}
 
Example 18
Source File: OutlineAction.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
    TopComponent win = OutlineTopComponent.findInstance();
    win.open();
    win.requestActive();
}
 
Example 19
Source File: ParametersAction.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
    TopComponent win = ParametersTopComponent.findInstance();
    win.open();
    win.requestActive();
}
 
Example 20
Source File: BytecodeViewAction.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
    TopComponent win = BytecodeViewTopComponent.findInstance();
    win.open();
    win.requestActive();
}