use of org.csstudio.swt.widgets.figures.ScrollbarFigure in project yamcs-studio by yamcs.
the class ScrollbarEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
registerLoadLimitsListener();
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
((ScrollbarFigure) getFigure()).setEnabled(getWidgetModel().isEnabled() && (getExecutionMode() == ExecutionMode.RUN_MODE));
removeAllPropertyChangeHandlers(AbstractWidgetModel.PROP_ENABLED);
// enable
IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (getExecutionMode() == ExecutionMode.RUN_MODE)
figure.setEnabled((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, enableHandler);
// value
IWidgetPropertyChangeHandler valueHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (newValue == null)
return false;
((ScrollbarFigure) refreshableFigure).setValue(VTypeHelper.getDouble((VType) newValue));
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, valueHandler);
// minimum
IWidgetPropertyChangeHandler minimumHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setMinimum((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_MIN, minimumHandler);
// maximum
IWidgetPropertyChangeHandler maximumHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setMaximum((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_MAX, maximumHandler);
// page increment
IWidgetPropertyChangeHandler pageIncrementHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setPageIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_PAGE_INCREMENT, pageIncrementHandler);
// step increment
IWidgetPropertyChangeHandler stepIncrementHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setStepIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_STEP_INCREMENT, stepIncrementHandler);
// bar length
IWidgetPropertyChangeHandler barLengthHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setExtent((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_BAR_LENGTH, barLengthHandler);
// value tip
IWidgetPropertyChangeHandler valueTipHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setShowValueTip((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ScrollBarModel.PROP_SHOW_VALUE_TIP, valueTipHandler);
// horizontal
IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((ScrollbarFigure) refreshableFigure).setHorizontal((Boolean) newValue);
ScrollBarModel model = getWidgetModel();
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(ScrollBarModel.PROP_HORIZONTAL, horizontalHandler);
}
use of org.csstudio.swt.widgets.figures.ScrollbarFigure in project yamcs-studio by yamcs.
the class ScrollbarEditPart method doCreateFigure.
@Override
protected IFigure doCreateFigure() {
ScrollbarFigure scrollBar = new ScrollbarFigure();
ScrollBarModel model = getWidgetModel();
scrollBar.setMaximum(model.getMaximum());
scrollBar.setMinimum(model.getMinimum());
scrollBar.setStepIncrement(model.getStepIncrement());
scrollBar.setPageIncrement(model.getPageIncrement());
scrollBar.setExtent(model.getBarLength());
scrollBar.setShowValueTip(model.isShowValueTip());
scrollBar.setHorizontal(model.isHorizontal());
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
scrollBar.addManualValueChangeListener(new IManualValueChangeListener() {
public void manualValueChanged(double newValue) {
setPVValue(ScrollBarModel.PROP_PVNAME, newValue);
}
});
}
markAsControlPV(AbstractPVWidgetModel.PROP_PVNAME, AbstractPVWidgetModel.PROP_PVVALUE);
return scrollBar;
}
Aggregations