1 8 package com.nightlabs.editor2d.command; 9 10 import org.eclipse.gef.commands.Command; 11 12 import com.nightlabs.editor2d.DrawComponent; 13 import com.nightlabs.editor2d.DrawComponentContainer; 14 import com.nightlabs.editor2d.EditorPlugin; 15 16 17 public class DrawComponentReorderCommand 18 extends Command 19 { 20 private int oldIndex, newIndex; 21 private DrawComponent child; 22 private DrawComponentContainer parent; 23 24 public DrawComponentReorderCommand(DrawComponent child, DrawComponentContainer parent, int newIndex ) 25 { 26 super(EditorPlugin.getResourceString("command_reorder_drawcomponent")); 27 this.child = child; 28 this.parent = parent; 29 this.newIndex = newIndex; 30 } 31 32 public void execute() 33 { 34 oldIndex = parent.getDrawComponents().indexOf(child); 35 parent.getDrawComponents().remove(child); 36 parent.getDrawComponents().add(newIndex, child); 37 } 38 39 public void undo() 40 { 41 parent.getDrawComponents().remove(child); 42 parent.getDrawComponents().add(oldIndex, child); 43 } 44 } 45 | Popular Tags |