|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2005, 2007 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 12-17
Link Here
|
| 12 |
|
12 |
|
| 13 |
import java.lang.reflect.InvocationTargetException; |
13 |
import java.lang.reflect.InvocationTargetException; |
| 14 |
|
14 |
|
|
|
15 |
import org.eclipse.core.runtime.IAdaptable; |
| 16 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 17 |
import org.eclipse.core.runtime.IStatus; |
| 18 |
import org.eclipse.core.runtime.OperationCanceledException; |
| 19 |
|
| 15 |
import org.eclipse.core.commands.ExecutionException; |
20 |
import org.eclipse.core.commands.ExecutionException; |
| 16 |
import org.eclipse.core.commands.operations.IAdvancedUndoableOperation2; |
21 |
import org.eclipse.core.commands.operations.IAdvancedUndoableOperation2; |
| 17 |
import org.eclipse.core.commands.operations.IOperationHistory; |
22 |
import org.eclipse.core.commands.operations.IOperationHistory; |
|
Lines 19-33
Link Here
|
| 19 |
import org.eclipse.core.commands.operations.IUndoContext; |
24 |
import org.eclipse.core.commands.operations.IUndoContext; |
| 20 |
import org.eclipse.core.commands.operations.IUndoableOperation; |
25 |
import org.eclipse.core.commands.operations.IUndoableOperation; |
| 21 |
import org.eclipse.core.commands.operations.OperationHistoryEvent; |
26 |
import org.eclipse.core.commands.operations.OperationHistoryEvent; |
| 22 |
import org.eclipse.core.runtime.IAdaptable; |
27 |
|
| 23 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
|
| 24 |
import org.eclipse.core.runtime.IStatus; |
| 25 |
import org.eclipse.core.runtime.OperationCanceledException; |
| 26 |
import org.eclipse.jface.action.Action; |
| 27 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
| 28 |
import org.eclipse.osgi.util.NLS; |
| 29 |
import org.eclipse.swt.widgets.Display; |
28 |
import org.eclipse.swt.widgets.Display; |
| 30 |
import org.eclipse.swt.widgets.Shell; |
29 |
import org.eclipse.swt.widgets.Shell; |
|
|
30 |
|
| 31 |
import org.eclipse.jface.action.Action; |
| 32 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
| 33 |
|
| 31 |
import org.eclipse.ui.IPartListener; |
34 |
import org.eclipse.ui.IPartListener; |
| 32 |
import org.eclipse.ui.IWorkbenchPart; |
35 |
import org.eclipse.ui.IWorkbenchPart; |
| 33 |
import org.eclipse.ui.IWorkbenchPartSite; |
36 |
import org.eclipse.ui.IWorkbenchPartSite; |
|
Lines 42-47
Link Here
|
| 42 |
import org.eclipse.ui.part.MultiPageEditorSite; |
45 |
import org.eclipse.ui.part.MultiPageEditorSite; |
| 43 |
import org.eclipse.ui.statushandlers.StatusManager; |
46 |
import org.eclipse.ui.statushandlers.StatusManager; |
| 44 |
|
47 |
|
|
|
48 |
import org.eclipse.osgi.util.NLS; |
| 49 |
|
| 45 |
/** |
50 |
/** |
| 46 |
* <p> |
51 |
* <p> |
| 47 |
* OperationHistoryActionHandler implements common behavior for the undo and |
52 |
* OperationHistoryActionHandler implements common behavior for the undo and |
|
Lines 120-133
Link Here
|
| 120 |
|
125 |
|
| 121 |
private class HistoryListener implements IOperationHistoryListener { |
126 |
private class HistoryListener implements IOperationHistoryListener { |
| 122 |
public void historyNotification(final OperationHistoryEvent event) { |
127 |
public void historyNotification(final OperationHistoryEvent event) { |
| 123 |
Display display = getWorkbenchWindow().getWorkbench().getDisplay(); |
128 |
IWorkbenchWindow workbenchWindow = getWorkbenchWindow(); |
|
|
129 |
if (workbenchWindow == null) |
| 130 |
return; |
| 131 |
|
| 132 |
Display display = workbenchWindow.getWorkbench().getDisplay(); |
| 133 |
if (display == null) |
| 134 |
return; |
| 135 |
|
| 124 |
switch (event.getEventType()) { |
136 |
switch (event.getEventType()) { |
| 125 |
case OperationHistoryEvent.OPERATION_ADDED: |
137 |
case OperationHistoryEvent.OPERATION_ADDED: |
| 126 |
case OperationHistoryEvent.OPERATION_REMOVED: |
138 |
case OperationHistoryEvent.OPERATION_REMOVED: |
| 127 |
case OperationHistoryEvent.UNDONE: |
139 |
case OperationHistoryEvent.UNDONE: |
| 128 |
case OperationHistoryEvent.REDONE: |
140 |
case OperationHistoryEvent.REDONE: |
| 129 |
if (display != null |
141 |
if (event.getOperation().hasContext(undoContext)) { |
| 130 |
&& event.getOperation().hasContext(undoContext)) { |
|
|
| 131 |
display.asyncExec(new Runnable() { |
142 |
display.asyncExec(new Runnable() { |
| 132 |
public void run() { |
143 |
public void run() { |
| 133 |
update(); |
144 |
update(); |
|
Lines 136-143
Link Here
|
| 136 |
} |
147 |
} |
| 137 |
break; |
148 |
break; |
| 138 |
case OperationHistoryEvent.OPERATION_NOT_OK: |
149 |
case OperationHistoryEvent.OPERATION_NOT_OK: |
| 139 |
if (display != null |
150 |
if (event.getOperation().hasContext(undoContext)) { |
| 140 |
&& event.getOperation().hasContext(undoContext)) { |
|
|
| 141 |
display.asyncExec(new Runnable() { |
151 |
display.asyncExec(new Runnable() { |
| 142 |
public void run() { |
152 |
public void run() { |
| 143 |
if (pruning) { |
153 |
if (pruning) { |
|
Lines 162-168
Link Here
|
| 162 |
} |
172 |
} |
| 163 |
break; |
173 |
break; |
| 164 |
case OperationHistoryEvent.OPERATION_CHANGED: |
174 |
case OperationHistoryEvent.OPERATION_CHANGED: |
| 165 |
if (display != null && event.getOperation() == getOperation()) { |
175 |
if (event.getOperation() == getOperation()) { |
| 166 |
display.asyncExec(new Runnable() { |
176 |
display.asyncExec(new Runnable() { |
| 167 |
public void run() { |
177 |
public void run() { |
| 168 |
update(); |
178 |
update(); |