當前位置: 首頁>>代碼示例>>Java>>正文


Java DiffContent類代碼示例

本文整理匯總了Java中com.intellij.diff.contents.DiffContent的典型用法代碼示例。如果您正苦於以下問題:Java DiffContent類的具體用法?Java DiffContent怎麽用?Java DiffContent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DiffContent類屬於com.intellij.diff.contents包,在下文中一共展示了DiffContent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showDiffForFiles

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
private void showDiffForFiles(File remoteFile, VirtualFile localFile) {
    if (remoteFile == null || localFile == null) {
        return;
    }

    final DiffContent remoteFileContent = DiffContentFactory.getInstance().create(new String(remoteFile.getContent(), StandardCharsets.UTF_8));

    final DiffContent localFileContent = DiffContentFactory.getInstance().create(project, localFile);

    DiffRequest dr = new SimpleDiffRequest("NetSuite File Cabinet Compare", remoteFileContent, localFileContent, "NetSuite File Cabinet - " + remoteFile.getName(), "Local File - " + localFile.getName());

    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
                @Override
                public void run() {
                    DiffManager.getInstance().showDiff(project, dr);
                }
            });
        }
    }, ModalityState.NON_MODAL);
}
 
開發者ID:Topher84,項目名稱:NetSuite-Tools-For-WebStorm,代碼行數:24,代碼來源:CompareWithFileCabinetTask.java

示例2: createFromFiles

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
@NotNull
@Override
public ContentDiffRequest createFromFiles(@Nullable Project project,
                                          @NotNull VirtualFile leftFile,
                                          @NotNull VirtualFile baseFile,
                                          @NotNull VirtualFile rightFile) {
  DiffContent content1 = myContentFactory.create(project, leftFile);
  DiffContent content2 = myContentFactory.create(project, baseFile);
  DiffContent content3 = myContentFactory.create(project, rightFile);

  String title1 = getContentTitle(leftFile);
  String title2 = getContentTitle(baseFile);
  String title3 = getContentTitle(rightFile);

  return new SimpleDiffRequest(null, content1, content2, content3, title1, title2, title3);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:DiffRequestFactoryImpl.java

示例3: createComponent

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
@NotNull
private JComponent createComponent(@NotNull DiffRequest request) {
  if (request instanceof MessageDiffRequest) {
    // TODO: explain some of ErrorDiffRequest exceptions ?
    String message = ((MessageDiffRequest)request).getMessage();
    return DiffUtil.createMessagePanel(message);
  }
  if (request instanceof ComponentDiffRequest) {
    return ((ComponentDiffRequest)request).getComponent(myContext);
  }
  if (request instanceof ContentDiffRequest) {
    List<DiffContent> contents = ((ContentDiffRequest)request).getContents();
    for (final DiffContent content : contents) {
      if (content instanceof FileContent && FileTypes.UNKNOWN.equals(content.getContentType())) {
        final VirtualFile file = ((FileContent)content).getFile();

        UnknownFileTypeDiffRequest unknownFileTypeRequest = new UnknownFileTypeDiffRequest(file, myRequest.getTitle());
        return unknownFileTypeRequest.getComponent(myContext);
      }
    }
  }

  return DiffUtil.createMessagePanel("Can't show diff");
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:ErrorDiffTool.java

示例4: checkDifferentDocuments

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
public static void checkDifferentDocuments(@NotNull ContentDiffRequest request) {
  // Actually, this should be a valid case. But it has little practical sense and will require explicit checks everywhere.
  // Some listeners will be processed once instead of 2 times, some listeners will cause illegal document modifications.
  List<DiffContent> contents = request.getContents();

  boolean sameDocuments = false;
  for (int i = 0; i < contents.size(); i++) {
    for (int j = i + 1; j < contents.size(); j++) {
      DiffContent content1 = contents.get(i);
      DiffContent content2 = contents.get(j);
      if (!(content1 instanceof DocumentContent)) continue;
      if (!(content2 instanceof DocumentContent)) continue;
      sameDocuments |= ((DocumentContent)content1).getDocument() == ((DocumentContent)content2).getDocument();
    }
  }

  if (sameDocuments) {
    StringBuilder message = new StringBuilder();
    message.append("DiffRequest with same documents detected\n");
    message.append(request.toString()).append("\n");
    for (DiffContent content : contents) {
      message.append(content.toString()).append("\n");
    }
    LOG.warn(new Throwable(message.toString()));
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:TextDiffViewerUtil.java

示例5: canShowRequest

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
public static <T extends EditorHolder> boolean canShowRequest(@NotNull DiffContext context,
                                                              @NotNull DiffRequest request,
                                                              @NotNull EditorHolderFactory<T> factory) {
  if (!(request instanceof ContentDiffRequest)) return false;

  List<DiffContent> contents = ((ContentDiffRequest)request).getContents();
  if (contents.size() != 2) return false;

  DiffContent content1 = contents.get(0);
  DiffContent content2 = contents.get(1);

  if (content1 instanceof EmptyContent) {
    return factory.canShowContent(content2, context) && factory.wantShowContent(content2, context);
  }
  if (content2 instanceof EmptyContent) {
    return factory.canShowContent(content1, context) && factory.wantShowContent(content1, context);
  }
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:OnesideDiffViewer.java

示例6: canShowRequest

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
public static <T extends EditorHolder> boolean canShowRequest(@NotNull DiffContext context,
                                                              @NotNull DiffRequest request,
                                                              @NotNull EditorHolderFactory<T> factory) {
  if (!(request instanceof ContentDiffRequest)) return false;

  List<DiffContent> contents = ((ContentDiffRequest)request).getContents();
  if (contents.size() != 2) return false;

  boolean canShow = true;
  boolean wantShow = false;
  for (DiffContent content : contents) {
    canShow &= factory.canShowContent(content, context);
    wantShow |= factory.wantShowContent(content, context);
  }
  return canShow && wantShow;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:TwosideDiffViewer.java

示例7: canShowRequest

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
public static <T extends EditorHolder> boolean canShowRequest(@NotNull DiffContext context,
                                                              @NotNull DiffRequest request,
                                                              @NotNull EditorHolderFactory<T> factory) {
  if (!(request instanceof ContentDiffRequest)) return false;

  List<DiffContent> contents = ((ContentDiffRequest)request).getContents();
  if (contents.size() != 3) return false;

  boolean canShow = true;
  boolean wantShow = false;
  for (DiffContent content : contents) {
    canShow &= factory.canShowContent(content, context);
    wantShow |= factory.wantShowContent(content, context);
  }
  return canShow && wantShow;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:ThreesideDiffViewer.java

示例8: BinaryMergeRequestImpl

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
public BinaryMergeRequestImpl(@Nullable Project project,
                              @NotNull FileContent file,
                              @NotNull byte[] originalContent,
                              @NotNull List<DiffContent> contents,
                              @NotNull List<byte[]> byteContents,
                              @Nullable String title,
                              @NotNull List<String> contentTitles,
                              @Nullable Consumer<MergeResult> applyCallback) {
  assert byteContents.size() == 3;
  assert contents.size() == 3;
  assert contentTitles.size() == 3;

  myProject = project;
  myFile = file;
  myOriginalContent = originalContent;

  myByteContents = byteContents;
  myContents = contents;
  myTitle = title;
  myTitles = contentTitles;

  myApplyCallback = applyCallback;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:BinaryMergeRequestImpl.java

示例9: createDifference

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
protected ContentDiffRequest createDifference(final FileDifferenceModel m) {
  final Ref<ContentDiffRequest> requestRef = new Ref<ContentDiffRequest>();

  new Task.Modal(myProject, message("message.processing.revisions"), false) {
    public void run(@NotNull final ProgressIndicator i) {
      ApplicationManager.getApplication().runReadAction(new Runnable() {
        @Override
        public void run() {
          RevisionProcessingProgressAdapter p = new RevisionProcessingProgressAdapter(i);
          p.processingLeftRevision();
          DiffContent left = m.getLeftDiffContent(p);

          p.processingRightRevision();
          DiffContent right = m.getRightDiffContent(p);

          requestRef.set(new SimpleDiffRequest(m.getTitle(), left, right, m.getLeftTitle(p), m.getRightTitle(p)));
        }
      });
    }
  }.queue();

  return requestRef.get();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:HistoryDialog.java

示例10: loadRequest

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
@NotNull
private DiffRequest loadRequest() {
  if (myIndex < 0 || myIndex >= myRequests.size()) return NoDiffRequest.INSTANCE;
  DiffHyperlink hyperlink = myRequests.get(myIndex);
  try {
    String title = hyperlink.getDiffTitle();

    Pair<String, DiffContent> content1 = createContentWithTitle("diff.content.expected.title", 
                                                                hyperlink.getLeft(), hyperlink.getFilePath());
    Pair<String, DiffContent> content2 = createContentWithTitle("diff.content.actual.title", 
                                                                hyperlink.getRight(), hyperlink.getActualFilePath());

    return new SimpleDiffRequest(title, content1.second, content2.second, content1.first, content2.first);
  }
  catch (Exception e) {
    return new ErrorDiffRequest(e);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:TestDiffRequestProcessor.java

示例11: createDiffData

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
private DiffRequest createDiffData() {
  Range range = expand(myRange, myLineStatusTracker.getDocument(), myLineStatusTracker.getVcsDocument());

  DiffContent vcsContent = createDiffContent(myLineStatusTracker.getVcsDocument(),
                                             myLineStatusTracker.getVcsTextRange(range),
                                             null);
  DiffContent currentContent = createDiffContent(myLineStatusTracker.getDocument(),
                                                 myLineStatusTracker.getCurrentTextRange(range),
                                                 myLineStatusTracker.getVirtualFile());

  return new SimpleDiffRequest(VcsBundle.message("dialog.title.diff.for.range"),
                               vcsContent, currentContent,
                               VcsBundle.message("diff.content.title.up.to.date"),
                               VcsBundle.message("diff.content.title.current.range")
  );
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:ShowLineStatusRangeDiffAction.java

示例12: showDiff

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
/**
 * Invokes {@link com.intellij.openapi.diff.DiffManager#getDiffTool()} to show difference between the given revisions of the given file.
 * @param project   project under vcs control.
 * @param path  file which revisions are compared.
 * @param revision1 first revision - 'before', to the left.
 * @param revision2 second revision - 'after', to the right.
 * @throws VcsException
 * @throws IOException
 */
public static void showDiff(@NotNull final Project project, @NotNull FilePath path,
                            @NotNull VcsFileRevision revision1, @NotNull VcsFileRevision revision2,
                            @NotNull String title1, @NotNull String title2) throws VcsException, IOException {
  final byte[] content1 = loadRevisionContent(revision1);
  final byte[] content2 = loadRevisionContent(revision2);

  String title = DiffRequestFactoryImpl.getContentTitle(path);

  DiffContent diffContent1 = createContent(project, content1, revision1, path);
  DiffContent diffContent2 = createContent(project, content2, revision2, path);

  final DiffRequest request = new SimpleDiffRequest(title, diffContent1, diffContent2, title1, title2);

  request.putUserData(REVISIONS_KEY, new VcsFileRevision[]{revision1, revision2});

  WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
    public void run() {
      DiffManager.getInstance().showDiff(project, request);
    }
  }, null, project);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:31,代碼來源:VcsHistoryUtil.java

示例13: fromPsiElement

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
@Nullable
private static DiffContent fromPsiElement(@NotNull PsiElement psiElement) {
  if (psiElement instanceof PsiFile) {
    return DiffContentFactory.getInstance().create(psiElement.getProject(), ((PsiFile)psiElement).getVirtualFile());
  }
  else if (psiElement instanceof PsiDirectory) {
    return DiffContentFactory.getInstance().create(psiElement.getProject(), ((PsiDirectory)psiElement).getVirtualFile());
  }
  PsiFile containingFile = psiElement.getContainingFile();
  if (containingFile == null) {
    String text = psiElement.getText();
    if (text == null) return null;
    return DiffContentFactory.getInstance().create(text, psiElement.getLanguage().getAssociatedFileType(), false);
  }
  DocumentContent wholeFileContent = DiffContentFactory.getInstance().createDocument(psiElement.getProject(), containingFile.getVirtualFile());
  if (wholeFileContent == null) return null;
  return new DocumentFragmentContent(psiElement.getProject(), wholeFileContent, psiElement.getTextRange());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:PsiDiffContentFactory.java

示例14: createNotification

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
@Nullable
private JComponent createNotification() {
  if (myPropertyRequest instanceof ErrorDiffRequest) {
    return createNotification(((ErrorDiffRequest)myPropertyRequest).getMessage());
  }

  List<DiffContent> contents = ((SvnPropertiesDiffRequest)myPropertyRequest).getContents();

  Map<String, PropertyValue> before = getProperties(contents.get(0));
  Map<String, PropertyValue> after = getProperties(contents.get(1));

  if (before.isEmpty() && after.isEmpty()) return null;

  if (!before.keySet().equals(after.keySet())) {
    return createNotification("SVN Properties changed");
  }

  for (String key : before.keySet()) {
    if (!Comparing.equal(before.get(key), after.get(key))) return createNotification("SVN Properties changed");
  }

  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:SvnDiffViewer.java

示例15: showResult

import com.intellij.diff.contents.DiffContent; //導入依賴的package包/類
@Override
protected void showResult() {
  if (!success.isNull()) {
    String title = SvnBundle.message("compare.with.branch.diff.title");

    String title1 = remoteTitleBuilder.toString();
    String title2 = myVirtualFile.getPresentableUrl();

    try {
      DiffContent content1 = DiffContentFactory.getInstance().createFromBytes(myProject, myVirtualFile, content.get());
      DiffContent content2 = DiffContentFactory.getInstance().create(myProject, myVirtualFile);

      DiffRequest request = new SimpleDiffRequest(title, content1, content2, title1, title2);

      DiffManager.getInstance().showDiff(myProject, request);
    }
    catch (IOException e) {
      reportGeneralException(e);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:FileWithBranchComparer.java


注:本文中的com.intellij.diff.contents.DiffContent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。