|
Lines 12-22
Link Here
|
| 12 |
|
12 |
|
| 13 |
import java.lang.reflect.InvocationTargetException; |
13 |
import java.lang.reflect.InvocationTargetException; |
| 14 |
|
14 |
|
|
|
15 |
import org.eclipse.core.resources.IFile; |
| 15 |
import org.eclipse.core.resources.IResource; |
16 |
import org.eclipse.core.resources.IResource; |
| 16 |
import org.eclipse.jface.action.IAction; |
17 |
import org.eclipse.jface.action.IAction; |
| 17 |
import org.eclipse.jface.dialogs.IDialogConstants; |
18 |
import org.eclipse.jface.dialogs.IDialogConstants; |
| 18 |
import org.eclipse.jface.dialogs.MessageDialogWithToggle; |
19 |
import org.eclipse.jface.dialogs.MessageDialogWithToggle; |
| 19 |
import org.eclipse.jface.preference.IPreferenceStore; |
20 |
import org.eclipse.jface.preference.IPreferenceStore; |
|
|
21 |
import org.eclipse.jface.viewers.ISelection; |
| 22 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 20 |
import org.eclipse.osgi.util.NLS; |
23 |
import org.eclipse.osgi.util.NLS; |
| 21 |
import org.eclipse.team.internal.ccvs.core.*; |
24 |
import org.eclipse.team.internal.ccvs.core.*; |
| 22 |
import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry; |
25 |
import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry; |
|
Lines 24-29
Link Here
|
| 24 |
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; |
27 |
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; |
| 25 |
import org.eclipse.team.internal.ccvs.ui.*; |
28 |
import org.eclipse.team.internal.ccvs.ui.*; |
| 26 |
import org.eclipse.team.internal.ccvs.ui.operations.ShowAnnotationOperation; |
29 |
import org.eclipse.team.internal.ccvs.ui.operations.ShowAnnotationOperation; |
|
|
30 |
import org.eclipse.ui.*; |
| 31 |
import org.eclipse.ui.handlers.HandlerUtil; |
| 32 |
import org.eclipse.ui.ide.ResourceUtil; |
| 27 |
|
33 |
|
| 28 |
public class ShowAnnotationAction extends WorkspaceAction { |
34 |
public class ShowAnnotationAction extends WorkspaceAction { |
| 29 |
|
35 |
|
|
Lines 155-158
Link Here
|
| 155 |
public String getId() { |
161 |
public String getId() { |
| 156 |
return ICVSUIConstants.CMD_ANNOTATE; |
162 |
return ICVSUIConstants.CMD_ANNOTATE; |
| 157 |
} |
163 |
} |
|
|
164 |
|
| 165 |
/* (non-Javadoc) |
| 166 |
* @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object) |
| 167 |
*/ |
| 168 |
public void setEnabled(Object evaluationContext) { |
| 169 |
IWorkbenchWindow activeWorkbenchWindow = (IWorkbenchWindow) HandlerUtil |
| 170 |
.getVariable(evaluationContext, |
| 171 |
ISources.ACTIVE_WORKBENCH_WINDOW_NAME); |
| 172 |
if (activeWorkbenchWindow != null) { |
| 173 |
ISelection selection = (ISelection) HandlerUtil.getVariable( |
| 174 |
evaluationContext, ISources.ACTIVE_CURRENT_SELECTION_NAME); |
| 175 |
if (selection == null) { |
| 176 |
selection = StructuredSelection.EMPTY; |
| 177 |
} |
| 178 |
IWorkbenchPart part = (IWorkbenchPart) HandlerUtil.getVariable( |
| 179 |
evaluationContext, ISources.ACTIVE_PART_NAME); |
| 180 |
updateSelection(activeWorkbenchWindow, part, selection); |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
private void updateSelection(IWorkbenchWindow activeWorkbenchWindow, |
| 185 |
IWorkbenchPart part, ISelection selection) { |
| 186 |
// If the action is run from within an editor, try and find the |
| 187 |
// file for the given editor. |
| 188 |
if (part != null && part instanceof IEditorPart) { |
| 189 |
IEditorInput input = ((IEditorPart) part).getEditorInput(); |
| 190 |
IFile file = ResourceUtil.getFile(input); |
| 191 |
if (file != null) { |
| 192 |
selectionChanged((IAction) null, new StructuredSelection(file)); |
| 193 |
} |
| 194 |
} else { |
| 195 |
// Fallback is to prime the action with the selection |
| 196 |
selectionChanged((IAction) null, selection); |
| 197 |
} |
| 198 |
} |
| 158 |
} |
199 |
} |