use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class IntensityGraphEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
innerUpdateGraphAreaSizeProperty();
registerAxisPropertyChangeHandler();
registerROIPropertyChangeHandlers();
registerROIAmountChangeHandler();
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (newValue == null)
return false;
VType value = (VType) newValue;
if (value instanceof VNumberArray) {
setValue(((VNumberArray) value).getData());
return false;
}
((IntensityGraphFigure) figure).setDataArray(VTypeHelper.getDoubleArray(value));
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
getWidgetModel().getProperty(IntensityGraphModel.PROP_MIN).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
((IntensityGraphFigure) figure).setMin((Double) evt.getNewValue());
figure.repaint();
innerUpdateGraphAreaSizeProperty();
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_MAX).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
((IntensityGraphFigure) figure).setMax((Double) evt.getNewValue());
figure.repaint();
innerUpdateGraphAreaSizeProperty();
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_STYLE).removeAllPropertyChangeListeners();
getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_STYLE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
figure.setBorder(BorderFactory.createBorder(BorderStyle.values()[(Integer) evt.getNewValue()], getWidgetModel().getBorderWidth(), getWidgetModel().getBorderColor(), getWidgetModel().getName()));
innerUpdateGraphAreaSizeProperty();
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_WIDTH).removeAllPropertyChangeListeners();
getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
figure.setBorder(BorderFactory.createBorder(getWidgetModel().getBorderStyle(), (Integer) evt.getNewValue(), getWidgetModel().getBorderColor(), getWidgetModel().getName()));
innerUpdateGraphAreaSizeProperty();
}
});
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setDataWidth((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_DATA_WIDTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setDataHeight((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_DATA_HEIGHT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setColorMap((ColorMap) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_COLOR_MAP, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setCropLeft((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_LEFT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setCropRight((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_RIGHT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setCropTop((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_TOP, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setCropBottom((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_BOTTOM, handler);
getWidgetModel().getProperty(IntensityGraphModel.PROP_SHOW_RAMP).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
((IntensityGraphFigure) getFigure()).setShowRamp((Boolean) evt.getNewValue());
Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
innerTrig = true;
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH, getWidgetModel().getWidth() - d.width);
innerTrig = false;
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!innerTrig) {
// if it is not triggered from inner
innerTrig = true;
Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH, ((Integer) evt.getNewValue()) - d.width);
// reset innerTrig to false after each inner triggering
innerTrig = false;
} else
// if it is triggered from inner, do nothing
innerTrig = false;
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!innerTrig) {
innerTrig = true;
Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_WIDTH, ((Integer) evt.getNewValue()) + d.width);
// reset innerTrig to false after each inner triggering
innerTrig = false;
} else
innerTrig = false;
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!innerTrig) {
innerTrig = true;
Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_HEIGHT, ((Integer) evt.getNewValue()) - d.height);
// reset innerTrig to false after each inner triggering
innerTrig = false;
} else
innerTrig = false;
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_GRAPH_AREA_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!innerTrig) {
innerTrig = true;
Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_HEIGHT, ((Integer) evt.getNewValue()) + d.height);
// reset innerTrig to false after each inner triggering
innerTrig = false;
} else
innerTrig = false;
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_RGB_MODE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updatePropSheet();
((IntensityGraphFigure) getFigure()).setInRGBMode((Boolean) (evt.getNewValue()));
}
});
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) getFigure()).setColorDepth(getWidgetModel().getColorDepth());
return false;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_COLOR_DEPTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) getFigure()).setSingleLineProfiling((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_SINGLE_LINE_PROFILING, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) getFigure()).setROIColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_ROI_COLOR, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class KnobEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// knob color
IWidgetPropertyChangeHandler knobColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
KnobFigure knob = (KnobFigure) refreshableFigure;
knob.setBulbColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(KnobModel.PROP_KNOB_COLOR, knobColorHandler);
// thumbColor
IWidgetPropertyChangeHandler thumbColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
KnobFigure knob = (KnobFigure) refreshableFigure;
knob.setThumbColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(KnobModel.PROP_THUMB_COLOR, thumbColorHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
KnobFigure knob = (KnobFigure) refreshableFigure;
knob.setEffect3D((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(KnobModel.PROP_EFFECT3D, effect3DHandler);
// show value label
IWidgetPropertyChangeHandler valueLabelHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
KnobFigure knob = (KnobFigure) refreshableFigure;
knob.setValueLabelVisibility((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(KnobModel.PROP_SHOW_VALUE_LABEL, valueLabelHandler);
// Ramp gradient
IWidgetPropertyChangeHandler gradientHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
KnobFigure knob = (KnobFigure) refreshableFigure;
knob.setGradient((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(KnobModel.PROP_RAMP_GRADIENT, gradientHandler);
// increment
IWidgetPropertyChangeHandler incrementHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
KnobFigure knob = (KnobFigure) refreshableFigure;
knob.setIncrement((Double) newValue);
return false;
}
};
setPropertyChangeHandler(KnobModel.PROP_INCREMENT, incrementHandler);
// force square size
final IWidgetPropertyChangeHandler sizeHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (((Integer) newValue) < KnobModel.MINIMUM_SIZE)
newValue = KnobModel.MINIMUM_SIZE;
getWidgetModel().setSize((Integer) newValue, (Integer) newValue);
return false;
}
};
PropertyChangeListener sizeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
sizeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
};
getWidgetModel().getProperty(AbstractWidgetModel.PROP_WIDTH).addPropertyChangeListener(sizeListener);
getWidgetModel().getProperty(AbstractWidgetModel.PROP_HEIGHT).addPropertyChangeListener(sizeListener);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class LabelEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
((TextFigure) figure).setText((String) newValue);
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
if (getWidgetModel().isAutoSize())
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
}
});
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_TEXT, handler);
IWidgetPropertyChangeHandler clickableHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((TextFigure) figure).setSelectable(determinSelectable());
return false;
}
};
setPropertyChangeHandler(LabelModel.PROP_ACTIONS, clickableHandler);
setPropertyChangeHandler(LabelModel.PROP_TOOLTIP, clickableHandler);
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()) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
figure.revalidate();
}
}
});
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_FONT, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((TextFigure) figure).setOpaque(!(Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_TRANSPARENT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if ((Boolean) newValue) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
figure.revalidate();
}
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_AUTOSIZE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_ALIGN_H, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) newValue]);
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_ALIGN_V, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
AbstractWidgetModel model = getWidgetModel();
AbstractContainerModel parent = model.getParent();
parent.removeChild(model);
parent.addChild(model);
parent.selectWidget(model, true);
return false;
}
};
setPropertyChangeHandler(LabelModel.PROP_WRAP_WORDS, handler);
getWidgetModel().getProperty(LabelModel.PROP_WRAP_WORDS).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updatePropertyVisibility();
}
});
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (figure instanceof WrappableTextFigure)
((WrappableTextFigure) figure).setShowScrollbar((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(LabelModel.PROP_SHOW_SCROLLBAR, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class LinkingContainerEditpart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (newValue != null && newValue instanceof IPath) {
LinkingContainerModel widgetModel = getWidgetModel();
IPath absolutePath = (IPath) newValue;
if (!absolutePath.isAbsolute())
absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
if (oldValue != null && oldValue instanceof IPath) {
widgetModel.setDisplayModel(null);
} else {
DisplayModel displayModel = new DisplayModel(resolveMacros(absolutePath));
if (widgetModel.getMacroMap().equals(displayModel.getMacroMap())) {
widgetModel.setDisplayModel(displayModel);
} else {
widgetModel.setDisplayModel(null);
}
}
configureDisplayModel();
}
return true;
}
};
setPropertyChangeHandler(LinkingContainerModel.PROP_OPI_FILE, handler);
// load from group
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
// loadWidgets(getWidgetModel(),true);
configureDisplayModel();
return false;
}
};
setPropertyChangeHandler(LinkingContainerModel.PROP_GROUP_NAME, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if ((int) newValue == LinkingContainerModel.ResizeBehaviour.SIZE_OPI_TO_CONTAINER.ordinal()) {
((LinkingContainerFigure) figure).setZoomToFitAll(true);
} else {
((LinkingContainerFigure) figure).setZoomToFitAll(false);
}
((LinkingContainerFigure) figure).updateZoom();
if ((int) newValue == LinkingContainerModel.ResizeBehaviour.SIZE_CONTAINER_TO_OPI.ordinal()) {
performAutosize();
}
return false;
}
};
setPropertyChangeHandler(LinkingContainerModel.PROP_RESIZE_BEHAVIOUR, handler);
// loadWidgets(getWidgetModel(),true);
configureDisplayModel();
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class MenuButtonEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
registerLoadActionsListener();
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
// PV_Value
IWidgetPropertyChangeHandler pvhandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if ((newValue != null) && (newValue instanceof Scalar))
((MenuButtonFigure) refreshableFigure).setText(VTypeHelper.getString((VType) newValue));
return true;
}
};
setPropertyChangeHandler(MenuButtonModel.PROP_PVVALUE, pvhandler);
// label
IWidgetPropertyChangeHandler labelHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((MenuButtonFigure) refreshableFigure).setText(newValue.toString());
return true;
}
};
setPropertyChangeHandler(MenuButtonModel.PROP_LABEL, labelHandler);
// Transparent
IWidgetPropertyChangeHandler transparentHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((MenuButtonFigure) refreshableFigure).setOpaque(!(Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(MenuButtonModel.PROP_TRANSPARENT, transparentHandler);
// Show down arrow
IWidgetPropertyChangeHandler downArrowHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((MenuButtonFigure) refreshableFigure).setDownArrowVisible((boolean) newValue);
return true;
}
};
setPropertyChangeHandler(MenuButtonModel.PROP_SHOW_DOWN_ARROW, downArrowHandler);
final IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
updatePropSheet((Boolean) newValue);
return false;
}
};
getWidgetModel().getProperty(MenuButtonModel.PROP_ACTIONS_FROM_PV).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
});
}
Aggregations