01: package jimm.datavision.gui.cmd;
02:
03: import jimm.datavision.*;
04: import jimm.datavision.gui.SectionWidget;
05: import jimm.util.I18N;
06:
07: /**
08: * Handles suppression proc edits.
09: *
10: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
11: */
12: public class SuppressionProcEditCommand extends CommandAdapter {
13:
14: protected SectionWidget sectionWidget;
15: protected boolean oldHidden;
16: protected boolean newHidden;
17: protected String oldText;
18: protected String newText;
19: protected String oldLanguage;
20: protected String newLanguage;
21:
22: public SuppressionProcEditCommand(SectionWidget sectionWidget,
23: boolean hidden, String formulaText, String language) {
24: super (I18N.get("SuppressionProcEditCommand.name"));
25: this .sectionWidget = sectionWidget;
26:
27: SuppressionProc sp = sectionWidget.getSection()
28: .getSuppressionProc();
29: newHidden = hidden;
30: oldHidden = sp.isHidden();
31:
32: Formula f = sp.getFormula();
33:
34: newText = formulaText;
35: oldText = f.getExpression();
36:
37: newLanguage = language;
38: oldLanguage = f.getLanguage();
39: }
40:
41: public void perform() {
42: SuppressionProc sp = sectionWidget.getSection()
43: .getSuppressionProc();
44: sp.setHidden(newHidden);
45:
46: Formula f = sp.getFormula();
47: f.setExpression(newText);
48: f.setLanguage(newLanguage);
49:
50: // Possible background color change
51: sectionWidget.getFieldPanel().setHidden(newHidden);
52: }
53:
54: public void undo() {
55: SuppressionProc sp = sectionWidget.getSection()
56: .getSuppressionProc();
57: sp.setHidden(oldHidden);
58:
59: Formula f = sp.getFormula();
60: f.setExpression(oldText);
61: f.setLanguage(oldLanguage);
62:
63: // Possible background color change
64: sectionWidget.getFieldPanel().setHidden(oldHidden);
65: }
66:
67: }
|