Search in sources :

Example 1 with GitMergeEditorInput

use of org.eclipse.egit.ui.internal.merge.GitMergeEditorInput in project egit by eclipse.

the class RebaseResultDialog method buttonPressed.

@Override
protected void buttonPressed(int buttonId) {
    // store the preference to hide these dialogs
    if (toggleButton != null)
        Activator.getDefault().getPreferenceStore().setValue(UIPreferences.SHOW_REBASE_CONFIRM, !toggleButton.getSelection());
    if (buttonId == IDialogConstants.OK_ID) {
        if (result.getStatus() != Status.STOPPED) {
            super.buttonPressed(buttonId);
            return;
        }
        if (startMergeButton.getSelection()) {
            super.buttonPressed(buttonId);
            // open the merge tool
            IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
            for (IProject project : projects) {
                RepositoryMapping mapping = RepositoryMapping.getMapping(project);
                if (mapping != null && mapping.getRepository().equals(repo)) {
                    try {
                        // make sure to refresh before opening the merge
                        // tool
                        project.refreshLocal(IResource.DEPTH_INFINITE, null);
                    } catch (CoreException e) {
                        Activator.handleError(e.getMessage(), e, false);
                    }
                }
            }
            List<IPath> locationList = new ArrayList<>();
            IPath repoWorkdirPath = new Path(repo.getWorkTree().getPath());
            for (String repoPath : conflictPaths) {
                IPath location = repoWorkdirPath.append(repoPath);
                locationList.add(location);
            }
            IPath[] locations = locationList.toArray(new IPath[locationList.size()]);
            int mergeMode = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.MERGE_MODE);
            CompareEditorInput input;
            if (mergeMode == 0) {
                MergeModeDialog dlg = new MergeModeDialog(getParentShell());
                if (dlg.open() != Window.OK)
                    return;
                input = new GitMergeEditorInput(dlg.useWorkspace(), locations);
            } else {
                boolean useWorkspace = mergeMode == 1;
                input = new GitMergeEditorInput(useWorkspace, locations);
            }
            CompareUI.openCompareEditor(input);
            return;
        } else if (skipCommitButton.getSelection()) {
            // skip the rebase
            SkipRebaseCommand skipCommand = new SkipRebaseCommand();
            execute(skipCommand);
        } else if (abortRebaseButton.getSelection()) {
            // abort the rebase
            AbortRebaseCommand abortCommand = new AbortRebaseCommand();
            execute(abortCommand);
        } else if (doNothingButton.getSelection()) {
        // nothing
        }
    }
    super.buttonPressed(buttonId);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) GitMergeEditorInput(org.eclipse.egit.ui.internal.merge.GitMergeEditorInput) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) AbortRebaseCommand(org.eclipse.egit.ui.internal.commands.shared.AbortRebaseCommand) CompareEditorInput(org.eclipse.compare.CompareEditorInput) CoreException(org.eclipse.core.runtime.CoreException) RepositoryMapping(org.eclipse.egit.core.project.RepositoryMapping) MergeModeDialog(org.eclipse.egit.ui.internal.merge.MergeModeDialog) SkipRebaseCommand(org.eclipse.egit.ui.internal.commands.shared.SkipRebaseCommand)

Example 2 with GitMergeEditorInput

use of org.eclipse.egit.ui.internal.merge.GitMergeEditorInput in project egit by eclipse.

the class MergeToolActionHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    int mergeMode = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.MERGE_MODE);
    IPath[] locations = getSelectedLocations(event);
    CompareEditorInput input;
    if (mergeMode == 0) {
        MergeModeDialog dlg = new MergeModeDialog(getShell(event));
        if (dlg.open() != Window.OK)
            return null;
        input = new GitMergeEditorInput(dlg.useWorkspace(), locations);
    } else {
        boolean useWorkspace = mergeMode == 1;
        input = new GitMergeEditorInput(useWorkspace, locations);
    }
    CompareUI.openCompareEditor(input);
    return null;
}
Also used : CompareEditorInput(org.eclipse.compare.CompareEditorInput) GitMergeEditorInput(org.eclipse.egit.ui.internal.merge.GitMergeEditorInput) IPath(org.eclipse.core.runtime.IPath) MergeModeDialog(org.eclipse.egit.ui.internal.merge.MergeModeDialog)

Aggregations

CompareEditorInput (org.eclipse.compare.CompareEditorInput)2 IPath (org.eclipse.core.runtime.IPath)2 GitMergeEditorInput (org.eclipse.egit.ui.internal.merge.GitMergeEditorInput)2 MergeModeDialog (org.eclipse.egit.ui.internal.merge.MergeModeDialog)2 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 Path (org.eclipse.core.runtime.Path)1 RepositoryMapping (org.eclipse.egit.core.project.RepositoryMapping)1 AbortRebaseCommand (org.eclipse.egit.ui.internal.commands.shared.AbortRebaseCommand)1 SkipRebaseCommand (org.eclipse.egit.ui.internal.commands.shared.SkipRebaseCommand)1