diff --git a/plugins/git4idea/src/git4idea/push/GitManualPushToBranch.java b/plugins/git4idea/src/git4idea/push/GitManualPushToBranch.java index 94c34a73f4a9..66665daa7174 100644 --- a/plugins/git4idea/src/git4idea/push/GitManualPushToBranch.java +++ b/plugins/git4idea/src/git4idea/push/GitManualPushToBranch.java @@ -140,7 +140,7 @@ class GitManualPushToBranch extends JPanel { } @NotNull - private static Collection getRemotesWithCommonNames(@NotNull Collection repositories) { + public static Collection getRemotesWithCommonNames(@NotNull Collection repositories) { if (repositories.isEmpty()) { return Collections.emptyList(); } diff --git a/plugins/git4idea/src/git4idea/push/GitPushDialog.java b/plugins/git4idea/src/git4idea/push/GitPushDialog.java index 301ef503987b..03f26a58b440 100644 --- a/plugins/git4idea/src/git4idea/push/GitPushDialog.java +++ b/plugins/git4idea/src/git4idea/push/GitPushDialog.java @@ -61,6 +61,8 @@ public class GitPushDialog extends DialogWrapper { private final Object COMMITS_LOADING_LOCK = new Object(); private final GitManualPushToBranch myRefspecPanel; private final AtomicReference myDestBranchInfoOnRefresh = new AtomicReference(); + + private final boolean myPushPossible; public GitPushDialog(@NotNull Project project) { super(project); @@ -84,10 +86,20 @@ public class GitPushDialog extends DialogWrapper { myListPanel = new GitPushLog(myProject, myRepositories, new RepositoryCheckboxListener()); myRefspecPanel = new GitManualPushToBranch(myRepositories, new RefreshButtonListener()); - + + if (GitManualPushToBranch.getRemotesWithCommonNames(myRepositories).isEmpty()) { + myRefspecPanel.setVisible(false); + setErrorText("Can't push, because no remotes are defined"); + setOKActionEnabled(false); + myPushPossible = false; + } else { + myPushPossible = true; + } + init(); setOKButtonText("Push"); setTitle("Git Push"); + } @Override @@ -105,7 +117,12 @@ public class GitPushDialog extends DialogWrapper { private JComponent createCommitListPanel() { myLoadingPanel.add(myListPanel, BorderLayout.CENTER); - loadCommitsInBackground(); + if (myPushPossible) { + loadCommitsInBackground(); + } else { + myLoadingPanel.startLoading(); + myLoadingPanel.stopLoading(); + } JPanel commitListPanel = new JPanel(new BorderLayout()); commitListPanel.add(myLoadingPanel, BorderLayout.CENTER); diff --git a/plugins/git4idea/src/git4idea/push/GitPushLog.java b/plugins/git4idea/src/git4idea/push/GitPushLog.java index 35be8eab1f66..997440bb2ca0 100644 --- a/plugins/git4idea/src/git4idea/push/GitPushLog.java +++ b/plugins/git4idea/src/git4idea/push/GitPushLog.java @@ -19,8 +19,6 @@ import com.intellij.openapi.actionSystem.CommonShortcuts; import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.actionSystem.DataSink; import com.intellij.openapi.actionSystem.TypeSafeDataProvider; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.colors.EditorFontType; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.vcs.VcsDataKeys; @@ -276,18 +274,41 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { private static class MyTreeCellRenderer extends CheckboxTree.CheckboxTreeCellRenderer { private int myDateMaxWidth; + private int myHashMaxWidth; + private static final int INSET = UIUtil.DEFAULT_HGAP; void recalculateWidth(@NotNull Collection commits) { for (GitCommit commit : commits) { - int len = getDateString(commit).length(); - if (len > myDateMaxWidth) { - myDateMaxWidth = len; + int dateLen = calcWidth(getDateString(commit)); + if (dateLen > myDateMaxWidth) { + myDateMaxWidth = dateLen; + } + int hashLen = calcWidth(getHashString(commit)); + if (hashLen > myHashMaxWidth) { + myHashMaxWidth = hashLen; } } } + @NotNull + private static String getHashString(@NotNull GitCommit commit) { + return commit.getShortHash().toString(); + } + + int calcWidth(String s) { + SimpleTextAttributes attributes = new SimpleTextAttributes(getCommitTextAttributesStyle(), getTextRenderer().getForeground()); + Font initialFont = getTextRenderer().getFont(); + Font font = initialFont.deriveFont(attributes.getFontStyle(), attributes.isSmaller() ? UIUtil.getFontSize(UIUtil.FontSize.SMALL) : initialFont.getSize()); + FontMetrics metrics = getTextRenderer().getFontMetrics(font); + return metrics.stringWidth(s); + } + + private static int getCommitTextAttributesStyle() { + return SimpleTextAttributes.STYLE_SMALLER; + } + private static String getDateString(GitCommit commit) { - return DateFormatUtil.formatPrettyDateTime(commit.getAuthorTime()); + return DateFormatUtil.formatPrettyDateTime(commit.getAuthorTime()) + " "; } @Override @@ -302,16 +323,19 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { } ColoredTreeCellRenderer renderer = getTextRenderer(); - Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN); // using probable monospace font to emulate table - renderer.setFont(font); - - SimpleTextAttributes smallGrey = new SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, UIUtil.getInactiveTextColor()); if (userObject instanceof GitCommit) { GitCommit commit = (GitCommit)userObject; - SimpleTextAttributes small = new SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, renderer.getForeground()); - renderer.append(commit.getShortHash().toString(), smallGrey); - renderer.append(String.format(" %" + myDateMaxWidth + "s ", getDateString(commit)), smallGrey); - renderer.append(commit.getSubject(), small); + SimpleTextAttributes grey = new SimpleTextAttributes(getCommitTextAttributesStyle(), UIUtil.getInactiveTextColor()); + + String hash = getHashString(commit); + renderer.append(hash, grey); + renderer.appendAlign(myHashMaxWidth + INSET); + + String date = getDateString(commit); + renderer.append(date, grey); + renderer.appendAlign(myDateMaxWidth + myHashMaxWidth + INSET * 2); + + renderer.append(commit.getSubject(), new SimpleTextAttributes(getCommitTextAttributesStyle(), getTextRenderer().getForeground())); } else if (userObject instanceof GitRepository) { String repositoryPath = calcRootPath((GitRepository)userObject); @@ -345,7 +369,7 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { break; } renderer.append(text, attrs); - renderer.append(additionalText, smallGrey); + renderer.append(additionalText, new SimpleTextAttributes(SimpleTextAttributes.STYLE_SMALLER, UIUtil.getInactiveTextColor())); } else if (userObject instanceof FakeCommit) { int spaces = 6 + 15 + 3 + 30; diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java index 092efb15b5b9..c9e2636c0e0d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java @@ -58,6 +58,7 @@ public class HgPullDialog extends DialogWrapper { }; sourceTxt.getDocument().addDocumentListener(documentListener); setTitle("Pull"); + setOKButtonText("Pull"); init(); } @@ -106,4 +107,9 @@ public class HgPullDialog extends DialogWrapper { setOKActionEnabled(StringUtils.isNotBlank(sourceTxt.getText())); } + @Override + protected String getDimensionServiceKey() { + return HgPullDialog.class.getName(); + } + } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomElementDescriptorHolder.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomElementDescriptorHolder.java index 9a72ca519824..5f4cf19f3724 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomElementDescriptorHolder.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomElementDescriptorHolder.java @@ -99,7 +99,7 @@ public class MavenDomElementDescriptorHolder { public Result compute() { return Result.create(doCreateDescriptor(kind), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT); } - }); + }, false); myDescriptorsMap.put(kind, result); } return result.getValue();