use of org.csstudio.opibuilder.commands.WidgetDeleteCommand in project yamcs-studio by yamcs.
the class WidgetComponentEditPolicy method createDeleteCommand.
@Override
protected Command createDeleteCommand(GroupRequest deleteRequest) {
Object containerModel = getHost().getParent().getModel();
Object widget = getHost().getModel();
if (containerModel instanceof AbstractContainerModel && widget instanceof AbstractWidgetModel)
return new WidgetDeleteCommand((AbstractContainerModel) containerModel, (AbstractWidgetModel) widget);
return super.createDeleteCommand(deleteRequest);
}
use of org.csstudio.opibuilder.commands.WidgetDeleteCommand in project yamcs-studio by yamcs.
the class RemoveGroupAction method run.
@Override
public void run(IAction action) {
var compoundCommand = new CompoundCommand("Remove Group");
var containerModel = getSelectedContainer();
// Orphan order should be reversed so that undo operation has the correct order.
var widgetsArray = containerModel.getChildren().toArray(new AbstractWidgetModel[containerModel.getChildren().size()]);
for (var i = widgetsArray.length - 1; i >= 0; i--) {
compoundCommand.add(new OrphanChildCommand(containerModel, widgetsArray[i]));
}
var leftCorner = containerModel.getLocation();
for (var widget : containerModel.getChildren()) {
compoundCommand.add(new AddWidgetCommand(containerModel.getParent(), widget, new Rectangle(widget.getLocation(), widget.getSize()).translate(leftCorner)));
}
compoundCommand.add(new WidgetDeleteCommand(containerModel.getParent(), containerModel));
execute(compoundCommand);
}
Aggregations