Search in sources :

Example 26 with ModeImpl

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

the class MoveWindowWithinModeAction method actionPerformed.

@Override
public void actionPerformed(java.awt.event.ActionEvent ev) {
    if (EditorOnlyDisplayer.getInstance().isActive()) {
        return;
    }
    TopComponent contextTc = null == tc ? TopComponent.getRegistry().getActivated() : tc;
    if (null == contextTc)
        return;
    ModeImpl mode = (ModeImpl) WindowManagerImpl.getInstance().findMode(contextTc);
    if (null == mode)
        return;
    int position = mode.getTopComponentTabPosition(contextTc);
    if (moveLeft)
        position--;
    else
        position++;
    if (position >= 0 && position < mode.getOpenedTopComponents().size())
        mode.addOpenedTopComponent(contextTc, position);
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl) TopComponent(org.openide.windows.TopComponent)

Example 27 with ModeImpl

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

the class NextTabAction method actionPerformed.

public void actionPerformed(ActionEvent evt) {
    TopComponent tc = TopComponent.getRegistry().getActivated();
    if (tc == null) {
        return;
    }
    ModeImpl mode = (ModeImpl) WindowManagerImpl.getInstance().findMode(tc);
    List openedTcs = mode.getOpenedTopComponents();
    int index = openedTcs.indexOf(tc);
    if (index == -1) {
        return;
    }
    // Next tab.
    index++;
    if (index >= openedTcs.size()) {
        index = 0;
    }
    TopComponent select = (TopComponent) openedTcs.get(index);
    if (select == null) {
        return;
    }
    mode.setSelectedTopComponent(select);
    select.requestActive();
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl) List(java.util.List) TopComponent(org.openide.windows.TopComponent)

Example 28 with ModeImpl

use of org.netbeans.core.windows.ModeImpl 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 29 with ModeImpl

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

the class CloseAllDocumentsAction method isEnabled.

@Override
public boolean isEnabled() {
    if (!Switches.isEditorTopComponentClosingEnabled())
        return false;
    WindowManagerImpl wmi = WindowManagerImpl.getInstance();
    if (isContext) {
        TopComponent activeTC = TopComponent.getRegistry().getActivated();
        ModeImpl mode = (ModeImpl) wmi.findMode(activeTC);
        return mode != null && mode.getKind() == Constants.MODE_KIND_EDITOR && !mode.getOpenedTopComponents().isEmpty();
    } else {
        return wmi.getEditorTopComponents().length > 0;
    }
}
Also used : WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) ModeImpl(org.netbeans.core.windows.ModeImpl) TopComponent(org.openide.windows.TopComponent)

Example 30 with ModeImpl

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

the class DockModeAction method isEnabled.

@Override
public boolean isEnabled() {
    ModeImpl contextMode = getMode2WorkWith();
    if (null == contextMode)
        return false;
    if (null != slidingMode)
        return true;
    boolean docked = contextMode.getState() == Constants.MODE_STATE_JOINED;
    if (docked)
        return false;
    if (contextMode.getKind() == Constants.MODE_KIND_EDITOR)
        return Switches.isEditorModeUndockingEnabled();
    return contextMode.getKind() == Constants.MODE_KIND_VIEW && Switches.isViewModeUndockingEnabled();
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl)

Aggregations

ModeImpl (org.netbeans.core.windows.ModeImpl)60 TopComponent (org.openide.windows.TopComponent)35 WindowManagerImpl (org.netbeans.core.windows.WindowManagerImpl)22 ArrayList (java.util.ArrayList)5 IOException (java.io.IOException)3 List (java.util.List)3 FileObject (org.openide.filesystems.FileObject)3 Component (java.awt.Component)2 File (java.io.File)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 BackingStoreException (java.util.prefs.BackingStoreException)2 Preferences (java.util.prefs.Preferences)2 WindowSystem (org.netbeans.core.WindowSystem)2 ModeStructureSnapshot (org.netbeans.core.windows.ModeStructureSnapshot)2 TopComponentTracker (org.netbeans.core.windows.TopComponentTracker)2 MultiSplitPane (org.netbeans.core.windows.view.ui.MultiSplitPane)2 TabActionEvent (org.netbeans.swing.tabcontrol.event.TabActionEvent)2 NbPreferences (org.openide.util.NbPreferences)2