IDEA-149737 Fixed NPE when rendering committed change list with null commit date

This commit is contained in:
Konstantin Kolosovsky
2016-02-26 09:53:39 +03:00
parent 5f91561ec1
commit 0cacfe0176
4 changed files with 10 additions and 5 deletions
@@ -159,7 +159,7 @@ public class DateFormatUtil {
}
@NotNull
public static String formatPrettyDateTime(Date date) {
public static String formatPrettyDateTime(@NotNull Date date) {
return formatPrettyDateTime(date.getTime());
}
@@ -52,7 +52,7 @@ public class CommittedChangeListRenderer extends ColoredTreeCellRenderer {
myFontSize = -1;
}
public static String getDateOfChangeList(final Date date) {
public static String getDateOfChangeList(@NotNull Date date) {
return DateFormatUtil.formatPrettyDateTime(date);
}
@@ -90,7 +90,6 @@ public class CommittedChangeListRenderer extends ColoredTreeCellRenderer {
final Container parent = tree.getParent();
final int rowX = getRowX(myTree, 2);
int availableWidth = parent == null ? 100 : parent.getWidth() - rowX;
String date = ", " + getDateOfChangeList(changeList.getCommitDate());
final FontMetrics fontMetrics = tree.getFontMetrics(tree.getFont());
final FontMetrics boldMetrics = tree.getFontMetrics(tree.getFont().deriveFont(Font.BOLD));
final FontMetrics italicMetrics = tree.getFontMetrics(tree.getFont().deriveFont(Font.ITALIC));
@@ -174,7 +173,11 @@ public class CommittedChangeListRenderer extends ColoredTreeCellRenderer {
}
append(changeList.getCommitterName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
append(date, SimpleTextAttributes.REGULAR_ATTRIBUTES);
if (changeList.getCommitDate() != null) {
String date = ", " + getDateOfChangeList(changeList.getCommitDate());
append(date, SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
private static String trimLastWord(final String description) {
@@ -34,7 +34,7 @@ public class LogEntry {
public static final LogEntry EMPTY = new LogEntry.Builder().setRevision(-1).setHasChildren(false).build();
private final long myRevision;
private final Date myDate;
@Nullable private final Date myDate;
private final String myMessage;
private final String myAuthor;
@NotNull private final Map<String, LogEntryPath> myChangedPaths;
@@ -89,6 +89,7 @@ public class LogEntry {
return myAuthor;
}
@Nullable
public Date getDate() {
return myDate;
}
@@ -170,6 +170,7 @@ public class SvnChangeList implements CommittedChangeList, VcsRevisionNumberAwar
return myAuthor;
}
@Nullable
public Date getCommitDate() {
return myDate;
}