This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Undo (Working, but text is not updated, would need to find the menu
entries to do so). - Select All
- Loading branch information
Christophe Bouhier
committed
Apr 12, 2013
1 parent
7400a4a
commit b57b36f
Showing
4 changed files
with
70 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
bundles/org.eclipse.e4mf.edit.ui/src/org/eclipse/e4mf/edit/ui/e4/action/UndoHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,69 @@ | ||
package org.eclipse.e4mf.edit.ui.e4.action; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.eclipse.e4.core.commands.ECommandService; | ||
import org.eclipse.e4.core.di.annotations.CanExecute; | ||
import org.eclipse.e4.core.di.annotations.Execute; | ||
import org.eclipse.e4.core.di.annotations.Optional; | ||
import org.eclipse.e4mf.edit.ui.EMFEditUIPlugin; | ||
import org.eclipse.emf.common.command.Command; | ||
import org.eclipse.emf.edit.domain.EditingDomain; | ||
|
||
@SuppressWarnings("restriction") | ||
public class UndoHandler { | ||
|
||
private static final String UNDO_COMMAND_ID = "org.eclipse.ui.edit.undo"; | ||
|
||
@Inject | ||
@Optional | ||
protected EditingDomain domain; | ||
|
||
@Inject | ||
@Optional | ||
private ECommandService commandService; | ||
|
||
@CanExecute | ||
public boolean canExecute() { | ||
|
||
// org.eclipse.core.commands.Command command = commandService | ||
// .getCommand(UNDO_COMMAND_ID); | ||
|
||
boolean result = domain.getCommandStack().canUndo(); | ||
|
||
String newText = null; | ||
String newDescription = null; | ||
|
||
Command undoCommand = domain.getCommandStack().getUndoCommand(); | ||
if (undoCommand != null && undoCommand.getLabel() != null) { | ||
newText = EMFEditUIPlugin.INSTANCE.getString("_UI_Undo_menu_item", | ||
new Object[] { undoCommand.getLabel() }); | ||
// setText(); | ||
} else { | ||
newText = EMFEditUIPlugin.INSTANCE.getString("_UI_Undo_menu_item", | ||
new Object[] { "" }); | ||
// setText(); | ||
} | ||
|
||
if (undoCommand != null && undoCommand.getDescription() != null) { | ||
newDescription = EMFEditUIPlugin.INSTANCE.getString( | ||
"_UI_Undo_menu_item_description", | ||
new Object[] { undoCommand.getDescription() }); | ||
// setDescription(); | ||
} else { | ||
newDescription = EMFEditUIPlugin.INSTANCE | ||
.getString("_UI_Undo_menu_item_simple_description"); | ||
// setDescription(); | ||
} | ||
|
||
System.out.println("Undo Handler: debug: " + newText + newDescription); | ||
|
||
return result; | ||
} | ||
|
||
@Execute | ||
public void execute() { | ||
domain.getCommandStack().undo(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters