use of org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME in project yamcs-studio by yamcs.
the class ArrayEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
for (var child : getWidgetModel().getAllChildren()) {
child.setEnabled((Boolean) newValue);
}
return true;
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, handler);
handler = (oldValue, newValue, figure) -> {
var value = (VType) newValue;
if (value instanceof VNumberArray) {
var wrappedArray = VTypeHelper.getWrappedArray((value));
if (wrappedArray != null) {
setValue(wrappedArray);
} else {
setValue(VTypeHelper.getDoubleArray(value));
}
} else {
if (value instanceof VEnum) {
setValue(new String[] { ((VEnum) value).getValue() });
} else if (value instanceof VString) {
setValue(new String[] { ((VString) value).getValue() });
} else if (value instanceof VStringArray) {
setValue(((VStringArray) value).getData().toArray());
} else {
setValue(VTypeHelper.getDoubleArray(value));
}
}
return false;
};
setPropertyChangeHandler(PROP_PVVALUE, handler);
getWidgetModel().getProperty(PROP_PVNAME).addPropertyChangeListener(evt -> updatePropSheet());
handler = (oldValue, newValue, figure) -> {
registerLoadPVDataTypeListener();
return false;
};
setPropertyChangeHandler(PROP_PVNAME, handler);
getWidgetModel().getProperty(PROP_DATA_TYPE).addPropertyChangeListener(evt -> initValueArray());
handler = (oldValue, newValue, figure) -> {
updateWidgetSize();
return false;
};
setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
handler = (oldValue, newValue, figure) -> {
getArrayFigure().setArrayLength((Integer) newValue);
return false;
};
setPropertyChangeHandler(PROP_ARRAY_LENGTH, handler);
handler = (oldValue, newValue, figure) -> {
((ArrayFigure) figure).setSpinnerWidth((Integer) newValue);
keepElementSize = true;
getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
keepElementSize = false;
return false;
};
setPropertyChangeHandler(PROP_SPINNER_WIDTH, handler);
handler = (oldValue, newValue, figure) -> {
((ArrayFigure) figure).setHorizontal((Boolean) newValue);
keepElementSize = true;
getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
keepElementSize = false;
return false;
};
setPropertyChangeHandler(PROP_HORIZONTAL, handler);
handler = (oldValue, newValue, figure) -> {
((ArrayFigure) figure).setShowScrollbar((Boolean) newValue);
keepElementSize = true;
getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
keepElementSize = false;
return false;
};
setPropertyChangeHandler(PROP_SHOW_SCROLLBAR, handler);
handler = (oldValue, newValue, figure) -> {
((ArrayFigure) figure).setShowSpinner((Boolean) newValue);
keepElementSize = true;
getWidgetModel().setSize(((ArrayFigure) figure).getPreferredSize());
keepElementSize = false;
return false;
};
setPropertyChangeHandler(PROP_SHOW_SPINNER, handler);
PropertyChangeListener sizePropertyChangeListener = evt -> {
if (getWidgetModel().getChildren().size() == 0 || inSync || keepElementSize) {
return;
}
var elementSize = getArrayFigure().getElementSize();
var delta = (Integer) evt.getNewValue() - (Integer) evt.getOldValue();
var elementWH = elementSize.height;
var propID = evt.getPropertyName();
var elementCountDirection = false;
if (getWidgetModel().isHorizontal() && propID.equals(PROP_WIDTH)) {
elementWH = elementSize.width;
elementCountDirection = true;
} else if (!getWidgetModel().isHorizontal() && propID.equals(PROP_HEIGHT)) {
elementWH = elementSize.height;
elementCountDirection = true;
}
if (elementCountDirection) {
var deltaElementsCount = Math.round((float) delta / elementWH);
var idelta = (Math.round((float) delta / elementWH) * elementWH);
setPropertyValue(propID, (Integer) evt.getOldValue() + idelta, false);
var visibleElementsCount = getArrayFigure().getVisibleElementsCount() + deltaElementsCount;
setPropertyValue(PROP_VISIBLE_ELEMENTS_COUNT, visibleElementsCount);
setValue(getValue());
} else {
int wh;
if (propID.equals(PROP_WIDTH)) {
wh = getArrayFigure().getElementSize().width;
} else {
wh = getArrayFigure().getElementSize().height;
}
syncAllChildrenProperties(propID, wh + delta);
}
};
getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(sizePropertyChangeListener);
getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(sizePropertyChangeListener);
}
use of org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME in project yamcs-studio by yamcs.
the class WidgetTreeEditpart method activate.
@Override
public void activate() {
super.activate();
PropertyChangeListener visualListener = evt -> refreshVisuals();
var nameProperty = getWidgetModel().getProperty(PROP_NAME);
if (nameProperty != null) {
nameProperty.addPropertyChangeListener(visualListener);
}
var pvNameProperty = getWidgetModel().getProperty(PROP_PVNAME);
if (pvNameProperty != null) {
pvNameProperty.addPropertyChangeListener(visualListener);
}
}
use of org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME in project yamcs-studio by yamcs.
the class MenuButtonEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVNAME, (oldValue, newValue, figure) -> {
registerLoadActionsListener();
return false;
});
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if ((newValue != null) && (newValue instanceof Scalar)) {
((MenuButtonFigure) refreshableFigure).setText(VTypeHelper.getString((VType) newValue));
}
return true;
});
setPropertyChangeHandler(PROP_LABEL, (oldValue, newValue, refreshableFigure) -> {
((MenuButtonFigure) refreshableFigure).setText(newValue.toString());
return true;
});
setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, refreshableFigure) -> {
((MenuButtonFigure) refreshableFigure).setOpaque(!(Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_SHOW_DOWN_ARROW, (oldValue, newValue, refreshableFigure) -> {
((MenuButtonFigure) refreshableFigure).setDownArrowVisible((boolean) newValue);
return true;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
updatePropSheet((Boolean) newValue);
return false;
};
getWidgetModel().getProperty(PROP_ACTIONS_FROM_PV).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
}
use of org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME in project yamcs-studio by yamcs.
the class AbstractBoolEditPart method registerCommonPropertyChangeHandlers.
/**
* Registers property change handlers for the properties defined in {@link AbstractBoolWidgetModel}. This method is
* provided for the convenience of subclasses, which can call this method in their implementation of
* {@link #registerPropertyChangeHandlers()}.
*/
protected void registerCommonPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if (newValue == null || !(newValue instanceof VType)) {
return false;
}
var figure = (AbstractBoolFigure) refreshableFigure;
switch(VTypeHelper.getBasicDataType((VType) newValue)) {
case SHORT:
figure.setTotalBits(TotalBits.BITS_16);
break;
case INT:
case ENUM:
figure.setTotalBits(TotalBits.BITS_32);
break;
default:
break;
}
updateFromValue((VType) newValue, figure);
return true;
});
setPropertyChangeHandler(PROP_BIT, (oldValue, newValue, refreshableFigure) -> {
if (getWidgetModel().getDataType() != 0) {
return false;
}
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setBit((Integer) newValue);
updateFromValue(getPVValue(PROP_PVNAME), figure);
return true;
});
IWidgetPropertyChangeHandler dataTypeHandler = (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
if ((Integer) newValue == 0) {
figure.setBit(getWidgetModel().getBit());
} else {
figure.setBit(-1);
}
updateFromValue(getPVValue(PROP_PVNAME), figure);
updatePropSheet((Integer) newValue);
return true;
};
getWidgetModel().getProperty(PROP_DATA_TYPE).addPropertyChangeListener(evt -> dataTypeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
setPropertyChangeHandler(PROP_ON_STATE, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
updateFromValue(getPVValue(PROP_PVNAME), figure);
return true;
});
setPropertyChangeHandler(PROP_SHOW_BOOL_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setShowBooleanLabel((Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_BOOL_LABEL_POS, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setBoolLabelPosition(BoolLabelPosition.values()[(Integer) newValue]);
return false;
});
setPropertyChangeHandler(PROP_ON_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOnLabel((String) newValue);
return true;
});
setPropertyChangeHandler(PROP_OFF_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOffLabel((String) newValue);
return true;
});
setPropertyChangeHandler(PROP_ON_COLOR, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOnColor(((OPIColor) newValue).getSWTColor());
return true;
});
setPropertyChangeHandler(PROP_OFF_COLOR, (oldValue, newValue, refreshableFigure) -> {
var figure = (AbstractBoolFigure) refreshableFigure;
figure.setOffColor(((OPIColor) newValue).getSWTColor());
return true;
});
}
use of org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME in project yamcs-studio by yamcs.
the class AbstractChoiceEditPart method registerPropertyChangeHandlers.
@Override
@SuppressWarnings("unchecked")
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVNAME, (oldValue, newValue, figure) -> {
registerLoadItemsListener();
return false;
});
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if (newValue != null && newValue instanceof VType) {
var stringValue = VTypeHelper.getString((VType) newValue);
((AbstractChoiceFigure) refreshableFigure).setState(stringValue);
}
return false;
});
setPropertyChangeHandler(PROP_ITEMS, (oldValue, newValue, refreshableFigure) -> {
if (newValue != null && newValue instanceof List) {
((AbstractChoiceFigure) refreshableFigure).setStates(((List<String>) newValue));
if (getWidgetModel().isItemsFromPV()) {
((AbstractChoiceFigure) refreshableFigure).setState(VTypeHelper.getString(getPVValue(PROP_PVNAME)));
}
}
return true;
});
IWidgetPropertyChangeHandler selectedColorHandler = (oldValue, newValue, figure) -> {
((AbstractChoiceFigure) figure).setSelectedColor(((OPIColor) newValue).getSWTColor());
return false;
};
setPropertyChangeHandler(PROP_SELECTED_COLOR, selectedColorHandler);
setPropertyChangeHandler(PROP_HORIZONTAL, (oldValue, newValue, figure) -> {
((AbstractChoiceFigure) figure).setHorizontal((Boolean) newValue);
return true;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
if (!(Boolean) newValue) {
((AbstractChoiceFigure) refreshableFigure).setStates((getWidgetModel().getItems()));
}
updatePropSheet((Boolean) newValue);
return false;
};
getWidgetModel().getProperty(PROP_ITEMS_FROM_PV).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
}
Aggregations