Search in sources :

Example 1 with EmptyContent

use of com.intellij.diff.contents.EmptyContent in project intellij-community by JetBrains.

the class SvnDiffViewer method getProperties.

@NotNull
private static Map<String, PropertyValue> getProperties(@NotNull DiffContent content) {
    if (content instanceof EmptyContent)
        return Collections.emptyMap();
    List<PropertyData> properties = ((SvnPropertiesDiffRequest.PropertyContent) content).getProperties();
    Map<String, PropertyValue> map = new HashMap<>();
    for (PropertyData data : properties) {
        if (map.containsKey(data.getName()))
            LOG.warn("Duplicated property: " + data.getName());
        map.put(data.getName(), data.getValue());
    }
    return map;
}
Also used : PropertyData(org.jetbrains.idea.svn.properties.PropertyData) HashMap(com.intellij.util.containers.HashMap) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) EmptyContent(com.intellij.diff.contents.EmptyContent) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with EmptyContent

use of com.intellij.diff.contents.EmptyContent in project intellij-community by JetBrains.

the class OnesideDiffViewer method canShowRequest.

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;
}
Also used : ContentDiffRequest(com.intellij.diff.requests.ContentDiffRequest) DiffContent(com.intellij.diff.contents.DiffContent) EmptyContent(com.intellij.diff.contents.EmptyContent)

Example 3 with EmptyContent

use of com.intellij.diff.contents.EmptyContent in project intellij-community by JetBrains.

the class DiffUtil method createTitle.

@Nullable
private static JComponent createTitle(@NotNull String title, @NotNull DiffContent content, boolean equalCharsets, boolean equalSeparators, @Nullable Editor editor) {
    if (content instanceof EmptyContent)
        return null;
    DocumentContent documentContent = (DocumentContent) content;
    Charset charset = equalCharsets ? null : documentContent.getCharset();
    Boolean bom = equalCharsets ? null : documentContent.hasBom();
    LineSeparator separator = equalSeparators ? null : documentContent.getLineSeparator();
    boolean isReadOnly = editor == null || editor.isViewer() || !canMakeWritable(editor.getDocument());
    return createTitle(title, separator, charset, bom, isReadOnly);
}
Also used : DocumentContent(com.intellij.diff.contents.DocumentContent) Charset(java.nio.charset.Charset) LineSeparator(com.intellij.util.LineSeparator) EmptyContent(com.intellij.diff.contents.EmptyContent)

Aggregations

EmptyContent (com.intellij.diff.contents.EmptyContent)3 DiffContent (com.intellij.diff.contents.DiffContent)1 DocumentContent (com.intellij.diff.contents.DocumentContent)1 ContentDiffRequest (com.intellij.diff.requests.ContentDiffRequest)1 LineSeparator (com.intellij.util.LineSeparator)1 HashMap (com.intellij.util.containers.HashMap)1 Charset (java.nio.charset.Charset)1 NotNull (org.jetbrains.annotations.NotNull)1 PropertyData (org.jetbrains.idea.svn.properties.PropertyData)1 PropertyValue (org.jetbrains.idea.svn.properties.PropertyValue)1