01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.field.Format;
04: import jimm.datavision.field.Border;
05: import jimm.datavision.field.Field;
06: import jimm.util.I18N;
07:
08: /**
09: * A command for changing a field's format and border.
10: *
11: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
12: */
13: public class FormatCommand extends CommandAdapter {
14:
15: protected Field field;
16: protected Format origFormat;
17: protected Format newFormat;
18: protected Border origBorder;
19: protected Border newBorder;
20:
21: public FormatCommand(Field f, Format format, Border border) {
22: super (I18N.get("FormatCommand.name"));
23:
24: field = f;
25:
26: origFormat = field.getFormat();
27: if (origFormat != null)
28: origFormat = (Format) origFormat.clone();
29: newFormat = format;
30:
31: origBorder = field.getBorder();
32: if (origBorder != null)
33: origBorder = (Border) origBorder.clone();
34: newBorder = border;
35: }
36:
37: public void perform() {
38: field.setFormat(newFormat);
39: field.setBorder(newBorder);
40: }
41:
42: public void undo() {
43: field.setFormat(origFormat);
44: field.setBorder(origBorder);
45: }
46:
47: }
|