use of org.csstudio.opibuilder.visualparts.WidgetsSelectDialog in project yamcs-studio by yamcs.
the class ReplaceWidgetsAction method run.
@Override
public void run() {
WidgetsSelectDialog dialog = new WidgetsSelectDialog(getWorkbenchPart().getSite().getShell(), 1, false);
// $NON-NLS-1$
dialog.setDefaultSelectedWidgetID("org.csstudio.opibuilder.widgets.NativeText");
if (dialog.open() == Window.OK) {
String typeID = dialog.getOutput();
execute(createReplaceWidgetCommand(typeID));
}
}
use of org.csstudio.opibuilder.visualparts.WidgetsSelectDialog 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) {
var dropPVRequest = (DropPVRequest) request;
if (dropPVRequest.getTargetWidget() != null && dropPVRequest.getTargetWidget() instanceof AbstractContainerEditpart) {
var dialog = new WidgetsSelectDialog(getHost().getViewer().getControl().getShell(), dropPVRequest.getPvNames().length, true);
if (dialog.open() == Window.OK) {
var typeID = dialog.getOutput();
var command = new CompoundCommand("Create Widget");
var pvNames = dropPVRequest.getPvNames();
var location = dropPVRequest.getLocation().getCopy();
var container = ((AbstractContainerEditpart) dropPVRequest.getTargetWidget()).getWidgetModel();
var parent = container.getParent();
var temp = container;
while (parent != null) {
location.translate(temp.getLocation().getNegated());
temp = parent;
parent = parent.getParent();
}
var i = 1;
int lastWidth = 0, lastHeight = 0;
for (var pvName : pvNames) {
var 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;
}
Aggregations