use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class NativeButtonEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
// text
IWidgetPropertyChangeHandler textHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
button.setText(newValue.toString());
button.setSize(button.getSize());
return true;
}
};
setPropertyChangeHandler(ActionButtonModel.PROP_TEXT, textHandler);
// image
IWidgetPropertyChangeHandler imageHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
NativeButtonFigure figure = (NativeButtonFigure) refreshableFigure;
IPath absolutePath = (IPath) newValue;
if (absolutePath != null && !absolutePath.isEmpty() && !absolutePath.isAbsolute())
absolutePath = ResourceUtil.buildAbsolutePath(getWidgetModel(), absolutePath);
figure.setImagePath(absolutePath);
return true;
}
};
setPropertyChangeHandler(ActionButtonModel.PROP_IMAGE, imageHandler);
// button style
final IWidgetPropertyChangeHandler buttonStyleHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
updatePropSheet((Boolean) newValue);
return true;
}
};
getWidgetModel().getProperty(ActionButtonModel.PROP_TOGGLE_BUTTON).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonStyleHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
});
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class NativeButtonEditPartDelegate method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
public void registerPropertyChangeHandlers() {
// text
IWidgetPropertyChangeHandler textHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
button.setText(newValue.toString());
button.setSize(button.getSize());
return true;
}
};
editpart.setPropertyChangeHandler(ActionButtonModel.PROP_TEXT, textHandler);
// image
IWidgetPropertyChangeHandler imageHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
NativeButtonFigure figure = (NativeButtonFigure) refreshableFigure;
IPath absolutePath = (IPath) newValue;
if (absolutePath != null && !absolutePath.isEmpty() && !absolutePath.isAbsolute())
absolutePath = ResourceUtil.buildAbsolutePath(editpart.getWidgetModel(), absolutePath);
figure.setImagePath(absolutePath);
return true;
}
};
editpart.setPropertyChangeHandler(ActionButtonModel.PROP_IMAGE, imageHandler);
// button style
final IWidgetPropertyChangeHandler buttonStyleHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
editpart.updatePropSheet();
return true;
}
};
editpart.getWidgetModel().getProperty(ActionButtonModel.PROP_TOGGLE_BUTTON).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
buttonStyleHandler.handleChange(evt.getOldValue(), evt.getNewValue(), editpart.getFigure());
}
});
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class NativeTextEditpart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
super.registerPropertyChangeHandlers();
removeAllPropertyChangeHandlers(NativeTextModel.PROP_ALIGN_H);
PropertyChangeListener updatePropSheetListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updatePropSheet();
}
};
getWidgetModel().getProperty(NativeTextModel.PROP_MULTILINE_INPUT).addPropertyChangeListener(updatePropSheetListener);
IWidgetPropertyChangeHandler 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(NativeTextModel.PROP_SHOW_NATIVE_BORDER, handler);
setPropertyChangeHandler(NativeTextModel.PROP_MULTILINE_INPUT, handler);
setPropertyChangeHandler(NativeTextModel.PROP_WRAP_WORDS, handler);
setPropertyChangeHandler(NativeTextModel.PROP_SHOW_H_SCROLL, handler);
setPropertyChangeHandler(NativeTextModel.PROP_SHOW_V_SCROLL, handler);
setPropertyChangeHandler(NativeTextModel.PROP_PASSWORD_INPUT, handler);
setPropertyChangeHandler(NativeTextModel.PROP_ALIGN_H, handler);
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class NativeTextEditpartDelegate method registerPropertyChangeHandlers.
@Override
public void registerPropertyChangeHandlers() {
editpart.removeAllPropertyChangeHandlers(TextInputModel.PROP_ALIGN_H);
PropertyChangeListener updatePropSheetListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updatePropSheet();
}
};
model.getProperty(TextInputModel.PROP_MULTILINE_INPUT).addPropertyChangeListener(updatePropSheetListener);
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
AbstractContainerModel parent = model.getParent();
parent.removeChild(model);
parent.addChild(model);
parent.selectWidget(model, true);
return false;
}
};
editpart.setPropertyChangeHandler(TextInputModel.PROP_SHOW_NATIVE_BORDER, handler);
editpart.setPropertyChangeHandler(TextInputModel.PROP_MULTILINE_INPUT, handler);
editpart.setPropertyChangeHandler(TextInputModel.PROP_WRAP_WORDS, handler);
editpart.setPropertyChangeHandler(TextInputModel.PROP_SHOW_H_SCROLL, handler);
editpart.setPropertyChangeHandler(TextInputModel.PROP_SHOW_V_SCROLL, handler);
editpart.setPropertyChangeHandler(TextInputModel.PROP_PASSWORD_INPUT, handler);
editpart.setPropertyChangeHandler(TextInputModel.PROP_ALIGN_H, handler);
}
use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.
the class ProgressBarEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
IWidgetPropertyChangeHandler originHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ProgressBarFigure) figure).setOrigin((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_ORIGIN, originHandler);
IWidgetPropertyChangeHandler originIgnoredHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ProgressBarFigure) figure).setOriginIgnored((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_ORIGIN_IGNORED, originIgnoredHandler);
// fillColor
IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setFillColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_FILL_COLOR, fillColorHandler);
// fillBackgroundColor
IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setEffect3D((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_EFFECT3D, effect3DHandler);
// effect 3D
IWidgetPropertyChangeHandler showLabelHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setShowLabel((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_SHOW_LABEL, showLabelHandler);
IWidgetPropertyChangeHandler indicatorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setIndicatorMode((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_INDICATOR_MODE, indicatorHandler);
// horizontal
IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setHorizontal((Boolean) newValue);
ProgressBarModel model = (ProgressBarModel) getModel();
if (// from vertical to horizontal
(Boolean) newValue)
model.setLocation(model.getLocation().x - model.getSize().height / 2 + model.getSize().width / 2, model.getLocation().y + model.getSize().height / 2 - model.getSize().width / 2);
else
// from horizontal to vertical
model.setLocation(model.getLocation().x + model.getSize().width / 2 - model.getSize().height / 2, model.getLocation().y - model.getSize().width / 2 + model.getSize().height / 2);
model.setSize(model.getSize().height, model.getSize().width);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_HORIZONTAL, horizontalHandler);
// enabled. WidgetBaseEditPart will force the widget as disabled in edit model,
// which is not the case for the scaled slider
IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setEnabled((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_ENABLED, enableHandler);
// Change fill color when "FillColor Alarm Sensitive" property changes.
IWidgetPropertyChangeHandler fillColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
ProgressBarFigure figure = (ProgressBarFigure) refreshableFigure;
boolean sensitive = (Boolean) newValue;
figure.setFillColor(delegate.calculateAlarmColor(sensitive, getWidgetModel().getFillColor()));
return true;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_FILLCOLOR_ALARM_SENSITIVE, fillColorAlarmSensitiveHandler);
// Change fill color when alarm severity changes.
delegate.addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!getWidgetModel().isFillColorAlarmSensitive())
return false;
ProgressBarFigure progress = (ProgressBarFigure) figure;
progress.setFillColor(delegate.calculateAlarmColor(getWidgetModel().isFillColorAlarmSensitive(), getWidgetModel().getFillColor()));
return true;
}
});
}
Aggregations