Search in sources :

Example 1 with WindowManagerImpl

use of org.netbeans.core.windows.WindowManagerImpl in project netbeans-rcp-lite by outersky.

the class DocumentsDlg method activate.

// GEN-LAST:event_closeDocuments
private void activate(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_activate
    // Add your handling code here:
    Node[] selNodes = explorer.getSelectedNodes();
    if (selNodes.length == 0) {
        return;
    }
    closeDialog();
    final TopComponent tc = ((TopComponentNode) selNodes[0]).getTopComponent();
    // Call using invokeLater to make sure it is performed after dialog
    // is closed.
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            // #37226-41075 Unmaximized the other mode if needed.
            WindowManagerImpl wm = WindowManagerImpl.getInstance();
            ModeImpl mode = (ModeImpl) wm.findMode(tc);
            if (mode != null && mode != wm.getCurrentMaximizedMode()) {
                wm.switchMaximizedMode(null);
            }
            tc.requestActive();
        }
    });
}
Also used : WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) Node(org.openide.nodes.Node) AbstractNode(org.openide.nodes.AbstractNode) ModeImpl(org.netbeans.core.windows.ModeImpl) TopComponent(org.openide.windows.TopComponent)

Example 2 with WindowManagerImpl

use of org.netbeans.core.windows.WindowManagerImpl in project netbeans-rcp-lite by outersky.

the class SlideBar method getRestoreModeNameForTab.

private String getRestoreModeNameForTab(TabData tab) {
    Component c = tab.getComponent();
    if (c instanceof TopComponent) {
        WindowManagerImpl wm = WindowManagerImpl.getInstance();
        String tcId = wm.findTopComponentID((TopComponent) c);
        if (null != tcId) {
            Mode prevMode = wm.getPreviousModeForTopComponent(tcId, tabbed.getSlidingMode());
            if (null != prevMode)
                return prevMode.getName();
        }
    }
    return null;
}
Also used : WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) Mode(org.openide.windows.Mode) TopComponent(org.openide.windows.TopComponent) TopComponent(org.openide.windows.TopComponent)

Example 3 with WindowManagerImpl

use of org.netbeans.core.windows.WindowManagerImpl in project netbeans-rcp-lite by outersky.

the class SlideBar method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (e instanceof TabActionEvent) {
        TabActionEvent tae = (TabActionEvent) e;
        if (TabbedContainer.COMMAND_RESTORE_GROUP.equals(tae.getActionCommand())) {
            String nameOfModeToRestore = tae.getGroupName();
            WindowManagerImpl wm = WindowManagerImpl.getInstance();
            ModeImpl modeToRestore = (ModeImpl) wm.findMode(nameOfModeToRestore);
            if (null != modeToRestore) {
                wm.userRestoredMode(tabbed.getSlidingMode(), modeToRestore);
            }
        }
    }
}
Also used : TabActionEvent(org.netbeans.swing.tabcontrol.event.TabActionEvent) WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) ModeImpl(org.netbeans.core.windows.ModeImpl)

Example 4 with WindowManagerImpl

use of org.netbeans.core.windows.WindowManagerImpl in project netbeans-rcp-lite by outersky.

the class GroupsManager method closeGroup.

boolean closeGroup(DocumentGroupImpl group) {
    // NOI18N
    TopComponent welcomeTc = WindowManager.getDefault().findTopComponent("Welcome");
    boolean welcomeWasOpened = null != welcomeTc && welcomeTc.isOpened();
    // save the window system first
    Lookup.getDefault().lookup(WindowSystem.class).save();
    // collect documents
    WindowManagerImpl wmi = WindowManagerImpl.getInstance();
    ArrayList<TopComponent> documents = new ArrayList<>(TopComponent.getRegistry().getOpened().size());
    for (TopComponent tc : TopComponent.getRegistry().getOpened()) {
        if (wmi.isEditorTopComponent(tc)) {
            documents.add(tc);
        }
    }
    String name = group.getName();
    File userDir = Places.getUserDirectory();
    // NOI18N
    File root = new File(new File(userDir, "config"), DOCUMENT_GROUPS);
    File groupDir = new File(root, name);
    // remove old data (if any)
    deleteAll(groupDir);
    groupDir.mkdirs();
    FileObject groupFO = FileUtil.toFileObject(groupDir);
    Preferences prefs = getPreferences().node(name);
    try {
        prefs.clear();
    } catch (BackingStoreException ex) {
        LOG.log(Level.INFO, null, ex);
    }
    prefs.put(DISPLAY_NAME, group.toString());
    File configRoot = new File(new File(Places.getUserDirectory(), CONFIG), WINDOWS2_LOCAL);
    File modesRoot = new File(configRoot, MODES);
    for (ModeImpl mode : wmi.getModes()) {
        if (mode.getKind() == Constants.MODE_KIND_EDITOR) {
            String modeName = mode.getName();
            // NOI18N //NOI18N
            FileObject modeFO = FileUtil.toFileObject(new File(modesRoot, modeName + "." + WSMODE));
            if (null == modeFO) {
                continue;
            }
            try {
                modeFO.copy(groupFO, modeName, WSMODE);
            } catch (IOException ex) {
                LOG.log(Level.INFO, null, ex);
                continue;
            }
            StringBuilder sb = new StringBuilder();
            for (String id : mode.getOpenedTopComponentsIDs()) {
                sb.append(id);
                sb.append(ID_SEPARATOR);
            }
            prefs.put(modeName, sb.toString());
        }
    }
    // copy TopComponents
    File componentRoot = new File(configRoot, COMPONENTS);
    for (TopComponent tc : documents) {
        String id = wmi.findTopComponentID(tc);
        if (tc.equals(welcomeTc) && !welcomeWasOpened)
            continue;
        if (tc.getPersistenceType() == TopComponent.PERSISTENCE_NEVER) {
            continue;
        }
        // NOI18N //NOI18N
        FileObject tcFO = FileUtil.toFileObject(new File(componentRoot, id + "." + SETTINGS));
        if (tcFO == null) {
            continue;
        }
        try {
            tcFO.copy(groupFO, id, SETTINGS);
        } catch (IOException ex) {
            LOG.log(Level.INFO, null, ex);
        }
    }
    // TODO save recent view list
    // NOI18N
    getPreferences().put(SEL_GROUP, "");
    return true;
}
Also used : WindowSystem(org.netbeans.core.WindowSystem) WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) ModeImpl(org.netbeans.core.windows.ModeImpl) ArrayList(java.util.ArrayList) BackingStoreException(java.util.prefs.BackingStoreException) IOException(java.io.IOException) FileObject(org.openide.filesystems.FileObject) Preferences(java.util.prefs.Preferences) NbPreferences(org.openide.util.NbPreferences) File(java.io.File) TopComponent(org.openide.windows.TopComponent)

Example 5 with WindowManagerImpl

use of org.netbeans.core.windows.WindowManagerImpl in project netbeans-rcp-lite by outersky.

the class SwitchRoleKeepDocumentsAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    String role = e.getActionCommand();
    WindowManagerImpl wm = WindowManagerImpl.getInstance();
    wm.setRole(role, true);
}
Also used : WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl)

Aggregations

WindowManagerImpl (org.netbeans.core.windows.WindowManagerImpl)27 ModeImpl (org.netbeans.core.windows.ModeImpl)22 TopComponent (org.openide.windows.TopComponent)22 ArrayList (java.util.ArrayList)5 IOException (java.io.IOException)3 FileObject (org.openide.filesystems.FileObject)3 Rectangle (java.awt.Rectangle)2 File (java.io.File)2 HashMap (java.util.HashMap)2 BackingStoreException (java.util.prefs.BackingStoreException)2 Preferences (java.util.prefs.Preferences)2 WindowSystem (org.netbeans.core.WindowSystem)2 TopComponentTracker (org.netbeans.core.windows.TopComponentTracker)2 TabActionEvent (org.netbeans.swing.tabcontrol.event.TabActionEvent)2 NbPreferences (org.openide.util.NbPreferences)2 Frame (java.awt.Frame)1 JFrame (javax.swing.JFrame)1 KeyStroke (javax.swing.KeyStroke)1 RegistryImpl (org.netbeans.core.windows.RegistryImpl)1 TopComponentGroupImpl (org.netbeans.core.windows.TopComponentGroupImpl)1