use of org.csstudio.opibuilder.widgets.figures.NativeButtonFigure 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.csstudio.opibuilder.widgets.figures.NativeButtonFigure in project yamcs-studio by yamcs.
the class NativeButtonEditPart method doCreateFigure.
/**
* {@inheritDoc}
*/
@Override
protected IFigure doCreateFigure() {
NativeButtonModel model = getWidgetModel();
int style = SWT.None;
style |= model.isToggleButton() ? SWT.TOGGLE : SWT.PUSH;
style |= SWT.WRAP;
final NativeButtonFigure buttonFigure = new NativeButtonFigure(this, style);
button = buttonFigure.getSWTWidget();
button.setText(model.getText());
buttonFigure.setImagePath(model.getImagePath());
updatePropSheet(model.isToggleButton());
markAsControlPV(AbstractPVWidgetModel.PROP_PVNAME, AbstractPVWidgetModel.PROP_PVVALUE);
return buttonFigure;
}
use of org.csstudio.opibuilder.widgets.figures.NativeButtonFigure in project yamcs-studio by yamcs.
the class NativeButtonEditPartDelegate method doCreateFigure.
@Override
public IFigure doCreateFigure() {
ActionButtonModel model = editpart.getWidgetModel();
int style = SWT.None;
style |= model.isToggleButton() ? SWT.TOGGLE : SWT.PUSH;
style |= SWT.WRAP;
final NativeButtonFigure buttonFigure = new NativeButtonFigure(editpart, style);
button = buttonFigure.getSWTWidget();
button.setText(model.getText());
button.addTraverseListener(e -> {
if (skipTraverse)
return;
e.doit = false;
skipTraverse = true;
if (e.stateMask == 0) {
SingleSourceHelper.swtControlTraverse(button, SWT.TRAVERSE_TAB_PREVIOUS);
} else {
SingleSourceHelper.swtControlTraverse(button, SWT.TRAVERSE_TAB_NEXT);
}
skipTraverse = false;
});
buttonFigure.setImagePath(model.getImagePath());
return buttonFigure;
}
use of org.csstudio.opibuilder.widgets.figures.NativeButtonFigure 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());
}
});
}
Aggregations