1 package com.explosion.expfmodules.texteditor;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.awt.Component;
23
24 import javax.swing.event.UndoableEditEvent;
25
26 import com.explosion.expf.Application;
27 import com.explosion.expf.ExpConstants;
28 import com.explosion.utilities.UndoRedoBuffer;
29 /***
30 * @author Stephen Cowx
31 * Date created:@07-Feb-2003
32 */
33 public class MenuAwareUndoRedoBuffer extends UndoRedoBuffer
34 {
35 private Component highLevelParent;
36 private Component component;
37
38 public MenuAwareUndoRedoBuffer(Component highLevelParent,Component component)
39 {
40 this.highLevelParent = highLevelParent;
41 this.component = component;
42 }
43
44 /***
45 * @see com.explosion.utilities.UndoRedoBuffer#redo()
46 */
47 public void redo()
48 {
49 super.redo();
50 checkRedo();
51 checkUndo();
52 }
53
54 /***
55 * @see com.explosion.utilities.UndoRedoBuffer#undo()
56 */
57 public void undo()
58 {
59 super.undo();
60 checkUndo();
61 checkRedo();
62 }
63
64
65 /***
66 * @see javax.swing.event.UndoableEditListener#undoableEditHappened(UndoableEditEvent)
67 */
68 public void undoableEditHappened(UndoableEditEvent e)
69 {
70 super.undoableEditHappened(e);
71 checkUndo();
72 checkRedo();
73 }
74
75 private void checkUndo()
76 {
77 if ( getUndoBuffer().size() > 0)
78 Application.ensureComponentCookie(ExpConstants.MENU_UNDO,1,highLevelParent,component);
79 else
80 Application.ensureComponentCookie(ExpConstants.MENU_UNDO,0,highLevelParent,component);
81 }
82
83 private void checkRedo()
84 {
85 if ( getRedoBuffer().size() > 0)
86 Application.ensureComponentCookie(ExpConstants.MENU_REDO,1,highLevelParent,component);
87 else
88 Application.ensureComponentCookie(ExpConstants.MENU_REDO,0,highLevelParent,component);
89 }
90
91
92 }