Search in sources :

Example 1 with CompositeDiffPanel

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

the class MultiLevelDiffTool method createPanel.

private CompositeDiffPanel createPanel(final DiffRequest request, final Window window, @NotNull Disposable parentDisposable) {
    final CompositeDiffPanel panel = new CompositeDiffPanel(request.getProject(), this, window, parentDisposable);
    request.getGenericData().put(PlatformDataKeys.COMPOSITE_DIFF_VIEWER.getName(), panel);
    final List<Pair<String, DiffRequest>> layers = request.getOtherLayers();
    if (layers != null) {
        for (Pair<String, DiffRequest> layer : layers) {
            layer.getSecond().getGenericData().put(PlatformDataKeys.COMPOSITE_DIFF_VIEWER.getName(), panel);
        }
    }
    Disposer.register(parentDisposable, new Disposable() {

        @Override
        public void dispose() {
            final String name = PlatformDataKeys.COMPOSITE_DIFF_VIEWER.getName();
            request.getGenericData().remove(name);
            if (layers != null) {
                for (Pair<String, DiffRequest> layer : layers) {
                    layer.getSecond().getGenericData().remove(name);
                }
            }
        }
    });
    return panel;
}
Also used : Disposable(com.intellij.openapi.Disposable) CompositeDiffPanel(com.intellij.openapi.diff.impl.CompositeDiffPanel) Pair(com.intellij.openapi.util.Pair)

Example 2 with CompositeDiffPanel

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

the class MultiLevelDiffTool method show.

@Override
public void show(DiffRequest request) {
    Collection hints = request.getHints();
    boolean shouldOpenDialog = FrameDiffTool.shouldOpenDialog(hints);
    if (shouldOpenDialog) {
        final DialogBuilder builder = new DialogBuilder(request.getProject());
        final CompositeDiffPanel diffPanel = createPanel(request, builder.getWindow(), builder);
        if (diffPanel == null) {
            Disposer.dispose(builder);
            return;
        }
        final Runnable onOkRunnable = request.getOnOkRunnable();
        if (onOkRunnable != null) {
            builder.setOkOperation(() -> {
                builder.getDialogWrapper().close(0);
                onOkRunnable.run();
            });
        } else {
            builder.removeAllActions();
        }
        builder.setCenterPanel(diffPanel.getComponent());
        builder.setPreferredFocusComponent(diffPanel.getPreferredFocusedComponent());
        builder.setTitle(request.getWindowTitle());
        builder.setDimensionServiceKey(request.getGroupKey());
        new AnAction() {

            public void actionPerformed(final AnActionEvent e) {
                builder.getDialogWrapper().close(0);
            }
        }.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
        diffPanel.setDiffRequest(request);
        FrameDiffTool.showDiffDialog(builder, hints);
    } else {
        final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey());
        final CompositeDiffPanel diffPanel = createPanel(request, frameWrapper.getFrame(), frameWrapper);
        if (diffPanel == null) {
            Disposer.dispose(frameWrapper);
            return;
        }
        frameWrapper.setTitle(request.getWindowTitle());
        diffPanel.setDiffRequest(request);
        DiffUtil.initDiffFrame(request.getProject(), frameWrapper, diffPanel, diffPanel.getComponent());
        new AnAction() {

            public void actionPerformed(final AnActionEvent e) {
                Disposer.dispose(frameWrapper);
            }
        }.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
        frameWrapper.show();
    }
}
Also used : CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) FrameWrapper(com.intellij.openapi.ui.FrameWrapper) CompositeDiffPanel(com.intellij.openapi.diff.impl.CompositeDiffPanel) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

CompositeDiffPanel (com.intellij.openapi.diff.impl.CompositeDiffPanel)2 Disposable (com.intellij.openapi.Disposable)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)1 DialogBuilder (com.intellij.openapi.ui.DialogBuilder)1 FrameWrapper (com.intellij.openapi.ui.FrameWrapper)1 Pair (com.intellij.openapi.util.Pair)1