use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class CheckBoxEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
// value
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (newValue == null)
return false;
CheckBoxFigure 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(AbstractPVWidgetModel.PROP_PVVALUE, handler);
// bit
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
CheckBoxFigure figure = (CheckBoxFigure) refreshableFigure;
figure.setBit((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_BIT, handler);
// label
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
CheckBoxFigure figure = (CheckBoxFigure) refreshableFigure;
figure.setText((String) newValue);
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
if (getWidgetModel().isAutoSize())
performAutoSize(refreshableFigure);
}
});
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_LABEL, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if ((Boolean) newValue) {
performAutoSize(figure);
figure.revalidate();
}
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_AUTOSIZE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((CheckBoxFigure) figure).setSelectedColor(getWidgetModel().getSelectedColor().getSWTColor());
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_SELECTED_COLOR, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
if (getWidgetModel().isAutoSize()) {
performAutoSize(figure);
figure.revalidate();
}
}
});
return true;
}
};
setPropertyChangeHandler(CheckBoxModel.PROP_FONT, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class GroupingContainerEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setOpaque(!(Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(GroupingContainerModel.PROP_TRANSPARENT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
for (AbstractWidgetModel child : getWidgetModel().getChildren()) {
child.setEnabled((Boolean) newValue);
}
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
lockChildren((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(GroupingContainerModel.PROP_LOCK_CHILDREN, handler);
lockChildren(getWidgetModel().isLocked());
if (getWidgetModel().getParent() instanceof TabModel) {
removeAllPropertyChangeHandlers(AbstractWidgetModel.PROP_VISIBLE);
IWidgetPropertyChangeHandler visibilityHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
boolean visible = (Boolean) newValue;
final IFigure figure = getFigure();
figure.setVisible(visible);
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_VISIBLE, visibilityHandler);
}
IWidgetPropertyChangeHandler showBarHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((GroupingContainerFigure) refreshableFigure).setShowScrollBar((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(GroupingContainerModel.PROP_SHOW_SCROLLBAR, showBarHandler);
IWidgetPropertyChangeHandler fowardColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (getWidgetModel().isForwardColors())
forwardColors();
return true;
}
};
setPropertyChangeHandler(GroupingContainerModel.PROP_FORWARD_COLORS, fowardColorHandler);
setPropertyChangeHandler(GroupingContainerModel.PROP_COLOR_BACKGROUND, fowardColorHandler);
setPropertyChangeHandler(GroupingContainerModel.PROP_COLOR_FOREGROUND, fowardColorHandler);
// use property listener because it doesn't need to be queued in GUIRefreshThread.
getWidgetModel().getProperty(AbstractWidgetModel.PROP_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), true);
}
});
getWidgetModel().getProperty(AbstractWidgetModel.PROP_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
resizeChildren((Integer) (evt.getNewValue()), (Integer) (evt.getOldValue()), false);
}
});
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class ImageBoolIndicatorEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// Don't autosize to save CPU usage
// removeAllPropertyChangeHandlers(AbstractPVWidgetModel.PROP_PVVALUE);
// value
// IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
// public boolean handleChange(final 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);
// changes to the on image property
IWidgetPropertyChangeHandler handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
IPath absolutePath = (IPath) newValue;
if (!absolutePath.isAbsolute())
absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
imageFigure.setOnImagePath(absolutePath);
autoSizeWidget(imageFigure);
return true;
}
};
setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_ON_IMAGE, handle);
// changes to the off image property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
IPath absolutePath = (IPath) newValue;
if (!absolutePath.isAbsolute())
absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
imageFigure.setOffImagePath(absolutePath);
autoSizeWidget(imageFigure);
return true;
}
};
setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_OFF_IMAGE, handle);
// changes to the stretch property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
imageFigure.setStretch((Boolean) newValue);
autoSizeWidget(imageFigure);
return true;
}
};
setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_STRETCH, handle);
// changes to the autosize property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
autoSizeWidget(imageFigure);
return true;
}
};
setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_AUTOSIZE, handle);
// changes to the stop animation property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
imageFigure.setAnimationDisabled((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_NO_ANIMATION, handle);
// changes to the align to nearest second property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
imageFigure.setAlignedToNearestSecond((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ImageBoolIndicatorModel.PROP_ALIGN_TO_NEAREST_SECOND, handle);
// changes to the border width property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
autoSizeWidget(imageFigure);
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handle);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handle);
// size change handlers - so we can stretch accordingly
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageBoolButtonFigure imageFigure = (ImageBoolButtonFigure) figure;
autoSizeWidget(imageFigure);
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_HEIGHT, handle);
setPropertyChangeHandler(AbstractWidgetModel.PROP_WIDTH, handle);
FigureTransparencyHelper.addHandler(this, figure);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class ImageEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
// changes to the filename property
IWidgetPropertyChangeHandler handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
IPath absolutePath = (IPath) newValue;
if (!absolutePath.isAbsolute())
absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
imageFigure.setFilePath(absolutePath);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_IMAGE_FILE, handle);
// changes to the stretch property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
imageFigure.setStretch((Boolean) newValue);
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_STRETCH, handle);
// changes to the autosize property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
imageFigure.setAutoSize((Boolean) newValue);
ImageModel model = (ImageModel) getModel();
Dimension d = imageFigure.getAutoSizedDimension();
if ((Boolean) newValue && !model.getStretch() && d != null)
model.setSize(d.width, d.height);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_AUTOSIZE, handle);
// changes to the stop animation property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
imageFigure.setAnimationDisabled((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_NO_ANIMATION, handle);
// changes to the align to nearest second property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
imageFigure.setAlignedToNearestSecond((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_ALIGN_TO_NEAREST_SECOND, handle);
// changes to the border width property
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
imageFigure.resizeImage();
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_BORDER_WIDTH, handle);
setPropertyChangeHandler(ImageModel.PROP_BORDER_STYLE, handle);
// size change handlers - so we can stretch accordingly
handle = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
ImageFigure imageFigure = (ImageFigure) figure;
imageFigure.resizeImage();
autoSizeWidget(imageFigure);
return false;
}
};
setPropertyChangeHandler(ImageModel.PROP_HEIGHT, handle);
setPropertyChangeHandler(ImageModel.PROP_WIDTH, handle);
FigureTransparencyHelper.addHandler(this, figure);
registerCropPropertyHandlers();
registerImageRotationPropertyHandlers();
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class IntensityGraphEditPart method registerROIPropertyChangeHandlers.
private void registerROIPropertyChangeHandlers() {
for (int i = 0; i < IntensityGraphModel.MAX_ROIS_AMOUNT; i++) {
final String roiName = getROIName(i);
for (final ROIProperty roiProperty : ROIProperty.values()) {
String propID = IntensityGraphModel.makeROIPropID(roiProperty.propIDPre, i);
if (i >= (Integer) getPropertyValue(IntensityGraphModel.PROP_ROI_COUNT)) {
getWidgetModel().setPropertyVisible(propID, false);
}
setPropertyChangeHandler(propID, new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
setROIProperty(roiName, roiProperty, newValue);
return false;
}
});
}
}
}
Aggregations