Package net.sf.myway.edit.ui.editors.commands

Examples of net.sf.myway.edit.ui.editors.commands.AddObjectCommand


      @SuppressWarnings("unchecked")
      @Override
      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;
      }
View Full Code Here

TOP

Related Classes of net.sf.myway.edit.ui.editors.commands.AddObjectCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.