blob: 2aa36cb67dacd11aa1155647f4a305bf99f35300 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*******************************************************************************
* Copyright (c) 2012, 2013 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.util;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.compare.domain.ICompareEditingDomain;
import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
import org.eclipse.jface.action.Action;
/**
* An redo action is implemented by using the {@link org.eclipse.emf.common.command.CommandStack}.
*/
public class RedoAction extends Action {
protected ICompareEditingDomain domain;
public RedoAction(ICompareEditingDomain domain) {
super(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object[] {"" })); //$NON-NLS-1$ //$NON-NLS-2$
setEditingDomain(domain);
}
/**
* Do not use this, will be removed in the next version.
*
* @deprecated
*/
@Deprecated
public RedoAction() {
super(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object[] {"" })); //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
public void run() {
if (domain != null) {
domain.getCommandStack().redo();
} else {
/*
* FIXME : Domain may be null since we never unregister the actions from the handler service. It
* is set to null from #setEditingDomain(ICompareEditingDomain) when we switch to another content
* viewer. In such cases, we "may" reach this run() before the new viwer is fully displayed and
* its action initialized with a proper editing domain.
*/
}
}
public void setEditingDomain(ICompareEditingDomain domain) {
this.domain = domain;
if (domain != null) {
update();
}
}
public void update() {
if (domain == null) {
return;
}
setEnabled(domain.getCommandStack().canRedo());
Command redoCommand = domain.getCommandStack().getRedoCommand();
if (redoCommand != null && redoCommand.getLabel() != null) {
setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object[] {redoCommand //$NON-NLS-1$
.getLabel() }));
} else {
setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item", new Object[] {"" })); //$NON-NLS-1$ //$NON-NLS-2$
}
if (redoCommand != null && redoCommand.getDescription() != null) {
setDescription(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item_description", //$NON-NLS-1$
new Object[] {redoCommand.getDescription() }));
} else {
setDescription(EMFEditUIPlugin.INSTANCE.getString("_UI_Redo_menu_item_simple_description")); //$NON-NLS-1$
}
}
}
|