Java Code Examples for org.openide.windows.WindowManager#findMode()

The following examples show how to use org.openide.windows.WindowManager#findMode() . 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: MonitorAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void openTransactionView() {

	TransactionView tv = TransactionView.getInstance(); 
        WindowManager wm = WindowManager.getDefault();
	Mode mode = wm.findMode(tv);
        
        if(mode == null) {
            mode = wm.findMode("output"); // NOI18N
            if(mode != null) {
                mode.dockInto(tv);
            }
        }
	tv.open();
        tv.requestVisible();
        tv.requestActive();        
    }
 
Example 2
Source File: LaoutPreviewTopComponent.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
static void showLaoutPreview(JPanel panel, String name) {
    WindowManager wm = WindowManager.getDefault();
    TopComponent topComponent = wm.findTopComponent("LaoutPreviewTopComponent"); // NOI18N
    if (topComponent == null) {
        topComponent = new LaoutPreviewTopComponent();
    }
    if (topComponent instanceof LaoutPreviewTopComponent) {
        if (!topComponent.isOpened()) {
            Mode mode = wm.findMode("commonpalette");
            if (mode != null) {
                mode.dockInto(topComponent);
            }
            topComponent.removeAll();
            if (panel != null) {
                topComponent.add(panel);
            }
            topComponent.updateUI();
            topComponent.setName("Laout Preview [" + name + "]");
            topComponent.setToolTipText("Laout Preview [" + name + "]");
            topComponent.open();
        }
    }

}
 
Example 3
Source File: TopComponentCreationTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Test saving of TopComponent with persistence type
 * TopComponent.PERSISTENCE_ALWAYS.
 */
public void testSavePersistentTopComponent () throws Exception {
    WindowManager wm = WindowManager.getDefault();
    
    Mode m = wm.findMode("explorer");
    assertNotNull("Mode explorer must be present", m);
    
    TopComponent tc = Component00.getDefault();
    m.dockInto(tc);
    tc.open();
    
    String res = "Windows2Local/Modes/explorer/"
    + wm.findTopComponentID(tc) + ".wstcref";
    //Check that persistent, opened TC is saved ie. wstcref file is created
    PersistenceHandler.getDefault().save();
    //Check wstcref file was created
    assertNotNull(FileUtil.getConfigFile(res));
    deleteLocalData();
    //Check wstcref file was deleted
    assertNull(FileUtil.getConfigFile(res));
    
    //Check that persistent, closed TC is saved ie. wstcref file is created
    tc.close();
    PersistenceHandler.getDefault().save();        
    //Check wstcref file was created
    assertNotNull(FileUtil.getConfigFile(res));
    deleteLocalData();
    //Check wstcref file was deleted
    assertNull(FileUtil.getConfigFile(res));
}
 
Example 4
Source File: TopComponentCreationTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Test saving of TopComponent with persistence type
 * TopComponent.PERSISTENCE_ONLY_OPENED.
 */
public void testSavePersistentOnlyOpenedTopComponent () throws Exception {
    WindowManager wm = WindowManager.getDefault();
    
    Mode m = wm.findMode("explorer");
    assertNotNull("Mode explorer must be present", m);
    
    TopComponent tc = new Component01();
    m.dockInto(tc);
    tc.open();
    
    String res = "Windows2Local/Modes/explorer/"
    + wm.findTopComponentID(tc) + ".wstcref";
    
    //Check that persistent only opened, opened TC is saved ie. wstcref file is created
    PersistenceHandler.getDefault().save();
    //Check wstcref file was created
    assertNotNull(FileUtil.getConfigFile(res));
    deleteLocalData();
    //Check wstcref file was deleted
    assertNull(FileUtil.getConfigFile(res));
    
    //Check that persistent only opened, closed TC is NOT saved ie. wstcref file is NOT created
    tc.close();
    PersistenceHandler.getDefault().save();        
    //Check wstcref file was not created
    assertNull(FileUtil.getConfigFile(res));
    deleteLocalData();
}
 
Example 5
Source File: TopComponentCreationTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Test saving of TopComponent with persistence type
 * TopComponent.PERSISTENCE_NEVER.
 */
public void testSavePersistentNeverTopComponent () throws Exception {
    WindowManager wm = WindowManager.getDefault();
    
    Mode m = wm.findMode("explorer");
    assertNotNull("Mode explorer must be present", m);
    
    TopComponent tc = new Component02();
    m.dockInto(tc);
    tc.open();
    
    String res = "Windows2Local/Modes/explorer/"
    + wm.findTopComponentID(tc) + ".wstcref";
    
    //Check that non persistent, opened TC is NOT saved ie. wstcref file is NOT created
    PersistenceHandler.getDefault().save();
    //Check wstcref file was not created
    assertNull(FileUtil.getConfigFile(res));
    deleteLocalData();
    
    //Check that non persistent, closed TC is NOT saved ie. wstcref file is NOT created
    tc.close();
    PersistenceHandler.getDefault().save();        
    //Check wstcref file was not created
    assertNull(FileUtil.getConfigFile(res));
    deleteLocalData();
}
 
Example 6
Source File: ProfilerWindow.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void open() {
    WindowManager windowManager = WindowManager.getDefault();
    if (windowManager.findMode(this) == null) { // needs docking
        Mode mode = windowManager.findMode(Bundle.ProfilerWindow_mode());
        if (mode != null) mode.dockInto(this);
    }
    super.open();
}
 
Example 7
Source File: SnapshotsWindowUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void open() {
    WindowManager wmanager = WindowManager.getDefault();
    if (wmanager.findMode(this) == null) { // needs docking
        Mode _mode = wmanager.findMode(Bundle.SnapshotsWindowUI_mode());
        if (_mode != null) _mode.dockInto(this);
    }
    super.open();
}
 
Example 8
Source File: DeveloperHtmlBrowserComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void open() {
    WindowManager wm = WindowManager.getDefault();
    Mode mode = wm.findMode( this );
    if( null == mode && !Boolean.getBoolean("webpreview.document") ) { //NOI18N
        mode = wm.findMode("webpreview"); //NOI18N
        if( null != mode ) {
            mode.dockInto( this );
        }
    }
    super.open();
}
 
Example 9
Source File: ProfilerWindow.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void open() {
    WindowManager windowManager = WindowManager.getDefault();
    if (windowManager.findMode(this) == null) { // needs docking
        Mode mode = windowManager.findMode(Bundle.ProfilerWindow_mode());
        if (mode != null) mode.dockInto(this);
    }
    super.open();
}
 
Example 10
Source File: SnapshotsWindowUI.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void open() {
    WindowManager wmanager = WindowManager.getDefault();
    if (wmanager.findMode(this) == null) { // needs docking
        Mode _mode = wmanager.findMode(Bundle.SnapshotsWindowUI_mode());
        if (_mode != null) _mode.dockInto(this);
    }
    super.open();
}
 
Example 11
Source File: WindowManagerModeTest.java    From netbeans with Apache License 2.0 3 votes vote down vote up
public void testGetEditorModeXml() {

        WindowManager wm = WindowManager.getDefault();
        assertNotNull(wm);

        Mode mode = wm.findMode("editor");

        String xml = ModeUtilities.toXml(mode);
        assertNotNull("editor Mode XML should not be null", xml);

    }