Search in sources :

Example 1 with Tabbed

use of org.netbeans.swing.tabcontrol.customtabs.Tabbed in project netbeans-rcp-lite by outersky.

the class CommandManager method slideIn.

public void slideIn(int tabIndex) {
    SlideBarDataModel model = slideBar.getModel();
    if (isCompSlided()) {
        if (curSlidedComp != model.getTab(tabIndex).getComponent()) {
            // another component requests slide in, so slide out current first
            slideOut(false, false);
        }
    }
    curSlidedIndex = tabIndex;
    curSlidedComp = model.getTab(tabIndex).getComponent();
    curSlideOrientation = model.getOrientation();
    curSlideButton = slideBar.getButton(tabIndex);
    Tabbed cont = updateSlidedTabContainer(tabIndex);
    SlideOperation operation = SlideOperationFactory.createSlideIn(cont.getComponent(), curSlideOrientation, true, true);
    boolean alreadyListening = false;
    for (AWTEventListener el : Toolkit.getDefaultToolkit().getAWTEventListeners()) {
        if (el == getAWTListener()) {
            alreadyListening = false;
            break;
        }
    }
    if (!alreadyListening)
        Toolkit.getDefaultToolkit().addAWTEventListener(getAWTListener(), MouseEvent.MOUSE_EVENT_MASK);
    curSlideButton.setSelected(true);
    postEvent(new SlideBarActionEvent(slideBar, SlideBar.COMMAND_SLIDE_IN, operation));
    recog.attachResizeRecognizer(orientation2Side(curSlideOrientation), cont.getComponent());
}
Also used : Tabbed(org.netbeans.swing.tabcontrol.customtabs.Tabbed) SlideBarDataModel(org.netbeans.swing.tabcontrol.SlideBarDataModel)

Example 2 with Tabbed

use of org.netbeans.swing.tabcontrol.customtabs.Tabbed in project netbeans-rcp-lite by outersky.

the class TopComponentDragSupport method doStartDrag.

/**
 * Actually starts the drag operation.
 */
private void doStartDrag(Component startingComp, TopComponentDraggable transfer, DragGestureEvent evt, TopComponentDroppable startingDroppable, final Point startingPoint) {
    if (DEBUG) {
        // NOI18N
        debugLog("");
        // NOI18N
        debugLog("doStartDrag");
    }
    TopComponent tc = transfer.getTopComponent();
    canCopy = tc instanceof TopComponent.Cloneable && !Boolean.TRUE.equals(tc.getClientProperty(TopComponent.PROP_DND_COPY_DISABLED));
    // Inform window sys there is DnD about to start.
    // XXX Using the firstTC in DnD manager is a hack.
    windowDnDManager.dragStarting(startingDroppable, startingPoint, transfer);
    Cursor cursor = hackUserDropAction == DnDConstants.ACTION_MOVE ? getDragCursor(startingComp, CURSOR_MOVE) : (canCopy ? getDragCursor(startingComp, CURSOR_COPY) : getDragCursor(startingComp, CURSOR_COPY_NO_MOVE));
    // Sets listnening for ESC key.
    addListening();
    hackESC = false;
    Tabbed tabbed = null;
    Tabbed.Accessor acc = (Tabbed.Accessor) SwingUtilities.getAncestorOfClass(Tabbed.Accessor.class, startingComp);
    tabbed = acc != null ? acc.getTabbed() : null;
    int tabIndex = -1;
    Image img = createDragImage();
    if (tabbed != null) {
        if (transfer.isTopComponentTransfer() && WinSysPrefs.HANDLER.getBoolean(WinSysPrefs.DND_DRAGIMAGE, Utilities.getOperatingSystem() != Utilities.OS_SOLARIS)) {
            tabIndex = tabbed.indexOf(transfer.getTopComponent());
            visualizer = new DragAndDropFeedbackVisualizer(tabbed, tabIndex);
        }
    }
    try {
        Transferable transferable;
        if (transfer.isTopComponentTransfer()) {
            transferable = new TopComponentTransferable(transfer.getTopComponent());
        } else {
            assert transfer.isModeTransfer();
            transferable = new TopComponentModeTransferable(transfer.getMode());
        }
        evt.startDrag(cursor, img, new Point(0, 0), transferable, this);
        evt.getDragSource().addDragSourceMotionListener(this);
        if (null != visualizer) {
            visualizer.start(evt);
        }
    } catch (InvalidDnDOperationException idoe) {
        Logger.getLogger(TopComponentDragSupport.class.getName()).log(Level.WARNING, null, idoe);
        removeListening();
        windowDnDManager.resetDragSource();
        if (null != visualizer) {
            visualizer.dispose(false);
            visualizer = null;
        }
    }
}
Also used : Point(java.awt.Point) Cursor(java.awt.Cursor) Image(java.awt.Image) BufferedImage(java.awt.image.BufferedImage) Point(java.awt.Point) Tabbed(org.netbeans.swing.tabcontrol.customtabs.Tabbed) TopComponent(org.openide.windows.TopComponent)

Example 3 with Tabbed

use of org.netbeans.swing.tabcontrol.customtabs.Tabbed in project netbeans-rcp-lite by outersky.

the class TabbedHandler method handlePopupMenuShowing.

/**
 * Possibly invokes popup menu.
 */
public static void handlePopupMenuShowing(MouseEvent e, int idx) {
    Component c = (Component) e.getSource();
    while (c != null && !(c instanceof Tabbed.Accessor)) c = c.getParent();
    if (c == null) {
        return;
    }
    final Tabbed tab = ((Tabbed.Accessor) c).getTabbed();
    final Point p = SwingUtilities.convertPoint((Component) e.getSource(), e.getPoint(), c);
    final int clickTab = idx;
    Lookup context = null;
    Action[] actions = null;
    if (clickTab >= 0) {
        TopComponent tc = tab.getTopComponentAt(clickTab);
        if (tc != null) {
            // ask also tabbed to possibly alter actions
            actions = tab.getPopupActions(tc.getActions(), clickTab);
            if (actions == null) {
                actions = tc.getActions();
            }
            if (actions == null || actions.length == 0)
                return;
            context = tc.getLookup();
        }
    }
    if (null == context) {
        actions = tab.getPopupActions(new Action[0], -1);
        if (actions == null || actions.length == 0)
            return;
        context = Lookup.getDefault();
    }
    showPopupMenu(Utilities.actionsToPopup(actions, context), p, c);
}
Also used : Tabbed(org.netbeans.swing.tabcontrol.customtabs.Tabbed) MaximizeWindowAction(org.netbeans.core.windows.actions.MaximizeWindowAction) Lookup(org.openide.util.Lookup) TopComponent(org.openide.windows.TopComponent) TopComponent(org.openide.windows.TopComponent)

Example 4 with Tabbed

use of org.netbeans.swing.tabcontrol.customtabs.Tabbed in project netbeans-rcp-lite by outersky.

the class CommandManager method updateSlidedTabContainer.

private Tabbed updateSlidedTabContainer(int tabIndex) {
    Tabbed container = getSlidingTabbed();
    // TabDataModel containerModel = container.getModel();
    SlideBarDataModel dataModel = slideBar.getModel();
    // creating new TabData instead of just referencing
    // to be able to compare and track changes between models of slide bar and
    // slided tabbed container
    TabData origTab = dataModel.getTab(tabIndex);
    TopComponent tc = (TopComponent) origTab.getComponent();
    container.setTopComponents(new TopComponent[] { tc }, tc);
    return container;
}
Also used : Tabbed(org.netbeans.swing.tabcontrol.customtabs.Tabbed) TabData(org.netbeans.swing.tabcontrol.TabData) SlideBarDataModel(org.netbeans.swing.tabcontrol.SlideBarDataModel) TopComponent(org.openide.windows.TopComponent)

Example 5 with Tabbed

use of org.netbeans.swing.tabcontrol.customtabs.Tabbed 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

Tabbed (org.netbeans.swing.tabcontrol.customtabs.Tabbed)6 TopComponent (org.openide.windows.TopComponent)5 Point (java.awt.Point)2 MaximizeWindowAction (org.netbeans.core.windows.actions.MaximizeWindowAction)2 SlideBarDataModel (org.netbeans.swing.tabcontrol.SlideBarDataModel)2 Component (java.awt.Component)1 Cursor (java.awt.Cursor)1 Dialog (java.awt.Dialog)1 Image (java.awt.Image)1 Rectangle (java.awt.Rectangle)1 BufferedImage (java.awt.image.BufferedImage)1 TabData (org.netbeans.swing.tabcontrol.TabData)1 Lookup (org.openide.util.Lookup)1