Search in sources :

Example 1 with SlideBarDataModel

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

the class CommandManager method syncWithModel.

/**
 * Synchronizes its state with current state of data model.
 * Removes currently slided component if it is no longer present in the model,
 * also keeps text up to date.
 */
void syncWithModel() {
    if (curSlidedComp == null) {
        return;
    }
    if (!slideBar.containsComp(curSlidedComp)) {
        // TBD - here should be closeSlide operation, which means
        // just remove from desktop
        slideOut(false, false);
    } else {
        // keep title text up to date
        SlideBarDataModel model = slideBar.getModel();
        // in which case do nothing
        if (curSlidedIndex < model.size()) {
            String freshText = model.getTab(curSlidedIndex).getText();
            getSlidingTabbed().setTitleAt(0, freshText);
            slideBar.repaint();
            curSlideButton = slideBar.getButton(curSlidedIndex);
            curSlideButton.setSelected(true);
        }
    }
}
Also used : SlideBarDataModel(org.netbeans.swing.tabcontrol.SlideBarDataModel)

Example 2 with SlideBarDataModel

use of org.netbeans.swing.tabcontrol.SlideBarDataModel 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 3 with SlideBarDataModel

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

the class TabbedSlideAdapter method setSide.

private void setSide(String side) {
    int orientation = SlideBarDataModel.WEST;
    if (Constants.LEFT.equals(side)) {
        orientation = SlideBarDataModel.WEST;
    } else if (Constants.RIGHT.equals(side)) {
        orientation = SlideBarDataModel.EAST;
    } else if (Constants.BOTTOM.equals(side)) {
        orientation = SlideBarDataModel.SOUTH;
    } else if (Constants.TOP.equals(side)) {
        orientation = SlideBarDataModel.NORTH;
    }
    ((SlideBarDataModel) dataModel).setOrientation(orientation);
}
Also used : SlideBarDataModel(org.netbeans.swing.tabcontrol.SlideBarDataModel) Point(java.awt.Point)

Example 4 with SlideBarDataModel

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

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

the class TabbedSlideAdapter method getIndicationForLocation.

@Override
public Shape getIndicationForLocation(Point location, TopComponent startingTransfer, Point startingPoint, boolean attachingPossible) {
    // int tab = tabForCoordinate(location);
    int nextTab = slideBar.nextTabForCoordinate(location.x, location.y);
    SlideBarDataModel sbdm = (SlideBarDataModel) dataModel;
    if (getTabCount() != 0) {
        if (nextTab == 0) {
            Rectangle rect = getTabBounds(0);
            if (isHorizontal()) {
                rect.x = 0;
                rect.width = rect.width / 2;
            } else {
                rect.y = 0;
                rect.height = rect.height / 2;
            }
            return rect;
        } else if (nextTab < getTabCount()) {
            Rectangle rect1 = getTabBounds(nextTab - 1);
            Rectangle rect2 = getTabBounds(nextTab);
            Rectangle result = new Rectangle();
            if (isHorizontal()) {
                result.y = rect1.y;
                result.height = rect1.height;
                result.x = rect1.x + (rect1.width / 2);
                result.width = rect2.x + (rect2.width / 2) - result.x;
            } else {
                result.x = rect1.x;
                result.width = rect1.width;
                result.y = rect1.y + (rect1.height / 2);
                result.height = rect2.y + (rect2.height / 2) - result.y;
            }
            return result;
        } else if (nextTab == getTabCount()) {
            Rectangle rect = getTabBounds(getTabCount() - 1);
            if (isHorizontal()) {
                rect.x = rect.x + rect.width;
            } else {
                rect.y = rect.y + rect.height;
            }
            return rect;
        }
    }
    if (isHorizontal()) {
        return new Rectangle(10, 0, 50, 20);
    }
    return new Rectangle(0, 10, 20, 50);
}
Also used : Rectangle(java.awt.Rectangle) SlideBarDataModel(org.netbeans.swing.tabcontrol.SlideBarDataModel) Point(java.awt.Point)

Aggregations

SlideBarDataModel (org.netbeans.swing.tabcontrol.SlideBarDataModel)5 Point (java.awt.Point)2 Tabbed (org.netbeans.swing.tabcontrol.customtabs.Tabbed)2 Rectangle (java.awt.Rectangle)1 TabData (org.netbeans.swing.tabcontrol.TabData)1 TopComponent (org.openide.windows.TopComponent)1