Search in sources :

Example 1 with SetWidgetPropertyCommand

use of org.csstudio.opibuilder.commands.SetWidgetPropertyCommand in project yamcs-studio by yamcs.

the class ArrayLayoutEditPolicy method addUpdateContainerCommands.

protected void addUpdateContainerCommands(AbstractContainerModel container, Dimension widgetSize, CompoundCommand result) {
    var elementsCount = getHostArrayEditPart().getArrayFigure().calcVisibleElementsCount(widgetSize);
    var proposedContainerSize = getHostArrayEditPart().getArrayFigure().calcWidgetSizeForElements(elementsCount, widgetSize);
    result.add(new WidgetSetConstraintCommand(container, null, new Rectangle(container.getLocation(), proposedContainerSize)));
    result.add(new SetWidgetPropertyCommand(container, ArrayModel.PROP_VISIBLE_ELEMENTS_COUNT, elementsCount));
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) WidgetSetConstraintCommand(org.csstudio.opibuilder.commands.WidgetSetConstraintCommand) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 2 with SetWidgetPropertyCommand

use of org.csstudio.opibuilder.commands.SetWidgetPropertyCommand 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);
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) SetBoundsCommand(org.csstudio.opibuilder.commands.SetBoundsCommand) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) GroupingContainerEditPart(org.csstudio.opibuilder.widgets.editparts.GroupingContainerEditPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 3 with SetWidgetPropertyCommand

use of org.csstudio.opibuilder.commands.SetWidgetPropertyCommand in project yamcs-studio by yamcs.

the class ShowXYGraphToolbarAction method run.

@Override
public void run(IAction action) {
    Command command = new SetWidgetPropertyCommand(getSelectedXYGraph().getWidgetModel(), XYGraphModel.PROP_SHOW_TOOLBAR, !getSelectedXYGraph().getWidgetModel().isShowToolbar());
    execute(command);
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) Command(org.eclipse.gef.commands.Command) SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)

Example 4 with SetWidgetPropertyCommand

use of org.csstudio.opibuilder.commands.SetWidgetPropertyCommand in project yamcs-studio by yamcs.

the class Draw2DTextInputEditpartDelegate method outputText.

/**
 * Call this method when user hit Enter or Ctrl+Enter for multiline input.
 */
protected void outputText(String newValue) {
    if (editpart.getExecutionMode() == ExecutionMode.RUN_MODE) {
        editpart.setPVValue(PROP_PVNAME, newValue);
        model.setPropertyValue(PROP_TEXT, newValue, false);
    } else {
        editpart.getViewer().getEditDomain().getCommandStack().execute(new SetWidgetPropertyCommand(model, PROP_TEXT, newValue));
    }
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)

Example 5 with SetWidgetPropertyCommand

use of org.csstudio.opibuilder.commands.SetWidgetPropertyCommand in project yamcs-studio by yamcs.

the class DistributeWidgetsAction method getVerticalCenterCommand.

private Command getVerticalCenterCommand() {
    var sortedModelArray = getSortedModelArray(false);
    var cmd = new CompoundCommand("Vertical Center Distribution");
    var averageGap = (getCenterLoc(sortedModelArray[sortedModelArray.length - 1], false) - getCenterLoc(sortedModelArray[0], false)) / (sortedModelArray.length - 1);
    var startX = getCenterLoc(sortedModelArray[0], false);
    for (var i = 1; i < sortedModelArray.length - 1; i++) {
        cmd.add(new SetWidgetPropertyCommand(sortedModelArray[i], AbstractWidgetModel.PROP_YPOS, startX + averageGap - sortedModelArray[i].getHeight() / 2));
        startX += averageGap;
    }
    return cmd;
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)18 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)11 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 ConnectionModel (org.csstudio.opibuilder.model.ConnectionModel)3 PointList (org.eclipse.draw2d.geometry.PointList)3 Command (org.eclipse.gef.commands.Command)3 ArrayList (java.util.ArrayList)2 ConnectionReconnectCommand (org.csstudio.opibuilder.commands.ConnectionReconnectCommand)2 WidgetCreateCommand (org.csstudio.opibuilder.commands.WidgetCreateCommand)2 WidgetSetConstraintCommand (org.csstudio.opibuilder.commands.WidgetSetConstraintCommand)2 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 RunOPIAction (org.csstudio.opibuilder.actions.RunOPIAction)1 AddWidgetCommand (org.csstudio.opibuilder.commands.AddWidgetCommand)1 ChangeGuideCommand (org.csstudio.opibuilder.commands.ChangeGuideCommand)1 CloneCommand (org.csstudio.opibuilder.commands.CloneCommand)1 SetBoundsCommand (org.csstudio.opibuilder.commands.SetBoundsCommand)1 WidgetIgnorableUITask (org.csstudio.opibuilder.datadefinition.WidgetIgnorableUITask)1 DropPVRequest (org.csstudio.opibuilder.dnd.DropPVRequest)1 AbstractContainerEditpart (org.csstudio.opibuilder.editparts.AbstractContainerEditpart)1