Search in sources :

Example 51 with ModeImpl

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

the class MoveWindowWithinModeAction method updateEnabled.

private void updateEnabled() {
    if (null == tc) {
        return;
    }
    ModeImpl mode = (ModeImpl) WindowManagerImpl.getInstance().findMode(tc);
    if (null == mode)
        return;
    int position = mode.getTopComponentTabPosition(tc);
    if (0 == position && moveLeft) {
        setEnabled(false);
        return;
    }
    if (position == mode.getOpenedTopComponents().size() - 1 && !moveLeft) {
        setEnabled(false);
        return;
    }
    if (EditorOnlyDisplayer.getInstance().isActive()) {
        setEnabled(false);
        return;
    }
    setEnabled(true);
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl)

Example 52 with ModeImpl

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

the class RecentViewListAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent evt) {
    boolean editors = true;
    boolean views = !documentsOnly;
    if ("immediately".equals(evt.getActionCommand())) {
        TopComponent activeTc = TopComponent.getRegistry().getActivated();
        if (null != activeTc) {
            if (TopComponentTracker.getDefault().isEditorTopComponent(activeTc)) {
                // switching in a document, go to some other document
                views = false;
            } else {
                // switching in a view, go to some other view
                editors = false;
                views = true;
            }
        }
    }
    TopComponent[] documents = getRecentWindows(editors, views);
    if (documents.length < 2) {
        return;
    }
    if (// NOI18N
    !"immediately".equals(evt.getActionCommand()) && !(evt.getSource() instanceof javax.swing.JMenuItem)) {
        // #46800: fetch key directly from action command
        KeyStroke keyStroke = Utilities.stringToKey(evt.getActionCommand());
        if (keyStroke != null) {
            int triggerKey = keyStroke.getKeyCode();
            int reverseKey = KeyEvent.VK_SHIFT;
            int releaseKey = 0;
            int modifiers = keyStroke.getModifiers();
            if ((InputEvent.CTRL_MASK & modifiers) != 0) {
                releaseKey = KeyEvent.VK_CONTROL;
            } else if ((InputEvent.ALT_MASK & modifiers) != 0) {
                releaseKey = KeyEvent.VK_ALT;
            } else if ((InputEvent.META_MASK & modifiers) != 0) {
                releaseKey = KeyEvent.VK_META;
            }
            if (releaseKey != 0) {
                if (!KeyboardPopupSwitcher.isShown()) {
                    KeyboardPopupSwitcher.showPopup(documentsOnly, releaseKey, triggerKey, (evt.getModifiers() & KeyEvent.SHIFT_MASK) == 0);
                }
                return;
            }
        }
    }
    int documentIndex = (evt.getModifiers() & KeyEvent.SHIFT_MASK) == 0 ? 1 : documents.length - 1;
    TopComponent tc = documents[documentIndex];
    // #37226 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) ModeImpl(org.netbeans.core.windows.ModeImpl) KeyStroke(javax.swing.KeyStroke) TopComponent(org.openide.windows.TopComponent)

Example 53 with ModeImpl

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

the class CloneDocumentAction method actionPerformed.

/**
 * Perform the action. Sets/unsets maximzed mode.
 */
@Override
public void actionPerformed(java.awt.event.ActionEvent ev) {
    TopComponent tc = TopComponent.getRegistry().getActivated();
    if (tc == null || !(tc instanceof TopComponent.Cloneable)) {
        return;
    }
    ModeImpl mode = (ModeImpl) WindowManagerImpl.getInstance().findMode(tc);
    if (mode == null) {
        return;
    }
    if (mode.getKind() == Constants.MODE_KIND_EDITOR) {
        ActionUtils.cloneWindow(tc);
    }
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl) TopComponent(org.openide.windows.TopComponent)

Example 54 with ModeImpl

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

the class CloneDocumentAction method updateEnabled.

private void updateEnabled() {
    TopComponent tc = TopComponent.getRegistry().getActivated();
    if (tc != null) {
        ModeImpl mode = (ModeImpl) WindowManagerImpl.getInstance().findMode(tc);
        setEnabled(tc instanceof TopComponent.Cloneable && mode != null && mode.getKind() == Constants.MODE_KIND_EDITOR);
    }
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl) TopComponent(org.openide.windows.TopComponent)

Example 55 with ModeImpl

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

the class DockModeAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    WindowManagerImpl wmi = WindowManagerImpl.getInstance();
    ModeImpl contextMode = getMode2WorkWith();
    if (null == contextMode)
        // just being paranoid
        return;
    if (null != slidingMode) {
        WindowManagerImpl.getInstance().userRestoredMode(slidingMode, contextMode);
    } else {
        boolean isDocked = contextMode.getState() == Constants.MODE_STATE_JOINED;
        if (!isDocked) {
            wmi.userDockedMode(contextMode);
        }
    }
}
Also used : WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) 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