diff: getEditors() - accept nullable values

This commit is contained in:
Aleksey Pivovarov
2015-05-20 21:07:51 +03:00
parent aeb5419d8b
commit a249aa4af9
3 changed files with 8 additions and 17 deletions
@@ -78,12 +78,12 @@ public abstract class TextDiffViewerBase extends ListenerDiffViewerBase {
List<? extends EditorEx> editors = getEditors();
for (EditorEx editor : editors) {
editor.addEditorMouseListener(myEditorPopupListener);
if (editor != null) editor.addEditorMouseListener(myEditorPopupListener);
}
if (editors.size() > 1) {
for (EditorEx editor : editors) {
editor.addPropertyChangeListener(myFontSizeListener);
if (editor != null) editor.addPropertyChangeListener(myFontSizeListener);
}
}
}
@@ -93,12 +93,12 @@ public abstract class TextDiffViewerBase extends ListenerDiffViewerBase {
List<? extends EditorEx> editors = getEditors();
for (EditorEx editor : editors) {
editor.removeEditorMouseListener(myEditorPopupListener);
if (editor != null) editor.removeEditorMouseListener(myEditorPopupListener);
}
if (editors.size() > 1) {
for (EditorEx editor : editors) {
editor.removePropertyChangeListener(myFontSizeListener);
if (editor != null) editor.removePropertyChangeListener(myFontSizeListener);
}
}
}
@@ -183,7 +183,7 @@ public abstract class TextDiffViewerBase extends ListenerDiffViewerBase {
int fontSize = ((Integer)evt.getNewValue()).intValue();
for (EditorEx editor : getEditors()) {
if (evt.getSource() != editor) updateEditor(editor, fontSize);
if (editor != null && evt.getSource() != editor) updateEditor(editor, fontSize);
}
}
@@ -449,7 +449,7 @@ public abstract class TextDiffViewerBase extends ListenerDiffViewerBase {
return ContainerUtil.filter(editors, new Condition<EditorEx>() {
@Override
public boolean value(EditorEx editor) {
return !editor.isViewer();
return editor != null && !editor.isViewer();
}
});
}
@@ -52,7 +52,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Collections;
import java.util.List;
public abstract class TwosideTextDiffViewer extends TextDiffViewerBase {
@@ -218,16 +217,7 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase {
@NotNull
@Override
protected List<? extends EditorEx> getEditors() {
if (getEditor1() != null && getEditor2() != null) {
return ContainerUtil.list(getEditor1(), getEditor2());
}
if (getEditor1() != null) {
return Collections.singletonList(getEditor1());
}
if (getEditor2() != null) {
return Collections.singletonList(getEditor2());
}
return Collections.emptyList();
return ContainerUtil.list(getEditor1(), getEditor2());
}
@NotNull
@@ -72,6 +72,7 @@ public class SvnPropertiesDiffViewer extends TwosideTextDiffViewer {
assert getEditor1() != null && getEditor2() != null;
for (EditorEx editor : getEditors()) {
if (editor == null) continue;
EditorSettings settings = editor.getSettings();
settings.setAdditionalLinesCount(0);