use of org.csstudio.opibuilder.commands.SetBoundsCommand in project yamcs-studio by yamcs.
the class FillParentContainerAction method run.
@Override
public void run(IAction action) {
AbstractBaseEditPart widget = (AbstractBaseEditPart) selection.getFirstElement();
AbstractContainerEditpart containerEditpart = getParentContainerEditpart();
Dimension size = null;
if (containerEditpart instanceof DisplayEditpart)
size = ((DisplayEditpart) containerEditpart).getWidgetModel().getSize();
else
size = containerEditpart.getFigure().getClientArea().getSize();
Command cmd = new SetBoundsCommand(widget.getWidgetModel(), new Rectangle(0, 0, size.width, size.height));
execute(cmd);
}
use of org.csstudio.opibuilder.commands.SetBoundsCommand in project yamcs-studio by yamcs.
the class LayoutWidgetsImp method run.
public static void run(AbstractLayoutEditpart layoutWidget, CommandStack commandStack) {
AbstractContainerModel container = layoutWidget.getWidgetModel().getParent();
List<AbstractWidgetModel> modelChildren = new ArrayList<AbstractWidgetModel>();
modelChildren.addAll(container.getChildren());
modelChildren.remove(layoutWidget.getWidgetModel());
if (modelChildren.size() == 0)
return;
List<Rectangle> newBounds = layoutWidget.getNewBounds(modelChildren, container.getBounds());
CompoundCommand compoundCommand = new CompoundCommand("Layout Widgets");
int i = 0;
for (AbstractWidgetModel model : modelChildren) {
compoundCommand.add(new SetBoundsCommand(model, newBounds.get(i)));
i++;
}
commandStack.execute(compoundCommand);
}
use of org.csstudio.opibuilder.commands.SetBoundsCommand 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);
}
Aggregations