use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE in project yamcs-studio by yamcs.
the class ImageBoolIndicatorEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// Don't autosize to 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;
// // 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;
});
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);
FigureTransparencyHelper.addHandler(this, figure);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE in project yamcs-studio by yamcs.
the class LabelEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_TEXT, (oldValue, newValue, figure) -> {
((TextFigure) figure).setText((String) newValue);
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
}
});
return true;
});
setPropertyChangeHandler(PROP_ACTIONS, (oldValue, newValue, figure) -> {
((TextFigure) figure).setSelectable(determinSelectable());
return false;
});
setPropertyChangeHandler(PROP_TOOLTIP, (oldValue, newValue, figure) -> {
((TextFigure) figure).setSelectable(determinSelectable());
return false;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
figure.revalidate();
}
});
return true;
};
setPropertyChangeHandler(PROP_FONT, handler);
setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, figure) -> {
((TextFigure) figure).setOpaque(!(Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
if ((Boolean) newValue) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
figure.revalidate();
}
return true;
});
setPropertyChangeHandler(PROP_ALIGN_H, (oldValue, newValue, figure) -> {
((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
return true;
});
setPropertyChangeHandler(PROP_ALIGN_V, (oldValue, newValue, figure) -> {
((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) newValue]);
return true;
});
setPropertyChangeHandler(PROP_WRAP_WORDS, (oldValue, newValue, figure) -> {
AbstractWidgetModel model = getWidgetModel();
var parent = model.getParent();
parent.removeChild(model);
parent.addChild(model);
parent.selectWidget(model, true);
return false;
});
getWidgetModel().getProperty(PROP_WRAP_WORDS).addPropertyChangeListener(evt -> updatePropertyVisibility());
setPropertyChangeHandler(PROP_SHOW_SCROLLBAR, (oldValue, newValue, figure) -> {
if (figure instanceof WrappableTextFigure) {
((WrappableTextFigure) figure).setShowScrollbar((Boolean) newValue);
}
return false;
});
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE 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.AbstractWidgetModel.PROP_BORDER_STYLE in project yamcs-studio by yamcs.
the class CheckBoxEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if (newValue == null) {
return false;
}
var figure = (CheckBoxFigure) 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;
}
figure.setValue(VTypeHelper.getDouble((VType) newValue));
return true;
});
setPropertyChangeHandler(PROP_BIT, (oldValue, newValue, refreshableFigure) -> {
var figure = (CheckBoxFigure) refreshableFigure;
figure.setBit((Integer) newValue);
return true;
});
setPropertyChangeHandler(PROP_LABEL, (oldValue, newValue, refreshableFigure) -> {
var figure = (CheckBoxFigure) refreshableFigure;
figure.setText((String) newValue);
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
performAutoSize(refreshableFigure);
}
});
return true;
});
setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
if ((Boolean) newValue) {
performAutoSize(figure);
figure.revalidate();
}
return true;
});
setPropertyChangeHandler(PROP_SELECTED_COLOR, (oldValue, newValue, figure) -> {
((CheckBoxFigure) figure).setSelectedColor(getWidgetModel().getSelectedColor().getSWTColor());
return true;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
performAutoSize(figure);
figure.revalidate();
}
});
return true;
};
setPropertyChangeHandler(PROP_FONT, handler);
setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE in project yamcs-studio by yamcs.
the class ImageEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_IMAGE_FILE, (oldValue, newValue, figure) -> {
var imageFigure = (ImageFigure) 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.setFilePath(absolutePath);
autoSizeWidget(imageFigure);
return false;
});
setPropertyChangeHandler(PROP_STRETCH, (oldValue, newValue, figure) -> {
var imageFigure = (ImageFigure) figure;
imageFigure.setStretch((Boolean) newValue);
autoSizeWidget(imageFigure);
return false;
});
setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
var imageFigure = (ImageFigure) figure;
imageFigure.setAutoSize((Boolean) newValue);
var model = (ImageModel) getModel();
var d = imageFigure.getAutoSizedDimension();
if ((Boolean) newValue && !model.getStretch() && d != null) {
model.setSize(d.width, d.height);
}
return false;
});
setPropertyChangeHandler(PROP_NO_ANIMATION, (oldValue, newValue, figure) -> {
var imageFigure = (ImageFigure) figure;
imageFigure.setAnimationDisabled((Boolean) newValue);
return false;
});
setPropertyChangeHandler(PROP_ALIGN_TO_NEAREST_SECOND, (oldValue, newValue, figure) -> {
var imageFigure = (ImageFigure) figure;
imageFigure.setAlignedToNearestSecond((Boolean) newValue);
return false;
});
// changes to the border width property
IWidgetPropertyChangeHandler handle = (oldValue, newValue, figure) -> {
var imageFigure = (ImageFigure) figure;
imageFigure.resizeImage();
autoSizeWidget(imageFigure);
return false;
};
setPropertyChangeHandler(PROP_BORDER_WIDTH, handle);
setPropertyChangeHandler(PROP_BORDER_STYLE, handle);
// size change handlers - so we can stretch accordingly
handle = (oldValue, newValue, figure) -> {
var imageFigure = (ImageFigure) figure;
imageFigure.resizeImage();
autoSizeWidget(imageFigure);
return false;
};
setPropertyChangeHandler(PROP_HEIGHT, handle);
setPropertyChangeHandler(PROP_WIDTH, handle);
FigureTransparencyHelper.addHandler(this, figure);
registerCropPropertyHandlers();
registerImageRotationPropertyHandlers();
}
Aggregations