[vcs-log] fix empty text in commit details

Paint empty text directly on DetailsPanel, since MyMainContentPanel has zero height when nothing is selected. Adjust empty text in changes browser to match details.
This commit is contained in:
Julia Beliaeva
2018-06-27 00:21:50 +03:00
parent 65fe7783ab
commit a1303886c7
2 changed files with 21 additions and 20 deletions
@@ -76,6 +76,7 @@ import static com.intellij.vcs.log.ui.frame.CommitPresentationUtil.buildPresenta
public class DetailsPanel extends JPanel implements EditorColorsListener, Disposable {
private static final int MAX_ROWS = 50;
private static final int MIN_SIZE = 20;
private static final String EMPTY_TEXT = "Select commits to view details";
@NotNull private final VcsLogData myLogData;
@@ -98,7 +99,7 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
myScrollPane = new JBScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
myMainContentPanel = new MyMainContentPanel();
myEmptyText = new StatusText(myMainContentPanel) {
myEmptyText = new StatusText(this) {
@Override
protected boolean isStatusVisible() {
return StringUtil.isNotEmpty(getText());
@@ -132,10 +133,20 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
}
}, this);
myEmptyText.setText("Commit details");
myEmptyText.setText(EMPTY_TEXT);
Disposer.register(parent, this);
}
@Override
protected void paintChildren(Graphics g) {
if (StringUtil.isNotEmpty(myEmptyText.getText())) {
myEmptyText.paint(this, g);
}
else {
super.paintChildren(g);
}
}
@Override
public void globalSchemeChange(EditorColorsScheme scheme) {
update();
@@ -168,7 +179,7 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
}
private void rebuildCommitPanels(int[] selection) {
myEmptyText.setText("");
myEmptyText.setText(selection.length == 0 ? EMPTY_TEXT : "");
int selectionLength = selection.length;
@@ -210,9 +221,9 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
Set<String> fullHashes =
ContainerUtil.newHashSet(ContainerUtil.filter(unResolvedHashes, h -> h.length() == HashImpl.FULL_HASH_LENGTH));
for (String fullHash : fullHashes) {
for (String fullHash: fullHashes) {
Hash hash = HashImpl.build(fullHash);
for (VirtualFile root : myLogData.getRoots()) {
for (VirtualFile root: myLogData.getRoots()) {
CommitId id = new CommitId(hash, root);
if (myLogData.getStorage().containsCommit(id)) {
resolvedHashes.putValue(fullHash, id);
@@ -224,7 +235,7 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
if (!unResolvedHashes.isEmpty()) {
myLogData.getStorage().iterateCommits(commitId -> {
for (String hashString : unResolvedHashes) {
for (String hashString: unResolvedHashes) {
if (StringUtil.startsWithIgnoreCase(commitId.getHash().asString(), hashString)) {
resolvedHashes.putValue(hashString, commitId);
}
@@ -309,7 +320,7 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
List<Integer> currentSelection = mySelection;
ApplicationManager.getApplication().executeOnPooledThread(() -> {
List<Collection<VcsRef>> result = ContainerUtil.newArrayList();
for (Integer row : currentSelection) {
for (Integer row: currentSelection) {
result.add(myGraphTable.getModel().getRefsAtRow(row));
}
ApplicationManager.getApplication().invokeLater(() -> {
@@ -326,7 +337,7 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
@Override
protected void onEmptySelection() {
cancelResolve();
setEmpty("No commits selected");
setEmpty(EMPTY_TEXT);
}
@NotNull
@@ -358,7 +369,7 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
}
}
private class MyMainContentPanel extends ScrollablePanel {
private static class MyMainContentPanel extends ScrollablePanel {
@Override
public Insets getInsets() {
// to fight ViewBorder
@@ -369,15 +380,5 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
public Color getBackground() {
return CommitPanel.getCommitDetailsBackground();
}
@Override
protected void paintChildren(Graphics g) {
if (StringUtil.isNotEmpty(myEmptyText.getText())) {
myEmptyText.paint(this, g);
}
else {
super.paintChildren(g);
}
}
}
}
@@ -50,7 +50,7 @@ import static com.intellij.vcs.log.impl.MainVcsLogUiProperties.SHOW_CHANGES_FROM
* Change browser for commits in the Log. For merge commits, can display changes to commits parents in separate groups.
*/
class VcsLogChangesBrowser extends ChangesBrowserBase implements Disposable {
@NotNull private static final String EMPTY_SELECTION_TEXT = "Select commit to view details";
@NotNull private static final String EMPTY_SELECTION_TEXT = "Select commits to view changes";
@NotNull private final Project myProject;
@NotNull private final MainVcsLogUiProperties myUiProperties;
@NotNull private final Function<CommitId, VcsShortCommitDetails> myDataGetter;