use of org.csstudio.opibuilder.util.OPIColor 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.util.OPIColor 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.util.OPIColor in project yamcs-studio by yamcs.
the class ColorProperty method readValueFromXML.
@Override
public Object readValueFromXML(Element propElement) {
Element colorElement = propElement.getChild(XML_ELEMENT_COLOR);
String name = colorElement.getAttributeValue(XML_ATTRIBUTE_NAME);
if (name == null) {
RGB result = new RGB(Integer.parseInt(colorElement.getAttributeValue(XML_ATTRIBUTE_RED)), Integer.parseInt(colorElement.getAttributeValue(XML_ATTRIBUTE_GREEN)), Integer.parseInt(colorElement.getAttributeValue(XML_ATTRIBUTE_BLUE)));
return new OPIColor(result);
} else {
String red = colorElement.getAttributeValue(XML_ATTRIBUTE_RED);
String green = colorElement.getAttributeValue(XML_ATTRIBUTE_GREEN);
String blue = colorElement.getAttributeValue(XML_ATTRIBUTE_BLUE);
RGB rgb;
if (red != null && green != null && blue != null) {
rgb = new RGB(Integer.parseInt(red), Integer.parseInt(green), Integer.parseInt(blue));
return MediaService.getInstance().getOPIColor(name, rgb);
}
return MediaService.getInstance().getOPIColor(name);
}
}
Aggregations