Search in sources :

Example 1 with MergeRequestImpl

use of com.intellij.openapi.diff.impl.mergeTool.MergeRequestImpl in project intellij-community by JetBrains.

the class MergePanel2 method setDiffRequest.

public void setDiffRequest(DiffRequest data) {
    setTitle(data.getWindowTitle());
    disposeMergeList();
    for (int i = 0; i < EDITORS_COUNT; i++) {
        getEditorPlace(i).setDocument(null);
    }
    LOG.assertTrue(!myDuringCreation);
    myDuringCreation = true;
    myProvider.putData(data.getGenericData());
    try {
        myData = data;
        String[] titles = myData.getContentTitles();
        for (int i = 0; i < myEditorsPanels.length; i++) {
            LabeledComponent editorsPanel = myEditorsPanels[i];
            editorsPanel.getLabel().setText(titles[i].isEmpty() ? " " : titles[i]);
        }
        createMergeList();
        data.customizeToolbar(myPanel.resetToolbar());
        myPanel.registerToolbarActions();
        if (data instanceof MergeRequestImpl && myBuilder != null) {
            Convertor<DialogWrapper, Boolean> preOkHook = new Convertor<DialogWrapper, Boolean>() {

                @Override
                public Boolean convert(DialogWrapper dialog) {
                    ChangeCounter counter = ChangeCounter.getOrCreate(myMergeList);
                    int changes = counter.getChangeCounter();
                    int conflicts = counter.getConflictCounter();
                    if (changes == 0 && conflicts == 0)
                        return true;
                    return Messages.showYesNoDialog(dialog.getRootPane(), DiffBundle.message("merge.dialog.apply.partially.resolved.changes.confirmation.message", changes, conflicts), DiffBundle.message("apply.partially.resolved.merge.dialog.title"), Messages.getQuestionIcon()) == Messages.YES;
                }
            };
            ((MergeRequestImpl) data).setActions(myBuilder, this, preOkHook);
        }
    } finally {
        myDuringCreation = false;
    }
}
Also used : MergeRequestImpl(com.intellij.openapi.diff.impl.mergeTool.MergeRequestImpl) ChangeCounter(com.intellij.openapi.diff.impl.incrementalMerge.ChangeCounter) LabeledComponent(com.intellij.openapi.ui.LabeledComponent) DiffDividerPaint(com.intellij.openapi.diff.impl.splitter.DiffDividerPaint) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Convertor(com.intellij.util.containers.Convertor)

Example 2 with MergeRequestImpl

use of com.intellij.openapi.diff.impl.mergeTool.MergeRequestImpl in project intellij-community by JetBrains.

the class ExtMergeFiles method show.

@Override
public void show(@NotNull final DiffRequest request) {
    saveContents(request);
    int result = DialogWrapper.CANCEL_EXIT_CODE;
    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setExePath(getToolPath());
    try {
        commandLine.addParameters(getParameters(request));
        commandLine.createProcess();
        ProgressManager.getInstance().run(new Task.Modal(request.getProject(), "Launching external tool", false) {

            @Override
            public void run(@NotNull ProgressIndicator indicator) {
                indicator.setIndeterminate(true);
                TimeoutUtil.sleep(1000);
            }
        });
        if (Messages.YES == Messages.showYesNoDialog(request.getProject(), "Press \"Mark as Resolved\" when you finish resolving conflicts in the external tool", "Merge In External Tool", "Mark as Resolved", "Revert", null)) {
            result = DialogWrapper.OK_EXIT_CODE;
        }
        ((MergeRequestImpl) request).getResultContent().getFile().refresh(false, false);
    // We can actually check exit code of external tool, but some of them could work with tabs -> do not close at all
    } catch (Exception e) {
        ExecutionErrorDialog.show(new ExecutionException(e.getMessage()), DiffBundle.message("cant.launch.diff.tool.error.message"), request.getProject());
    } finally {
        ((MergeRequestImpl) request).setResult(result);
    }
}
Also used : Task(com.intellij.openapi.progress.Task) MergeRequestImpl(com.intellij.openapi.diff.impl.mergeTool.MergeRequestImpl) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException) ExecutionException(com.intellij.execution.ExecutionException)

Aggregations

MergeRequestImpl (com.intellij.openapi.diff.impl.mergeTool.MergeRequestImpl)2 ExecutionException (com.intellij.execution.ExecutionException)1 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 ChangeCounter (com.intellij.openapi.diff.impl.incrementalMerge.ChangeCounter)1 DiffDividerPaint (com.intellij.openapi.diff.impl.splitter.DiffDividerPaint)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 LabeledComponent (com.intellij.openapi.ui.LabeledComponent)1 Convertor (com.intellij.util.containers.Convertor)1