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.EditorPlugin; 14 15 public class SetConstraintCommand 16 extends Command 17 { 18 private static final String Command_Label_Location = EditorPlugin.getResourceString("command_change_location"); 19 private static final String Command_Label_Resize = EditorPlugin.getResourceString("command_resize"); 20 21 private DrawComponent part; 22 private java.awt.Rectangle oldBounds; 23 private java.awt.Rectangle newBounds; 24 25 public void execute() 26 { 27 oldBounds = new java.awt.Rectangle (part.getBounds()); 29 part.setBounds(newBounds); 30 } 31 32 public String getLabel() 33 { 34 if ((oldBounds.getWidth() == newBounds.getWidth()) && 35 (oldBounds.getHeight() == newBounds.getHeight())) 36 return Command_Label_Location; 37 38 return Command_Label_Resize; 39 } 40 41 public void redo() 42 { 43 part.setBounds(newBounds); 44 } 45 46 public void setPart(DrawComponent part) 47 { 48 this.part = part; 49 } 50 51 public void undo() 52 { 53 part.setBounds(oldBounds); 54 } 55 56 public void setBounds(java.awt.Rectangle bounds) 57 { 58 newBounds = bounds; 59 } 60 } 61 | Popular Tags |