1 8 package com.nightlabs.editor2d.tools; 9 10 import java.util.List ; 11 12 import org.apache.log4j.Logger; 13 import org.eclipse.gef.EditPart; 14 import org.eclipse.gef.Request; 15 16 import com.nightlabs.editor2d.edit.ShapeDrawComponentEditPart; 17 import com.nightlabs.editor2d.j2d.GeneralShape; 18 import com.nightlabs.editor2d.request.EditorEditShapeRequest; 19 20 public class ShapeEditTracker 22 extends AbstractDragTracker 23 { 24 public static final Logger LOGGER = Logger.getLogger(ShapeEditTracker.class); 25 26 protected ShapeDrawComponentEditPart getShapeDrawComponentEditPart() { 27 return (ShapeDrawComponentEditPart) owner; 28 } 29 protected GeneralShape getGeneralShape() { 30 return getShapeDrawComponentEditPart().getGeneralShape(); 31 } 32 protected int pathSegmentIndex; 34 35 public ShapeEditTracker(ShapeDrawComponentEditPart owner, int pathSegmentIndex) 36 { 37 super(owner); 38 this.pathSegmentIndex = pathSegmentIndex; 39 } 40 41 protected String getCommandName() { 42 return REQ_EDIT_SHAPE; 43 } 44 45 48 public void deactivate() 49 { 50 super.deactivate(); 51 } 53 54 57 protected String getDebugName() 58 { 59 return "Edit Shape Handle Tracker"; } 61 62 65 protected Request createSourceRequest() 66 { 67 EditorEditShapeRequest request = new EditorEditShapeRequest(); 68 request.setType(REQ_EDIT_SHAPE); 69 request.setPathSegmentIndex(pathSegmentIndex); 70 request.setLocation(getLocation()); 71 List selectedEditParts = getCurrentViewer().getSelectedEditParts(); 72 if (selectedEditParts != null && !selectedEditParts.isEmpty()) { 73 EditPart selectedEditPart = (EditPart)selectedEditParts.get(0); 74 request.setTargetEditPart(selectedEditPart); 75 } 76 return request; 77 } 78 79 82 protected void updateSourceRequest() 83 { 84 EditorEditShapeRequest request = (EditorEditShapeRequest) getSourceRequest(); 85 request.setLocation(getLocation()); 86 } 87 88 } 89 | Popular Tags |