1 package jimm.datavision.gui.cmd; 2 import jimm.datavision.field.Field; 3 import jimm.datavision.field.Rectangle; 4 import jimm.datavision.gui.FieldWidget; 5 import jimm.util.I18N; 6 7 13 public class FieldResizeCommand extends CommandAdapter { 14 15 protected FieldWidget fw; 16 protected int which; 17 protected Field prototype; 18 protected Rectangle origBounds; 19 protected SectionResizeCommand sectionResizeCommand; 20 21 public FieldResizeCommand(FieldWidget fw, int which, Field prototype) { 22 super(I18N.get("FieldResizeCommand.name")); 23 24 this.fw = fw; 25 this.which = which; 26 this.prototype = prototype; 27 origBounds = new Rectangle(fw.getField().getBounds()); sectionResizeCommand = new SectionResizeCommand(fw.getSectionWidget()); 29 } 30 31 public void perform() { 32 fw.size(which, prototype); 33 34 fw.getSectionWidget().growToFit(); 35 sectionResizeCommand.perform(); 36 } 37 38 public void undo() { 39 fw.getField().getBounds().setBounds(origBounds); 40 sectionResizeCommand.undo(); 41 } 42 43 } 44 | Popular Tags |