Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 303784 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (+2 lines)
Lines 1321-1331 Link Here
1321
            description="%ShowAnnotationAction.tooltip"
1321
            description="%ShowAnnotationAction.tooltip"
1322
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1322
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1323
            name="%ShowAnnotationAction.name"
1323
            name="%ShowAnnotationAction.name"
1324
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.ShowAnnotationAction"
1324
            id="org.eclipse.team.cvs.ui.showAnnotation"/>
1325
            id="org.eclipse.team.cvs.ui.showAnnotation"/>
1325
      <command
1326
      <command
1326
            description="%ShowHistoryAction.tooltip"
1327
            description="%ShowHistoryAction.tooltip"
1327
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1328
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1328
            name="%ShowHistoryAction.name"
1329
            name="%ShowHistoryAction.name"
1330
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.ShowResourceInHistoryAction"
1329
            id="org.eclipse.team.cvs.ui.showHistory"/>
1331
            id="org.eclipse.team.cvs.ui.showHistory"/>
1330
      <command
1332
      <command
1331
            description="%AddAction.tooltip"
1333
            description="%AddAction.tooltip"
(-)src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java (+41 lines)
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
}
(-)src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java (+41 lines)
Lines 12-27 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.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.operation.IRunnableWithProgress;
19
import org.eclipse.jface.operation.IRunnableWithProgress;
20
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.StructuredSelection;
19
import org.eclipse.team.internal.ccvs.core.CVSException;
22
import org.eclipse.team.internal.ccvs.core.CVSException;
20
import org.eclipse.team.internal.ccvs.core.ICVSResource;
23
import org.eclipse.team.internal.ccvs.core.ICVSResource;
21
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
24
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
22
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
25
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
23
import org.eclipse.team.internal.ui.TeamUIPlugin;
26
import org.eclipse.team.internal.ui.TeamUIPlugin;
24
import org.eclipse.team.ui.TeamUI;
27
import org.eclipse.team.ui.TeamUI;
28
import org.eclipse.ui.*;
29
import org.eclipse.ui.handlers.HandlerUtil;
30
import org.eclipse.ui.ide.ResourceUtil;
25
31
26
public class ShowResourceInHistoryAction extends WorkspaceAction {
32
public class ShowResourceInHistoryAction extends WorkspaceAction {
27
	/*
33
	/*
Lines 86-89 Link Here
86
	protected boolean isEnabledForIgnoredResources() {
92
	protected boolean isEnabledForIgnoredResources() {
87
		return true;
93
		return true;
88
	}
94
	}
95
	
96
	/* (non-Javadoc)
97
	 * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
98
	 */
99
	public void setEnabled(Object evaluationContext) {
100
		IWorkbenchWindow activeWorkbenchWindow = (IWorkbenchWindow) HandlerUtil
101
				.getVariable(evaluationContext,
102
						ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
103
		if (activeWorkbenchWindow != null) {
104
			ISelection selection = (ISelection) HandlerUtil.getVariable(
105
					evaluationContext, ISources.ACTIVE_CURRENT_SELECTION_NAME);
106
			if (selection == null) {
107
				selection = StructuredSelection.EMPTY;
108
			}
109
			IWorkbenchPart part = (IWorkbenchPart) HandlerUtil.getVariable(
110
					evaluationContext, ISources.ACTIVE_PART_NAME);
111
			updateSelection(activeWorkbenchWindow, part, selection);
112
		}
113
	}
114
	
115
	private void updateSelection(IWorkbenchWindow activeWorkbenchWindow,
116
			IWorkbenchPart part, ISelection selection) {
117
		// If the action is run from within an editor, try and find the
118
		// file for the given editor.
119
		if (part != null && part instanceof IEditorPart) {
120
			IEditorInput input = ((IEditorPart) part).getEditorInput();
121
			IFile file = ResourceUtil.getFile(input);
122
			if (file != null) {
123
				selectionChanged((IAction) null, new StructuredSelection(file));
124
			}
125
		} else {
126
			// Fallback is to prime the action with the selection
127
			selectionChanged((IAction) null, selection);
128
		}
129
	}
89
}
130
}

Return to bug 303784