1 9 10 package org.enhydra.jawe.actions; 11 12 import org.enhydra.jawe.*; 13 14 import java.util.*; 15 import java.awt.event.ActionEvent ; 16 import javax.swing.Action ; 17 import javax.swing.undo.*; 18 19 22 public class Undo extends ActionBase { 23 public Undo (AbstractEditor editor) { 24 super(editor); 25 setEnabled(false); 26 } 27 28 public void actionPerformed(ActionEvent e) { 29 try { 30 Set s1=JaWEGraphModel.getAllCellsInModel(editor.getGraph().getModel()); 31 editor.getUndoManager().undo(editor.getGraph().getGraphLayoutCache()); 32 Set s2=JaWEGraphModel.getAllCellsInModel(editor.getGraph().getModel()); 33 editor.refreshCollections(s1,s2); 34 } catch (CannotUndoException ex) { 35 System.err.println("Unable to undo: " + ex); 36 ex.printStackTrace(); 37 } 38 editor.update(); 39 editor.getRedo().update(); 40 editor.getGraph().repaint(); 41 } 43 44 public void update() { 45 if(editor.getUndoManager().canUndo(editor.getGraph().getGraphLayoutCache())) { 46 setEnabled(true); 47 putValue(Action.NAME, editor.getUndoManager().getUndoPresentationName()); 48 editor.getToolbarComponent("Undo").setToolTipText(editor.getUndoManager().getUndoPresentationName()); 49 } 50 else { 51 setEnabled(false); 52 putValue(Action.NAME,ResourceManager.getLanguageDependentString("UndoLabel")); 53 } 54 } 55 } 56 | Popular Tags |