Search in sources :

Example 1 with MaximizeWindowAction

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

the class TabbedHandler method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (e instanceof TabActionEvent) {
        TabActionEvent tae = (TabActionEvent) e;
        String cmd = tae.getActionCommand();
        if (TabbedContainer.COMMAND_SELECT.equals(cmd)) {
            return;
        }
        tae.consume();
        if (TabbedContainer.COMMAND_CLOSE == cmd) {
            // == test is safe here
            TopComponent tc = tabbed.getTopComponentAt(tae.getTabIndex());
            if (tc != null && modeView != null) {
                modeView.getController().userClosedTopComponent(modeView, tc);
            } else {
                Logger.getLogger(TabbedHandler.class.getName()).warning("TopComponent to be closed is null at index " + tae.getTabIndex());
            }
        } else if (TabbedContainer.COMMAND_POPUP_REQUEST == cmd) {
            handlePopupMenuShowing(tae.getMouseEvent(), tae.getTabIndex());
        } else if (TabbedContainer.COMMAND_MAXIMIZE == cmd) {
            handleMaximization(tae);
        } else if (TabbedContainer.COMMAND_CLOSE_ALL == cmd) {
            ActionUtils.closeAllDocuments(true);
        } else if (TabbedContainer.COMMAND_CLOSE_ALL_BUT_THIS == cmd) {
            TopComponent tc = tabbed.getTopComponentAt(tae.getTabIndex());
            ActionUtils.closeAllExcept(tc, true);
        // Pin button handling here
        } else if (TabbedContainer.COMMAND_ENABLE_AUTO_HIDE.equals(cmd)) {
            if (Switches.isTopComponentSlidingEnabled() && tabbed.getComponent().isShowing()) {
                TopComponent tc = tabbed.getTopComponentAt(tae.getTabIndex());
                // prepare slide operation
                Component tabbedComp = tabbed.getComponent();
                String side = WindowManagerImpl.getInstance().guessSlideSide(tc);
                SlideOperation operation = SlideOperationFactory.createSlideIntoEdge(tabbedComp, side, true);
                operation.setStartBounds(new Rectangle(tabbedComp.getLocationOnScreen(), tabbedComp.getSize()));
                operation.prepareEffect();
                modeView.getController().userEnabledAutoHide(modeView, tc);
                modeView.getController().userTriggeredSlideIntoEdge(modeView, operation);
            }
        } else if (TabbedContainer.COMMAND_MINIMIZE_GROUP.equals(cmd)) {
            if (Switches.isModeSlidingEnabled()) {
                TopComponent tc = tabbed.getTopComponentAt(0);
                WindowManagerImpl wm = WindowManagerImpl.getInstance();
                ModeImpl mode = (ModeImpl) wm.findMode(tc);
                if (null != mode) {
                    wm.userMinimizedMode(mode);
                }
            }
        } else if (TabbedContainer.COMMAND_RESTORE_GROUP.equals(cmd)) {
            String nameOfModeToRestore = tae.getGroupName();
            if (null != nameOfModeToRestore) {
                TopComponent tc = tabbed.getTopComponentAt(0);
                WindowManagerImpl wm = WindowManagerImpl.getInstance();
                ModeImpl slidingMode = (ModeImpl) wm.findMode(tc);
                ModeImpl modeToRestore = (ModeImpl) wm.findMode(nameOfModeToRestore);
                if (null != modeToRestore && null != slidingMode) {
                    wm.userRestoredMode(slidingMode, modeToRestore);
                }
            }
        } else if (TabbedContainer.COMMAND_CLOSE_GROUP.equals(cmd)) {
            if (Switches.isModeClosingEnabled()) {
                TopComponent tc = tabbed.getTopComponentAt(0);
                WindowManagerImpl wm = WindowManagerImpl.getInstance();
                ModeImpl mode = (ModeImpl) wm.findMode(tc);
                if (null != mode) {
                    wm.userClosedMode(mode);
                }
            }
        }
    } else if (e instanceof SlideBarActionEvent) {
        // slide bar commands
        SlideBarActionEvent sbe = (SlideBarActionEvent) e;
        String cmd = sbe.getActionCommand();
        if (SlideBar.COMMAND_POPUP_REQUEST.equals(cmd)) {
            handlePopupMenuShowing(sbe.getMouseEvent(), sbe.getTabIndex());
        } else if (SlideBar.COMMAND_SLIDE_IN.equals(cmd)) {
            modeView.getController().userTriggeredSlideIn(modeView, sbe.getSlideOperation());
        } else if (SlideBar.COMMAND_SLIDE_RESIZE.equals(cmd)) {
            modeView.getController().userResizedSlidingWindow(modeView, sbe.getSlideOperation());
        } else if (SlideBar.COMMAND_SLIDE_OUT.equals(cmd)) {
            // when the call comes from the change of tehmodel rather than user clicking,
            // ignore activation requests.
            // #48539
            SlideOperation op = new ProxySlideOperation(sbe.getSlideOperation(), ignoreChange);
            modeView.getController().userTriggeredSlideOut(modeView, op);
        } else if (SlideBar.COMMAND_DISABLE_AUTO_HIDE.equals(cmd)) {
            TopComponent tc = tabbed.getTopComponentAt(sbe.getTabIndex());
            modeView.getController().userDisabledAutoHide(modeView, tc);
        } else if (SlideBar.COMMAND_MAXIMIZE == cmd) {
            TopComponent tc = tabbed.getTopComponentAt(sbe.getTabIndex());
            MaximizeWindowAction mwa = new MaximizeWindowAction(tc);
            if (mwa.isEnabled())
                mwa.actionPerformed(e);
        }
    }
}
Also used : TabActionEvent(org.netbeans.swing.tabcontrol.event.TabActionEvent) SlideBarActionEvent(org.netbeans.core.windows.view.ui.slides.SlideBarActionEvent) WindowManagerImpl(org.netbeans.core.windows.WindowManagerImpl) ModeImpl(org.netbeans.core.windows.ModeImpl) MaximizeWindowAction(org.netbeans.core.windows.actions.MaximizeWindowAction) TopComponent(org.openide.windows.TopComponent) TopComponent(org.openide.windows.TopComponent) SlideOperation(org.netbeans.core.windows.view.ui.slides.SlideOperation)

Example 2 with MaximizeWindowAction

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

the class TabbedHandler method handleMaximization.

/**
 * Possibly invokes the (un)maximization.
 */
public static void handleMaximization(TabActionEvent tae) {
    Component c = (Component) tae.getSource();
    while (c != null && !(c instanceof Tabbed.Accessor)) c = c.getParent();
    if (c == null) {
        return;
    }
    final Tabbed tab = ((Tabbed.Accessor) c).getTabbed();
    TopComponent tc = tab.getTopComponentAt(tae.getTabIndex());
    // perform action
    MaximizeWindowAction mwa = new MaximizeWindowAction(tc);
    if (mwa.isEnabled())
        mwa.actionPerformed(tae);
}
Also used : Tabbed(org.netbeans.swing.tabcontrol.customtabs.Tabbed) MaximizeWindowAction(org.netbeans.core.windows.actions.MaximizeWindowAction) TopComponent(org.openide.windows.TopComponent) TopComponent(org.openide.windows.TopComponent)

Aggregations

MaximizeWindowAction (org.netbeans.core.windows.actions.MaximizeWindowAction)2 TopComponent (org.openide.windows.TopComponent)2 ModeImpl (org.netbeans.core.windows.ModeImpl)1 WindowManagerImpl (org.netbeans.core.windows.WindowManagerImpl)1 SlideBarActionEvent (org.netbeans.core.windows.view.ui.slides.SlideBarActionEvent)1 SlideOperation (org.netbeans.core.windows.view.ui.slides.SlideOperation)1 Tabbed (org.netbeans.swing.tabcontrol.customtabs.Tabbed)1 TabActionEvent (org.netbeans.swing.tabcontrol.event.TabActionEvent)1