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 306173 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-48 / +71 lines)
Lines 1238-1247 Link Here
1238
            description="%CVSActionSet.checkoutTooltip"
1238
            description="%CVSActionSet.checkoutTooltip"
1239
            id="org.eclipse.team.cvs.ui.checkout"/>
1239
            id="org.eclipse.team.cvs.ui.checkout"/>
1240
      <command
1240
      <command
1241
            description="%CommitAction.tooltip"
1242
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1241
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1243
            name="%CommitAction.name"
1242
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.CommitAction"
1244
            id="org.eclipse.team.cvs.ui.commit"/>
1243
            description="%CommitAction.tooltip"
1244
            id="org.eclipse.team.cvs.ui.commit"
1245
            name="%CommitAction.name"/>
1245
      <command
1246
      <command
1246
            description="%CommitAllAction.tooltip"
1247
            description="%CommitAllAction.tooltip"
1247
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1248
            categoryId="org.eclipse.team.cvs.ui.actionSet"
Lines 1249-1322 Link Here
1249
            id="org.eclipse.team.cvs.ui.commitAll"/>
1250
            id="org.eclipse.team.cvs.ui.commitAll"/>
1250
      <command
1251
      <command
1251
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1252
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1253
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.ReplaceWithRemoteAction"
1252
            description="%ReplaceWithAction.tooltip"
1254
            description="%ReplaceWithAction.tooltip"
1253
            name="%ReplaceWithAction.name"
1255
            id="org.eclipse.team.cvs.ui.replace"
1254
            id="org.eclipse.team.cvs.ui.replace"/>
1256
            name="%ReplaceWithAction.name"/>
1255
      <command
1257
      <command
1256
            description="%ReplaceWithTagAction.tooltip"
1257
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1258
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1258
            name="%ReplaceWithTagAction.name"
1259
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.ReplaceWithSelectableTagAction"
1259
            id="org.eclipse.team.cvs.ui.replaceWithTag"/>
1260
            description="%ReplaceWithTagAction.tooltip"
1261
            id="org.eclipse.team.cvs.ui.replaceWithTag"
1262
            name="%ReplaceWithTagAction.name"/>
1260
      <command
1263
      <command
1264
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1265
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.ReplaceWithRevisionAction"
1261
            description="%ReplaceWithRevisionAction.tooltip"
1266
            description="%ReplaceWithRevisionAction.tooltip"
1267
            id="org.eclipse.team.cvs.ui.replaceWithRevision"
1268
            name="%ReplaceWithRevisionAction.name"/>
1269
      <command
1262
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1270
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1263
            name="%ReplaceWithRevisionAction.name"
1271
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.ReplaceWithLatestRevisionAction"
1264
            id="org.eclipse.team.cvs.ui.replaceWithRevision"/>
1272
            description="%ReplaceWithLastRevision.tooltip"
1273
            id="org.eclipse.team.cvs.ui.replaceWithBase"
1274
            name="%ReplaceWithLastRevision.label"/>            
1265
      <command
1275
      <command
1266
            description="%CompareWithRemoteAction.tooltip"
1267
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1276
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1268
            name="%CompareWithRemoteAction.name"
1277
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.CompareWithRemoteAction"
1269
            id="org.eclipse.team.cvs.ui.compareWithRemote"/>
1278
            description="%CompareWithRemoteAction.tooltip"
1279
            id="org.eclipse.team.cvs.ui.compareWithRemote"
1280
            name="%CompareWithRemoteAction.name"/>
1270
      <command
1281
      <command
1271
            description="%CompareWithTagAction.tooltip"
1272
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1282
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1273
            name="%CompareWithTagAction.name"
1283
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.CompareWithTagAction"
1274
            id="org.eclipse.team.cvs.ui.compareWithTag"/>
1284
            description="%CompareWithTagAction.tooltip"
1285
            id="org.eclipse.team.cvs.ui.compareWithTag"
1286
            name="%CompareWithTagAction.name"/>
1275
      <command
1287
      <command
1276
            description="%CompareWithRevisionAction.tooltip"
1277
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1288
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1278
            name="%CompareWithRevisionAction.name"
1289
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.CompareWithRevisionAction"
1279
            id="org.eclipse.team.cvs.ui.compareWithRevision"/>
1290
            description="%CompareWithRevisionAction.tooltip"
1291
            id="org.eclipse.team.cvs.ui.compareWithRevision"
1292
            name="%CompareWithRevisionAction.name"/>
1280
      <command
1293
      <command
1281
            description="%UpdateAction.tooltip"
1282
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1294
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1283
            name="%UpdateAction.name"
1295
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.UpdateSilentAction"
1284
            id="org.eclipse.team.cvs.ui.update"/>
1296
            description="%UpdateAction.tooltip"
1297
            id="org.eclipse.team.cvs.ui.update"
1298
            name="%UpdateAction.name"/>
1285
      <command
1299
      <command
1286
            description="%UpdateAllAction.tooltip"
1300
            description="%UpdateAllAction.tooltip"
1287
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1301
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1288
            id="org.eclipse.team.cvs.ui.updateAll"
1302
            id="org.eclipse.team.cvs.ui.updateAll"
1289
            name="%UpdateAllAction.name"/>
1303
            name="%UpdateAllAction.name"/>
1290
      <command
1304
      <command
1291
            description="%GenerateDiff.tooltip"
1292
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1305
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1293
            name="%GenerateDiff.name"
1306
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.GenerateDiffFileAction"
1294
            id="org.eclipse.team.cvs.ui.GenerateDiff"/>
1307
            description="%GenerateDiff.tooltip"
1308
            id="org.eclipse.team.cvs.ui.GenerateDiff"
1309
            name="%GenerateDiff.name"/>
1295
      <command
1310
      <command
1296
            description="%TagAction.tooltip"
1297
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1311
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1298
            name="%TagAction.name"
1312
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.TagLocalAction"
1299
            id="org.eclipse.team.cvs.ui.tag"/>
1313
            description="%TagAction.tooltip"
1314
            id="org.eclipse.team.cvs.ui.tag"
1315
            name="%TagAction.name"/>
1300
      <command
1316
      <command
1301
            description="%BranchAction.tooltip"
1302
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1317
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1303
            name="%BranchAction.name"
1318
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.BranchAction"
1304
            id="org.eclipse.team.cvs.ui.branch"/>
1319
            description="%BranchAction.tooltip"
1320
            id="org.eclipse.team.cvs.ui.branch"
1321
            name="%BranchAction.name"/>
1305
      <command
1322
      <command
1306
            description="%MergeAction.tooltip"
1307
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1323
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1308
            name="%MergeAction.name"
1324
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.MergeAction"
1309
            id="org.eclipse.team.cvs.ui.merge"/>
1325
            description="%MergeAction.tooltip"
1326
            id="org.eclipse.team.cvs.ui.merge"
1327
            name="%MergeAction.name"/>
1310
      <command
1328
      <command
1311
            description="%UpdateActionSwitch.tooltip"
1312
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1329
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1313
            name="%UpdateActionSwitch.name"
1330
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.UpdateAction"
1314
            id="org.eclipse.team.cvs.ui.updateSwitch"/>
1331
            description="%UpdateActionSwitch.tooltip"
1332
            id="org.eclipse.team.cvs.ui.updateSwitch"
1333
            name="%UpdateActionSwitch.name"/>
1315
      <command
1334
      <command
1316
            description="%SetKeywordSubstitutionAction.tooltip"
1317
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1335
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1318
            name="%SetKeywordSubstitutionAction.name"
1336
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.SetKeywordSubstitutionAction"
1319
            id="org.eclipse.team.cvs.ui.setKeywordSubstitution"/>
1337
            description="%SetKeywordSubstitutionAction.tooltip"
1338
            id="org.eclipse.team.cvs.ui.setKeywordSubstitution"
1339
            name="%SetKeywordSubstitutionAction.name"/>
1320
      <command
1340
      <command
1321
            description="%ShowAnnotationAction.tooltip"
1341
            description="%ShowAnnotationAction.tooltip"
1322
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1342
            categoryId="org.eclipse.team.cvs.ui.actionSet"
Lines 1330-1349 Link Here
1330
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.ShowResourceInHistoryAction"
1350
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.ShowResourceInHistoryAction"
1331
            id="org.eclipse.team.cvs.ui.showHistory"/>
1351
            id="org.eclipse.team.cvs.ui.showHistory"/>
1332
      <command
1352
      <command
1333
            description="%AddAction.tooltip"
1334
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1353
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1335
            name="%AddAction.name"
1354
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.AddAction"
1336
            id="org.eclipse.team.cvs.ui.add"/>
1355
            description="%AddAction.tooltip"
1356
            id="org.eclipse.team.cvs.ui.add"
1357
            name="%AddAction.name"/>
1337
      <command
1358
      <command
1338
            description="%IgnoreAction.tooltip"
1339
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1359
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1340
            name="%IgnoreAction.name"
1360
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.IgnoreAction"
1341
            id="org.eclipse.team.cvs.ui.ignore"/>
1361
            description="%IgnoreAction.tooltip"
1362
            id="org.eclipse.team.cvs.ui.ignore"
1363
            name="%IgnoreAction.name"/>
1342
      <command
1364
      <command
1343
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1365
            categoryId="org.eclipse.team.cvs.ui.actionSet"
1366
            defaultHandler="org.eclipse.team.internal.ccvs.ui.actions.SyncAction"
1344
            description="%Synchronize.tooltip"
1367
            description="%Synchronize.tooltip"
1345
            name="%Synchronize.name"
1368
            id="org.eclipse.team.cvs.ui.sync"
1346
            id="org.eclipse.team.cvs.ui.sync"/> 
1369
            name="%Synchronize.name"/> 
1347
   </extension>
1370
   </extension>
1348
   
1371
   
1349
   <!-- Commented out awaiting menu support from UI
1372
   <!-- Commented out awaiting menu support from UI
(-)src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithLatestRevisionAction.java (-7 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2010 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 22-30 Link Here
22
	protected CVSTag getTag(ReplaceOperation replaceOperation) {
22
	protected CVSTag getTag(ReplaceOperation replaceOperation) {
23
		return CVSTag.BASE;
23
		return CVSTag.BASE;
24
	}
24
	}
25
	
25
}
26
	public boolean isEnabled(){
27
		return super.isEnabled();
28
	}
29
30
}
(-)src/org/eclipse/team/internal/ccvs/ui/actions/ShowAnnotationAction.java (-42 lines)
Lines 12-25 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;
16
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IResource;
17
import org.eclipse.jface.action.IAction;
16
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.dialogs.IDialogConstants;
17
import org.eclipse.jface.dialogs.IDialogConstants;
19
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
18
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
20
import org.eclipse.jface.preference.IPreferenceStore;
19
import org.eclipse.jface.preference.IPreferenceStore;
21
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.StructuredSelection;
23
import org.eclipse.osgi.util.NLS;
20
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.team.internal.ccvs.core.*;
21
import org.eclipse.team.internal.ccvs.core.*;
25
import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
22
import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
Lines 27-35 Link Here
27
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
24
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
28
import org.eclipse.team.internal.ccvs.ui.*;
25
import org.eclipse.team.internal.ccvs.ui.*;
29
import org.eclipse.team.internal.ccvs.ui.operations.ShowAnnotationOperation;
26
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;
33
27
34
public class ShowAnnotationAction extends WorkspaceAction {
28
public class ShowAnnotationAction extends WorkspaceAction {
35
29
Lines 161-200 Link Here
161
	public String getId() {
155
	public String getId() {
162
		return ICVSUIConstants.CMD_ANNOTATE;
156
		return ICVSUIConstants.CMD_ANNOTATE;
163
	}
157
	}
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
		setActivePart(null, part);
189
		if (part != null && part instanceof IEditorPart) {
190
			IEditorInput input = ((IEditorPart) part).getEditorInput();
191
			IFile file = ResourceUtil.getFile(input);
192
			if (file != null) {
193
				selectionChanged((IAction) null, new StructuredSelection(file));
194
			}
195
		} else {
196
			// Fallback is to prime the action with the selection
197
			selectionChanged((IAction) null, selection);
198
		}
199
	}
200
}
158
}
(-)src/org/eclipse/team/internal/ccvs/ui/actions/ShowResourceInHistoryAction.java (-41 lines)
Lines 12-33 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;
16
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.jface.action.IAction;
17
import org.eclipse.jface.action.IAction;
19
import org.eclipse.jface.operation.IRunnableWithProgress;
18
import org.eclipse.jface.operation.IRunnableWithProgress;
20
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.StructuredSelection;
22
import org.eclipse.team.internal.ccvs.core.CVSException;
19
import org.eclipse.team.internal.ccvs.core.CVSException;
23
import org.eclipse.team.internal.ccvs.core.ICVSResource;
20
import org.eclipse.team.internal.ccvs.core.ICVSResource;
24
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
21
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
25
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
22
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
26
import org.eclipse.team.internal.ui.TeamUIPlugin;
23
import org.eclipse.team.internal.ui.TeamUIPlugin;
27
import org.eclipse.team.ui.TeamUI;
24
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;
31
25
32
public class ShowResourceInHistoryAction extends WorkspaceAction {
26
public class ShowResourceInHistoryAction extends WorkspaceAction {
33
	/*
27
	/*
Lines 92-130 Link Here
92
	protected boolean isEnabledForIgnoredResources() {
86
	protected boolean isEnabledForIgnoredResources() {
93
		return true;
87
		return true;
94
	}
88
	}
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
	}
130
}
89
}
(-)plugin.xml (-2 / +3 lines)
Lines 329-338 Link Here
329
            id="org.eclipse.team.ui.synchronizeLast">
329
            id="org.eclipse.team.ui.synchronizeLast">
330
      </command>
330
      </command>
331
      <command
331
      <command
332
            name="%Command.applyPatch.name"
333
            categoryId="org.eclipse.team.ui.category.team"
332
            categoryId="org.eclipse.team.ui.category.team"
333
            defaultHandler="org.eclipse.team.internal.ui.actions.ApplyPatchAction"
334
            description="%Command.applyPatch.description"
334
            description="%Command.applyPatch.description"
335
            id="org.eclipse.team.ui.applyPatch">
335
            id="org.eclipse.team.ui.applyPatch"
336
            name="%Command.applyPatch.name">
336
      </command>
337
      </command>
337
      <command
338
      <command
338
       		name="%Synchronizing.perspective"
339
       		name="%Synchronizing.perspective"
(-)src/org/eclipse/team/internal/ui/actions/TeamAction.java (-3 / +40 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 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 18-24 Link Here
18
import org.eclipse.core.commands.*;
18
import org.eclipse.core.commands.*;
19
import org.eclipse.core.resources.*;
19
import org.eclipse.core.resources.*;
20
import org.eclipse.core.resources.mapping.ResourceMapping;
20
import org.eclipse.core.resources.mapping.ResourceMapping;
21
import org.eclipse.core.runtime.*;
21
import org.eclipse.core.runtime.IAdaptable;
22
import org.eclipse.core.runtime.NullProgressMonitor;
22
import org.eclipse.jface.action.IAction;
23
import org.eclipse.jface.action.IAction;
23
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
25
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
Lines 211-217 Link Here
211
212
212
    private Object getResourceMapping(Object object) {
213
    private Object getResourceMapping(Object object) {
213
        if (object instanceof ResourceMapping)
214
        if (object instanceof ResourceMapping)
214
            return (ResourceMapping)object;
215
            return object;
215
        return Utils.getResourceMapping(object);
216
        return Utils.getResourceMapping(object);
216
    }
217
    }
217
    
218
    
Lines 547-551 Link Here
547
    final public void runWithEvent(IAction action, Event event) {
548
    final public void runWithEvent(IAction action, Event event) {
548
        run(action);
549
        run(action);
549
    }
550
    }
551
    
552
	/* (non-Javadoc)
553
	 * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
554
	 */
555
	public void setEnabled(Object evaluationContext) {
556
		IWorkbenchWindow activeWorkbenchWindow = (IWorkbenchWindow) HandlerUtil
557
				.getVariable(evaluationContext,
558
						ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
559
		if (activeWorkbenchWindow != null) {
560
			ISelection selection = (ISelection) HandlerUtil.getVariable(
561
					evaluationContext, ISources.ACTIVE_CURRENT_SELECTION_NAME);
562
			if (selection == null) {
563
				selection = StructuredSelection.EMPTY;
564
			}
565
			IWorkbenchPart part = (IWorkbenchPart) HandlerUtil.getVariable(
566
					evaluationContext, ISources.ACTIVE_PART_NAME);
567
			updateSelection(activeWorkbenchWindow, part, selection);
568
		}
569
	}
570
	
571
	private void updateSelection(IWorkbenchWindow activeWorkbenchWindow,
572
			IWorkbenchPart part, ISelection selection) {
573
		// If the action is run from within an editor, try and find the
574
		// file for the given editor.
575
		setActivePart(null, part);
576
		if (part != null && part instanceof IEditorPart) {
577
			IEditorInput input = ((IEditorPart) part).getEditorInput();
578
			IFile file = ResourceUtil.getFile(input);
579
			if (file != null) {
580
				selectionChanged((IAction) null, new StructuredSelection(file));
581
			}
582
		} else {
583
			// Fallback is to prime the action with the selection
584
			selectionChanged((IAction) null, selection);
585
		}
586
	}
550
587
551
}
588
}

Return to bug 306173