Example usage for com.intellij.openapi.diff DiffRequest getHints

List of usage examples for com.intellij.openapi.diff DiffRequest getHints

Introduction

In this page you can find the example usage for com.intellij.openapi.diff DiffRequest getHints.

Prototype

public Collection getHints() 

Source Link

Document

Work in progress.

Usage

From source file:com.urswolfer.intellij.plugin.gerrit.ui.diff.CustomizableFrameDiffTool.java

License:Apache License

public void show(DiffRequest request) {
    Collection hints = request.getHints();
    boolean shouldOpenDialog = shouldOpenDialog(hints);
    if (shouldOpenDialog) {
        final DialogBuilder builder = new DialogBuilder(request.getProject());
        DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, builder.getWindow(), builder, true);
        if (diffPanel == null) {
            Disposer.dispose(builder);// ww w .  ja  va 2s.  com
            return;
        }
        if (hints.contains(DiffTool.HINT_DIFF_IS_APPROXIMATE)) {
            diffPanel.setPatchAppliedApproximately(); // todo read only and not variants
        }
        final Runnable onOkRunnable = request.getOnOkRunnable();
        if (onOkRunnable != null) {
            builder.setOkOperation(new Runnable() {
                @Override
                public void run() {
                    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());
        showDiffDialog(builder, hints);
    } else {
        final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey());
        DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, frameWrapper.getFrame(), frameWrapper,
                true);
        if (diffPanel == null) {
            Disposer.dispose(frameWrapper);
            return;
        }
        if (hints.contains(DiffTool.HINT_DIFF_IS_APPROXIMATE)) {
            diffPanel.setPatchAppliedApproximately();
        }
        frameWrapper.setTitle(request.getWindowTitle());
        DiffUtil.initDiffFrame(diffPanel.getProject(), frameWrapper, diffPanel, diffPanel.getComponent());

        new AnAction() {
            public void actionPerformed(final AnActionEvent e) {
                frameWrapper.getFrame().dispose();
            }
        }.registerCustomShortcutSet(
                new CustomShortcutSet(
                        KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")),
                diffPanel.getComponent());

        frameWrapper.show();
    }
}

From source file:com.urswolfer.intellij.plugin.gerrit.ui.diff.CustomizableFrameDiffTool.java

License:Apache License

private boolean checkNoDifferenceAndNotify(DiffPanel diffPanel, DiffRequest data, final Window window,
        final boolean showMessage) {
    if (!diffPanel.hasDifferences() && !data.getHints().contains(HINT_ALLOW_NO_DIFFERENCES)) {
        DiffManagerImpl manager = (DiffManagerImpl) DiffManager.getInstance();
        if (!Comparing.equal(manager.getComparisonPolicy(), ComparisonPolicy.DEFAULT)) {
            ComparisonPolicy oldPolicy = manager.getComparisonPolicy();
            manager.setComparisonPolicy(ComparisonPolicy.DEFAULT);
            Disposable parentDisposable = Disposer.newDisposable();
            DiffPanel maybeDiffPanel = createDiffPanel(data, window, parentDisposable, this);
            manager.setComparisonPolicy(oldPolicy);

            boolean hasDiffs = maybeDiffPanel.hasDifferences();
            Disposer.dispose(parentDisposable);

            if (hasDiffs)
                return false;
        }//from w ww  .  j a  va 2s.  com

        if (!showMessage) {
            return true;
        }
        return !askForceOpenDiff(data);
    }
    return false;
}