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;
}
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);
}
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);
}
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));
}
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));
}
}
Aggregations