Java Code Examples for com.intellij.diff.contents.DiffContent#getContentType()
The following examples show how to use
com.intellij.diff.contents.DiffContent#getContentType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ErrorDiffTool.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private JComponent createComponent(@Nonnull 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 && UnknownFileType.INSTANCE == 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"); }
Example 2
Source File: CompareClipboardWithSelectionAction.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static FileType getEditorFileType(@Nonnull AnActionEvent e) { DiffContent content = e.getData(DiffDataKeys.CURRENT_CONTENT); if (content != null && content.getContentType() != null) return content.getContentType(); DiffRequest request = e.getData(DiffDataKeys.DIFF_REQUEST); if (request instanceof ContentDiffRequest) { for (DiffContent diffContent : ((ContentDiffRequest)request).getContents()) { FileType type = diffContent.getContentType(); if (type != null && type != UnknownFileType.INSTANCE) return type; } } return null; }
Example 3
Source File: BinaryEditorHolder.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean wantShowContent(@Nonnull DiffContent content, @Nonnull DiffContext context) { if (content instanceof FileContent) { if (content.getContentType() == null) return false; if (content.getContentType().isBinary()) return true; if (content.getContentType() instanceof UIBasedFileType) return true; return false; } return false; }
Example 4
Source File: DirDiffViewer.java From consulo with Apache License 2.0 | 5 votes |
private static boolean canShowContent(@Nonnull DiffContent content) { if (content instanceof EmptyContent) return true; if (content instanceof DirectoryContent) return true; if (content instanceof FileContent && content.getContentType() instanceof ArchiveFileType && ((FileContent)content).getFile().isValid() && ((FileContent)content).getFile().isInLocalFileSystem()) { return true; } return false; }
Example 5
Source File: DirDiffViewer.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private static DiffElement createDiffElement(@Nonnull DiffContent content) { if (content instanceof EmptyContent) { return new DiffElement() { @Override public String getPath() { return ""; } @Nonnull @Override public String getName() { return "Nothing"; } @Override public long getSize() { return -1; } @Override public long getTimeStamp() { return -1; } @Override public boolean isContainer() { return true; } @Override public DiffElement[] getChildren() throws IOException { return EMPTY_ARRAY; } @Nullable @Override public byte[] getContent() throws IOException { return null; } @Override public Object getValue() { return null; } }; } if (content instanceof DirectoryContent) { return new VirtualFileDiffElement(((DirectoryContent)content).getFile()); } if (content instanceof FileContent && content.getContentType() instanceof ArchiveFileType) { return new ArchiveFileDiffElement(((FileContent)content).getFile()); } throw new IllegalArgumentException(content.getClass() + " " + content.getContentType()); }