Search in sources :

Example 1 with TopComponentTracker

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

the class ResetWindowsAction method collectEditors.

private TopComponent[] collectEditors() {
    TopComponentTracker tcTracker = TopComponentTracker.getDefault();
    ArrayList<TopComponent> editors = new ArrayList<TopComponent>(TopComponent.getRegistry().getOpened().size());
    // collect from the main editor mode first
    ModeImpl editorMode = (ModeImpl) WindowManagerImpl.getInstance().findMode("editor");
    if (null != editorMode) {
        for (TopComponent tc : editorMode.getOpenedTopComponents()) {
            if (tcTracker.isViewTopComponent(tc))
                continue;
            editors.add(tc);
        }
    }
    for (ModeImpl m : WindowManagerImpl.getInstance().getModes()) {
        if ("editor".equals(m.getName()))
            continue;
        for (TopComponent tc : m.getOpenedTopComponents()) {
            if (tcTracker.isViewTopComponent(tc))
                continue;
            editors.add(tc);
        }
    }
    return editors.toArray(new TopComponent[editors.size()]);
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl) ArrayList(java.util.ArrayList) TopComponentTracker(org.netbeans.core.windows.TopComponentTracker) TopComponent(org.openide.windows.TopComponent)

Example 2 with TopComponentTracker

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

the class RecentViewListAction method getRecentWindows.

private static TopComponent[] getRecentWindows(boolean editors, boolean views) {
    WindowManagerImpl wm = WindowManagerImpl.getInstance();
    TopComponent[] documents = wm.getRecentViewList();
    TopComponentTracker tcTracker = TopComponentTracker.getDefault();
    List<TopComponent> docsList = new ArrayList<TopComponent>();
    for (int i = 0; i < documents.length; i++) {
        TopComponent tc = documents[i];
        if (tc == null) {
            continue;
        }
        ModeImpl mode = (ModeImpl) wm.findMode(tc);
        if (mode == null) {
            continue;
        }
        if ((editors && tcTracker.isEditorTopComponent(tc)) || (views && tcTracker.isViewTopComponent(tc))) {
            docsList.add(tc);
        }
    }
    return docsList.toArray(new TopComponent[0]);
}
Also used : WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) ModeImpl(org.netbeans.core.windows.ModeImpl) ArrayList(java.util.ArrayList) TopComponentTracker(org.netbeans.core.windows.TopComponentTracker) TopComponent(org.openide.windows.TopComponent)

Example 3 with TopComponentTracker

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

the class DocumentsDlg method getOpenedDocuments.

private static List<TopComponent> getOpenedDocuments() {
    WindowManagerImpl wm = WindowManagerImpl.getInstance();
    TopComponent[] recentDocuments = wm.getRecentViewList();
    List<TopComponent> documents = new ArrayList<TopComponent>(recentDocuments.length);
    TopComponentTracker tcTracker = TopComponentTracker.getDefault();
    for (TopComponent tc : recentDocuments) {
        if (tcTracker.isEditorTopComponent(tc)) {
            documents.add(tc);
        }
    }
    return documents;
}
Also used : WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) ArrayList(java.util.ArrayList) TopComponentTracker(org.netbeans.core.windows.TopComponentTracker) TopComponent(org.openide.windows.TopComponent)

Aggregations

ArrayList (java.util.ArrayList)3 TopComponentTracker (org.netbeans.core.windows.TopComponentTracker)3 TopComponent (org.openide.windows.TopComponent)3 ModeImpl (org.netbeans.core.windows.ModeImpl)2 WindowManagerImpl (org.netbeans.core.windows.WindowManagerImpl)2