1 17 package org.eclipse.emf.edit.ui.action; 18 19 20 import org.eclipse.jface.action.Action; 21 import org.eclipse.ui.IEditorPart; 22 import org.eclipse.ui.IWorkbenchPart; 23 24 import org.eclipse.emf.common.command.Command; 25 import org.eclipse.emf.edit.domain.EditingDomain; 26 import org.eclipse.emf.edit.domain.IEditingDomainProvider; 27 import org.eclipse.emf.edit.ui.EMFEditUIPlugin; 28 29 30 33 public class RedoAction extends Action 34 { 35 protected EditingDomain domain; 36 37 public RedoAction(EditingDomain domain) 38 { 39 super(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object [] { "" })); 40 this.domain = domain; 41 update(); 42 } 43 44 public RedoAction() 45 { 46 super(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object [] { "" })); 47 } 48 49 52 public EditingDomain getEditingDomain() 53 { 54 return domain; 55 } 56 57 60 public void setEditingDomain(EditingDomain domain) 61 { 62 this.domain = domain; 63 } 64 65 public void run() 66 { 67 domain.getCommandStack().redo(); 68 } 69 70 public void update() 71 { 72 setEnabled(domain.getCommandStack().canRedo()); 73 74 Command redoCommand = domain.getCommandStack().getRedoCommand(); 75 if (redoCommand != null && redoCommand.getLabel() != null) 76 { 77 setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object [] { redoCommand.getLabel() })); 78 } 79 else 80 { 81 setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object [] { "" })); 82 } 83 84 if (redoCommand != null && redoCommand.getDescription() != null) 85 { 86 setDescription(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item_description", new Object [] { redoCommand.getDescription() })); 87 } 88 else 89 { 90 setDescription(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item_simple_description")); 91 } 92 } 93 94 97 public void setActiveEditor(IEditorPart editorPart) 98 { 99 setActiveWorkbenchPart(editorPart); 100 } 101 102 105 public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart) 106 { 107 if (workbenchPart instanceof IEditingDomainProvider) 108 { 109 domain = ((IEditingDomainProvider)workbenchPart).getEditingDomain(); 110 } 111 } 112 } 113 | Popular Tags |