1 19 package org.openide.actions; 20 21 import org.openide.awt.UndoRedo; 22 import org.openide.util.HelpCtx; 23 import org.openide.util.NbBundle; 24 import org.openide.util.actions.CallableSystemAction; 25 26 import javax.swing.UIManager ; 27 import javax.swing.undo.CannotRedoException ; 28 import org.openide.util.Exceptions; 29 30 31 36 public class RedoAction extends CallableSystemAction { 37 private static String SWING_DEFAULT_LABEL = UIManager.getString("AbstractUndoableEdit.redoText"); 39 public boolean isEnabled() { 40 UndoAction.initializeUndoRedo(); 41 42 return super.isEnabled(); 43 } 44 45 public String getName() { 46 String redo = UndoAction.getUndoRedo().getRedoPresentationName(); 50 51 if ((redo != null) && (SWING_DEFAULT_LABEL != null) && redo.startsWith(SWING_DEFAULT_LABEL)) { 52 redo = redo.substring(SWING_DEFAULT_LABEL.length()).trim(); 53 } 54 55 return NbBundle.getMessage(RedoAction.class, "Redo", redo); 56 } 57 58 public HelpCtx getHelpCtx() { 59 return new HelpCtx(RedoAction.class); 60 } 61 62 protected String iconResource() { 63 return "org/openide/resources/actions/redo.gif"; } 65 66 public void performAction() { 67 try { 68 UndoRedo undoRedo = UndoAction.getUndoRedo(); 69 70 if (undoRedo.canRedo()) { 71 undoRedo.redo(); 72 } 73 } catch (CannotRedoException ex) { 74 Exceptions.printStackTrace(ex); 75 } 76 77 UndoAction.updateStatus(); 78 } 79 80 protected boolean asynchronous() { 81 return false; 82 } 83 } 84 | Popular Tags |