use of com.intellij.util.LineSeparator 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);
}
use of com.intellij.util.LineSeparator in project intellij-community by JetBrains.
the class DiffContentFactoryImpl method createImpl.
@NotNull
private static DocumentContent createImpl(@Nullable Project project, @NotNull String text, @Nullable FileType fileType, @Nullable String fileName, @Nullable VirtualFile highlightFile, @Nullable Charset charset, @Nullable Boolean bom, boolean respectLineSeparators, boolean readOnly) {
if (FileTypes.UNKNOWN.equals(fileType))
fileType = PlainTextFileType.INSTANCE;
// TODO: detect invalid (different across the file) separators ?
LineSeparator separator = respectLineSeparators ? StringUtil.detectSeparators(text) : null;
String correctedContent = StringUtil.convertLineSeparators(text);
Document document = createDocument(project, correctedContent, fileType, fileName, readOnly);
DocumentContent content = new DocumentContentImpl(project, document, fileType, highlightFile, separator, charset, bom);
if (fileName != null)
content.putUserData(DiffUserDataKeysEx.FILE_NAME, fileName);
return content;
}
use of com.intellij.util.LineSeparator in project intellij-community by JetBrains.
the class DiffPanelImpl method createComponentForTitle.
static JComponent createComponentForTitle(@Nullable String title, @Nullable final LineSeparator sep1, @Nullable final LineSeparator sep2, boolean left) {
if (sep1 != null && sep2 != null && !sep1.equals(sep2)) {
LineSeparator separator = left ? sep1 : sep2;
JPanel bottomPanel = new JPanel(new BorderLayout());
JLabel sepLabel = new JLabel(separator.name());
sepLabel.setForeground(separator.equals(LineSeparator.CRLF) ? JBColor.RED : PlatformColors.BLUE);
bottomPanel.add(sepLabel, left ? BorderLayout.EAST : BorderLayout.WEST);
JPanel panel = new JPanel(new BorderLayout());
panel.add(new JLabel(title == null ? "" : title));
panel.add(bottomPanel, BorderLayout.SOUTH);
return panel;
} else {
return new JBLabel(title == null ? "" : title);
}
}
Aggregations