use of org.csstudio.opibuilder.editparts.AbstractBaseEditPart in project yamcs-studio by yamcs.
the class PerformAutoSizeAction method run.
@Override
public void run(IAction action) {
if (getContainerEditpart().getChildren().size() <= 0) {
return;
}
CompoundCommand compoundCommand = new CompoundCommand("Perform AutoSize");
AbstractContainerEditpart containerEditpart = getContainerEditpart();
AbstractContainerModel containerModel = containerEditpart.getWidgetModel();
// temporary unlock children so children will not be resized.
if (containerEditpart instanceof GroupingContainerEditPart) {
compoundCommand.add(new SetWidgetPropertyCommand(containerModel, GroupingContainerModel.PROP_LOCK_CHILDREN, false));
}
IFigure figure = getContainerFigure();
Rectangle childrenRange = GeometryUtil.getChildrenRange(containerEditpart);
Point tranlateSize = new Point(childrenRange.x, childrenRange.y);
compoundCommand.add(new SetBoundsCommand(containerModel, new Rectangle(containerModel.getLocation().translate(tranlateSize), new Dimension(childrenRange.width + figure.getInsets().left + figure.getInsets().right, childrenRange.height + figure.getInsets().top + figure.getInsets().bottom))));
for (Object editpart : containerEditpart.getChildren()) {
AbstractWidgetModel widget = ((AbstractBaseEditPart) editpart).getWidgetModel();
compoundCommand.add(new SetBoundsCommand(widget, new Rectangle(widget.getLocation().translate(tranlateSize.getNegated()), widget.getSize())));
}
// recover lock
if (containerEditpart instanceof GroupingContainerEditPart) {
Object oldvalue = containerEditpart.getWidgetModel().getPropertyValue(GroupingContainerModel.PROP_LOCK_CHILDREN);
compoundCommand.add(new SetWidgetPropertyCommand(containerModel, GroupingContainerModel.PROP_LOCK_CHILDREN, oldvalue));
}
execute(compoundCommand);
}
use of org.csstudio.opibuilder.editparts.AbstractBaseEditPart in project yamcs-studio by yamcs.
the class ArrayEditPart method removeChild.
@Override
protected void removeChild(EditPart child) {
super.removeChild(child);
AbstractWidgetModel childModel = ((AbstractBaseEditPart) child).getWidgetModel();
// recover property visibility
if (getExecutionMode() == ExecutionMode.EDIT_MODE) {
for (String propId : INVISIBLE_CHILD_PROPIDS) try {
childModel.setPropertyVisibleAndSavable(propId, true, true);
} catch (NonExistPropertyException e) {
}
}
}
use of org.csstudio.opibuilder.editparts.AbstractBaseEditPart in project yamcs-studio by yamcs.
the class LinkingContainerEditpart method layout.
@Override
public void layout() {
AbstractLayoutEditpart layoutter = getLayoutWidget();
if (layoutter != null && layoutter.getWidgetModel().isEnabled()) {
List<AbstractWidgetModel> modelChildren = new ArrayList<AbstractWidgetModel>();
for (Object child : getChildren()) {
if (child instanceof AbstractBaseEditPart && !(child instanceof AbstractLayoutEditpart)) {
modelChildren.add(((AbstractBaseEditPart) child).getWidgetModel());
}
}
layoutter.layout(modelChildren, getFigure().getClientArea());
}
}
use of org.csstudio.opibuilder.editparts.AbstractBaseEditPart 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.editparts.AbstractBaseEditPart in project yamcs-studio by yamcs.
the class SelectParentHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
GraphicalViewer viewer = HandlerUtil.getActivePart(event).getAdapter(GraphicalViewer.class);
if (viewer == null)
return null;
ISelection currentSelection = viewer.getSelection();
if (currentSelection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) currentSelection).getFirstElement();
if (element instanceof AbstractBaseEditPart && !(element instanceof DisplayEditpart)) {
if (((AbstractBaseEditPart) element).getParent().isSelectable())
((AbstractBaseEditPart) element).getViewer().select(((AbstractBaseEditPart) element).getParent());
else
ConsoleUtil.writeWarning("Parent of the selected widget is unselectable. Its grandparent may be locked.");
}
}
return null;
}
Aggregations