Search in sources :

Example 1 with GroupingContainerFigure

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

the class GroupingContainerEditPart method registerPropertyChangeHandlers.

@Override
protected void registerPropertyChangeHandlers() {
    IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            figure.setOpaque(!(Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(GroupingContainerModel.PROP_TRANSPARENT, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            for (AbstractWidgetModel child : getWidgetModel().getChildren()) {
                child.setEnabled((Boolean) newValue);
            }
            return true;
        }
    };
    setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, handler);
    handler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            lockChildren((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(GroupingContainerModel.PROP_LOCK_CHILDREN, handler);
    lockChildren(getWidgetModel().isLocked());
    if (getWidgetModel().getParent() instanceof TabModel) {
        removeAllPropertyChangeHandlers(AbstractWidgetModel.PROP_VISIBLE);
        IWidgetPropertyChangeHandler visibilityHandler = new IWidgetPropertyChangeHandler() {

            @Override
            public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
                boolean visible = (Boolean) newValue;
                final IFigure figure = getFigure();
                figure.setVisible(visible);
                return true;
            }
        };
        setPropertyChangeHandler(AbstractWidgetModel.PROP_VISIBLE, visibilityHandler);
    }
    IWidgetPropertyChangeHandler showBarHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            ((GroupingContainerFigure) refreshableFigure).setShowScrollBar((Boolean) newValue);
            return true;
        }
    };
    setPropertyChangeHandler(GroupingContainerModel.PROP_SHOW_SCROLLBAR, showBarHandler);
    IWidgetPropertyChangeHandler fowardColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
            if (getWidgetModel().isForwardColors())
                forwardColors();
            return true;
        }
    };
    setPropertyChangeHandler(GroupingContainerModel.PROP_FORWARD_COLORS, fowardColorHandler);
    setPropertyChangeHandler(GroupingContainerModel.PROP_COLOR_BACKGROUND, fowardColorHandler);
    setPropertyChangeHandler(GroupingContainerModel.PROP_COLOR_FOREGROUND, fowardColorHandler);
    // use property listener because it doesn't need to be queued in GUIRefreshThread.
    getWidgetModel().getProperty(AbstractWidgetModel.PROP_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), true);
        }
    });
    getWidgetModel().getProperty(AbstractWidgetModel.PROP_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), false);
        }
    });
}
Also used : GroupingContainerFigure(org.csstudio.swt.widgets.figures.GroupingContainerFigure) PropertyChangeEvent(java.beans.PropertyChangeEvent) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) PropertyChangeListener(java.beans.PropertyChangeListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure) TabModel(org.csstudio.opibuilder.widgets.model.TabModel)

Example 2 with GroupingContainerFigure

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

the class GroupingContainerEditPart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    GroupingContainerFigure f = new GroupingContainerFigure();
    f.setOpaque(!getWidgetModel().isTransparent());
    f.setShowScrollBar(getWidgetModel().isShowScrollbar());
    return f;
}
Also used : GroupingContainerFigure(org.csstudio.swt.widgets.figures.GroupingContainerFigure)

Aggregations

GroupingContainerFigure (org.csstudio.swt.widgets.figures.GroupingContainerFigure)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 TabModel (org.csstudio.opibuilder.widgets.model.TabModel)1 IFigure (org.eclipse.draw2d.IFigure)1