Search in sources :

Example 6 with SetWidgetPropertyCommand

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

the class DistributeWidgetsAction method getVerticalCenterCommand.

private Command getVerticalCenterCommand() {
    AbstractWidgetModel[] sortedModelArray = getSortedModelArray(false);
    CompoundCommand cmd = new CompoundCommand("Vertical Center Distribution");
    int averageGap = (getCenterLoc(sortedModelArray[sortedModelArray.length - 1], false) - getCenterLoc(sortedModelArray[0], false)) / (sortedModelArray.length - 1);
    int startX = getCenterLoc(sortedModelArray[0], false);
    for (int 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) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 7 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;
    }
    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);
}
Also used : 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) SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) AbstractContainerEditpart(org.csstudio.opibuilder.editparts.AbstractContainerEditpart) IFigure(org.eclipse.draw2d.IFigure)

Example 8 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 9 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) {
    int elementsCount = getHostArrayEditPart().getArrayFigure().calcVisibleElementsCount(widgetSize);
    Dimension 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) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 10 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.
 * @param newValue
 */
protected void outputText(String newValue) {
    if (editpart.getExecutionMode() == ExecutionMode.RUN_MODE) {
        editpart.setPVValue(TextInputModel.PROP_PVNAME, newValue);
        model.setPropertyValue(TextInputModel.PROP_TEXT, newValue, false);
    } else {
        editpart.getViewer().getEditDomain().getCommandStack().execute(new SetWidgetPropertyCommand(model, TextInputModel.PROP_TEXT, newValue));
    }
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)

Aggregations

SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)18 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)12 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)11 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)3 ConnectionModel (org.csstudio.opibuilder.model.ConnectionModel)3 Dimension (org.eclipse.draw2d.geometry.Dimension)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 AbstractContainerEditpart (org.csstudio.opibuilder.editparts.AbstractContainerEditpart)2 ConnectionAnchor (org.eclipse.draw2d.ConnectionAnchor)2 Point (org.eclipse.draw2d.geometry.Point)2 RunOPIAction (org.csstudio.opibuilder.actions.RunOPIAction)1 AddWidgetCommand (org.csstudio.opibuilder.commands.AddWidgetCommand)1 ChangeGuideCommand (org.csstudio.opibuilder.commands.ChangeGuideCommand)1