use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class GeometryUtil method getChildrenRange.
/**
*Get the range of children widgets.
* @param container editpart of the container widget.
* @return the range (minX, minY, maxX-minX, maxY-minY) relative to the container.
*/
public static Rectangle getChildrenRange(AbstractContainerEditpart container) {
PointList pointList = new PointList(container.getChildren().size());
for (Object child : container.getChildren()) {
AbstractWidgetModel childModel = ((AbstractBaseEditPart) child).getWidgetModel();
pointList.addPoint(childModel.getLocation());
pointList.addPoint(childModel.getX() + childModel.getWidth(), childModel.getY() + childModel.getHeight());
}
return pointList.getBounds();
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class ArrayModel method addChild.
@Override
public synchronized void addChild(AbstractWidgetModel child, boolean changeParent) {
if (!getChildren().isEmpty())
return;
// child should not be scalable because their size are layoutted by the array figure.
child.setScaleOptions(false, false, false);
super.addChild(child, changeParent);
for (int i = 1; i < getVisibleElementsCount(); i++) {
try {
AbstractWidgetModel clone = XMLUtil.XMLElementToWidget(XMLUtil.widgetToXMLElement(child));
super.addChild(clone, changeParent);
} catch (Exception e) {
ErrorHandlerUtil.handleError("Failed to generate copy of the element widget in array widget.", e);
}
}
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class GroupingContainerModel method rotate90.
@Override
public void rotate90(boolean clockwise) {
boolean oldLock = isLocked();
setPropertyValue(PROP_LOCK_CHILDREN, false);
Point center = new Point(getWidth() / 2, getHeight() / 2);
for (AbstractWidgetModel abstractWidgetModel : getChildren()) {
abstractWidgetModel.rotate90(clockwise, center);
}
Point oldLoc = getLocation();
super.rotate90(clockwise);
Point newLoc = getLocation();
int dx = newLoc.x - oldLoc.x;
int dy = newLoc.y - oldLoc.y;
// move back
for (AbstractWidgetModel abstractWidgetModel : getChildren()) {
abstractWidgetModel.setLocation(abstractWidgetModel.getLocation().translate(-dx, -dy));
}
setPropertyValue(PROP_LOCK_CHILDREN, oldLock);
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class LabelEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_TEXT, (oldValue, newValue, figure) -> {
((TextFigure) figure).setText((String) newValue);
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
}
});
return true;
});
setPropertyChangeHandler(PROP_ACTIONS, (oldValue, newValue, figure) -> {
((TextFigure) figure).setSelectable(determinSelectable());
return false;
});
setPropertyChangeHandler(PROP_TOOLTIP, (oldValue, newValue, figure) -> {
((TextFigure) figure).setSelectable(determinSelectable());
return false;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, figure) -> {
Display.getCurrent().timerExec(10, () -> {
if (getWidgetModel().isAutoSize()) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
figure.revalidate();
}
});
return true;
};
setPropertyChangeHandler(PROP_FONT, handler);
setPropertyChangeHandler(PROP_BORDER_STYLE, handler);
setPropertyChangeHandler(PROP_BORDER_WIDTH, handler);
setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, figure) -> {
((TextFigure) figure).setOpaque(!(Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_AUTOSIZE, (oldValue, newValue, figure) -> {
if ((Boolean) newValue) {
getWidgetModel().setSize(((TextFigure) figure).getAutoSizeDimension());
figure.revalidate();
}
return true;
});
setPropertyChangeHandler(PROP_ALIGN_H, (oldValue, newValue, figure) -> {
((TextFigure) figure).setHorizontalAlignment(H_ALIGN.values()[(Integer) newValue]);
return true;
});
setPropertyChangeHandler(PROP_ALIGN_V, (oldValue, newValue, figure) -> {
((TextFigure) figure).setVerticalAlignment(V_ALIGN.values()[(Integer) newValue]);
return true;
});
setPropertyChangeHandler(PROP_WRAP_WORDS, (oldValue, newValue, figure) -> {
AbstractWidgetModel model = getWidgetModel();
var parent = model.getParent();
parent.removeChild(model);
parent.addChild(model);
parent.selectWidget(model, true);
return false;
});
getWidgetModel().getProperty(PROP_WRAP_WORDS).addPropertyChangeListener(evt -> updatePropertyVisibility());
setPropertyChangeHandler(PROP_SHOW_SCROLLBAR, (oldValue, newValue, figure) -> {
if (figure instanceof WrappableTextFigure) {
((WrappableTextFigure) figure).setShowScrollbar((Boolean) newValue);
}
return false;
});
}
use of org.csstudio.opibuilder.model.AbstractWidgetModel in project yamcs-studio by yamcs.
the class ActionButtonEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
PropertyChangeListener styleListener = evt -> {
AbstractWidgetModel model = getWidgetModel();
var descriptor = WidgetsService.getInstance().getWidgetDescriptor(model.getTypeID());
var type = descriptor == null ? model.getTypeID().substring(model.getTypeID().lastIndexOf(".") + 1) : descriptor.getName();
model.setPropertyValue(AbstractWidgetModel.PROP_WIDGET_TYPE, type);
var parent = model.getParent();
parent.removeChild(model);
parent.addChild(model);
parent.selectWidget(model, true);
};
getWidgetModel().getProperty(ActionButtonModel.PROP_STYLE).addPropertyChangeListener(styleListener);
updatePropSheet();
delegate.registerPropertyChangeHandlers();
}
Aggregations