use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH 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_WIDTH 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_WIDTH 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();
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH in project yamcs-studio by yamcs.
the class KnobEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
setPropertyChangeHandler(PROP_KNOB_COLOR, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setBulbColor(((OPIColor) newValue).getSWTColor());
return false;
});
setPropertyChangeHandler(PROP_THUMB_COLOR, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setThumbColor(((OPIColor) newValue).getSWTColor());
return false;
});
setPropertyChangeHandler(PROP_EFFECT3D, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setEffect3D((Boolean) newValue);
return false;
});
setPropertyChangeHandler(PROP_SHOW_VALUE_LABEL, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setValueLabelVisibility((Boolean) newValue);
return false;
});
setPropertyChangeHandler(PROP_RAMP_GRADIENT, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setGradient((Boolean) newValue);
return false;
});
setPropertyChangeHandler(PROP_INCREMENT, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setIncrement((Double) newValue);
return false;
});
// force square size
IWidgetPropertyChangeHandler sizeHandler = (oldValue, newValue, figure) -> {
if (((Integer) newValue) < KnobModel.MINIMUM_SIZE) {
newValue = KnobModel.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 GroupingContainerEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, figure) -> {
figure.setOpaque(!(Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_ENABLED, (oldValue, newValue, figure) -> {
for (var child : getWidgetModel().getChildren()) {
child.setEnabled((Boolean) newValue);
}
return true;
});
setPropertyChangeHandler(PROP_LOCK_CHILDREN, (oldValue, newValue, figure) -> {
lockChildren((Boolean) newValue);
return true;
});
lockChildren(getWidgetModel().isLocked());
if (getWidgetModel().getParent() instanceof TabModel) {
removeAllPropertyChangeHandlers(PROP_VISIBLE);
setPropertyChangeHandler(PROP_VISIBLE, (oldValue, newValue, refreshableFigure) -> {
boolean visible = (Boolean) newValue;
var figure = getFigure();
figure.setVisible(visible);
return true;
});
}
setPropertyChangeHandler(PROP_SHOW_SCROLLBAR, (oldValue, newValue, refreshableFigure) -> {
((GroupingContainerFigure) refreshableFigure).setShowScrollBar((Boolean) newValue);
return true;
});
IWidgetPropertyChangeHandler fowardColorHandler = (oldValue, newValue, refreshableFigure) -> {
if (getWidgetModel().isForwardColors()) {
forwardColors();
}
return true;
};
setPropertyChangeHandler(PROP_FORWARD_COLORS, fowardColorHandler);
setPropertyChangeHandler(PROP_COLOR_BACKGROUND, fowardColorHandler);
setPropertyChangeHandler(PROP_COLOR_FOREGROUND, fowardColorHandler);
// use property listener because it doesn't need to be queued in GUIRefreshThread.
getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(evt -> resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), true));
getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(evt -> resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), false));
}
Aggregations