KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > actions > Redo


1 /*
2  * Authors:
3  * Stefanovic Nenad chupo@iis.ns.ac.yu
4  * Bojanic Sasa sasaboy@neobee.net
5  * Puskas Vladimir vpuskas@eunet.yu
6  * Pilipovic Goran zboniek@uns.ac.yu
7  *
8  */

9
10 package org.enhydra.jawe.actions;
11
12 import org.enhydra.jawe.*;
13
14 import java.util.*;
15 import java.awt.event.ActionEvent JavaDoc;
16 import javax.swing.Action JavaDoc;
17 import javax.swing.undo.*;
18
19 /**
20  * Class that realizes <B>redo</B> action
21  */

22 public class Redo extends ActionBase {
23    public Redo (AbstractEditor editor) {
24       super(editor);
25       setEnabled(false);
26    }
27
28    public void actionPerformed(ActionEvent JavaDoc e) {
29       try {
30          Set s1=JaWEGraphModel.getAllCellsInModel(editor.getGraph().getModel());
31          editor.getUndoManager().redo(editor.getGraph().getGraphLayoutCache());
32          Set s2=JaWEGraphModel.getAllCellsInModel(editor.getGraph().getModel());
33          editor.refreshCollections(s1,s2);
34       } catch (CannotRedoException ex) {
35          System.err.println("Unable to redo: " + ex);
36          ex.printStackTrace();
37       }
38       update();
39       editor.getUndo().update();
40       editor.getGraph().repaint();
41       //graph.getUI().paint(editor.getGraph().getGraphics(),editor.getGraph());
42
}
43
44    public void update() {
45       if(editor.getUndoManager().canRedo(editor.getGraph().getGraphLayoutCache())) {
46          setEnabled(true);
47          putValue(Action.NAME, editor.getUndoManager().getRedoPresentationName());
48          editor.getToolbarComponent("Redo").setToolTipText(editor.getUndoManager().getRedoPresentationName());
49       }
50       else {
51          setEnabled(false);
52          putValue(Action.NAME,ResourceManager.getLanguageDependentString("RedoLabel"));
53       }
54    }
55 }
56
Popular Tags