use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class AbstractContainerEditpart method registerBasePropertyChangeHandlers.
@Override
protected void registerBasePropertyChangeHandlers() {
super.registerBasePropertyChangeHandlers();
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
MacrosInput macrosInput = (MacrosInput) newValue;
LinkedHashMap<String, String> macrosMap = new LinkedHashMap<String, String>();
if (macrosInput.isInclude_parent_macros()) {
macrosMap.putAll(getWidgetModel().getParentMacroMap());
}
macrosMap.putAll(macrosInput.getMacrosMap());
getWidgetModel().setMacroMap(macrosMap);
return false;
}
};
setPropertyChangeHandler(AbstractContainerModel.PROP_MACROS, handler);
layout();
childrenPropertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getOldValue() instanceof Integer) {
addChild(createChild(evt.getNewValue()), ((Integer) evt.getOldValue()).intValue());
layout();
} else if (evt.getOldValue() instanceof AbstractWidgetModel) {
EditPart child = (EditPart) getViewer().getEditPartRegistry().get(evt.getOldValue());
if (child != null) {
removeChild(child);
layout();
}
} else
refreshChildren();
}
};
getWidgetModel().getChildrenProperty().addPropertyChangeListener(childrenPropertyChangeListener);
if (getExecutionMode() == ExecutionMode.EDIT_MODE) {
selectionPropertyChangeListener = new PropertyChangeListener() {
@SuppressWarnings("unchecked")
@Override
public void propertyChange(PropertyChangeEvent evt) {
List<AbstractWidgetModel> widgets = (List<AbstractWidgetModel>) evt.getNewValue();
List<EditPart> widgetEditparts = new ArrayList<EditPart>();
for (AbstractWidgetModel w : widgets) {
EditPart e = (EditPart) getViewer().getEditPartRegistry().get(w);
if (e != null)
widgetEditparts.add(e);
}
if (!(Boolean) evt.getOldValue()) {
// append
getViewer().deselectAll();
}
for (EditPart editpart : widgetEditparts) {
if (editpart.isSelectable())
getViewer().appendSelection(editpart);
}
}
};
getWidgetModel().getSelectionProperty().addPropertyChangeListener(selectionPropertyChangeListener);
}
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler 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.properties.IWidgetPropertyChangeHandler 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.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler 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.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler 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);
}
Aggregations