| 1 8 package com.nightlabs.editor2d.actions; 9 10 import org.eclipse.gef.ui.actions.SelectionAction; 11 import org.eclipse.ui.IWorkbenchPart; 12 13 import com.nightlabs.editor2d.EditorPlugin; 14 import com.nightlabs.editor2d.EditorStateManager; 15 import com.nightlabs.editor2d.edit.ShapeDrawComponentEditPart; 16 import com.nightlabs.editor2d.request.EditorRequestConstants; 17 18 19 public class EditShapeAction 20 extends SelectionAction 21 implements EditorRequestConstants 22 { 23 public static final String ID = EditShapeAction.class.getName(); 24 25 28 public EditShapeAction(IWorkbenchPart part) { 29 super(part); 30 } 31 32 37 protected boolean calculateEnabled() 38 { 39 if (EditorStateManager.getCurrentState() != EditorStateManager.STATE_EDIT_SHAPE) 40 { 41 if (getSelectedObjects().size() == 1 && (getSelectedObjects().get(0) instanceof ShapeDrawComponentEditPart)) { 42 return true; 43 } 44 } 45 return false; 46 } 47 48 51 protected void init() 52 { 53 super.init(); 54 setText(EditorPlugin.getResourceString("action.editshape.text")); 55 setToolTipText(EditorPlugin.getResourceString("action.editshape.tooltip")); 56 setId(ID); 57 } 59 60 63 public void run() 64 { 65 if (getSelectedObjects().size() == 1 && (getSelectedObjects().get(0) instanceof ShapeDrawComponentEditPart)) 67 { 68 ShapeDrawComponentEditPart sdcEP = (ShapeDrawComponentEditPart) getSelectedObjects().get(0); 69 EditorStateManager.setEditShapeMode(sdcEP); 70 } 71 } 72 73 } 74 | Popular Tags |