use of org.csstudio.opibuilder.widgets.editparts.GroupingContainerEditPart in project yamcs-studio by yamcs.
the class PerformAutoSizeAction method run.
@Override
public void run(IAction action) {
if (getContainerEditpart().getChildren().size() <= 0) {
return;
}
var compoundCommand = new CompoundCommand("Perform AutoSize");
var containerEditpart = getContainerEditpart();
var 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));
}
var figure = getContainerFigure();
var childrenRange = GeometryUtil.getChildrenRange(containerEditpart);
var 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 (var editpart : containerEditpart.getChildren()) {
var widget = ((AbstractBaseEditPart) editpart).getWidgetModel();
compoundCommand.add(new SetBoundsCommand(widget, new Rectangle(widget.getLocation().translate(tranlateSize.getNegated()), widget.getSize())));
}
// recover lock
if (containerEditpart instanceof GroupingContainerEditPart) {
var 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.widgets.editparts.GroupingContainerEditPart in project yamcs-studio by yamcs.
the class LockUnlockChildrenHandler 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 GroupingContainerEditPart) {
CommandStack commandStack = HandlerUtil.getActivePart(event).getAdapter(CommandStack.class);
if (commandStack != null)
commandStack.execute(LockUnlockChildrenAction.createLockUnlockCommand(((GroupingContainerEditPart) element).getWidgetModel()));
}
}
return null;
}
Aggregations