2 * Copyright 2000-2015 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.diff;
18 import com.intellij.diff.chains.DiffRequestChain;
19 import com.intellij.diff.chains.SimpleDiffRequestChain;
20 import com.intellij.diff.impl.DiffRequestPanelImpl;
21 import com.intellij.diff.impl.DiffWindow;
22 import com.intellij.diff.merge.*;
23 import com.intellij.diff.requests.DiffRequest;
24 import com.intellij.diff.tools.binary.BinaryDiffTool;
25 import com.intellij.diff.tools.dir.DirDiffTool;
26 import com.intellij.diff.tools.external.ExternalDiffTool;
27 import com.intellij.diff.tools.external.ExternalMergeTool;
28 import com.intellij.diff.tools.fragmented.UnifiedDiffTool;
29 import com.intellij.diff.tools.simple.SimpleDiffTool;
30 import com.intellij.openapi.Disposable;
31 import com.intellij.openapi.project.Project;
32 import com.intellij.openapi.util.Disposer;
33 import org.jetbrains.annotations.CalledInAwt;
34 import org.jetbrains.annotations.NotNull;
35 import org.jetbrains.annotations.Nullable;
38 import java.util.ArrayList;
39 import java.util.Collections;
40 import java.util.List;
42 public class DiffManagerImpl extends DiffManagerEx {
44 public void showDiff(@Nullable Project project, @NotNull DiffRequest request) {
45 showDiff(project, request, DiffDialogHints.DEFAULT);
49 public void showDiff(@Nullable Project project, @NotNull DiffRequest request, @NotNull DiffDialogHints hints) {
50 DiffRequestChain requestChain = new SimpleDiffRequestChain(request);
51 showDiff(project, requestChain, hints);
55 public void showDiff(@Nullable Project project, @NotNull DiffRequestChain requests, @NotNull DiffDialogHints hints) {
56 if (ExternalDiffTool.isDefault()) {
57 ExternalDiffTool.show(project, requests, hints);
61 showDiffBuiltin(project, requests, hints);
65 public void showDiffBuiltin(@Nullable Project project, @NotNull DiffRequest request) {
66 showDiffBuiltin(project, request, DiffDialogHints.DEFAULT);
70 public void showDiffBuiltin(@Nullable Project project, @NotNull DiffRequest request, @NotNull DiffDialogHints hints) {
71 DiffRequestChain requestChain = new SimpleDiffRequestChain(request);
72 showDiffBuiltin(project, requestChain, hints);
76 public void showDiffBuiltin(@Nullable Project project, @NotNull DiffRequestChain requests, @NotNull DiffDialogHints hints) {
77 new DiffWindow(project, requests, hints).show();
82 public DiffRequestPanel createRequestPanel(@Nullable Project project, @NotNull Disposable parent, @Nullable Window window) {
83 DiffRequestPanelImpl panel = new DiffRequestPanelImpl(project, window);
84 Disposer.register(parent, panel);
90 public List<DiffTool> getDiffTools() {
91 List<DiffTool> result = new ArrayList<DiffTool>();
92 Collections.addAll(result, DiffTool.EP_NAME.getExtensions());
93 result.add(SimpleDiffTool.INSTANCE);
94 result.add(UnifiedDiffTool.INSTANCE);
95 result.add(BinaryDiffTool.INSTANCE);
96 result.add(DirDiffTool.INSTANCE);
102 public List<MergeTool> getMergeTools() {
103 List<MergeTool> result = new ArrayList<MergeTool>();
104 Collections.addAll(result, MergeTool.EP_NAME.getExtensions());
105 result.add(TextMergeTool.INSTANCE);
106 result.add(BinaryMergeTool.INSTANCE);
111 public void showMerge(@Nullable Project project, @NotNull MergeRequest request) {
112 if (ExternalMergeTool.isDefault()) {
113 ExternalMergeTool.show(project, request);
117 showMergeBuiltin(project, request);
121 public void showMergeBuiltin(@Nullable Project project, @NotNull MergeRequest request) {
122 new MergeWindow(project, request).show();