Search in sources :

Example 1 with TabFigure

use of org.csstudio.swt.widgets.figures.TabFigure in project yamcs-studio by yamcs.

the class TabEditPart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    TabFigure tabFigure = new TabFigure();
    tabFigure.setHorizontal(getWidgetModel().isHorizontal());
    tabFigure.setMinimumTabHeight(getWidgetModel().getMinimumTabHeight());
    tabFigure.addTabListener(new ITabListener() {

        @Override
        public void activeTabIndexChanged(int oldIndex, int newIndex) {
            for (AbstractWidgetModel child : getWidgetModel().getChildren()) child.setPropertyValue(AbstractWidgetModel.PROP_VISIBLE, false);
            getWidgetModel().getChildren().get(newIndex).setPropertyValue(AbstractWidgetModel.PROP_VISIBLE, true);
        // if (getExecutionMode() == ExecutionMode.RUN_MODE)
        // setPropertyValue(TabModel.PROP_ACTIVE_TAB, newIndex);
        }
    });
    return tabFigure;
}
Also used : ITabListener(org.csstudio.swt.widgets.figures.TabFigure.ITabListener) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) TabFigure(org.csstudio.swt.widgets.figures.TabFigure)

Example 2 with TabFigure

use of org.csstudio.swt.widgets.figures.TabFigure in project yamcs-studio by yamcs.

the class TabEditPart method registerTabsAmountChangeHandler.

private void registerTabsAmountChangeHandler() {
    IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
        var model = getWidgetModel();
        var figure = (TabFigure) refreshableFigure;
        var currentTabAmount = figure.getTabAmount();
        // add tabs
        if ((Integer) newValue > currentTabAmount) {
            for (var i1 = 0; i1 < (Integer) newValue - currentTabAmount; i1++) {
                for (var tabProperty1 : TabProperty.values()) {
                    var propID1 = TabModel.makeTabPropID(tabProperty1.propIDPre, i1 + currentTabAmount);
                    model.setPropertyVisible(propID1, true);
                }
                addTab();
            }
        } else if ((Integer) newValue < currentTabAmount) {
            // remove tabs
            for (var i2 = currentTabAmount - 1; i2 >= (Integer) newValue; i2--) {
                for (var tabProperty2 : TabProperty.values()) {
                    var propID2 = TabModel.makeTabPropID(tabProperty2.propIDPre, i2);
                    model.setPropertyVisible(propID2, false);
                }
                removeTab();
            }
            setActiveTabIndex(0);
        }
        return true;
    };
    getWidgetModel().getProperty(PROP_TAB_COUNT).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
}
Also used : PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) Dimension(org.eclipse.draw2d.geometry.Dimension) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) CustomMediaFactory(org.csstudio.ui.util.CustomMediaFactory) IFigure(org.eclipse.draw2d.IFigure) Level(java.util.logging.Level) TabFigure(org.csstudio.swt.widgets.figures.TabFigure) PROP_HORIZONTAL_TABS(org.csstudio.opibuilder.widgets.model.TabModel.PROP_HORIZONTAL_TABS) UIBundlingThread(org.csstudio.ui.util.thread.UIBundlingThread) PROP_ACTIVE_TAB(org.csstudio.opibuilder.widgets.model.TabModel.PROP_ACTIVE_TAB) OPIColor(org.csstudio.opibuilder.util.OPIColor) GroupingContainerModel(org.csstudio.opibuilder.widgets.model.GroupingContainerModel) LinkedList(java.util.LinkedList) PROP_VISIBLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_VISIBLE) OPIBuilderPlugin(org.csstudio.opibuilder.OPIBuilderPlugin) TabProperty(org.csstudio.opibuilder.widgets.model.TabModel.TabProperty) PROP_TAB_COUNT(org.csstudio.opibuilder.widgets.model.TabModel.PROP_TAB_COUNT) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) PROP_TRANSPARENT(org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_TRANSPARENT) PROP_MINIMUM_TAB_HEIGHT(org.csstudio.opibuilder.widgets.model.TabModel.PROP_MINIMUM_TAB_HEIGHT) TabModel(org.csstudio.opibuilder.widgets.model.TabModel) AbstractContainerEditpart(org.csstudio.opibuilder.editparts.AbstractContainerEditpart) Path(org.eclipse.core.runtime.Path) OPIFont(org.csstudio.opibuilder.util.OPIFont) ITabItemHandler(org.csstudio.opibuilder.widgets.model.TabModel.ITabItemHandler) Label(org.eclipse.draw2d.Label) EditPolicy(org.eclipse.gef.EditPolicy) BorderStyle(org.csstudio.opibuilder.visualparts.BorderStyle) EditPart(org.eclipse.gef.EditPart) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)

Example 3 with TabFigure

use of org.csstudio.swt.widgets.figures.TabFigure in project yamcs-studio by yamcs.

the class TabEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    // init tabs
    var i = 0;
    for (var child : getWidgetModel().getChildren()) {
        if (child instanceof GroupingContainerModel) {
            child.setPropertyValue(PROP_VISIBLE, true);
            child.setPropertyValue(PROP_VISIBLE, false);
            getTabFigure().addTab((String) getWidgetModel().getPropertyValue(TabModel.makeTabPropID(TabProperty.TITLE.propIDPre, i)));
            tabItemList.add(i, new TabItem(getWidgetModel(), i, (GroupingContainerModel) child));
            for (var tabProperty : TabProperty.values()) {
                setTabProperty(i, tabProperty, getWidgetModel().getPropertyValue(TabModel.makeTabPropID(tabProperty.propIDPre, i)));
            }
            i++;
        }
    }
    IWidgetPropertyChangeHandler relocContainerHandler = (oldValue, newValue, figure) -> {
        updateTabAreaSize();
        refreshVisuals();
        return false;
    };
    setPropertyChangeHandler(PROP_WIDTH, relocContainerHandler);
    setPropertyChangeHandler(PROP_HEIGHT, relocContainerHandler);
    setPropertyChangeHandler(PROP_HORIZONTAL_TABS, (oldValue, newValue, figure) -> {
        ((TabFigure) figure).setHorizontal((Boolean) newValue);
        updateTabAreaSize();
        refreshVisuals();
        return false;
    });
    setPropertyChangeHandler(PROP_ACTIVE_TAB, (oldValue, newValue, figure) -> {
        ((TabFigure) figure).setActiveTabIndex((Integer) newValue);
        updateTabAreaSize();
        refreshVisuals();
        return false;
    });
    setPropertyChangeHandler(PROP_MINIMUM_TAB_HEIGHT, (oldValue, newValue, figure) -> {
        ((TabFigure) figure).setMinimumTabHeight((Integer) newValue);
        return false;
    });
    setPropertyChangeHandler(PROP_BORDER_WIDTH, (oldValue, newValue, figure) -> {
        updateTabAreaSize();
        return false;
    });
    registerTabPropertyChangeHandlers();
    registerTabsAmountChangeHandler();
}
Also used : PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) Dimension(org.eclipse.draw2d.geometry.Dimension) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) CustomMediaFactory(org.csstudio.ui.util.CustomMediaFactory) IFigure(org.eclipse.draw2d.IFigure) Level(java.util.logging.Level) TabFigure(org.csstudio.swt.widgets.figures.TabFigure) PROP_HORIZONTAL_TABS(org.csstudio.opibuilder.widgets.model.TabModel.PROP_HORIZONTAL_TABS) UIBundlingThread(org.csstudio.ui.util.thread.UIBundlingThread) PROP_ACTIVE_TAB(org.csstudio.opibuilder.widgets.model.TabModel.PROP_ACTIVE_TAB) OPIColor(org.csstudio.opibuilder.util.OPIColor) GroupingContainerModel(org.csstudio.opibuilder.widgets.model.GroupingContainerModel) LinkedList(java.util.LinkedList) PROP_VISIBLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_VISIBLE) OPIBuilderPlugin(org.csstudio.opibuilder.OPIBuilderPlugin) TabProperty(org.csstudio.opibuilder.widgets.model.TabModel.TabProperty) PROP_TAB_COUNT(org.csstudio.opibuilder.widgets.model.TabModel.PROP_TAB_COUNT) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) PROP_TRANSPARENT(org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_TRANSPARENT) PROP_MINIMUM_TAB_HEIGHT(org.csstudio.opibuilder.widgets.model.TabModel.PROP_MINIMUM_TAB_HEIGHT) TabModel(org.csstudio.opibuilder.widgets.model.TabModel) AbstractContainerEditpart(org.csstudio.opibuilder.editparts.AbstractContainerEditpart) Path(org.eclipse.core.runtime.Path) OPIFont(org.csstudio.opibuilder.util.OPIFont) ITabItemHandler(org.csstudio.opibuilder.widgets.model.TabModel.ITabItemHandler) Label(org.eclipse.draw2d.Label) EditPolicy(org.eclipse.gef.EditPolicy) BorderStyle(org.csstudio.opibuilder.visualparts.BorderStyle) EditPart(org.eclipse.gef.EditPart) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) GroupingContainerModel(org.csstudio.opibuilder.widgets.model.GroupingContainerModel) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) TabFigure(org.csstudio.swt.widgets.figures.TabFigure)

Aggregations

TabFigure (org.csstudio.swt.widgets.figures.TabFigure)3 LinkedList (java.util.LinkedList)2 Level (java.util.logging.Level)2 OPIBuilderPlugin (org.csstudio.opibuilder.OPIBuilderPlugin)2 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)2 AbstractContainerEditpart (org.csstudio.opibuilder.editparts.AbstractContainerEditpart)2 PROP_BORDER_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH)2 PROP_HEIGHT (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT)2 PROP_VISIBLE (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_VISIBLE)2 PROP_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH)2 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)2 OPIColor (org.csstudio.opibuilder.util.OPIColor)2 OPIFont (org.csstudio.opibuilder.util.OPIFont)2 BorderStyle (org.csstudio.opibuilder.visualparts.BorderStyle)2 GroupingContainerModel (org.csstudio.opibuilder.widgets.model.GroupingContainerModel)2 PROP_TRANSPARENT (org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_TRANSPARENT)2 TabModel (org.csstudio.opibuilder.widgets.model.TabModel)2 ITabItemHandler (org.csstudio.opibuilder.widgets.model.TabModel.ITabItemHandler)2 PROP_ACTIVE_TAB (org.csstudio.opibuilder.widgets.model.TabModel.PROP_ACTIVE_TAB)2 PROP_HORIZONTAL_TABS (org.csstudio.opibuilder.widgets.model.TabModel.PROP_HORIZONTAL_TABS)2