use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class BoolButtonEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// effect 3D
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
BoolButtonFigure btn = (BoolButtonFigure) refreshableFigure;
btn.setEffect3D((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(BoolButtonModel.PROP_EFFECT3D, handler);
// Square LED
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
BoolButtonFigure btn = (BoolButtonFigure) refreshableFigure;
btn.setSquareButton((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(BoolButtonModel.PROP_SQUARE_BUTTON, handler);
// Show LED
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
BoolButtonFigure btn = (BoolButtonFigure) refreshableFigure;
btn.setShowLED((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(BoolButtonModel.PROP_SHOW_LED, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class BoolSwitchEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// effect 3D
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
BoolSwitchFigure boolSwitch = (BoolSwitchFigure) refreshableFigure;
boolSwitch.setEffect3D((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(BoolSwitchModel.PROP_EFFECT3D, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class ByteMonitorEditPart method registerPropertyChangeHandlers.
/* (non-Javadoc)
* @see org.csstudio.opibuilder.editparts.AbstractBaseEditPart#registerPropertyChangeHandlers()
*/
@Override
protected void registerPropertyChangeHandlers() {
super.registerBasePropertyChangeHandlers();
getFigure().setEnabled(getWidgetModel().isEnabled() && (getExecutionMode() == ExecutionMode.RUN_MODE));
removeAllPropertyChangeHandlers(AbstractWidgetModel.PROP_ENABLED);
// enable
IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {
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);
// PV_Value
IWidgetPropertyChangeHandler pvhandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
boolean succeed = true;
if ((newValue != null) && (newValue instanceof VType)) {
Number number = VTypeHelper.getNumber(((VType) newValue));
if (number != null) {
setValue(number);
} else
succeed = false;
} else {
succeed = false;
}
if (!succeed) {
setValue(0);
ConsoleUtil.writeError(NLS.bind("{0} does not accept non-numeric value.", getWidgetModel().getName()));
}
return false;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_PVVALUE, pvhandler);
// on color
IWidgetPropertyChangeHandler colorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
figure.setOnColor(((OPIColor) newValue).getSWTColor());
figure.drawValue();
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_ON_COLOR, colorHandler);
// off color
colorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
figure.setOffColor(((OPIColor) newValue).getSWTColor());
figure.drawValue();
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_OFF_COLOR, colorHandler);
// change orientation of the bit display
IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
figure.setHorizontal((Boolean) newValue);
ByteMonitorModel 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);
figure.drawValue();
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_HORIZONTAL, horizontalHandler);
// change the display order of the bits
IWidgetPropertyChangeHandler reverseBitsHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
figure.setReverseBits((Boolean) newValue);
figure.drawValue();
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_BIT_REVERSE, reverseBitsHandler);
// Set the bit to use as a starting point
IWidgetPropertyChangeHandler startBitHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
figure.setStartBit((Integer) newValue);
figure.drawValue();
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_START_BIT, startBitHandler);
// Set the number of bits to display
IWidgetPropertyChangeHandler numBitsHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
figure.setNumBits((Integer) newValue);
figure.drawValue();
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_NUM_BITS, numBitsHandler);
// Square LED
IWidgetPropertyChangeHandler squareLEDHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ByteMonitorFigure bm = (ByteMonitorFigure) refreshableFigure;
bm.setSquareLED((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_SQUARE_LED, squareLEDHandler);
// LED spacing
IWidgetPropertyChangeHandler ledBorderWidthHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ByteMonitorFigure bm = (ByteMonitorFigure) refreshableFigure;
bm.setLedBorderWidth((int) newValue);
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_LED_BORDER, ledBorderWidthHandler);
// LED border color
IWidgetPropertyChangeHandler ledBorderColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ByteMonitorFigure bm = (ByteMonitorFigure) refreshableFigure;
bm.setLedBorderColor(((OPIColor) newValue).getSWTColor());
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_LED_BORDER_COLOR, ledBorderColorHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ByteMonitorFigure bmFig = (ByteMonitorFigure) refreshableFigure;
bmFig.setEffect3D((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_EFFECT3D, effect3DHandler);
// labels
IWidgetPropertyChangeHandler labelsHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ByteMonitorFigure bmFig = (ByteMonitorFigure) refreshableFigure;
ByteMonitorModel model = getWidgetModel();
bmFig.setLabels(model.getLabels());
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_LABELS, labelsHandler);
// Set the LED rendering style
IWidgetPropertyChangeHandler packHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
ByteMonitorFigure figure = (ByteMonitorFigure) refreshableFigure;
figure.setPackedLEDs((Boolean) newValue);
figure.drawValue();
return true;
}
};
setPropertyChangeHandler(ByteMonitorModel.PROP_PACK_LEDS, packHandler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class ComboEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
registerLoadItemsListener();
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
autoSizeWidget((ComboFigure) getFigure());
// PV_Value
IWidgetPropertyChangeHandler pvhandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (newValue != null) {
String stringValue = VTypeHelper.getString((VType) newValue);
if (Arrays.asList(combo.getItems()).contains(stringValue))
combo.setText(stringValue);
else
combo.deselectAll();
//
// if(getWidgetModel().isBorderAlarmSensitve())
// autoSizeWidget((ComboFigure) refreshableFigure);
}
return true;
}
};
setPropertyChangeHandler(ComboModel.PROP_PVVALUE, pvhandler);
// Items
IWidgetPropertyChangeHandler itemsHandler = new IWidgetPropertyChangeHandler() {
@SuppressWarnings("unchecked")
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (newValue != null && newValue instanceof List) {
updateCombo((List<String>) newValue);
if (getWidgetModel().isItemsFromPV())
combo.setText(VTypeHelper.getString(getPVValue(AbstractPVWidgetModel.PROP_PVNAME)));
}
return true;
}
};
setPropertyChangeHandler(ComboModel.PROP_ITEMS, itemsHandler);
final IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
updatePropSheet((Boolean) newValue);
return false;
}
};
getWidgetModel().getProperty(ComboModel.PROP_ITEMS_FROM_PV).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
});
// size change handlers--always apply the default height
IWidgetPropertyChangeHandler handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
autoSizeWidget((ComboFigure) figure);
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_WIDTH, handle);
setPropertyChangeHandler(AbstractWidgetModel.PROP_HEIGHT, handle);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handle);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handle);
setPropertyChangeHandler(ComboModel.PROP_FONT, handle);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class Draw2DButtonEditPartDelegate method registerPropertyChangeHandlers.
/* (non-Javadoc)
* @see org.csstudio.opibuilder.widgets.editparts.IButtonEditPartDelegate#registerPropertyChangeHandlers()
*/
@Override
public void registerPropertyChangeHandlers() {
// text
IWidgetPropertyChangeHandler textHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ActionButtonFigure figure = (ActionButtonFigure) refreshableFigure;
figure.setText(newValue.toString());
figure.calculateTextPosition();
return true;
}
};
editpart.setPropertyChangeHandler(ActionButtonModel.PROP_TEXT, textHandler);
// image
IWidgetPropertyChangeHandler imageHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ActionButtonFigure figure = (ActionButtonFigure) refreshableFigure;
IPath absolutePath = (IPath) newValue;
if (absolutePath != null && !absolutePath.isEmpty() && !absolutePath.isAbsolute())
absolutePath = ResourceUtil.buildAbsolutePath(editpart.getWidgetModel(), absolutePath);
figure.setImagePath(absolutePath);
return true;
}
};
editpart.setPropertyChangeHandler(ActionButtonModel.PROP_IMAGE, imageHandler);
// width
IWidgetPropertyChangeHandler widthHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ActionButtonFigure figure = (ActionButtonFigure) refreshableFigure;
Integer height = (Integer) editpart.getPropertyValue(ActionButtonModel.PROP_HEIGHT);
figure.calculateTextPosition((Integer) newValue, height);
return true;
}
};
editpart.setPropertyChangeHandler(ActionButtonModel.PROP_WIDTH, widthHandler);
// height
IWidgetPropertyChangeHandler heightHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ActionButtonFigure figure = (ActionButtonFigure) refreshableFigure;
Integer width = (Integer) editpart.getPropertyValue(ActionButtonModel.PROP_WIDTH);
figure.calculateTextPosition(width, (Integer) newValue);
return true;
}
};
editpart.setPropertyChangeHandler(ActionButtonModel.PROP_HEIGHT, heightHandler);
// button style
final IWidgetPropertyChangeHandler buttonStyleHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ActionButtonFigure figure = (ActionButtonFigure) refreshableFigure;
figure.setToggleStyle((Boolean) newValue);
editpart.updatePropSheet();
return true;
}
};
editpart.getWidgetModel().getProperty(ActionButtonModel.PROP_TOGGLE_BUTTON).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonStyleHandler.handleChange(evt.getOldValue(), evt.getNewValue(), editpart.getFigure());
}
});
}
Aggregations