use of org.csstudio.opibuilder.dnd.DropPVRequest in project yamcs-studio by yamcs.
the class DropPVtoXYGraphEditPolicy 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 XYGraphEditPart) {
CompoundCommand command = new CompoundCommand("Add Traces");
XYGraphModel xyGraphModel = (XYGraphModel) dropPVRequest.getTargetWidget().getWidgetModel();
int existTraces = xyGraphModel.getTracesAmount();
if (existTraces >= XYGraphModel.MAX_TRACES_AMOUNT)
return null;
command.add(new SetWidgetPropertyCommand(xyGraphModel, XYGraphModel.PROP_TRACE_COUNT, dropPVRequest.getPvNames().length + existTraces));
int i = existTraces;
for (String pvName : dropPVRequest.getPvNames()) {
command.add(new SetWidgetPropertyCommand(xyGraphModel, XYGraphModel.makeTracePropID(XYGraphModel.TraceProperty.YPV.propIDPre, i), pvName));
command.add(new SetWidgetPropertyCommand(xyGraphModel, XYGraphModel.makeTracePropID(XYGraphModel.TraceProperty.NAME.propIDPre, i), pvName));
if (++i >= XYGraphModel.MAX_TRACES_AMOUNT)
break;
}
return command;
}
}
return super.getCommand(request);
}
Aggregations