use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class RectangleEditpart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
super.registerPropertyChangeHandlers();
// fill
IWidgetPropertyChangeHandler fillHandler = new IWidgetPropertyChangeHandler() {
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
OPIRectangleFigure figure = (OPIRectangleFigure) refreshableFigure;
figure.setFill((Double) newValue);
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_FILL_LEVEL, fillHandler);
// fill orientaion
IWidgetPropertyChangeHandler fillOrientHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
OPIRectangleFigure figure = (OPIRectangleFigure) refreshableFigure;
figure.setHorizontalFill((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_HORIZONTAL_FILL, fillOrientHandler);
// transparent
IWidgetPropertyChangeHandler transparentHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
OPIRectangleFigure figure = (OPIRectangleFigure) refreshableFigure;
figure.setTransparent((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(RectangleModel.PROP_TRANSPARENT, transparentHandler);
// line color
IWidgetPropertyChangeHandler lineColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((OPIRectangleFigure) refreshableFigure).setLineColor(((OPIColor) newValue).getSWTColor());
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_LINE_COLOR, lineColorHandler);
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((OPIRectangleFigure) figure).setGradient((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(RectangleModel.PROP_GRADIENT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((OPIRectangleFigure) figure).setBackGradientStartColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(RectangleModel.PROP_BACKGROUND_GRADIENT_START_COLOR, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((OPIRectangleFigure) figure).setForeGradientStartColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(RoundedRectangleModel.PROP_FOREGROUND_GRADIENT_START_COLOR, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class RoundedRectangleEditpart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
super.registerPropertyChangeHandlers();
// fill
IWidgetPropertyChangeHandler fillHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
figure.setFill((Double) newValue);
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_FILL_LEVEL, fillHandler);
// fill orientaion
IWidgetPropertyChangeHandler fillOrientHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
figure.setHorizontalFill((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_HORIZONTAL_FILL, fillOrientHandler);
// transparent
IWidgetPropertyChangeHandler transparentHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
figure.setTransparent((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(RoundedRectangleModel.PROP_TRANSPARENT, transparentHandler);
// line color
IWidgetPropertyChangeHandler lineColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((RoundedRectangleFigure) refreshableFigure).setLineColor(((OPIColor) newValue).getSWTColor());
return true;
}
};
setPropertyChangeHandler(AbstractShapeModel.PROP_LINE_COLOR, lineColorHandler);
// corner width
IWidgetPropertyChangeHandler cornerWidthHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
figure.setCornerWidth((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(RoundedRectangleModel.PROP_CORNER_WIDTH, cornerWidthHandler);
// corner height
IWidgetPropertyChangeHandler cornerHeightHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
RoundedRectangleFigure figure = (RoundedRectangleFigure) refreshableFigure;
figure.setCornerHeight((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(RoundedRectangleModel.PROP_CORNER_HEIGHT, cornerHeightHandler);
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((RoundedRectangleFigure) figure).setGradient((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(RoundedRectangleModel.PROP_GRADIENT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((RoundedRectangleFigure) figure).setBackGradientStartColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(RoundedRectangleModel.PROP_BACKGROUND_GRADIENT_START_COLOR, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((RoundedRectangleFigure) figure).setForeGradientStartColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(RoundedRectangleModel.PROP_FOREGROUND_GRADIENT_START_COLOR, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class ScaledSliderEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// fillColor
IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setFillColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_FILL_COLOR, fillColorHandler);
// fillBackgroundColor
IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
// thumbColor
IWidgetPropertyChangeHandler thumbColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setThumbColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_THUMB_COLOR, thumbColorHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setEffect3D((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_EFFECT3D, effect3DHandler);
// horizontal
IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setHorizontal((Boolean) newValue);
ScaledSliderModel model = (ScaledSliderModel) getModel();
if (// from vertical to horizontal
(Boolean) newValue)
model.setLocation(model.getLocation().x - model.getSize().height / 2 + model.getSize().width / 2, model.getLocation().y + model.getSize().height / 2 - model.getSize().width / 2);
else
// from horizontal to vertical
model.setLocation(model.getLocation().x + model.getSize().width / 2 - model.getSize().height / 2, model.getLocation().y - model.getSize().width / 2 + model.getSize().height / 2);
model.setSize(model.getSize().height, model.getSize().width);
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_HORIZONTAL, horizontalHandler);
// enabled. WidgetBaseEditPart will force the widget as disabled in edit model,
// which is not the case for the scaled slider
IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setEnabled((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_ENABLED, enableHandler);
IWidgetPropertyChangeHandler incrementHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setStepIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_STEP_INCREMENT, incrementHandler);
IWidgetPropertyChangeHandler pageIncrementHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ScaledSliderFigure slider = (ScaledSliderFigure) refreshableFigure;
slider.setPageIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScaledSliderModel.PROP_PAGE_INCREMENT, pageIncrementHandler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class TabEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
// init tabs
int i = 0;
for (AbstractWidgetModel child : getWidgetModel().getChildren()) {
if (child instanceof GroupingContainerModel) {
child.setPropertyValue(AbstractWidgetModel.PROP_VISIBLE, true);
child.setPropertyValue(AbstractWidgetModel.PROP_VISIBLE, false);
getTabFigure().addTab((String) getWidgetModel().getPropertyValue(TabModel.makeTabPropID(TabProperty.TITLE.propIDPre, i)));
tabItemList.add(i, new TabItem(getWidgetModel(), i, (GroupingContainerModel) child));
for (TabProperty tabProperty : TabProperty.values()) setTabProperty(i, tabProperty, getWidgetModel().getPropertyValue(TabModel.makeTabPropID(tabProperty.propIDPre, i)));
i++;
}
}
IWidgetPropertyChangeHandler relocContainerHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
updateTabAreaSize();
refreshVisuals();
return false;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_WIDTH, relocContainerHandler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_HEIGHT, relocContainerHandler);
IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((TabFigure) figure).setHorizontal((Boolean) newValue);
updateTabAreaSize();
refreshVisuals();
return false;
}
};
setPropertyChangeHandler(TabModel.PROP_HORIZONTAL_TABS, horizontalHandler);
IWidgetPropertyChangeHandler activeTabHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((TabFigure) figure).setActiveTabIndex((Integer) newValue);
updateTabAreaSize();
refreshVisuals();
return false;
}
};
setPropertyChangeHandler(TabModel.PROP_ACTIVE_TAB, activeTabHandler);
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((TabFigure) figure).setMinimumTabHeight((Integer) newValue);
return false;
}
};
setPropertyChangeHandler(TabModel.PROP_MINIMUM_TAB_HEIGHT, handler);
IWidgetPropertyChangeHandler updateTabAreaSizeHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
updateTabAreaSize();
return false;
}
};
setPropertyChangeHandler(TabModel.PROP_BORDER_WIDTH, updateTabAreaSizeHandler);
registerTabPropertyChangeHandlers();
registerTabsAmountChangeHandler();
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class TabEditPart method registerTabsAmountChangeHandler.
private void registerTabsAmountChangeHandler() {
final IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
TabModel model = getWidgetModel();
TabFigure figure = (TabFigure) refreshableFigure;
int currentTabAmount = figure.getTabAmount();
// add tabs
if ((Integer) newValue > currentTabAmount) {
for (int i = 0; i < (Integer) newValue - currentTabAmount; i++) {
for (TabProperty tabProperty : TabProperty.values()) {
String propID = TabModel.makeTabPropID(tabProperty.propIDPre, i + currentTabAmount);
model.setPropertyVisible(propID, true);
}
addTab();
}
} else if ((Integer) newValue < currentTabAmount) {
// remove tabs
for (int i = currentTabAmount - 1; i >= (Integer) newValue; i--) {
for (TabProperty tabProperty : TabProperty.values()) {
String propID = TabModel.makeTabPropID(tabProperty.propIDPre, i);
model.setPropertyVisible(propID, false);
}
removeTab();
}
setActiveTabIndex(0);
}
return true;
}
};
getWidgetModel().getProperty(TabModel.PROP_TAB_COUNT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
});
}
Aggregations