1 package net.sf.bibkeeper.undo;
2
3 import javax.swing.undo;
4 import net.sf.bibkeeper;
5 import net.sf.bibkeeper.Util;
6
7 public class UndoableRemoveString extends AbstractUndoableEdit {
8
9 private BibtexDatabase base;
10 private BibtexString string;
11 private int pos;
12 private BibtexBaseFrame baseFrame;
13
14 public UndoableRemoveString(BibtexBaseFrame baseFrame,
15 BibtexDatabase base, BibtexString string,
16 int pos) {
17 this.base = base;
18 this.string = string;
19 this.pos = pos;
20 this.baseFrame = baseFrame;
21 }
22
23 public String getUndoPresentationName() {
24 return "Undo: remove string ";
25 }
26
27 public String getRedoPresentationName() {
28 return "Redo: remove string ";
29 }
30
31 public void undo() {
32 super.undo();
33
34 // Revert the change.
35 try {
36 base.addString(string, pos);
37 } catch (KeyCollisionException ex) {
38 ex.printStackTrace();
39 }
40
41 baseFrame.updateStringDialog();
42 }
43
44 public void redo() {
45 super.redo();
46
47 // Redo the change.
48 base.removeString(pos);
49
50 baseFrame.updateStringDialog();
51 }
52
53
54
55 }