1 27 28 package org.nightlabs.editor2d.actions; 29 30 import org.eclipse.gef.ui.actions.SelectionAction; 31 import org.eclipse.ui.IWorkbenchPart; 32 33 import org.nightlabs.editor2d.EditorPlugin; 34 import org.nightlabs.editor2d.EditorStateManager; 35 import org.nightlabs.editor2d.edit.ShapeDrawComponentEditPart; 36 import org.nightlabs.editor2d.request.EditorRequestConstants; 37 38 39 public class EditShapeAction 40 extends SelectionAction 41 implements EditorRequestConstants 42 { 43 public static final String ID = EditShapeAction.class.getName(); 44 45 48 public EditShapeAction(IWorkbenchPart part) { 49 super(part); 50 } 51 52 57 protected boolean calculateEnabled() 58 { 59 if (EditorStateManager.getCurrentState() != EditorStateManager.STATE_EDIT_SHAPE) 60 { 61 if (getSelectedObjects().size() == 1 && (getSelectedObjects().get(0) instanceof ShapeDrawComponentEditPart)) { 62 return true; 63 } 64 } 65 return false; 66 } 67 68 71 protected void init() 72 { 73 super.init(); 74 setText(EditorPlugin.getResourceString("action.editshape.text")); 75 setToolTipText(EditorPlugin.getResourceString("action.editshape.tooltip")); 76 setId(ID); 77 } 79 80 83 public void run() 84 { 85 if (getSelectedObjects().size() == 1 && (getSelectedObjects().get(0) instanceof ShapeDrawComponentEditPart)) 87 { 88 ShapeDrawComponentEditPart sdcEP = (ShapeDrawComponentEditPart) getSelectedObjects().get(0); 89 EditorStateManager.setEditShapeMode(sdcEP); 90 } 91 } 92 93 } 94 | Popular Tags |