blob: f29be99f9e22e760158a73d5740285b0b5160f0f (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/*******************************************************************************
* Copyright (c) 2010 SAP AG.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Stefan Lay (SAP AG) - initial implementation
*******************************************************************************/
package org.eclipse.egit.ui.internal.actions;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.CompareUI;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.merge.GitMergeEditorInput;
import org.eclipse.egit.ui.internal.merge.MergeModeDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.jgit.lib.Repository;
/**
* Action for selecting a commit and merging it with the current branch.
*/
public class MergeToolActionHandler extends RepositoryActionHandler {
public Object execute(final ExecutionEvent event) throws ExecutionException {
int mergeMode = Activator.getDefault().getPreferenceStore().getInt(
UIPreferences.MERGE_MODE);
CompareEditorInput input;
if (mergeMode == 0) {
MergeModeDialog dlg = new MergeModeDialog(getShell(event));
if (dlg.open() != Window.OK)
return null;
input = new GitMergeEditorInput(dlg.useWorkspace(),
getSelectedResources(event));
} else {
boolean useWorkspace = mergeMode == 1;
input = new GitMergeEditorInput(useWorkspace,
getSelectedResources(event));
}
CompareUI.openCompareEditor(input);
return null;
}
public boolean isEnabled() {
Repository[] repos = getRepositoriesFor(getProjectsForSelectedResources());
if (repos.length != 1)
return false;
switch (repos[0].getRepositoryState()) {
case MERGING:
// fall through
case CHERRY_PICKING:
// fall through
case REBASING:
// fall through
case REBASING_INTERACTIVE:
// fall through
case REBASING_MERGE:
// fall through
case REBASING_REBASING:
return true;
default:
return false;
}
}
}
|