Java Code Examples for org.openide.windows.Mode#dockInto()

The following examples show how to use org.openide.windows.Mode#dockInto() . 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: NewWorkspaceAction.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    String defaultName = WindowUtilities.getUniqueTitle(Bundle.VAL_NewWorkspaceActionValue(),
                                                        WorkspaceTopComponent.class);
    NotifyDescriptor.InputLine d = new NotifyDescriptor.InputLine(Bundle.LBL_NewWorkspaceActionName(),
                                                                  Bundle.CTL_NewWorkspaceActionName());
    d.setInputText(defaultName);
    Object result = DialogDisplayer.getDefault().notify(d);
    if (NotifyDescriptor.OK_OPTION.equals(result)) {
        WorkspaceTopComponent workspaceTopComponent = new WorkspaceTopComponent(d.getInputText());
        Mode editor = WindowManager.getDefault().findMode("editor");
        Assert.notNull(editor, "editor");
        editor.dockInto(workspaceTopComponent);
        workspaceTopComponent.open();
        workspaceTopComponent.requestActive();
    }
}
 
Example 2
Source File: AnalysisResultTopComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static synchronized AnalysisResultTopComponent findInstance() {
    TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID);
    if (win instanceof AnalysisResultTopComponent) {
        return (AnalysisResultTopComponent) win;
    }
    if (win == null) {
        Logger.getLogger(AnalysisResultTopComponent.class.getName()).warning(
                "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system.");
    } else {
        Logger.getLogger(AnalysisResultTopComponent.class.getName()).warning(
                "There seem to be multiple components with the '" + PREFERRED_ID +
                "' ID. That is a potential source of errors and unexpected behavior.");
    }
    
    AnalysisResultTopComponent result = new AnalysisResultTopComponent();
    Mode outputMode = WindowManager.getDefault().findMode("output");
    
    if (outputMode != null) {
        outputMode.dockInto(result);
    }
    return result;
}
 
Example 3
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 4
Source File: TileUtilities.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Opens a top component in the given mode.
 *
 * @param topComponent The top component to open.
 * @param modeName     The mode's name.
 * @return {@code true} on success.
 */
public static boolean openInMode(TopComponent topComponent, String modeName) {
    Mode mode = WindowManager.getDefault().findMode(modeName);
    if (mode != null) {
        if (!Arrays.asList(mode.getTopComponents()).contains(topComponent)) {
            if (mode.dockInto(topComponent)) {
                topComponent.open();
                return true;
            }
        } else {
            topComponent.open();
            return true;
        }
    }
    return false;
}
 
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: 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 7
Source File: ProfilingPointsWindow.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void open() {
    if (needsDocking()) { // needs docking

        Mode mode = WindowManager.getDefault().findMode(Bundle.ProfilingPointsWindow_WindowMode());
        if (mode != null) {
            mode.dockInto(this);
        }
    }

    super.open();
}
 
Example 8
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 9
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 10
Source File: VerifierSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Shows the TC in the output mode and activates it.
 */
public void showInMode() {
    if (!isOpened()) {
        Mode mode = WindowManager.getDefault().findMode("output"); // NOI18N
        if (mode != null) {
            mode.dockInto(this);
        }
    }
    open();
    requestVisible();
    requestActive();
}
 
Example 11
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 12
Source File: VerifierSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Shows the TC in the output mode and activates it.
 */
public void showInMode() {
    if (!isOpened()) {
        Mode mode = WindowManager.getDefault().findMode("output"); // NOI18N
        if (mode != null) {
            mode.dockInto(this);
        }
    }
    open();
    requestVisible();
    requestActive();
}
 
Example 13
Source File: PaletteSwitchTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initEditorTopComponent( TopComponent tc ) throws IOException {
    Mode editorMode = WindowManagerImpl.getInstance().findMode( "unitTestEditorMode" );
    if( null == editorMode ) {
        editorMode = WindowManagerImpl.getInstance().createMode( "unitTestEditorMode", Constants.MODE_KIND_EDITOR, Constants.MODE_STATE_JOINED, false, new SplitConstraint[0] );
    }
    editorMode.dockInto(tc);
}
 
Example 14
Source File: WorkspaceTopComponent.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private TopComponent dockInternalFrame(JInternalFrame internalFrame) {
    TopComponent topComponent = closeInternalFrame(internalFrame, true);

    Mode mode = WindowManager.getDefault().findMode("editor");
    mode.dockInto(topComponent);
    if (!topComponent.isOpened()) {
        topComponent.open();
    }

    return topComponent;
}
 
Example 15
Source File: FormEditorSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected CloneableEditorSupport.Pane createPane() {
    if (!formDataObject.isValid()) {
        return super.createPane(); // Issue 110249
    } 
    
    CloneableTopComponent mvtc = MultiViews.createCloneableMultiView("text/x-form", getDataObject());
    
    // #45665 - dock into editor mode if possible..
    Mode editorMode = WindowManager.getDefault().findMode(CloneableEditorSupport.EDITOR_MODE);
    if (editorMode != null) {
        editorMode.dockInto(mvtc);
    }
    return (CloneableEditorSupport.Pane)mvtc;
}
 
Example 16
Source File: ExplorerTopComponent.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public void open() {
    if (needsDocking()) {
        Mode mode = WindowManager.getDefault().findMode("explorer"); // NOI18N
        if (mode != null) mode.dockInto(this);
    }
    super.open();
}
 
Example 17
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 18
Source File: DocumentWindowManager.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Opens a document window.
 * <p>
 * Document windows are initially opened in the NetBeans {@code "editor"} mode which
 * is the central panel of the main frame.
 *
 * @param documentWindow The document window to be opened.
 * @return {@code true} on success
 */
public boolean openWindow(DocumentWindow documentWindow) {
    TopComponent topComponent = documentWindow.getTopComponent();
    WorkspaceTopComponent workspaceTopComponent = WorkspaceTopComponent.findShowingInstance();
    if (workspaceTopComponent != null) {
        workspaceTopComponent.addTopComponent(topComponent);
        return true;
    }
    Mode editor = WindowManager.getDefault().findMode("editor");
    if (editor.dockInto(topComponent)) {
        topComponent.open();
        return true;
    }
    return false;
}
 
Example 19
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 20
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();
}