Example usage for com.intellij.openapi.diff DiffRequestFactory getInstance

List of usage examples for com.intellij.openapi.diff DiffRequestFactory getInstance

Introduction

In this page you can find the example usage for com.intellij.openapi.diff DiffRequestFactory getInstance.

Prototype

public static DiffRequestFactory getInstance() 

Source Link

Usage

From source file:com.microsoft.alm.plugin.idea.tfvc.core.tfs.conflicts.DialogContentMerger.java

License:Open Source License

public boolean mergeContent(final ContentTriplet contentTriplet, final Project project,
        final VirtualFile localFile, final VcsRevisionNumber serverVersion) {
    ArgumentHelper.checkIfFileWriteable(new File(localFile.getPath()));

    final MergeDialogCustomizer c = new MergeDialogCustomizer();
    final MergeRequest request = DiffRequestFactory.getInstance().createMergeRequest(
            StreamUtil.convertSeparators(contentTriplet.localContent),
            StreamUtil.convertSeparators(contentTriplet.serverContent),
            StreamUtil.convertSeparators(contentTriplet.baseContent), localFile, project,
            ActionButtonPresentation.APPLY, ActionButtonPresentation.CANCEL_WITH_PROMPT);

    request.setWindowTitle(c.getMergeWindowTitle(localFile));
    request.setVersionTitles(new String[] { c.getLeftPanelTitle(localFile), c.getCenterPanelTitle(localFile),
            c.getRightPanelTitle(localFile, serverVersion) });

    // TODO (Jetbrains) call canShow() first
    DiffManager.getInstance().getDiffTool().show(request);
    if (request.getResult() == DialogWrapper.OK_EXIT_CODE) {
        return true;
    } else {/*from  w w  w .  java 2s .c  o m*/
        request.restoreOriginalContent();
        // TODO (Jetbrains) maybe MergeVersion.MergeDocumentVersion.restoreOriginalContent() should save document itself?
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
            public void run() {
                final Document document = FileDocumentManager.getInstance().getDocument(localFile);
                if (document != null) {
                    FileDocumentManager.getInstance().saveDocument(document);
                }
            }
        });
        return false;
    }
}

From source file:org.jetbrains.tfsIntegration.core.tfs.conflicts.DialogContentMerger.java

License:Apache License

public boolean mergeContent(Conflict conflict, ContentTriplet contentTriplet, Project project,
        final VirtualFile localFile, String localPath, VcsRevisionNumber serverVersion) {
    TFSVcs.assertTrue(localFile.isWritable(), localFile.getPresentableUrl() + " must be writable");

    MergeDialogCustomizer c = new MergeDialogCustomizer();
    MergeRequest request = DiffRequestFactory.getInstance().createMergeRequest(
            StreamUtil.convertSeparators(contentTriplet.localContent),
            StreamUtil.convertSeparators(contentTriplet.serverContent),
            StreamUtil.convertSeparators(contentTriplet.baseContent), localFile, project,
            ActionButtonPresentation.APPLY, ActionButtonPresentation.CANCEL_WITH_PROMPT);

    request.setWindowTitle(c.getMergeWindowTitle(localFile));
    request.setVersionTitles(new String[] { c.getLeftPanelTitle(localFile), c.getCenterPanelTitle(localFile),
            c.getRightPanelTitle(localFile, serverVersion) });

    // TODO call canShow() first
    DiffManager.getInstance().getDiffTool().show(request);
    if (request.getResult() == DialogWrapper.OK_EXIT_CODE) {
        return true;
    } else {//from   w ww .ja va2s .  c  om
        request.restoreOriginalContent();
        // TODO maybe MergeVersion.MergeDocumentVersion.restoreOriginalContent() should save document itself?
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
            public void run() {
                final Document document = FileDocumentManager.getInstance().getDocument(localFile);
                if (document != null) {
                    FileDocumentManager.getInstance().saveDocument(document);
                }
            }
        });
        return false;
    }
}