protected Command getCreateCommand(final CreateRequest request) {
final Object no = request.getNewObject();
if (no instanceof MapObject) {
final AddObjectCommand cmd = new AddObjectCommand();
cmd.setObject((MapObject) no);
final FigureCanvas control = (FigureCanvas) EditMapEditPart.this.getViewer()
.getControl();
final Point loc = request.getLocation();
if (control.getVerticalBar() != null)
loc.y += control.getVerticalBar().getSelection();
if (control.getHorizontalBar() != null)
loc.x += control.getHorizontalBar().getSelection();
cmd.setLocation(loc);
cmd.setTarget(EditMapEditPart.this);
return cmd;
}
if (no instanceof MapNode) {
final List<EditPart> sel = getViewer().getSelectedEditParts();
if (sel.isEmpty())
return null;
final MapObject mo = getFirstMapObject(sel);
if (mo == null)
return null;
final AddNodeCommand cmd = new AddNodeCommand();
cmd.setTarget(mo);
cmd.setNode((MapNode) no);
final FigureCanvas control = (FigureCanvas) EditMapEditPart.this.getViewer()
.getControl();
final Point loc = request.getLocation();
if (control.getVerticalBar() != null)
loc.y += control.getVerticalBar().getSelection();
if (control.getHorizontalBar() != null)
loc.x += control.getHorizontalBar().getSelection();
cmd.setLocation(loc);
cmd.setCoordSys(_coordinateSystem);
return cmd;
}
return null;