From cb62b0643e6cc46fa57756f45d31b35258596fe1 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Thu, 26 Jul 2012 15:20:28 +0400 Subject: [PATCH 01/16] Add a border to the quick doc font size control --- .../codeInsight/documentation/DocumentationComponent.java | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java index ad93627383ed..60d6788c32e3 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java @@ -346,6 +346,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr myFontSizeSlider.setSnapToTicks(true); UIUtil.setSliderIsFilled(myFontSizeSlider, true); result.add(myFontSizeSlider); + result.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor(), 1)); myFontSizeSlider.addChangeListener(new ChangeListener() { @Override From 5b33689581ca7b5338ceb94c949e23491d48b348 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Thu, 26 Jul 2012 15:20:46 +0400 Subject: [PATCH 02/16] IDEA-66333 Quick documentation lookup on mouse hover Ensure that the doc is shown on client request --- .../codeInsight/documentation/DocumentationManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java index 36b50d88b113..356b518169db 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java @@ -182,12 +182,14 @@ public class DocumentationManager extends DockablePopupManager Date: Thu, 26 Jul 2012 15:26:43 +0400 Subject: [PATCH 03/16] Allow to show quick doc info at the previously docked documentation tool window --- .../codeInsight/documentation/DocumentationManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java index 356b518169db..e37f1971b422 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java @@ -214,7 +214,7 @@ public class DocumentationManager extends DockablePopupManager Date: Wed, 25 Jul 2012 19:37:48 +0400 Subject: [PATCH 04/16] FileHistoryPanelImpl: calculate maximum string value of the columns to make them resize properly. --- .../vcs/history/FileHistoryPanelImpl.java | 59 ++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index 68dee6a11e81..a11fed484150 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -139,7 +139,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { } }; - private final DualViewColumnInfo REVISION = + private final VcsColumnInfo REVISION = new VcsColumnInfo(VcsBundle.message("column.name.revision.version")) { protected VcsRevisionNumber getDataOf(VcsFileRevision object) { return object.getRevisionNumber(); @@ -162,7 +162,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { }; - private final DualViewColumnInfo DATE = new VcsColumnInfo(VcsBundle.message("column.name.revision.date")) { + private final VcsColumnInfo DATE = new VcsColumnInfo(VcsBundle.message("column.name.revision.date")) { protected String getDataOf(VcsFileRevision object) { Date date = object.getRevisionDate(); if (date == null) return ""; @@ -216,7 +216,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { private static final TableCellRenderer AUTHOR_RENDERER = new AuthorCellRenderer(); - private final DualViewColumnInfo AUTHOR = new VcsColumnInfo(VcsBundle.message("column.name.revision.list.author")) { + private final VcsColumnInfo AUTHOR = new VcsColumnInfo(VcsBundle.message("column.name.revision.list.author")) { protected String getDataOf(VcsFileRevision object) { VcsFileRevision rev = object; if (object instanceof TreeNodeOnVcsRevision) { @@ -540,20 +540,50 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { refreshRevisionsOrder(); HistoryAsTreeProvider treeHistoryProvider = session.getHistoryAsTreeProvider(); + List revisionList = myHistorySession.getRevisionList(); + updateMaxStringValues(revisionList); if (treeHistoryProvider != null) { myDualView.setRoot(new TreeNodeOnVcsRevision(null, - treeHistoryProvider.createTreeOn(myHistorySession.getRevisionList())), myTargetSelection); + treeHistoryProvider.createTreeOn(revisionList)), myTargetSelection); } else { myDualView.setRoot(new TreeNodeOnVcsRevision(null, - wrapWithTreeElements(myHistorySession.getRevisionList())), myTargetSelection); + wrapWithTreeElements(revisionList)), myTargetSelection); } + updateMaxStringValues(revisionList); myDualView.getFlatView().updateColumnSizes(); myDualView.expandAll(); myDualView.repaint(); } + private void updateMaxStringValues(@NotNull List list) { + int maxAuthorWidth = getStringWidth(AUTHOR.getMaxStringValue()); + int maxRevisionWidth = getStringWidth(REVISION.getMaxStringValue()); + int maxDateWidth = getStringWidth(DATE.getMaxStringValue()); + for (VcsFileRevision revision : list) { + int authorWidth = getStringWidth(revision.getAuthor()); + int revWidth = getStringWidth(REVISION.valueOf(revision)); + int dateWidth = getStringWidth(DATE.getDataOf(revision)); + if (authorWidth > maxAuthorWidth) { + AUTHOR.setMaxStringValue(revision.getAuthor()); + } + if (revWidth > maxRevisionWidth) { + REVISION.setMaxStringValue(REVISION.valueOf(revision)); + } + if (dateWidth > maxDateWidth) { + DATE.setMaxStringValue(DATE.getDataOf(revision)); + } + } + } + + private int getStringWidth(@Nullable String string) { + if (string == null) { + return 0; + } + return myDualView.getFontMetrics(myDualView.getFont()).stringWidth(string); + } + protected void addActionsTo(DefaultActionGroup group) { addToGroup(false, group); } @@ -1417,8 +1447,13 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { } } - abstract static class VcsColumnInfo extends DualViewColumnInfo - implements Comparator { + private abstract static class VcsColumnInfo + extends DualViewColumnInfo + implements Comparator + { + + @Nullable private String myMaxStringValue; + public VcsColumnInfo(String name) { super(name); } @@ -1453,6 +1488,16 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { return true; } + @Nullable + @Override + public String getMaxStringValue() { + return myMaxStringValue; + } + + public void setMaxStringValue(@Nullable String maxStringValue) { + myMaxStringValue = maxStringValue; + } + } private class MyColumnWrapper extends DualViewColumnInfo { From df3eb95c045e16243a7a530ad36d9986d4686153 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 25 Jul 2012 20:30:42 +0400 Subject: [PATCH 05/16] DialogBuilder: better assertion message --- .../src/com/intellij/openapi/ui/DialogBuilder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java index cf8c4948089b..8838ef14b826 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java @@ -68,7 +68,8 @@ public class DialogBuilder implements Disposable { } private MyDialogWrapper showImpl(boolean isModal) { - LOG.assertTrue(myTitle != null && myTitle.trim().length() != 0, String.valueOf(myTitle)); + LOG.assertTrue(myTitle != null && myTitle.trim().length() != 0, + String.format("Dialog title shouldn't be empty or null: [%s]", myTitle)); myDialogWrapper.setTitle(myTitle); myDialogWrapper.init(); myDialogWrapper.setModal(isModal); From 83d6f8d5287191067af838b1752035ac7a584cca Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Wed, 25 Jul 2012 20:34:29 +0400 Subject: [PATCH 06/16] javadoc --- .../src/com/intellij/openapi/ui/DialogBuilder.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java index 8838ef14b826..d6b39552d658 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java @@ -31,6 +31,10 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.util.ArrayList; +/** + * The DialogBuilder is a simpler alternative to {@link DialogWrapper}. + * There is no need to create a subclass (which is needed in the DialogWrapper), which can be nice for simple dialogs. + */ public class DialogBuilder implements Disposable { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.ui.DialogBuilder"); From e507331aec82fa8a6f27f2615f945381b00b2fc9 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 26 Jul 2012 14:55:38 +0400 Subject: [PATCH 07/16] IDEA-79870 Git push dialog: allow to push when some repositories don't have remotes Just don't count repositories without remotes: don't add them to the list, don't query them when looking for common remotes. (cherry picked from commit 90298e61c590b44ea38539b9348132f2b9fc9d90) --- .../src/git4idea/push/GitPushDialog.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/plugins/git4idea/src/git4idea/push/GitPushDialog.java b/plugins/git4idea/src/git4idea/push/GitPushDialog.java index bb460d6c0d70..c4172595676b 100644 --- a/plugins/git4idea/src/git4idea/push/GitPushDialog.java +++ b/plugins/git4idea/src/git4idea/push/GitPushDialog.java @@ -31,14 +31,14 @@ import git4idea.branch.GitBranchUtil; import git4idea.history.browser.GitCommit; import git4idea.repo.GitRemote; import git4idea.repo.GitRepository; +import git4idea.repo.GitRepositoryManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; +import java.util.*; +import java.util.List; import java.util.concurrent.atomic.AtomicReference; /** @@ -50,6 +50,7 @@ public class GitPushDialog extends DialogWrapper { private static final String DEFAULT_REMOTE = "origin"; private Project myProject; + private final GitRepositoryManager myRepositoryManager; private final GitPusher myPusher; private final GitPushLog myListPanel; private GitCommitsByRepoAndBranch myGitCommitsToPush; @@ -66,8 +67,9 @@ public class GitPushDialog extends DialogWrapper { super(project); myProject = project; myPusher = new GitPusher(myProject, new EmptyProgressIndicator()); + myRepositoryManager = GitUtil.getRepositoryManager(myProject); - myRepositories = GitUtil.getRepositoryManager(myProject).getRepositories(); + myRepositories = getRepositoriesWithRemotes(); myLoadingPanel = new JBLoadingPanel(new BorderLayout(), this.getDisposable()); @@ -89,6 +91,17 @@ public class GitPushDialog extends DialogWrapper { setTitle("Git Push"); } + @NotNull + private List getRepositoriesWithRemotes() { + List repositories = new ArrayList(); + for (GitRepository repository : myRepositoryManager.getRepositories()) { + if (!repository.getRemotes().isEmpty()) { + repositories.add(repository); + } + } + return repositories; + } + @Override protected JComponent createCenterPanel() { JPanel optionsPanel = new JPanel(new BorderLayout()); From 5c26f7865b03b7123e637ac9608b59301ff1f40a Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 26 Jul 2012 15:16:34 +0400 Subject: [PATCH 08/16] DialogBuilder.CloseDialogAction: simpler constructor with common defaults. --- .../src/com/intellij/openapi/ui/DialogBuilder.java | 4 ++++ .../src/com/intellij/openapi/ui/DialogWrapper.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java index d6b39552d658..be8213574143 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogBuilder.java @@ -218,6 +218,10 @@ public class DialogBuilder implements Disposable { public static class CloseDialogAction extends DialogActionDescriptor { private final int myExitCode; + public CloseDialogAction() { + this(CommonBundle.getCloseButtonText(), -1, DialogWrapper.CLOSE_EXIT_CODE); + } + public CloseDialogAction(String name, int mnemonicChar, int exitCode) { super(name, mnemonicChar); myExitCode = exitCode; diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index 50162deaf448..993ad9b8a96c 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -74,6 +74,10 @@ public abstract class DialogWrapper { * The default exit code for "Cancel" action. */ public static final int CANCEL_EXIT_CODE = 1; + /** + * The default exit code for "Close" action. Equal to cancel. + */ + public static final int CLOSE_EXIT_CODE = CANCEL_EXIT_CODE; /** * If you use your custom exit codes you have have to start them with * this constant. From c7fb458fc2f3e69e3f0c58ca4b264ea50ea73271 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 26 Jul 2012 15:25:33 +0400 Subject: [PATCH 09/16] GitChangeUtils.showDiff: correct the order of revisions for Changes parsing. --- .../src/git4idea/branch/GitBranchOperationsProcessor.java | 2 +- plugins/git4idea/src/git4idea/changes/GitChangeUtils.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java b/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java index 03aefdeee6a5..c8c354d1738f 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java @@ -405,7 +405,7 @@ public final class GitBranchOperationsProcessor { @NotNull private static Collection loadTotalDiff(@NotNull GitRepository repository, @NotNull String branchName) { try { - return GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), null, branchName, null); + return GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), "HEAD", branchName, null); } catch (VcsException e) { // we treat it as critical and report an error diff --git a/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java b/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java index c0080c347893..ac54cdad14c1 100644 --- a/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java +++ b/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java @@ -419,7 +419,7 @@ public class GitChangeUtils { String range = firstRevision == null ? nextRevision : firstRevision + ".." + nextRevision; String output = getDiffOutput(project, root, range, dirtyPaths); GitRevisionNumber thisRevision = firstRevision == null ? null : loadRevision(project, root, firstRevision); - parseChanges(project, root, thisRevision, loadRevision(project, root, nextRevision), output, changes, Collections.emptySet()); + parseChanges(project, root, loadRevision(project, root, nextRevision), thisRevision, output, changes, Collections.emptySet()); return changes; } From 2d994d83afa0d1ee74981201cb91d3e0fab61375 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 26 Jul 2012 15:31:36 +0400 Subject: [PATCH 10/16] [git] Fix "Show Diff" from file history for directories. IDEA-63725, IDEA-53116 Show the ChangesBrowser window with differences in the folder between revisions. VcsHistoryUtil: extract revision sorting to a separate method to reuse it. --- .../openapi/vcs/history/VcsHistoryUtil.java | 23 +++- .../history/GitDiffFromHistoryHandler.java | 123 +++++++++++++++--- 2 files changed, 125 insertions(+), 21 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java index 0cf2c513dd97..3fba542ae1e6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/VcsHistoryUtil.java @@ -27,6 +27,7 @@ import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.FilePath; @@ -213,9 +214,10 @@ public class VcsHistoryUtil { public void run(@NotNull ProgressIndicator indicator) { VcsFileRevision left = revision1; VcsFileRevision right = revision2; - if (findOlderNewer && compare(revision1, revision2) > 0) { - left = revision2; - right = revision1; + if (findOlderNewer) { + Pair pair = sortRevisions(revision1, revision2); + left = pair.first; + right = pair.second; } try { @@ -244,4 +246,19 @@ public class VcsHistoryUtil { }.queue(); } + /** + * Compares the given revisions and returns a pair of them, where the first one is older, and second is newer. + */ + @NotNull + public static Pair sortRevisions(@NotNull VcsFileRevision revision1, + @NotNull VcsFileRevision revision2) { + VcsFileRevision left = revision1; + VcsFileRevision right = revision2; + if (compare(revision1, revision2) > 0) { + left = revision2; + right = revision1; + } + return Pair.create(left, right); + } + } diff --git a/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java b/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java index 410131c760d8..8f2f0d26661d 100644 --- a/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java +++ b/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java @@ -22,12 +22,16 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.DialogBuilder; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.changes.Change; +import com.intellij.openapi.vcs.changes.ui.ChangesBrowser; import com.intellij.openapi.vcs.history.DiffFromHistoryHandler; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.history.VcsHistoryUtil; @@ -35,9 +39,11 @@ import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.ArrayUtil; +import com.intellij.util.Consumer; import git4idea.GitFileRevision; import git4idea.GitRevisionNumber; import git4idea.GitUtil; +import git4idea.changes.GitChangeUtils; import git4idea.commands.Git; import git4idea.commands.GitCommandResult; import git4idea.repo.GitRepository; @@ -92,34 +98,122 @@ class GitDiffFromHistoryHandler implements DiffFromHistoryHandler { private void doShowDiff(@NotNull FilePath filePath, @NotNull VcsFileRevision revision1, @NotNull VcsFileRevision revision2, boolean autoSort) { - VcsHistoryUtil.showDifferencesInBackground(myProject, filePath, revision1, revision2, autoSort); + if (!filePath.isDirectory()) { + VcsHistoryUtil.showDifferencesInBackground(myProject, filePath, revision1, revision2, autoSort); + } + else { + GitFileRevision left = (GitFileRevision)revision1; + GitFileRevision right = (GitFileRevision)revision2; + if (autoSort) { + Pair pair = VcsHistoryUtil.sortRevisions(revision1, revision2); + left = (GitFileRevision)pair.first; + right = (GitFileRevision)pair.second; + } + showDiffForDirectory(filePath, left, right); + } } - private void showDiffForMergeCommit(@NotNull final AnActionEvent event, @NotNull final FilePath filePath, @NotNull final GitFileRevision rev, - @NotNull final Collection parents) { - final AtomicBoolean fileTouched = new AtomicBoolean(); - new Task.Backgroundable(myProject, "Retrieving revision changes", false) { - @Override public void run(@NotNull ProgressIndicator indicator) { + private void showDiffForDirectory(@NotNull final FilePath path, @NotNull final GitFileRevision revision1, @NotNull final GitFileRevision revision2) { + GitRepository repository = getRepository(path); + calculateDiffInBackground(repository, revision1.getHash(), revision2.getHash(), new Consumer>() { + @Override + public void consume(List changes) { + showDirDiffDialog(path, revision1, revision2, changes); + } + }); + } + + @NotNull + private GitRepository getRepository(@NotNull FilePath path) { + VirtualFile file = path.getVirtualFile(); + LOG.assertTrue(file != null, "VirtualFile can't be null for " + path); // we clicked on a file and asked its history => VF must exist. + GitRepository repository = myRepositoryManager.getRepositoryForFile(file); + LOG.assertTrue(repository != null, "Repository is null for " + file); + return repository; + } + + private void calculateDiffInBackground(@NotNull final GitRepository repository, final String hash1, final String hash2, + final Consumer> successHandler) { + new Task.Backgroundable(myProject, "Comparing revisions...") { + private List myChanges; + @Override + public void run(@NotNull ProgressIndicator indicator) { try { - fileTouched.set(wasFileTouched(rev, filePath)); + myChanges = new ArrayList(GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), hash1, hash2, null)); } catch (VcsException e) { - LOG.info("Error happened while executing git show " + rev + ":" + filePath, e); - VcsBalloonProblemNotifier.showOverVersionControlView(GitDiffFromHistoryHandler.this.myProject, e.getMessage(), MessageType.ERROR); + showError(e, "Error during requesting diff for directory"); } } @Override public void onSuccess() { - if (fileTouched.get()) { + successHandler.consume(myChanges); + } + }.queue(); + } + + private void showDirDiffDialog(@NotNull FilePath path, GitFileRevision revision1, GitFileRevision revision2, @NotNull List diff) { + DialogBuilder dialogBuilder = new DialogBuilder(myProject); + dialogBuilder.setTitle(String.format("%s diff in %s..%s", path.getName(), GitUtil.getShortHash(revision1.getHash()), + GitUtil.getShortHash(revision2.getHash()))); + dialogBuilder.setActionDescriptors(new DialogBuilder.ActionDescriptor[] { new DialogBuilder.CloseDialogAction()}); + final ChangesBrowser changesBrowser = new ChangesBrowser(myProject, null, diff, null, false, true, + null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null); + changesBrowser.setChangesToDisplay(diff); + dialogBuilder.setCenterPanel(changesBrowser); + dialogBuilder.show(); + } + + private void showDiffForMergeCommit(@NotNull final AnActionEvent event, @NotNull final FilePath filePath, + @NotNull final GitFileRevision rev, @NotNull final Collection parents) { + + final Consumer afterTouchCheck = new Consumer() { + @Override + public void consume(Boolean wasTouched) { + if (wasTouched) { String message = filePath.getName() + " did not change in this merge commit"; VcsBalloonProblemNotifier.showOverVersionControlView(GitDiffFromHistoryHandler.this.myProject, message, MessageType.INFO); } showPopup(event, rev, filePath, parents); } + }; + + if (filePath.isDirectory()) { // for directories don't check if the file was modified in the merge commit + afterTouchCheck.consume(false); + } + else { + checkIfFileWasTouchedInBackground(filePath, rev, afterTouchCheck); + } + } + + private void checkIfFileWasTouchedInBackground(@NotNull final FilePath filePath, @NotNull final GitFileRevision rev, + @NotNull final Consumer afterTouchCheck) { + new Task.Backgroundable(myProject, "Loading changes...", false) { + private final AtomicBoolean fileTouched = new AtomicBoolean(); + + @Override public void run(@NotNull ProgressIndicator indicator) { + try { + fileTouched.set(wasFileTouched(rev, filePath)); + } + catch (VcsException e) { + String logMessage = "Error happened while executing git show " + rev + ":" + filePath; + showError(e, logMessage); + } + } + + @Override + public void onSuccess() { + afterTouchCheck.consume(fileTouched.get()); + } }.queue(); } + private void showError(VcsException e, String logMessage) { + LOG.info(logMessage, e); + VcsBalloonProblemNotifier.showOverVersionControlView(this.myProject, e.getMessage(), MessageType.ERROR); + } + private void showPopup(@NotNull AnActionEvent event, @NotNull GitFileRevision rev, @NotNull FilePath filePath, @NotNull Collection parents) { ActionGroup parentActions = createActionGroup(rev, filePath, parents); @@ -175,10 +269,7 @@ class GitDiffFromHistoryHandler implements DiffFromHistoryHandler { } private boolean wasFileTouched(@NotNull GitFileRevision rev, @NotNull FilePath path) throws VcsException { - VirtualFile file = path.getVirtualFile(); - LOG.assertTrue(file != null, "VirtualFile can't be null for " + path); // we clicked on a file and asked its history => VF must exist. - GitRepository repository = myRepositoryManager.getRepositoryForFile(file); - LOG.assertTrue(repository != null, "Repository is null for " + file); + GitRepository repository = getRepository(path); GitCommandResult result = myGit.show(repository, rev + ":" + path); if (result.success()) { return isFilePresentInOutput(repository, path, result.getOutput()); @@ -216,9 +307,5 @@ class GitDiffFromHistoryHandler implements DiffFromHistoryHandler { doShowDiff(myFilePath, makeRevisionFromHash(myFilePath, myParentRevision), myRevision, false); } - @Override - public void update(AnActionEvent e) { - - } } } From b1394d3740013999d1a427307d2be2b47e73d360 Mon Sep 17 00:00:00 2001 From: Andrey Vokin Date: Thu, 26 Jul 2012 15:41:57 +0400 Subject: [PATCH 11/16] Dependency from module 'cucumber' to 'testFramework-java' switched to 'testFramework' --- .../src/com/intellij/testFramework/CodeInsightTestCase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/CodeInsightTestCase.java b/platform/testFramework/src/com/intellij/testFramework/CodeInsightTestCase.java index 2f9710cb817d..b6d3fb87f2cc 100644 --- a/platform/testFramework/src/com/intellij/testFramework/CodeInsightTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/CodeInsightTestCase.java @@ -4,13 +4,14 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.testFramework.fixtures.CodeInsightTestFixture; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import org.jetbrains.annotations.NonNls; /** * User: Andrey.Vokin * Date: 7/23/12 */ -public class CodeInsightTestCase extends UsefulTestCase { +public class CodeInsightTestCase extends LightPlatformCodeInsightFixtureTestCase { @NonNls protected static final String CARET_STR = ""; protected CodeInsightTestFixture myFixture; From a404caa1cdf917c774b53b6e3febb06587b39229 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Thu, 26 Jul 2012 15:09:03 +0400 Subject: [PATCH 12/16] cleanup --- .../tasks-tests/test/com/intellij/tasks/TaskUiTest.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskUiTest.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskUiTest.java index d99e2a51a984..d55cdacd97b0 100644 --- a/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskUiTest.java +++ b/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskUiTest.java @@ -22,7 +22,6 @@ import com.intellij.tasks.actions.SwitchTaskCombo; import com.intellij.tasks.config.TaskSettings; import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.TestActionEvent; -import com.intellij.testFramework.UsefulTestCase; import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase; /** @@ -31,10 +30,6 @@ import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase; */ public class TaskUiTest extends CodeInsightFixtureTestCase { - public TaskUiTest() { - PlatformTestCase.initPlatformPrefix(UsefulTestCase.IDEA_MARKER_CLASS, "PlatformLangXml"); - } - public void testTaskComboVisible() throws Exception { TaskManager manager = TaskManager.getManager(getProject()); @@ -76,4 +71,8 @@ public class TaskUiTest extends CodeInsightFixtureTestCase { return event.getPresentation(); } + @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") + public TaskUiTest() { + PlatformTestCase.initPlatformLangPrefix(); + } } From e21464d34b5497c34d5c441ff0efa7b254393b5c Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Thu, 26 Jul 2012 16:18:45 +0400 Subject: [PATCH 13/16] IDEA-89307 Unable to share a run configuration --- .../execution/impl/ConfigurationSettingsEditorWrapper.java | 1 - .../execution/impl/SingleConfigurationConfigurable.java | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java index a5db03805fb6..5003776aee53 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConfigurationSettingsEditorWrapper.java @@ -62,7 +62,6 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor Date: Thu, 26 Jul 2012 16:04:13 +0400 Subject: [PATCH 14/16] FileHistoryPanelImpl: disable "Get" for directories, since it doesn't work for any VCS anyway. Relates to IDEA-53116 --- .../intellij/openapi/vcs/history/FileHistoryPanelImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index a11fed484150..0d486101cae8 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -946,9 +946,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { @Override public boolean isEnabled() { - if (!super.isEnabled()) return false; - if (!myHistorySession.isContentAvailable(getFirstSelectedRevision())) return false; - return true; + return super.isEnabled() && myHistorySession.isContentAvailable(getFirstSelectedRevision()) && !myFilePath.isDirectory(); } protected void executeAction(AnActionEvent e) { From 4ca0296da7675986d4642718b8b744602211d418 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 26 Jul 2012 16:58:40 +0400 Subject: [PATCH 15/16] [git] "Show Diff with local" from file history for dirs. IDEA-53116 * Call the DiffFromHistoryHandler from the "Show Diff with Local" action. * In Git implementation be aware that a CurrentRevision may be passed. Pass null hash in that case. * GitChangeUtils: fix the order of revisions again; make code more clear; remove the not-used parameter. --- .../vcs/history/FileHistoryPanelImpl.java | 8 ++--- .../branch/GitBranchOperationsProcessor.java | 2 +- .../src/git4idea/changes/GitChangeUtils.java | 21 +++++++++---- .../history/GitDiffFromHistoryHandler.java | 30 +++++++++++++------ 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index 0d486101cae8..ca14240cb1e3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -905,11 +905,9 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { if (selection.size() != 1) return; if (ChangeListManager.getInstance(myVcs.getProject()).isFreezedWithNotification(null)) return; final VcsRevisionNumber currentRevisionNumber = myHistorySession.getCurrentRevisionNumber(); - if (currentRevisionNumber != null) { - VcsHistoryUtil.showDifferencesInBackground(myVcs.getProject(), myFilePath, - getFirstSelectedRevision(), - new CurrentRevision(myFilePath.getVirtualFile(), currentRevisionNumber), - true); + VcsFileRevision selectedRevision = getFirstSelectedRevision(); + if (currentRevisionNumber != null && selectedRevision != null) { + myDiffHandler.showDiff(myFilePath, selectedRevision, new CurrentRevision(myFilePath.getVirtualFile(), currentRevisionNumber)); } } diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java b/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java index c8c354d1738f..0b76583eb7af 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java @@ -405,7 +405,7 @@ public final class GitBranchOperationsProcessor { @NotNull private static Collection loadTotalDiff(@NotNull GitRepository repository, @NotNull String branchName) { try { - return GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), "HEAD", branchName, null); + return GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), "HEAD", branchName); } catch (VcsException e) { // we treat it as critical and report an error diff --git a/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java b/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java index ac54cdad14c1..3347e3b2a6d9 100644 --- a/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java +++ b/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java @@ -413,13 +413,22 @@ public class GitChangeUtils { @NotNull public static Collection getDiff(@NotNull Project project, @NotNull VirtualFile root, - @Nullable String firstRevision, @NotNull String nextRevision, - @Nullable Collection dirtyPaths) throws VcsException { + @NotNull String oldRevision, @Nullable String newRevision) throws VcsException { + String range; + GitRevisionNumber newRev; + if (newRevision == null) { + // it is current revision + range = oldRevision; + newRev = null; + } + else { + range = oldRevision + ".." + newRevision; + newRev = loadRevision(project, root, newRevision); + } + String output = getDiffOutput(project, root, range, null); + Collection changes = new ArrayList(); - String range = firstRevision == null ? nextRevision : firstRevision + ".." + nextRevision; - String output = getDiffOutput(project, root, range, dirtyPaths); - GitRevisionNumber thisRevision = firstRevision == null ? null : loadRevision(project, root, firstRevision); - parseChanges(project, root, loadRevision(project, root, nextRevision), thisRevision, output, changes, Collections.emptySet()); + parseChanges(project, root, newRev, loadRevision(project, root, oldRevision), output, changes, Collections.emptySet()); return changes; } diff --git a/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java b/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java index 8f2f0d26661d..25992ef252d8 100644 --- a/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java +++ b/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java @@ -32,6 +32,7 @@ import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ui.ChangesBrowser; +import com.intellij.openapi.vcs.history.CurrentRevision; import com.intellij.openapi.vcs.history.DiffFromHistoryHandler; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.history.VcsHistoryUtil; @@ -49,6 +50,7 @@ import git4idea.commands.GitCommandResult; import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryManager; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.awt.event.MouseEvent; import java.util.ArrayList; @@ -101,6 +103,10 @@ class GitDiffFromHistoryHandler implements DiffFromHistoryHandler { if (!filePath.isDirectory()) { VcsHistoryUtil.showDifferencesInBackground(myProject, filePath, revision1, revision2, autoSort); } + else if (revision2 instanceof CurrentRevision) { + GitFileRevision left = (GitFileRevision)revision1; + showDiffForDirectory(filePath, left.getHash(), null); + } else { GitFileRevision left = (GitFileRevision)revision1; GitFileRevision right = (GitFileRevision)revision2; @@ -109,16 +115,16 @@ class GitDiffFromHistoryHandler implements DiffFromHistoryHandler { left = (GitFileRevision)pair.first; right = (GitFileRevision)pair.second; } - showDiffForDirectory(filePath, left, right); + showDiffForDirectory(filePath, left.getHash(), right.getHash()); } } - private void showDiffForDirectory(@NotNull final FilePath path, @NotNull final GitFileRevision revision1, @NotNull final GitFileRevision revision2) { + private void showDiffForDirectory(@NotNull final FilePath path, @NotNull final String hash1, @Nullable final String hash2) { GitRepository repository = getRepository(path); - calculateDiffInBackground(repository, revision1.getHash(), revision2.getHash(), new Consumer>() { + calculateDiffInBackground(repository, hash1, hash2, new Consumer>() { @Override public void consume(List changes) { - showDirDiffDialog(path, revision1, revision2, changes); + showDirDiffDialog(path, hash1, hash2, changes); } }); } @@ -132,14 +138,14 @@ class GitDiffFromHistoryHandler implements DiffFromHistoryHandler { return repository; } - private void calculateDiffInBackground(@NotNull final GitRepository repository, final String hash1, final String hash2, + private void calculateDiffInBackground(@NotNull final GitRepository repository, final String hash1, @Nullable final String hash2, final Consumer> successHandler) { new Task.Backgroundable(myProject, "Comparing revisions...") { private List myChanges; @Override public void run(@NotNull ProgressIndicator indicator) { try { - myChanges = new ArrayList(GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), hash1, hash2, null)); + myChanges = new ArrayList(GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), hash1, hash2)); } catch (VcsException e) { showError(e, "Error during requesting diff for directory"); @@ -153,10 +159,16 @@ class GitDiffFromHistoryHandler implements DiffFromHistoryHandler { }.queue(); } - private void showDirDiffDialog(@NotNull FilePath path, GitFileRevision revision1, GitFileRevision revision2, @NotNull List diff) { + private void showDirDiffDialog(@NotNull FilePath path, @NotNull String hash1, @Nullable String hash2, @NotNull List diff) { DialogBuilder dialogBuilder = new DialogBuilder(myProject); - dialogBuilder.setTitle(String.format("%s diff in %s..%s", path.getName(), GitUtil.getShortHash(revision1.getHash()), - GitUtil.getShortHash(revision2.getHash()))); + String title; + if (hash2 != null) { + title = String.format("%s diff in %s..%s", path.getName(), GitUtil.getShortHash(hash1), GitUtil.getShortHash(hash2)); + } + else { + title = String.format("%s diff from %s", path.getName(), GitUtil.getShortHash(hash1)); + } + dialogBuilder.setTitle(title); dialogBuilder.setActionDescriptors(new DialogBuilder.ActionDescriptor[] { new DialogBuilder.CloseDialogAction()}); final ChangesBrowser changesBrowser = new ChangesBrowser(myProject, null, diff, null, false, true, null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null); From 822769a0c70c3e2acc09cdcd0a1ddb0449806bd4 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Thu, 26 Jul 2012 15:20:53 +0200 Subject: [PATCH 16/16] problems with file colors and bg painting --- .../com/intellij/psi/search/scope/NonProjectFilesScope.java | 3 ++- .../src/com/intellij/ui/ColoredTreeCellRenderer.java | 6 ++++-- platform/util/src/com/intellij/ui/ColorUtil.java | 3 ++- platform/util/src/com/intellij/util/ui/UIUtil.java | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/platform/lang-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java b/platform/lang-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java index 4615be75f74f..b0d1c3142d1f 100644 --- a/platform/lang-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java +++ b/platform/lang-api/src/com/intellij/psi/search/scope/NonProjectFilesScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +40,7 @@ public class NonProjectFilesScope extends NamedScope { super(NAME, new AbstractPackageSet("NonProject") { public boolean contains(VirtualFile file, NamedScopesHolder holder) { if (file == null) return true; + if (file.getFileSystem() != LocalFileSystem.getInstance()) return true; if (isInsideProjectContent(holder.getProject(), file)) return false; return !ProjectScope.getProjectScope(holder.getProject()).contains(file); } diff --git a/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java b/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java index b2605435d345..3e3485c79515 100644 --- a/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java +++ b/platform/platform-api/src/com/intellij/ui/ColoredTreeCellRenderer.java @@ -64,9 +64,11 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp if (UIUtil.isFullRowSelectionLAF()) { setBackground(selected ? UIUtil.getTreeSelectionBackground() : null); } - else if (/*UIUtil.isUnderAquaBasedLookAndFeel() && */tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) { + else if (tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) { setPaintFocusBorder(false); - //setBackground(selected ? UIUtil.getTreeSelectionBackground() : null); + if (selected) { + setBackground(hasFocus ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground()); + } } else { if (selected) { diff --git a/platform/util/src/com/intellij/ui/ColorUtil.java b/platform/util/src/com/intellij/ui/ColorUtil.java index e7e787cbea63..959650626e1a 100644 --- a/platform/util/src/com/intellij/ui/ColorUtil.java +++ b/platform/util/src/com/intellij/ui/ColorUtil.java @@ -34,8 +34,9 @@ public class ColorUtil { } public static Color softer(@NotNull Color color) { + if (color.getBlue() > 220 && color.getRed() > 220 && color.getGreen() > 220) return color; final float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); - return Color.getHSBColor(hsb[0], 0.4f *hsb[1], hsb[2]); + return Color.getHSBColor(hsb[0], 0.6f *hsb[1], hsb[2]); } private static int shift(int colorComponent, double d) { diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 631cb227fac3..d271a48e1e76 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -947,7 +947,7 @@ public class UIUtil { } public static boolean isFullRowSelectionLAF() { - return isUnderNimbusLookAndFeel() || isUnderQuaquaLookAndFeel() || isUnderDarcula(); + return isUnderNimbusLookAndFeel() || isUnderQuaquaLookAndFeel(); } public static boolean isUnderNativeMacLookAndFeel() {