Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6f3c51e499762ad047d22fc9f3bbc3ca6345c514 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*******************************************************************************
 * Copyright (c) 2006, 2009 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.examples.filesystem.ui;

import java.lang.reflect.InvocationTargetException;

import org.eclipse.jface.action.IAction;
import org.eclipse.team.ui.synchronize.ModelMergeOperation;

/**
 * This merge action is contributed as a a popupmenu objectContribution in
 * the plugin.xml. You can change the value return from {@link #isUseSyncFramework()}
 * to try out different dialogs.
 *
 * @since 3.2
 */
public class MergeAction extends FileSystemAction {

	protected void execute(IAction action) {
		try {
			ModelMergeOperation operation;
			if (isUseSyncFramework()) {
				operation = new SyncDialogModelMergeOperation(getTargetPart(),
						FileSystemOperation.createScopeManager("Merging", getSelectedMappings()));
			} else {
				operation = new NonSyncModelMergeOperation(getTargetPart(),
						FileSystemOperation.createScopeManager("Merging", getSelectedMappings()));
			}
			operation.run();
		} catch (InvocationTargetException e) {
			handle(e, null, "Errors occurred while merging");
		} catch (InterruptedException e) {
			// Ignore
		}
	}

	private boolean isUseSyncFramework() {
		return true;
	}
}

Back to the top