View | Details | Raw Unified | Return to bug 264498
Collapse All | Expand All

(-)compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java (-3 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008 Aleksandra Wozniak and others.
2
 * Copyright (c) 2008, 2009 Aleksandra Wozniak 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 7-13 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Aleksandra Wozniak (aleksandra.k.wozniak@gmail.com) - initial implementation
9
 *    Aleksandra Wozniak (aleksandra.k.wozniak@gmail.com) - initial implementation
10
 *    IBM Corporation - Bug 73923 (major refactoring and adjustments)
10
 *    IBM Corporation - maintenance
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.compare.internal;
12
package org.eclipse.compare.internal;
13
13
Lines 15-21 Link Here
15
import org.eclipse.jface.viewers.IStructuredSelection;
15
import org.eclipse.jface.viewers.IStructuredSelection;
16
16
17
/**
17
/**
18
 * The "Compare with other resource" action
18
 * The "Compare with other resource" action.
19
 * 
20
 * @deprecated Temporarily replaced by CompareWithOtherResourceHandler. See bug
21
 *             264498.
19
 */
22
 */
20
public class CompareWithOtherResourceAction extends CompareAction {
23
public class CompareWithOtherResourceAction extends CompareAction {
21
24
(-)plugin.xml (-9 / +1 lines)
Lines 166-171 Link Here
166
      </command>
166
      </command>
167
      <command
167
      <command
168
            categoryId="org.eclipse.compare.ui.category.compare"
168
            categoryId="org.eclipse.compare.ui.category.compare"
169
            defaultHandler="org.eclipse.compare.internal.CompareWithOtherResourceHandler"
169
            description="%Command.compareWithOther.description"
170
            description="%Command.compareWithOther.description"
170
            id="org.eclipse.compare.compareWithOther"
171
            id="org.eclipse.compare.compareWithOther"
171
            name="%Command.compareWithOther.name">
172
            name="%Command.compareWithOther.name">
Lines 207-221 Link Here
207
               enablesFor="2+"
208
               enablesFor="2+"
208
               id="compareWithEachOther">
209
               id="compareWithEachOther">
209
         </action>
210
         </action>
210
         <action
211
               class="org.eclipse.compare.internal.CompareWithOtherResourceAction"
212
               definitionId="org.eclipse.compare.compareWithOther"
213
               enablesFor="*"
214
               id="compareWithOtherResource"
215
               label="%CompareWithOtherResource.label"
216
               menubarPath="compareWithMenu/compareWithGroup"
217
               tooltip="%CompareWithOtherResourceAction.tooltip">
218
         </action>
219
      </objectContribution>
211
      </objectContribution>
220
      <objectContribution
212
      <objectContribution
221
            objectClass="org.eclipse.core.resources.IFile"
213
            objectClass="org.eclipse.core.resources.IFile"
(-)compare/org/eclipse/compare/internal/CompareWithOtherResourceHandler.java (+52 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.compare.internal;
12
import org.eclipse.compare.CompareConfiguration;
13
import org.eclipse.compare.CompareUI;
14
import org.eclipse.core.commands.AbstractHandler;
15
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.jface.viewers.ISelection;
18
import org.eclipse.jface.viewers.IStructuredSelection;
19
import org.eclipse.ui.IWorkbenchPage;
20
import org.eclipse.ui.handlers.HandlerUtil;
21
22
/**
23
 * This is a temporarily replacement for CompareWithOtherResourceAction which
24
 * was available from "Compare With > Other Resource...". See bug 264498.
25
 */
26
public class CompareWithOtherResourceHandler extends AbstractHandler {
27
	
28
	public Object execute(ExecutionEvent event) throws ExecutionException {
29
		ISelection selection = HandlerUtil.getCurrentSelection(event);
30
		IWorkbenchPage workbenchPage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
31
		
32
		// CompareAction#isEnabled(ISelection)
33
		CompareConfiguration cc= new CompareConfiguration();
34
		cc.setProperty(CompareEditor.CONFIRM_SAVE_PROPERTY, new Boolean(false));
35
		ResourceCompareInput input= new ResourceCompareInput(cc);
36
		
37
		int selectionSize = 0;
38
		if (selection instanceof IStructuredSelection) {
39
			selectionSize = ((IStructuredSelection) selection).toArray().length;
40
		}
41
		if (input.isEnabled(selection) || selectionSize == 1) {
42
43
			// CompareAction#run(ISelection)
44
			if (!input.setSelection(selection, workbenchPage.getWorkbenchWindow().getShell(), false))
45
				return null;
46
			input.initializeCompareConfiguration();
47
			CompareUI.openCompareEditorOnPage(input, workbenchPage);
48
		}
49
		return null;
50
	}
51
52
}

Return to bug 264498