From 254a5c19c1f033d44fd338b51ee776461683b41d Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 29 Nov 2011 17:59:44 +0300 Subject: [PATCH 1/4] IDEA-74806 Remember HgPullDialog size --- plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPullDialog.java | 6 ++++++ 1 file changed, 6 insertions(+) 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(); + } + } From 6dcc04af15f9c3026ef879f7e89a02a6d4f4367c Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 29 Nov 2011 18:31:59 +0300 Subject: [PATCH 2/4] IDEA-77358 If there are no remotes, don't show panel, don't load commits, disable push button, show error --- .../git4idea/push/GitManualPushToBranch.java | 2 +- .../src/git4idea/push/GitPushDialog.java | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) 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); From 434c3e84d4b2ecd7940464f50e8406e06de4cb9c Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Tue, 29 Nov 2011 19:02:25 +0300 Subject: [PATCH 3/4] GitPushLog: don't use monospace font. Align commits by pre-calculating their width according to fontmetrics. --- .../src/git4idea/push/GitPushLog.java | 54 +++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) 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; From 369b6d98ad605295871a17677ebc39b4833143f5 Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Wed, 30 Nov 2011 11:42:45 +0100 Subject: [PATCH 4/4] Maven: invalidate dom element descriptors on psi changes (tests fixed) --- .../idea/maven/dom/MavenDomElementDescriptorHolder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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();