From 0dd8844cd5ee582d2c304eeb0275c8cf74cab2bf Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Sun, 22 Mar 2015 18:02:18 +0300 Subject: [PATCH] [vcs-log] more correctly use prepositions in commit details (specifically: at -> on for dates and add at before time) IDEA-135940 --- .../vcs/log/ui/frame/DetailsPanel.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java index 93f6bf0f6583..38ca2a23ab5f 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/frame/DetailsPanel.java @@ -65,7 +65,10 @@ import javax.swing.text.Position; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.parser.ParserDelegator; import java.awt.*; -import java.io.*; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -324,14 +327,15 @@ class DetailsPanel extends JPanel implements ListSelectionListener { } if (myBranches.isEmpty()) return "Not in any branch"; if (myExpanded) { - int rowCount = (int) Math.ceil((double)myBranches.size() / BRANCHES_TABLE_COLUMN_COUNT); + int rowCount = (int)Math.ceil((double)myBranches.size() / BRANCHES_TABLE_COLUMN_COUNT); HtmlTableBuilder builder = new HtmlTableBuilder(); for (int i = 0; i < rowCount; i++) { builder.startRow(); if (i == 0) { builder.append("In " + myBranches.size() + " branches, hide: "); - } else { + } + else { builder.append(""); } @@ -339,9 +343,11 @@ class DetailsPanel extends JPanel implements ListSelectionListener { int index = rowCount * j + i; if (index >= myBranches.size()) { builder.append(""); - } else if (index != myBranches.size() - 1) { + } + else if (index != myBranches.size() - 1) { builder.append(myBranches.get(index) + "," + StringUtil.repeat(" ", 20), LEFT_ALIGN); - } else { + } + else { builder.append(myBranches.get(index), LEFT_ALIGN); } } @@ -401,23 +407,31 @@ class DetailsPanel extends JPanel implements ListSelectionListener { } private static String getAuthorText(VcsFullCommitDetails commit) { - String authorText = commit.getAuthor().getName() + " at " + DateFormatUtil.formatDateTime(commit.getAuthorTime()); + long authorTime = commit.getAuthorTime(); + long commitTime = commit.getCommitTime(); + + String authorText = commit.getAuthor().getName() + formatDateTime(authorTime); if (!commit.getAuthor().equals(commit.getCommitter())) { - String commitTime; - if (commit.getAuthorTime() != commit.getCommitTime()) { - commitTime = " at " + DateFormatUtil.formatDateTime(commit.getCommitTime()); + String commitTimeText; + if (authorTime != commitTime) { + commitTimeText = formatDateTime(commitTime); } else { - commitTime = ""; + commitTimeText = ""; } - authorText += " (committed by " + commit.getCommitter().getName() + commitTime + ")"; + authorText += " (committed by " + commit.getCommitter().getName() + commitTimeText + ")"; } - else if (commit.getAuthorTime() != commit.getCommitTime()) { - authorText += " (committed at " + DateFormatUtil.formatDateTime(commit.getCommitTime()) + ")"; + else if (authorTime != commitTime) { + authorText += " (committed " + formatDateTime(commitTime) + ")"; } return authorText; } + @NotNull + private static String formatDateTime(long time) { + return " on " + DateFormatUtil.formatDate(time) + " at " + DateFormatUtil.formatTime(time); + } + @Override public String getSelectedText() { Document doc = getDocument();