use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class XYGraphEditPart method registerTracePropertyChangeHandlers.
protected void registerTracePropertyChangeHandlers() {
XYGraphModel model = (XYGraphModel) getModel();
// set prop handlers and init all the potential axes
for (int i = 0; i < XYGraphModel.MAX_TRACES_AMOUNT; i++) {
boolean concatenate = (Boolean) getWidgetModel().getProperty(XYGraphModel.makeTracePropID(TraceProperty.CONCATENATE_DATA.propIDPre, i)).getPropertyValue();
String xPVPropID = XYGraphModel.makeTracePropID(TraceProperty.XPV.propIDPre, i);
String yPVPropID = XYGraphModel.makeTracePropID(TraceProperty.YPV.propIDPre, i);
for (TraceProperty traceProperty : TraceProperty.values()) {
final String propID = XYGraphModel.makeTracePropID(traceProperty.propIDPre, i);
final IWidgetPropertyChangeHandler handler = new TracePropertyChangeHandler(i, traceProperty, xPVPropID, yPVPropID);
if (concatenate) {
// cannot use setPropertyChangeHandler because the PV value has to be buffered
// which means that it cannot be ignored.
getWidgetModel().getProperty(propID).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
UIBundlingThread.getInstance().addRunnable(getViewer().getControl().getDisplay(), new Runnable() {
@Override
public void run() {
if (isActive()) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
}
});
}
});
} else
setPropertyChangeHandler(propID, handler);
}
}
for (int i = XYGraphModel.MAX_TRACES_AMOUNT - 1; i >= model.getTracesAmount(); i--) {
for (TraceProperty traceProperty : TraceProperty.values()) {
String propID = XYGraphModel.makeTracePropID(traceProperty.propIDPre, i);
model.setPropertyVisible(propID, false);
}
}
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class XYGraphEditPart method registerTraceAmountChangeHandler.
private void registerTraceAmountChangeHandler() {
final IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
XYGraphModel model = (XYGraphModel) getModel();
IXYGraph xyGraph = ((ToolbarArmedXYGraph) refreshableFigure).getXYGraph();
int currentTracesAmount = xyGraph.getPlotArea().getTraceList().size();
// add trace
if ((Integer) newValue > currentTracesAmount) {
for (int i = 0; i < (Integer) newValue - currentTracesAmount; i++) {
for (TraceProperty traceProperty : TraceProperty.values()) {
if (traceProperty == TraceProperty.XPV_VALUE || traceProperty == TraceProperty.YPV_VALUE)
continue;
String propID = XYGraphModel.makeTracePropID(traceProperty.propIDPre, i + currentTracesAmount);
model.setPropertyVisible(propID, true);
}
xyGraph.addTrace(traceList.get(i + currentTracesAmount));
}
} else if ((Integer) newValue < currentTracesAmount) {
// remove trace
for (int i = 0; i < currentTracesAmount - (Integer) newValue; i++) {
for (TraceProperty traceProperty : TraceProperty.values()) {
String propID = XYGraphModel.makeTracePropID(traceProperty.propIDPre, i + (Integer) newValue);
model.setPropertyVisible(propID, false);
}
xyGraph.removeTrace(traceList.get(i + (Integer) newValue));
}
}
return true;
}
};
getWidgetModel().getProperty(XYGraphModel.PROP_TRACE_COUNT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
});
// setPropertyChangeHandler(XYGraphModel.PROP_TRACES_AMOUNT, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class AbstractBaseEditPart method registerBasePropertyChangeHandlers.
protected void registerBasePropertyChangeHandlers() {
IWidgetPropertyChangeHandler refreshVisualHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
refreshVisuals();
return false;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_XPOS, refreshVisualHandler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_YPOS, refreshVisualHandler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_WIDTH, refreshVisualHandler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_HEIGHT, refreshVisualHandler);
// add connection should not be ignored by widget listener.
getWidgetModel().getProperty(AbstractWidgetModel.PROP_SRC_CONNECTIONS).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
refreshSourceConnections();
}
});
getWidgetModel().getProperty(AbstractWidgetModel.PROP_TGT_CONNECTIONS).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
refreshTargetConnections();
}
});
IWidgetPropertyChangeHandler backColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setBackgroundColor(CustomMediaFactory.getInstance().getColor(((OPIColor) newValue).getRGBValue()));
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_COLOR_BACKGROUND, backColorHandler);
IWidgetPropertyChangeHandler foreColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setForegroundColor(CustomMediaFactory.getInstance().getColor(((OPIColor) newValue).getRGBValue()));
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_COLOR_FOREGROUND, foreColorHandler);
IWidgetPropertyChangeHandler fontHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setFont(((OPIFont) newValue).getSWTFont());
return false;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_FONT, fontHandler);
IWidgetPropertyChangeHandler borderHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
setFigureBorder(calculateBorder());
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, borderHandler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_COLOR, borderHandler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, borderHandler);
IWidgetPropertyChangeHandler labelBorderHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (figure.getBorder() instanceof LabeledBorder)
figure.setBorder(BorderFactory.createBorder(getWidgetModel().getBorderStyle(), getWidgetModel().getBorderWidth(), getWidgetModel().getBorderColor(), getWidgetModel().getName()));
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_NAME, labelBorderHandler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_FONT, labelBorderHandler);
IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setEnabled((Boolean) newValue);
figure.repaint();
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_ENABLED, enableHandler);
IWidgetPropertyChangeHandler tooltipHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (// $NON-NLS-1$
newValue.toString().equals(""))
figure.setToolTip(null);
else {
if (tooltipLabel == null)
tooltipLabel = new TooltipLabel(AbstractBaseEditPart.this);
figure.setToolTip(tooltipLabel);
}
return false;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_TOOLTIP, tooltipHandler);
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();
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
figure.setVisible(visible);
} else {
if (!visible) {
figure.setVisible(false);
UIJob job = new UIJob("reset") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
figure.setVisible(true);
return Status.OK_STATUS;
}
};
job.schedule(2000);
}
}
return true;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_VISIBLE, visibilityHandler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class DisplayEditpart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler backColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setBackgroundColor(((OPIColor) newValue).getSWTColor());
getViewer().getControl().setBackground(CustomMediaFactory.getInstance().getColor(((OPIColor) newValue).getRGBValue()));
return false;
}
};
setPropertyChangeHandler(AbstractWidgetModel.PROP_COLOR_BACKGROUND, backColorHandler);
// grid
if (getExecutionMode() == ExecutionMode.EDIT_MODE) {
IWidgetPropertyChangeHandler gridColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ScalableFreeformRootEditPart) getViewer().getRootEditPart()).getLayer(LayerConstants.GRID_LAYER).setForegroundColor(CustomMediaFactory.getInstance().getColor(((OPIColor) newValue).getRGBValue()));
return false;
}
};
setPropertyChangeHandler(DisplayModel.PROP_COLOR_FOREGROUND, gridColorHandler);
IWidgetPropertyChangeHandler gridSpaceHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension((Integer) newValue, (Integer) newValue));
return false;
}
};
setPropertyChangeHandler(DisplayModel.PROP_GRID_SPACE, gridSpaceHandler);
IWidgetPropertyChangeHandler showGridHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, (Boolean) newValue);
getViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, (Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(DisplayModel.PROP_SHOW_GRID, showGridHandler);
IWidgetPropertyChangeHandler showRulerHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getViewer().setProperty(RulerProvider.PROPERTY_RULER_VISIBILITY, (Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(DisplayModel.PROP_SHOW_RULER, showRulerHandler);
IWidgetPropertyChangeHandler snapGeoHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, (Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(DisplayModel.PROP_SNAP_GEOMETRY, snapGeoHandler);
IWidgetPropertyChangeHandler showEditRangeHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.repaint();
return true;
}
};
setPropertyChangeHandler(DisplayModel.PROP_SHOW_EDIT_RANGE, showEditRangeHandler);
}
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class PVWidgetEditpartDelegate method registerBasePropertyChangeHandlers.
public void registerBasePropertyChangeHandlers() {
IWidgetPropertyChangeHandler borderHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
editpart.setFigureBorder(editpart.calculateBorder());
return true;
}
};
editpart.setPropertyChangeHandler(IPVWidgetModel.PROP_BORDER_ALARMSENSITIVE, borderHandler);
// value
IWidgetPropertyChangeHandler valueHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
// No valid value is given. Do nothing.
if (newValue == null || !(newValue instanceof VType))
return false;
AlarmSeverity newSeverity = VTypeHelper.getAlarmSeverity((VType) newValue);
if (newSeverity == null)
return false;
if (newSeverity != alarmSeverity) {
alarmSeverity = newSeverity;
fireAlarmSeverityChanged(newSeverity, figure);
}
return true;
}
};
editpart.setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, valueHandler);
// Border Alarm Sensitive
addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!isBorderAlarmSensitive)
return false;
editpart.setFigureBorder(editpart.calculateBorder());
return true;
}
});
// BackColor Alarm Sensitive
addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!isBackColorAlarmSensitive)
return false;
figure.setBackgroundColor(calculateBackColor());
return true;
}
});
// ForeColor Alarm Sensitive
addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!isForeColorAlarmSensitive)
return false;
figure.setForegroundColor(calculateForeColor());
return true;
}
});
// Pulsing Alarm Sensitive
addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!isAlarmPulsing)
return false;
if (severity == AlarmSeverity.MAJOR || severity == AlarmSeverity.MINOR) {
startPulsing();
} else {
stopPulsing();
}
return true;
}
});
class PVNamePropertyChangeHandler implements IWidgetPropertyChangeHandler {
private String pvNamePropID;
public PVNamePropertyChangeHandler(String pvNamePropID) {
this.pvNamePropID = pvNamePropID;
}
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
IPV oldPV = pvMap.get(pvNamePropID);
editpart.removeFromConnectionHandler((String) oldValue);
if (oldPV != null) {
oldPV.stop();
oldPV.removeListener(pvListenerMap.get(pvNamePropID));
}
pvMap.remove(pvNamePropID);
String newPVName = ((String) newValue).trim();
if (newPVName.length() <= 0)
return false;
try {
lastWriteAccess = null;
IPV newPV = BOYPVFactory.createPV(newPVName, isAllValuesBuffered);
WidgetPVListener pvListener = new WidgetPVListener(pvNamePropID);
newPV.addListener(pvListener);
pvMap.put(pvNamePropID, newPV);
editpart.addToConnectionHandler(newPVName, newPV);
pvListenerMap.put(pvNamePropID, pvListener);
newPV.start();
} catch (Exception e) {
OPIBuilderPlugin.getLogger().log(Level.WARNING, // $NON-NLS-1$
"Unable to connect to PV:" + newPVName, e);
}
return false;
}
}
// PV name
for (StringProperty pvNameProperty : editpart.getWidgetModel().getPVMap().keySet()) {
if (editpart.getExecutionMode() == ExecutionMode.RUN_MODE)
editpart.setPropertyChangeHandler(pvNameProperty.getPropertyID(), new PVNamePropertyChangeHandler(pvNameProperty.getPropertyID()));
}
if (editpart.getExecutionMode() == ExecutionMode.EDIT_MODE)
editpart.getWidgetModel().getProperty(IPVWidgetModel.PROP_PVNAME).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
// reselect the widget to update feedback.
int selected = editpart.getSelected();
if (selected != EditPart.SELECTED_NONE) {
editpart.setSelected(EditPart.SELECTED_NONE);
editpart.setSelected(selected);
}
}
});
IWidgetPropertyChangeHandler backColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
saveBackColor = ((OPIColor) newValue).getSWTColor();
return false;
}
};
editpart.setPropertyChangeHandler(AbstractWidgetModel.PROP_COLOR_BACKGROUND, backColorHandler);
IWidgetPropertyChangeHandler foreColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
saveForeColor = ((OPIColor) newValue).getSWTColor();
return false;
}
};
editpart.setPropertyChangeHandler(AbstractWidgetModel.PROP_COLOR_FOREGROUND, foreColorHandler);
IWidgetPropertyChangeHandler backColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
isBackColorAlarmSensitive = (Boolean) newValue;
figure.setBackgroundColor(calculateBackColor());
return true;
}
};
editpart.setPropertyChangeHandler(AbstractPVWidgetModel.PROP_BACKCOLOR_ALARMSENSITIVE, backColorAlarmSensitiveHandler);
IWidgetPropertyChangeHandler foreColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
isForeColorAlarmSensitive = (Boolean) newValue;
figure.setForegroundColor(calculateForeColor());
return true;
}
};
editpart.setPropertyChangeHandler(AbstractPVWidgetModel.PROP_FORECOLOR_ALARMSENSITIVE, foreColorAlarmSensitiveHandler);
IWidgetPropertyChangeHandler alarmPulsingHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
isAlarmPulsing = (Boolean) newValue;
stopPulsing();
fireAlarmSeverityChanged(alarmSeverity, figure);
return true;
}
};
editpart.setPropertyChangeHandler(AbstractPVWidgetModel.PROP_ALARM_PULSING, alarmPulsingHandler);
}
Aggregations