use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class TableEditPart method registerPropertyChangeHandlers.
/* (non-Javadoc)
* @see org.csstudio.opibuilder.editparts.AbstractBaseEditPart#registerPropertyChangeHandlers()
*/
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
spreadSheetTable.setEditable((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(TableModel.PROP_EDITABLE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
spreadSheetTable.setColumnHeaderVisible((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(TableModel.PROP_COLUMN_HEADER_VISIBLE, handler);
final IWidgetPropertyChangeHandler headersHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
String[] s = getWidgetModel().getColumnHeaders();
spreadSheetTable.setColumnHeaders(s);
int[] w = getWidgetModel().getColumnWidthes();
spreadSheetTable.setColumnWidths(w);
setPropertyValue(TableModel.PROP_COLUMNS_COUNT, s.length);
getWidgetModel().updateContentPropertyTitles();
return false;
}
};
// update prop sheet immediately
getWidgetModel().getProperty(TableModel.PROP_COLUMN_HEADERS).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
headersHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
}
});
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
String[][] headers = (String[][]) getPropertyValue(TableModel.PROP_COLUMN_HEADERS);
if (headers.length > (Integer) newValue) {
String[][] newHeaders = Arrays.copyOf(headers, (Integer) newValue);
setPropertyValue(TableModel.PROP_COLUMN_HEADERS, newHeaders);
}
spreadSheetTable.setColumnsCount((Integer) newValue);
getWidgetModel().updateContentPropertyTitles();
return false;
}
};
setPropertyChangeHandler(TableModel.PROP_COLUMNS_COUNT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
spreadSheetTable.setContent((String[][]) newValue);
return false;
}
};
setPropertyChangeHandler(TableModel.PROP_DEFAULT_CONTENT, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class TextUpdateEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
setFigureText((String) newValue);
if (isAutoSize) {
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
performAutoSize();
}
});
}
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_TEXT, handler);
IWidgetPropertyChangeHandler fontHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setFont(CustomMediaFactory.getInstance().getFont(((OPIFont) newValue).getFontData()));
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_FONT, fontHandler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
Display.getCurrent().timerExec(10, new Runnable() {
@Override
public void run() {
if (getWidgetModel().isAutoSize()) {
performAutoSize();
figure.revalidate();
}
}
});
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_FONT, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(AbstractWidgetModel.PROP_BORDER_WIDTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
figure.setOpaque(!(Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_TRANSPARENT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
isAutoSize = (Boolean) newValue;
if ((Boolean) newValue) {
performAutoSize();
figure.revalidate();
}
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_AUTOSIZE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (figure instanceof TextFigure)
((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_ALIGN_H, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (figure instanceof TextFigure)
((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) newValue]);
return true;
}
};
setPropertyChangeHandler(LabelModel.PROP_ALIGN_V, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
if (newValue == null)
return false;
formatValue(newValue, AbstractPVWidgetModel.PROP_PVVALUE);
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
format = FormatEnum.values()[(Integer) newValue];
formatValue(newValue, TextUpdateModel.PROP_FORMAT_TYPE);
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_FORMAT_TYPE, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
precision = (Integer) newValue;
formatValue(newValue, TextUpdateModel.PROP_PRECISION);
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_PRECISION, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
isPrecisionFromDB = (Boolean) newValue;
formatValue(newValue, TextUpdateModel.PROP_PRECISION_FROM_DB);
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_PRECISION_FROM_DB, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
isShowUnits = (Boolean) newValue;
formatValue(newValue, TextUpdateModel.PROP_SHOW_UNITS);
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_SHOW_UNITS, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, final IFigure figure) {
if (figure instanceof TextFigure)
((TextFigure) figure).setRotate((Double) newValue);
return true;
}
};
setPropertyChangeHandler(TextUpdateModel.PROP_ROTATION, handler);
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(TextUpdateModel.PROP_WRAP_WORDS, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class ThumbWheelEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
// PV value
IWidgetPropertyChangeHandler pvhandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
if (newValue != null) {
double doubleValue = VTypeHelper.getDouble((VType) newValue);
logic.setValue(doubleValue);
updateWheelValues();
}
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_PVVALUE, pvhandler);
IWidgetPropertyChangeHandler pvNameHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
registerLoadLimitsListener();
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVNAME, pvNameHandler);
// decimal wheels
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
logic.setDecimalWheels((Integer) newValue);
figure.setDecimalDigits(logic.getDecimalWheels());
model.setDecimalPartDigits(logic.getDecimalWheels());
updateWheelValues();
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_DECIMAL_DIGITS_PART, handler);
// integer wheels
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
logic.setIntegerWheels((Integer) newValue);
figure.setIntegerDigits(logic.getIntegerWheels());
model.setWholePartDigits(logic.getIntegerWheels());
updateWheelValues();
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_INTEGER_DIGITS_PART, handler);
// min
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
logic.setMin((Double) newValue);
updateWheelValues();
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_MIN, handler);
// max
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
logic.setMax((Double) newValue);
updateWheelValues();
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_MAX, handler);
// value
// handler = new IWidgetPropertyChangeHandler() {
// public boolean handleChange(final Object oldValue,
// final Object newValue, final IFigure refreshableFigure) {
// logic.setValue((Double) newValue);
// updateWheelValues();
// return true;
// }
// };
// setPropertyChangeHandler(ThumbWheelModel.PROP_VALUE, handler);
// font
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
FontData fontData = ((OPIFont) newValue).getFontData();
figure.setWheelFont(CustomMediaFactory.getInstance().getFont(fontData.getName(), fontData.getHeight(), fontData.getStyle()));
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_FONT, handler);
// border color
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
figure.setInternalBorderColor(((OPIColor) newValue).getSWTColor());
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_INTERNAL_FRAME_COLOR, handler);
// focused border color
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
figure.setInternalFocusedBorderColor(((OPIColor) newValue).getSWTColor());
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_INTERNAL_FOCUSED_FRAME_COLOR, handler);
// border width
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
figure.setInternalBorderThickness((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_INTERNAL_FRAME_THICKNESS, handler);
// show button
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThumbWheelFigure figure = (ThumbWheelFigure) refreshableFigure;
figure.setButtonVisibility((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(ThumbWheelModel.PROP_SHOW_BUTTONS, handler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class WebBrowserEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
// URL
IWidgetPropertyChangeHandler urlHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
((AbstractWebBrowserFigure<?>) refreshableFigure).setUrl((String) newValue);
return false;
}
};
setPropertyChangeHandler(WebBrowserModel.PROP_URL, urlHandler);
}
use of org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler in project yamcs-studio by yamcs.
the class XYGraphEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerAxisPropertyChangeHandlers();
registerTracePropertyChangeHandlers();
// Title
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
graph.getXYGraph().setTitle((String) newValue);
return true;
}
};
setPropertyChangeHandler(XYGraphModel.PROP_TITLE, handler);
// Title Font
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
graph.getXYGraph().setTitleFont(CustomMediaFactory.getInstance().getFont(((OPIFont) newValue).getFontData()));
return true;
}
};
setPropertyChangeHandler(XYGraphModel.PROP_TITLE_FONT, handler);
// Show plot area border
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
graph.getXYGraph().getPlotArea().setShowBorder((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(XYGraphModel.PROP_SHOW_PLOTAREA_BORDER, handler);
// Plot area background color
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
graph.getXYGraph().getPlotArea().setBackgroundColor(CustomMediaFactory.getInstance().getColor(((OPIColor) newValue).getRGBValue()));
return true;
}
};
setPropertyChangeHandler(XYGraphModel.PROP_PLOTAREA_BACKCOLOR, handler);
// Transparent
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
graph.setTransparent((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(XYGraphModel.PROP_TRANSPARENT, handler);
// Show legend
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
graph.getXYGraph().setShowLegend((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(XYGraphModel.PROP_SHOW_LEGEND, handler);
// Show Toolbar
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ToolbarArmedXYGraph graph = (ToolbarArmedXYGraph) refreshableFigure;
graph.setShowToolbar((Boolean) newValue);
return true;
}
};
setPropertyChangeHandler(XYGraphModel.PROP_SHOW_TOOLBAR, handler);
// trigger pv value
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
for (int i = 0; i < getWidgetModel().getTracesAmount(); i++) {
CircularBufferDataProvider dataProvider = (CircularBufferDataProvider) traceList.get(i).getDataProvider();
if (dataProvider.getUpdateMode() == UpdateMode.TRIGGER) {
dataProvider.triggerUpdate();
}
}
return false;
}
};
setPropertyChangeHandler(XYGraphModel.PROP_TRIGGER_PV_VALUE, handler);
registerAxesAmountChangeHandler();
registerTraceAmountChangeHandler();
}
Aggregations