Search in sources :

Example 56 with ModeImpl

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

the class MaximizeWindowAction method doUpdateState.

/**
 * Updates state and text of this action.
 */
private void doUpdateState() {
    WindowManagerImpl wm = WindowManagerImpl.getInstance();
    TopComponent active = getTCToWorkWith();
    boolean maximize;
    ModeImpl activeMode = (ModeImpl) wm.findMode(active);
    if (activeMode == null || !Switches.isTopComponentMaximizationEnabled() || !Switches.isMaximizationEnabled(active) || (!wm.isDocked(active) && !wm.isEditorMode(activeMode))) {
        getMenuPresenter().setSelected(false);
        getPopupPresenter().setSelected(false);
        setEnabled(false);
        return;
    }
    if (wm.isDocked(active)) {
        maximize = wm.getCurrentMaximizedMode() != activeMode;
    } else {
        maximize = activeMode.getFrameState() == Frame.NORMAL;
    }
    if (activeMode != null && activeMode.getKind() == Constants.MODE_KIND_SLIDING) {
        maximize = null != active && !wm.isTopComponentMaximizedWhenSlidedIn(wm.findTopComponentID(active));
    }
    state = !maximize;
    getMenuPresenter().setSelected(state);
    getPopupPresenter().setSelected(state);
    setEnabled(activeMode != null);
}
Also used : WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) ModeImpl(org.netbeans.core.windows.ModeImpl) TopComponent(org.openide.windows.TopComponent)

Example 57 with ModeImpl

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

the class MoveWindowAction method updateEnabled.

private void updateEnabled() {
    TopComponent contextTc = getTCToWorkWith();
    if (null == contextTc) {
        setEnabled(false);
        return;
    }
    ModeImpl mode = (ModeImpl) WindowManagerImpl.getInstance().findMode(contextTc);
    if (null == mode || // || mode.getKind() == Constants.MODE_KIND_EDITOR
    WindowManagerImpl.getInstance().getCurrentMaximizedMode() != null) {
        setEnabled(false);
        return;
    }
    setEnabled(true);
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl) TopComponent(org.openide.windows.TopComponent)

Example 58 with ModeImpl

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

the class NewTabGroupAction method isEnabled.

@Override
public boolean isEnabled() {
    TopComponent context = getTC2WorkWith();
    boolean res = null != context;
    if (res) {
        WindowManagerImpl wm = WindowManagerImpl.getInstance();
        ModeImpl mode = (ModeImpl) wm.findMode(context);
        res &= null != mode;
        if (res) {
            res &= mode.getKind() == Constants.MODE_KIND_EDITOR;
            res &= mode.getOpenedTopComponents().size() > 1;
            res &= wm.isDocked(context);
        }
    }
    return res;
}
Also used : WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) ModeImpl(org.netbeans.core.windows.ModeImpl) TopComponent(org.openide.windows.TopComponent)

Example 59 with ModeImpl

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

the class NewTabGroupAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    // contextTC shound never be null thanks to isEnabled impl
    WindowManagerImpl wmi = WindowManagerImpl.getInstance();
    TopComponent contextTC = getTC2WorkWith();
    if (null == contextTC)
        // just being paranoid
        return;
    ModeImpl currentMode = (ModeImpl) wmi.findMode(contextTC);
    if (null == currentMode || currentMode.getKind() != Constants.MODE_KIND_EDITOR || !wmi.isDocked(contextTC))
        return;
    wmi.newTabGroup(contextTC);
}
Also used : WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) ModeImpl(org.netbeans.core.windows.ModeImpl) TopComponent(org.openide.windows.TopComponent)

Example 60 with ModeImpl

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

the class ModesSubModel method createSlidingModeSnapshots.

public Set<ModeStructureSnapshot.SlidingModeSnapshot> createSlidingModeSnapshots() {
    Set<ModeStructureSnapshot.SlidingModeSnapshot> result = new HashSet<ModeStructureSnapshot.SlidingModeSnapshot>();
    for (Map.Entry<ModeImpl, String> curEntry : slidingModes2Sides.entrySet()) {
        final ModeImpl key = curEntry.getKey();
        AbstractMap<TopComponent, Integer> lazy = new AbstractMap<TopComponent, Integer>() {

            Map<TopComponent, Integer> delegate;

            @Override
            public Set<Entry<TopComponent, Integer>> entrySet() {
                if (delegate == null) {
                    delegate = getSlideInSizes(key);
                }
                return delegate.entrySet();
            }
        };
        result.add(new ModeStructureSnapshot.SlidingModeSnapshot(curEntry.getKey(), curEntry.getValue(), lazy));
    }
    return result;
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl) AbstractMap(java.util.AbstractMap) ModeStructureSnapshot(org.netbeans.core.windows.ModeStructureSnapshot) HashMap(java.util.HashMap) AbstractMap(java.util.AbstractMap) Map(java.util.Map) TopComponent(org.openide.windows.TopComponent) HashSet(java.util.HashSet)

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