use of org.eclipse.draw2d.LabeledBorder 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);
}
Aggregations