Search in sources :

Example 1 with PROP_VISIBLE

use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_VISIBLE in project yamcs-studio by yamcs.

the class GroupingContainerEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, figure) -> {
        figure.setOpaque(!(Boolean) newValue);
        return true;
    });
    setPropertyChangeHandler(PROP_ENABLED, (oldValue, newValue, figure) -> {
        for (var child : getWidgetModel().getChildren()) {
            child.setEnabled((Boolean) newValue);
        }
        return true;
    });
    setPropertyChangeHandler(PROP_LOCK_CHILDREN, (oldValue, newValue, figure) -> {
        lockChildren((Boolean) newValue);
        return true;
    });
    lockChildren(getWidgetModel().isLocked());
    if (getWidgetModel().getParent() instanceof TabModel) {
        removeAllPropertyChangeHandlers(PROP_VISIBLE);
        setPropertyChangeHandler(PROP_VISIBLE, (oldValue, newValue, refreshableFigure) -> {
            boolean visible = (Boolean) newValue;
            var figure = getFigure();
            figure.setVisible(visible);
            return true;
        });
    }
    setPropertyChangeHandler(PROP_SHOW_SCROLLBAR, (oldValue, newValue, refreshableFigure) -> {
        ((GroupingContainerFigure) refreshableFigure).setShowScrollBar((Boolean) newValue);
        return true;
    });
    IWidgetPropertyChangeHandler fowardColorHandler = (oldValue, newValue, refreshableFigure) -> {
        if (getWidgetModel().isForwardColors()) {
            forwardColors();
        }
        return true;
    };
    setPropertyChangeHandler(PROP_FORWARD_COLORS, fowardColorHandler);
    setPropertyChangeHandler(PROP_COLOR_BACKGROUND, fowardColorHandler);
    setPropertyChangeHandler(PROP_COLOR_FOREGROUND, fowardColorHandler);
    // use property listener because it doesn't need to be queued in GUIRefreshThread.
    getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(evt -> resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), true));
    getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(evt -> resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), false));
}
Also used : PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) PROP_ENABLED(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_ENABLED) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) PROP_TRANSPARENT(org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_TRANSPARENT) IFigure(org.eclipse.draw2d.IFigure) PROP_FORWARD_COLORS(org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_FORWARD_COLORS) TabModel(org.csstudio.opibuilder.widgets.model.TabModel) PROP_COLOR_FOREGROUND(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_COLOR_FOREGROUND) PROP_SHOW_SCROLLBAR(org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_SHOW_SCROLLBAR) PROP_COLOR_BACKGROUND(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_COLOR_BACKGROUND) PROP_LOCK_CHILDREN(org.csstudio.opibuilder.widgets.model.GroupingContainerModel.PROP_LOCK_CHILDREN) GroupingContainerFigure(org.csstudio.swt.widgets.figures.GroupingContainerFigure) AbstractContainerEditpart(org.csstudio.opibuilder.editparts.AbstractContainerEditpart) IActionFilter(org.eclipse.ui.IActionFilter) EditPolicy(org.eclipse.gef.EditPolicy) GroupingContainerModel(org.csstudio.opibuilder.widgets.model.GroupingContainerModel) EditPart(org.eclipse.gef.EditPart) PROP_VISIBLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_VISIBLE) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) GroupingContainerFigure(org.csstudio.swt.widgets.figures.GroupingContainerFigure) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) TabModel(org.csstudio.opibuilder.widgets.model.TabModel)

Example 2 with PROP_VISIBLE

use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_VISIBLE 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

AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)2 AbstractContainerEditpart (org.csstudio.opibuilder.editparts.AbstractContainerEditpart)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 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 IFigure (org.eclipse.draw2d.IFigure)2 EditPart (org.eclipse.gef.EditPart)2 EditPolicy (org.eclipse.gef.EditPolicy)2 LinkedList (java.util.LinkedList)1 Level (java.util.logging.Level)1 OPIBuilderPlugin (org.csstudio.opibuilder.OPIBuilderPlugin)1 ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)1 PROP_BORDER_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH)1 PROP_COLOR_BACKGROUND (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_COLOR_BACKGROUND)1 PROP_COLOR_FOREGROUND (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_COLOR_FOREGROUND)1 PROP_ENABLED (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_ENABLED)1