getRepositories() {
try {
REPO_LOCK.readLock().lock();
- return myRepositories.values();
+ return sortRepositories(myRepositories.values());
}
finally {
REPO_LOCK.readLock().unlock();
diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java
index 2e6309a2ed9b..c31352bbd3a2 100644
--- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java
+++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java
@@ -39,7 +39,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.event.HyperlinkEvent;
-import java.util.Collection;
+import java.util.List;
/**
*
@@ -65,12 +65,9 @@ class GitBranchPopup {
}
/**
- *
- * @param project
* @param currentRepository Current repository, which means the repository of the currently open or selected file.
* In the case of synchronized branch operations current repository matter much less, but sometimes is used,
* for example, it is preselected in the repositories combobox in the compare branches dialog.
- * @return
*/
static GitBranchPopup getInstance(@NotNull Project project, @NotNull GitRepository currentRepository) {
return new GitBranchPopup(project, currentRepository);
@@ -157,7 +154,7 @@ class GitBranchPopup {
}
private void fillWithCommonRepositoryActions(DefaultActionGroup popupGroup, GitRepositoryManager repositoryManager) {
- Collection repositories = repositoryManager.getRepositories();
+ List repositories = repositoryManager.getRepositories();
String currentBranch = myMultiRootBranchConfig.getCurrentBranch();
assert currentBranch != null : "Current branch can't be null if branches have not diverged";
popupGroup.add(new GitBranchPopupActions.CurrentBranchAction(currentBranch, " in all roots"));
diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java
index 42be940eaf37..8f8bcb176f4f 100644
--- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java
+++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java
@@ -33,7 +33,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -56,7 +55,7 @@ class GitBranchPopupActions {
DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
popupGroup.addAction(new CurrentBranchAction(GitBranchUiUtil.getDisplayableBranchText(myRepository), "in root " + GitUIUtil.getShortRepositoryName(myRepository)));
- popupGroup.addAction(new NewBranchAction(myProject, Collections.singleton(myRepository), myRepository));
+ popupGroup.addAction(new NewBranchAction(myProject, Collections.singletonList(myRepository), myRepository));
popupGroup.addAction(new CheckoutRevisionActions(myProject, myRepository));
if (toInsert != null) {
@@ -68,7 +67,7 @@ class GitBranchPopupActions {
Collections.sort(localBranches);
for (GitBranch localBranch : localBranches) {
if (!localBranch.equals(myRepository.getCurrentBranch())) { // don't show current branch in the list
- popupGroup.add(new LocalBranchActions(myProject, Collections.singleton(myRepository), localBranch.getName(), myRepository));
+ popupGroup.add(new LocalBranchActions(myProject, Collections.singletonList(myRepository), localBranch.getName(), myRepository));
}
}
@@ -76,7 +75,7 @@ class GitBranchPopupActions {
List remoteBranches = new ArrayList(myRepository.getBranches().getRemoteBranches());
Collections.sort(remoteBranches);
for (GitBranch remoteBranch : remoteBranches) {
- popupGroup.add(new RemoteBranchActions(myProject, Collections.singleton(myRepository), remoteBranch.getName(), myRepository));
+ popupGroup.add(new RemoteBranchActions(myProject, Collections.singletonList(myRepository), remoteBranch.getName(), myRepository));
}
return popupGroup;
@@ -101,10 +100,10 @@ class GitBranchPopupActions {
static class NewBranchAction extends DumbAwareAction {
private final Project myProject;
- private final Collection myRepositories;
+ private final List myRepositories;
@NotNull private final GitRepository mySelectedRepository;
- NewBranchAction(@NotNull Project project, @NotNull Collection repositories, @NotNull GitRepository selectedRepository) {
+ NewBranchAction(@NotNull Project project, @NotNull List repositories, @NotNull GitRepository selectedRepository) {
super("New Branch", "Create and checkout new branch", IconLoader.getIcon("/general/add.png"));
myProject = project;
myRepositories = repositories;
@@ -175,11 +174,11 @@ class GitBranchPopupActions {
static class LocalBranchActions extends ActionGroup {
private final Project myProject;
- private final Collection myRepositories;
+ private final List myRepositories;
private String myBranchName;
@NotNull private final GitRepository mySelectedRepository;
- LocalBranchActions(@NotNull Project project, @NotNull Collection repositories, @NotNull String branchName,
+ LocalBranchActions(@NotNull Project project, @NotNull List repositories, @NotNull String branchName,
@NotNull GitRepository selectedRepository) {
super("", true);
myProject = project;
@@ -202,11 +201,11 @@ class GitBranchPopupActions {
private static class CheckoutAction extends DumbAwareAction {
private final Project myProject;
- private final Collection myRepositories;
+ private final List myRepositories;
private final String myBranchName;
@NotNull private final GitRepository mySelectedRepository;
- CheckoutAction(@NotNull Project project, @NotNull Collection repositories, @NotNull String branchName,
+ CheckoutAction(@NotNull Project project, @NotNull List repositories, @NotNull String branchName,
@NotNull GitRepository selectedRepository) {
super("Checkout");
myProject = project;
@@ -224,11 +223,11 @@ class GitBranchPopupActions {
private static class CheckoutAsNewBranch extends DumbAwareAction {
private final Project myProject;
- private final Collection myRepositories;
+ private final List myRepositories;
private final String myBranchName;
@NotNull private final GitRepository mySelectedRepository;
- CheckoutAsNewBranch(@NotNull Project project, @NotNull Collection repositories, @NotNull String branchName,
+ CheckoutAsNewBranch(@NotNull Project project, @NotNull List repositories, @NotNull String branchName,
@NotNull GitRepository selectedRepository) {
super("Checkout as new branch");
myProject = project;
@@ -254,11 +253,11 @@ class GitBranchPopupActions {
*/
private static class DeleteAction extends DumbAwareAction {
private final Project myProject;
- private final Collection myRepositories;
+ private final List myRepositories;
private final String myBranchName;
private final GitRepository mySelectedRepository;
- DeleteAction(Project project, Collection repositories, String branchName, GitRepository selectedRepository) {
+ DeleteAction(Project project, List repositories, String branchName, GitRepository selectedRepository) {
super("Delete");
myProject = project;
myRepositories = repositories;
@@ -279,11 +278,11 @@ class GitBranchPopupActions {
static class RemoteBranchActions extends ActionGroup {
private final Project myProject;
- private final Collection myRepositories;
+ private final List myRepositories;
private String myBranchName;
@NotNull private final GitRepository mySelectedRepository;
- RemoteBranchActions(@NotNull Project project, @NotNull Collection repositories, @NotNull String branchName,
+ RemoteBranchActions(@NotNull Project project, @NotNull List repositories, @NotNull String branchName,
@NotNull GitRepository selectedRepository) {
super("", true);
myProject = project;
@@ -304,11 +303,11 @@ class GitBranchPopupActions {
private static class CheckoutRemoteBranchAction extends DumbAwareAction {
private final Project myProject;
- private final Collection myRepositories;
+ private final List myRepositories;
private final String myRemoteBranchName;
@NotNull private final GitRepository mySelectedRepository;
- public CheckoutRemoteBranchAction(@NotNull Project project, @NotNull Collection repositories,
+ public CheckoutRemoteBranchAction(@NotNull Project project, @NotNull List repositories,
@NotNull String remoteBranchName, @NotNull GitRepository selectedRepository) {
super("Checkout as new local branch");
myProject = project;
@@ -339,12 +338,12 @@ class GitBranchPopupActions {
private static class CompareAction extends DumbAwareAction {
private final Project myProject;
- private final Collection myRepositories;
+ private final List myRepositories;
private final String myBranchName;
private final GitRepository mySelectedRepository;
public CompareAction(@NotNull Project project,
- @NotNull Collection repositories,
+ @NotNull List repositories,
@NotNull String branchName,
GitRepository selectedRepository) {
super("Compare");
diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitMultiRootBranchConfig.java b/plugins/git4idea/src/git4idea/ui/branch/GitMultiRootBranchConfig.java
index 4e45aed7a5b4..c45b886bd1f2 100644
--- a/plugins/git4idea/src/git4idea/ui/branch/GitMultiRootBranchConfig.java
+++ b/plugins/git4idea/src/git4idea/ui/branch/GitMultiRootBranchConfig.java
@@ -24,15 +24,16 @@ import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
/**
* @author Kirill Likhodedov
*/
public class GitMultiRootBranchConfig {
- private final Collection myRepositories;
+ private final List myRepositories;
- public GitMultiRootBranchConfig(@NotNull Collection repositories) {
+ public GitMultiRootBranchConfig(@NotNull List repositories) {
myRepositories = repositories;
}
diff --git a/plugins/git4idea/tests/git4idea/branch/GitBranchOperationsTest.java b/plugins/git4idea/tests/git4idea/branch/GitBranchOperationsTest.java
index d10e26f0f000..2209fdc834d9 100644
--- a/plugins/git4idea/tests/git4idea/branch/GitBranchOperationsTest.java
+++ b/plugins/git4idea/tests/git4idea/branch/GitBranchOperationsTest.java
@@ -36,7 +36,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
-import java.util.Collection;
+import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import static git4idea.test.GitExec.*;
@@ -51,7 +51,7 @@ public class GitBranchOperationsTest extends AbstractVcsTestCase {
private static final String NEW_BRANCH = "new_branch";
private static final String MASTER = "master";
- private Collection myRepositories;
+ private List myRepositories;
private GitRepository myUltimate;
private GitRepository myCommunity;
private GitRepository myContrib;
diff --git a/plugins/gradle/resources/icons/gradle.png b/plugins/gradle/resources/icons/gradle.png
index b76b4ba5b8a8..af8da119630b 100644
Binary files a/plugins/gradle/resources/icons/gradle.png and b/plugins/gradle/resources/icons/gradle.png differ
diff --git a/plugins/gradle/src/META-INF/plugin.xml b/plugins/gradle/src/META-INF/plugin.xml
index 1487b063dbc5..36d93560b32e 100644
--- a/plugins/gradle/src/META-INF/plugin.xml
+++ b/plugins/gradle/src/META-INF/plugin.xml
@@ -36,7 +36,12 @@
-
+
+
+
+
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/bootstrap/GradleBootstrap.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/bootstrap/GradleBootstrap.java
index 762c18a47488..254145d26a65 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/bootstrap/GradleBootstrap.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/bootstrap/GradleBootstrap.java
@@ -15,7 +15,7 @@ import org.jetbrains.plugins.gradle.ui.GradleIcons;
import org.jetbrains.plugins.gradle.util.GradleBundle;
/**
- * // TODO den add doc
+ * Encapsulates initialisation routine of the gradle integration.
*
* @author Denis Zhdanov
* @since 11/3/11 4:01 PM
@@ -42,10 +42,6 @@ public class GradleBootstrap extends AbstractProjectComponent {
}
private void initToolWindow() {
- // TODO den don't show tool window if no gradle project is associated with the current project.
- if (!Boolean.getBoolean("gradle.show.tool.window")) {
- return;
- }
final ToolWindowManagerEx manager = ToolWindowManagerEx.getInstanceEx(myProject);
ToolWindow toolWindow = manager.registerToolWindow(GRADLE_TOOL_WINDOW_ID, false, ToolWindowAnchor.RIGHT);
toolWindow.setIcon(GradleIcons.GRADLE_ICON);
diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java
index bbafe4cd653a..a6b51a7b8204 100644
--- a/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java
+++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/diff/GradleDiffUtil.java
@@ -25,11 +25,10 @@ public class GradleDiffUtil {
* Example: particular module has been added at the gradle side. We want to mark that module, its content root(s), dependencies etc
* as gradle-local changes.
*
- * @param entity target gradle-local entity
- * @return collection of gradle-local changes for the given entity and its interested sub-entities
+ * @param entity target gradle-local entity
+ * @param currentChanges holder for the changes built during the current call
*/
- public static Set buildLocalChanges(@NotNull GradleEntity entity) {
- final Set result = new HashSet();
+ public static void buildLocalChanges(@NotNull GradleEntity entity, @NotNull final Set currentChanges) {
entity.invite(new GradleEntityVisitor() {
@Override
public void visit(@NotNull GradleProject project) {
@@ -38,7 +37,7 @@ public class GradleDiffUtil {
@Override
public void visit(@NotNull GradleModule module) {
- result.add(new GradleModulePresenceChange(module, null));
+ currentChanges.add(new GradleModulePresenceChange(module, null));
for (GradleDependency dependency : module.getDependencies()) {
dependency.invite(this);
}
@@ -61,79 +60,52 @@ public class GradleDiffUtil {
@Override
public void visit(@NotNull GradleLibraryDependency dependency) {
- result.add(new GradleLibraryDependencyPresenceChange(dependency, null));
+ currentChanges.add(new GradleLibraryDependencyPresenceChange(dependency, null));
}
});
- return result;
}
/**
* Analogues to {@link #buildLocalChanges} but targets intellij entity.
*
- * @param module target intellij-local module that doesn't present at the gradle side
- * @return collection of intellij-local changes for the given entity and its interested sub-entities
+ * @param module target intellij-local module that doesn't present at the gradle side
+ * @param currentChanges holder for the changes built during the current call
*/
- public static Set extends GradleProjectStructureChange> buildLocalChanges(@NotNull Module module) {
- Set result = new HashSet();
- result.add(new GradleModulePresenceChange(null, module));
+ public static void buildLocalChanges(@NotNull Module module, @NotNull Set currentChanges) {
+ currentChanges.add(new GradleModulePresenceChange(null, module));
// TODO den process module sub-entities here (content roots and dependencies).
- return result;
}
/**
* Analogues to {@link #buildLocalChanges} but targets intellij entity.
*
* @param libraryDependency target intellij-local library dependency that doesn't present at the gradle side
- * @return collection of intellij-local changes for the given entity and its interested sub-entities
+ * @param currentChanges holder for the changes built during the current call
*/
- public static Set extends GradleProjectStructureChange> buildLocalChanges(@NotNull LibraryOrderEntry libraryDependency) {
- return Collections.singleton(new GradleLibraryDependencyPresenceChange(null, libraryDependency));
+ public static void buildLocalChanges(@NotNull LibraryOrderEntry libraryDependency,
+ @NotNull Set currentChanges)
+ {
+ currentChanges.add(new GradleLibraryDependencyPresenceChange(null, libraryDependency));
}
/**
* Performs argument type-based dispatch and delegates to one of strongly typed 'buildLocalChanges()' methods.
*
- * @param entity target intellij-local entity that doesn't present at the gradle side
- * @return collection of intellij-local changes for the given entity and its interested sub-entities
+ * @param entity target intellij-local entity that doesn't present at the gradle side
+ * @param currentChanges holder for the changes built during the current call
*/
- @NotNull
- public static Set extends GradleProjectStructureChange> buildLocalChanges(@NotNull Object entity) {
+ public static void buildLocalChanges(@NotNull Object entity,
+ @NotNull Set currentChanges)
+ {
if (entity instanceof GradleEntity) {
- return buildLocalChanges((GradleEntity)entity);
+ buildLocalChanges((GradleEntity)entity, currentChanges);
}
else if (entity instanceof Module) {
- return buildLocalChanges((Module)entity);
+ buildLocalChanges((Module)entity, currentChanges);
}
else if (entity instanceof LibraryOrderEntry) {
- return buildLocalChanges((LibraryOrderEntry)entity);
+ buildLocalChanges((LibraryOrderEntry)entity, currentChanges);
}
- else {
- return Collections.emptySet();
- }
- }
-
- /**
- * Concatenates given entities into the single collection and returns it.
- *
- * The main idea behind this method is that most of the time we don't expect changes at all, hence, corresponding changes calculators
- * can use {@link Collections#emptySet()}. However, if some sub-nodes do have changes, attempt
- * to {@link Collection#addAll(Collection) merge} them within the empty set mentioned above would cause an exception.
- *
- * That's why we provide dedicated method for creating new collection as a merge result.
- *
- * @param collections collections to merge
- * @return merge result
- */
- @NotNull
- public static Set concatenate(Collection extends GradleProjectStructureChange>... collections) {
- Set result = null;
- for (Collection extends GradleProjectStructureChange> collection : collections) {
- if (result == null) {
- result = new HashSet();
- }
- result.addAll(collection);
- }
- return result == null ? Collections.emptySet() : result;
}
/**
@@ -146,39 +118,34 @@ public class GradleDiffUtil {
* @param gradleEntities entities available at the gradle side
* @param intellijEntities entities available at the intellij side
* @param knownChanges collection that contains known changes about the entities
+ * @param currentChanges holder for the changes discovered during the current call
* @param target intellij entity type
* @param target gradle entity type
- * @return set of changes between the given entity collections
*/
- @NotNull
- public static Set calculate(
+ public static void calculate(
@NotNull GradleStructureChangesCalculator calculator,
@NotNull Iterable extends G> gradleEntities,
@NotNull Iterable extends I> intellijEntities,
- @NotNull Set knownChanges)
+ @NotNull Set knownChanges,
+ @NotNull Set currentChanges)
{
- Set result = Collections.emptySet();
Map