use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT in project yamcs-studio by yamcs.
the class LEDEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
setPropertyChangeHandler(PROP_EFFECT3D, (oldValue, newValue, refreshableFigure) -> {
var led = (LEDFigure) refreshableFigure;
led.setEffect3D((Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_SQUARE_LED, (oldValue, newValue, refreshableFigure) -> {
var led = (LEDFigure) refreshableFigure;
led.setSquareLED((Boolean) newValue);
if (!(Boolean) newValue) {
var width = Math.min(getWidgetModel().getWidth(), getWidgetModel().getHeight());
getWidgetModel().setSize(width, width);
}
return true;
});
// force square size
IWidgetPropertyChangeHandler sizeHandler = (oldValue, newValue, figure) -> {
if (getWidgetModel().isSquareLED()) {
return false;
}
if (((Integer) newValue) < LEDModel.MINIMUM_SIZE) {
newValue = LEDModel.MINIMUM_SIZE;
}
getWidgetModel().setSize((Integer) newValue, (Integer) newValue);
return false;
};
PropertyChangeListener sizeListener = evt -> sizeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(sizeListener);
getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(sizeListener);
getWidgetModel().getProperty(PROP_NSTATES).addPropertyChangeListener(evt -> initializeNStatesProperties((Integer) evt.getOldValue(), (Integer) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_STATE_FALLBACK_LABEL).addPropertyChangeListener(evt -> initializeStateFallbackLabel((String) evt.getOldValue(), (String) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_STATE_FALLBACK_COLOR).addPropertyChangeListener(evt -> initializeStateFallbackColor(((OPIColor) evt.getOldValue()).getSWTColor(), ((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_BULB_BORDER).addPropertyChangeListener(evt -> initializeStateBulbBorderWidth((Integer) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(PROP_BULB_BORDER_COLOR).addPropertyChangeListener(evt -> initializeStateBulbBorderColor(((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel()));
for (var idx = 0; idx < LEDFigure.MAX_NSTATES; idx++) {
var state = idx;
getWidgetModel().getProperty(String.format(PROP_STATE_LABEL, state)).addPropertyChangeListener(evt -> initializeStateLabel(state, (String) evt.getOldValue(), (String) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(String.format(PROP_STATE_COLOR, state)).addPropertyChangeListener(evt -> initializeStateColor(state, ((OPIColor) evt.getOldValue()).getSWTColor(), ((OPIColor) evt.getNewValue()).getSWTColor(), (LEDFigure) getFigure(), getWidgetModel()));
getWidgetModel().getProperty(String.format(PROP_STATE_VALUE, state)).addPropertyChangeListener(evt -> initializeStateValue(state, (Double) evt.getOldValue(), (Double) evt.getNewValue(), (LEDFigure) getFigure(), getWidgetModel()));
}
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT in project yamcs-studio by yamcs.
the class Draw2DButtonEditPartDelegate method registerPropertyChangeHandlers.
@Override
public void registerPropertyChangeHandlers() {
editpart.setPropertyChangeHandler(PROP_TEXT, (oldValue, newValue, refreshableFigure) -> {
var figure = (ActionButtonFigure) refreshableFigure;
figure.setText(newValue.toString());
figure.calculateTextPosition();
return true;
});
editpart.setPropertyChangeHandler(PROP_IMAGE, (oldValue, newValue, refreshableFigure) -> {
var figure = (ActionButtonFigure) refreshableFigure;
var absolutePath = (String) newValue;
if (absolutePath != null && !absolutePath.contains("://")) {
var path = Path.fromPortableString(absolutePath);
if (!path.isAbsolute()) {
path = ResourceUtil.buildAbsolutePath(editpart.getWidgetModel(), path);
absolutePath = path.toPortableString();
}
}
figure.setImagePath(absolutePath);
return true;
});
editpart.setPropertyChangeHandler(PROP_WIDTH, (oldValue, newValue, refreshableFigure) -> {
var figure = (ActionButtonFigure) refreshableFigure;
var height = (Integer) editpart.getPropertyValue(PROP_HEIGHT);
figure.calculateTextPosition((Integer) newValue, height);
return true;
});
editpart.setPropertyChangeHandler(PROP_HEIGHT, (oldValue, newValue, refreshableFigure) -> {
var figure = (ActionButtonFigure) refreshableFigure;
var width = (Integer) editpart.getPropertyValue(PROP_WIDTH);
figure.calculateTextPosition(width, (Integer) newValue);
return true;
});
IWidgetPropertyChangeHandler buttonStyleHandler = (oldValue, newValue, refreshableFigure) -> {
var figure = (ActionButtonFigure) refreshableFigure;
figure.setToggleStyle((Boolean) newValue);
editpart.updatePropSheet();
return true;
};
editpart.getWidgetModel().getProperty(PROP_TOGGLE_BUTTON).addPropertyChangeListener(evt -> buttonStyleHandler.handleChange(evt.getOldValue(), evt.getNewValue(), editpart.getFigure()));
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT in project yamcs-studio by yamcs.
the class ImageBoolButtonEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// Save CPU usage
// removeAllPropertyChangeHandlers(AbstractPVWidgetModel.PROP_PVVALUE);
// value
// IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
// public boolean handleChange(Object oldValue,
// final Object newValue,
// final IFigure refreshableFigure) {
// if(newValue == null)
// return false;
// ImageBoolButtonFigure figure = (ImageBoolButtonFigure) refreshableFigure;
// //figure.setValue(ValueUtil.getDouble((IValue)newValue));
// autoSizeWidget(figure);
// return true;
// }
// };
// setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
setPropertyChangeHandler(PROP_ON_IMAGE, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
var absolutePath = (String) newValue;
if (!absolutePath.contains("://")) {
var path = Path.fromPortableString(absolutePath);
if (!path.isAbsolute()) {
path = ResourceUtil.buildAbsolutePath(getWidgetModel(), path);
absolutePath = path.toPortableString();
}
}
imageFigure.setOnImagePath(absolutePath);
autoSizeWidget(imageFigure);
return true;
});
setPropertyChangeHandler(PROP_OFF_IMAGE, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
var absolutePath = (String) newValue;
if (!absolutePath.contains("://")) {
var path = Path.fromPortableString(absolutePath);
if (!path.isAbsolute()) {
path = ResourceUtil.buildAbsolutePath(getWidgetModel(), path);
absolutePath = path.toPortableString();
}
}
imageFigure.setOffImagePath(absolutePath);
autoSizeWidget(imageFigure);
return true;
});
setPropertyChangeHandler(PROP_STRETCH, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
imageFigure.setStretch((Boolean) newValue);
autoSizeWidget(imageFigure);
return true;
});
FigureTransparencyHelper.addHandler(this, figure);
setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
autoSizeWidget(imageFigure);
return true;
});
setPropertyChangeHandler(PROP_NO_ANIMATION, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
imageFigure.setAnimationDisabled((Boolean) newValue);
return false;
});
setPropertyChangeHandler(PROP_ALIGN_TO_NEAREST_SECOND, (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
imageFigure.setAlignedToNearestSecond((Boolean) newValue);
return false;
});
// changes to the border width property
IWidgetPropertyChangeHandler handle = (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
autoSizeWidget(imageFigure);
return true;
};
setPropertyChangeHandler(PROP_BORDER_WIDTH, handle);
setPropertyChangeHandler(PROP_BORDER_STYLE, handle);
// size change handlers - so we can stretch accordingly
handle = (oldValue, newValue, figure) -> {
var imageFigure = (ImageBoolButtonFigure) figure;
autoSizeWidget(imageFigure);
return true;
};
setPropertyChangeHandler(PROP_HEIGHT, handle);
setPropertyChangeHandler(PROP_WIDTH, handle);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT in project yamcs-studio by yamcs.
the class ComboEditPart method registerPropertyChangeHandlers.
@Override
@SuppressWarnings("unchecked")
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVNAME, (oldValue, newValue, figure) -> {
registerLoadItemsListener();
return false;
});
autoSizeWidget((ComboFigure) getFigure());
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if (newValue != null) {
var 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(PROP_ITEMS, (oldValue, newValue, refreshableFigure) -> {
if (newValue != null && newValue instanceof List) {
updateCombo((List<String>) newValue);
if (getWidgetModel().isItemsFromPV()) {
combo.setText(VTypeHelper.getString(getPVValue(PROP_PVNAME)));
}
}
return true;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
updatePropSheet((Boolean) newValue);
return false;
};
getWidgetModel().getProperty(PROP_ITEMS_FROM_PV).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
// size change handlers--always apply the default height
IWidgetPropertyChangeHandler handle = (oldValue, newValue, figure) -> {
autoSizeWidget((ComboFigure) figure);
return true;
};
setPropertyChangeHandler(PROP_WIDTH, handle);
setPropertyChangeHandler(PROP_HEIGHT, handle);
setPropertyChangeHandler(PROP_BORDER_STYLE, handle);
setPropertyChangeHandler(PROP_BORDER_WIDTH, handle);
setPropertyChangeHandler(PROP_FONT, handle);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT in project yamcs-studio by yamcs.
the class GaugeEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
setPropertyChangeHandler(PROP_NEEDLE_COLOR, (oldValue, newValue, refreshableFigure) -> {
var gauge = (GaugeFigure) refreshableFigure;
gauge.setNeedleColor(((OPIColor) newValue).getSWTColor());
return false;
});
setPropertyChangeHandler(PROP_EFFECT3D, (oldValue, newValue, refreshableFigure) -> {
var gauge = (GaugeFigure) refreshableFigure;
gauge.setEffect3D((Boolean) newValue);
return false;
});
setPropertyChangeHandler(PROP_RAMP_GRADIENT, (oldValue, newValue, refreshableFigure) -> {
var gauge = (GaugeFigure) refreshableFigure;
gauge.setGradient((Boolean) newValue);
return false;
});
IWidgetPropertyChangeHandler sizeHandler = (oldValue, newValue, figure) -> {
if (((Integer) newValue) < GaugeModel.MINIMUM_SIZE) {
newValue = GaugeModel.MINIMUM_SIZE;
}
getWidgetModel().setSize((Integer) newValue, (Integer) newValue);
return false;
};
PropertyChangeListener sizeListener = evt -> sizeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(sizeListener);
getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(sizeListener);
}
Aggregations