use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH 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_WIDTH in project yamcs-studio by yamcs.
the class TabEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
// init tabs
var i = 0;
for (var child : getWidgetModel().getChildren()) {
if (child instanceof GroupingContainerModel) {
child.setPropertyValue(PROP_VISIBLE, true);
child.setPropertyValue(PROP_VISIBLE, false);
getTabFigure().addTab((String) getWidgetModel().getPropertyValue(TabModel.makeTabPropID(TabProperty.TITLE.propIDPre, i)));
tabItemList.add(i, new TabItem(getWidgetModel(), i, (GroupingContainerModel) child));
for (var tabProperty : TabProperty.values()) {
setTabProperty(i, tabProperty, getWidgetModel().getPropertyValue(TabModel.makeTabPropID(tabProperty.propIDPre, i)));
}
i++;
}
}
IWidgetPropertyChangeHandler relocContainerHandler = (oldValue, newValue, figure) -> {
updateTabAreaSize();
refreshVisuals();
return false;
};
setPropertyChangeHandler(PROP_WIDTH, relocContainerHandler);
setPropertyChangeHandler(PROP_HEIGHT, relocContainerHandler);
setPropertyChangeHandler(PROP_HORIZONTAL_TABS, (oldValue, newValue, figure) -> {
((TabFigure) figure).setHorizontal((Boolean) newValue);
updateTabAreaSize();
refreshVisuals();
return false;
});
setPropertyChangeHandler(PROP_ACTIVE_TAB, (oldValue, newValue, figure) -> {
((TabFigure) figure).setActiveTabIndex((Integer) newValue);
updateTabAreaSize();
refreshVisuals();
return false;
});
setPropertyChangeHandler(PROP_MINIMUM_TAB_HEIGHT, (oldValue, newValue, figure) -> {
((TabFigure) figure).setMinimumTabHeight((Integer) newValue);
return false;
});
setPropertyChangeHandler(PROP_BORDER_WIDTH, (oldValue, newValue, figure) -> {
updateTabAreaSize();
return false;
});
registerTabPropertyChangeHandlers();
registerTabsAmountChangeHandler();
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH 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);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH 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_WIDTH 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()));
}
Aggregations