use of org.csstudio.opibuilder.commands.SetWidgetPropertyCommand in project yamcs-studio by yamcs.
the class DistributeWidgetsAction method getHorizontalCenterCommand.
private Command getHorizontalCenterCommand() {
AbstractWidgetModel[] sortedModelArray = getSortedModelArray(true);
CompoundCommand cmd = new CompoundCommand("Horizontal Center Distribution");
int averageGap = (getCenterLoc(sortedModelArray[sortedModelArray.length - 1], true) - getCenterLoc(sortedModelArray[0], true)) / (sortedModelArray.length - 1);
int startX = getCenterLoc(sortedModelArray[0], true);
for (int i = 1; i < sortedModelArray.length - 1; i++) {
cmd.add(new SetWidgetPropertyCommand(sortedModelArray[i], AbstractWidgetModel.PROP_XPOS, startX + averageGap - sortedModelArray[i].getWidth() / 2));
startX += averageGap;
}
return cmd;
}
use of org.csstudio.opibuilder.commands.SetWidgetPropertyCommand in project yamcs-studio by yamcs.
the class DropPVtoContainerEditPolicy method getCommand.
@Override
public Command getCommand(Request request) {
if (request.getType() == DropPVRequest.REQ_DROP_PV && request instanceof DropPVRequest) {
DropPVRequest dropPVRequest = (DropPVRequest) request;
if (dropPVRequest.getTargetWidget() != null && dropPVRequest.getTargetWidget() instanceof AbstractContainerEditpart) {
WidgetsSelectDialog dialog = new WidgetsSelectDialog(getHost().getViewer().getControl().getShell(), dropPVRequest.getPvNames().length, true);
if (dialog.open() == Window.OK) {
String typeID = dialog.getOutput();
CompoundCommand command = new CompoundCommand("Create Widget");
// $NON-NLS-1$
String[] pvNames = dropPVRequest.getPvNames();
Point location = dropPVRequest.getLocation().getCopy();
AbstractContainerModel container = ((AbstractContainerEditpart) dropPVRequest.getTargetWidget()).getWidgetModel();
AbstractContainerModel parent = container.getParent();
AbstractContainerModel temp = container;
while (parent != null) {
location.translate(temp.getLocation().getNegated());
temp = parent;
parent = parent.getParent();
}
int i = 1;
int lastWidth = 0, lastHeight = 0;
for (String pvName : pvNames) {
AbstractWidgetModel widgetModel = WidgetsService.getInstance().getWidgetDescriptor(typeID).getWidgetModel();
command.add(new WidgetCreateCommand(widgetModel, container, new Rectangle(location.getCopy().translate(lastWidth, lastHeight), new Dimension(-1, -1)), i != 1, true));
command.add(new SetWidgetPropertyCommand(widgetModel, AbstractPVWidgetModel.PROP_PVNAME, pvName.trim()));
if (i % WIDGETS_ACCOUNT_ON_A_ROW == 0) {
lastWidth = 0;
lastHeight += widgetModel.getHeight();
} else
lastWidth += widgetModel.getWidth();
i++;
}
return command;
}
}
}
return null;
}
use of org.csstudio.opibuilder.commands.SetWidgetPropertyCommand in project yamcs-studio by yamcs.
the class WidgetNodeEditPolicy method getReconnectSourceCommand.
@Override
protected Command getReconnectSourceCommand(ReconnectRequest request) {
ConnectionModel connection = (ConnectionModel) request.getConnectionEditPart().getModel();
AbstractWidgetModel newSource = getWidgetEditPart().getWidgetModel();
ConnectionAnchor anchor = getWidgetEditPart().getTargetConnectionAnchor(request);
String newTerminal = getWidgetEditPart().getTerminalNameFromAnchor(anchor);
ConnectionReconnectCommand cmd = new ConnectionReconnectCommand(connection);
cmd.setNewSource(newSource);
cmd.setNewSourceTerminal(newTerminal);
// clear point list
return cmd.chain(new SetWidgetPropertyCommand(connection, ConnectionModel.PROP_POINTS, new PointList()));
}
Aggregations