01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.field.Field;
04: import jimm.datavision.field.Rectangle;
05: import jimm.datavision.gui.FieldWidget;
06: import jimm.util.I18N;
07:
08: /**
09: * Resizes a single field by comparing it with another field and copying
10: * one of its dimensions.
11: *
12: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
13: */
14: public class FieldResizeCommand extends CommandAdapter {
15:
16: protected FieldWidget fw;
17: protected int which;
18: protected Field prototype;
19: protected Rectangle origBounds;
20: protected SectionResizeCommand sectionResizeCommand;
21:
22: public FieldResizeCommand(FieldWidget fw, int which, Field prototype) {
23: super (I18N.get("FieldResizeCommand.name"));
24:
25: this .fw = fw;
26: this .which = which;
27: this .prototype = prototype;
28: origBounds = new Rectangle(fw.getField().getBounds()); // Make a copy
29: sectionResizeCommand = new SectionResizeCommand(fw
30: .getSectionWidget());
31: }
32:
33: public void perform() {
34: fw.size(which, prototype);
35:
36: fw.getSectionWidget().growToFit();
37: sectionResizeCommand.perform();
38: }
39:
40: public void undo() {
41: fw.getField().getBounds().setBounds(origBounds);
42: sectionResizeCommand.undo();
43: }
44:
45: }
|