Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Wagenknecht2012-11-02 14:19:22 +0000
committerMatthias Sohn2012-11-02 23:27:34 +0000
commitba68aa691289343b2af9acd1fa8c658a49c58d92 (patch)
tree2c4593d33c3683d74caf332e1c3fa642024b1775 /org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceMapping.java
parentdb01bb996ce1c38b262402323dc3fd286daf49d4 (diff)
downloadegit-ba68aa691289343b2af9acd1fa8c658a49c58d92.tar.gz
egit-ba68aa691289343b2af9acd1fa8c658a49c58d92.tar.xz
egit-ba68aa691289343b2af9acd1fa8c658a49c58d92.zip
Propagate project text label decoration up to working set
This introduces a different type for resource mappings so that the configured project text decoration is used for working sets instead of the default container/folder decoration. It also collects repository name and branch info to allow those decorations for working sets. Bug: 369969 Change-Id: I4aaea78104b5ab74f819e72c07126b34425b00d3 Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceMapping.java')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceMapping.java52
1 files changed, 50 insertions, 2 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceMapping.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceMapping.java
index 479b4a5c88..d8d54449af 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceMapping.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceMapping.java
@@ -11,6 +11,8 @@ package org.eclipse.egit.ui.internal.decorators;
import static org.eclipse.jgit.lib.Repository.stripWorkDir;
+import java.io.IOException;
+import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.resources.IProject;
@@ -26,12 +28,19 @@ import org.eclipse.ui.IWorkingSet;
*/
public class DecoratableResourceMapping extends DecoratableResource {
+ private static final String MULTIPLE = "*"; //$NON-NLS-1$
+
/**
* Denotes the type of decoratable resource, used by the decoration helper.
*/
public static final int RESOURCE_MAPPING = 0x10;
/**
+ * Denotes the type of decoratable resource, used by the decoration helper.
+ */
+ public static final int WORKING_SET = 0x9999;
+
+ /**
* Stores the actual mapping we are currently decorating.
*/
private ResourceMapping mapping;
@@ -40,8 +49,9 @@ public class DecoratableResourceMapping extends DecoratableResource {
* Creates a decoratable resource mapping (used for e.g. working sets)
*
* @param mapping the resource mapping to decorate
+ * @throws IOException
*/
- public DecoratableResourceMapping(ResourceMapping mapping) {
+ public DecoratableResourceMapping(ResourceMapping mapping) throws IOException {
super(null); // no resource ...
this.mapping = mapping;
@@ -50,6 +60,9 @@ public class DecoratableResourceMapping extends DecoratableResource {
if(projects == null || projects.length == 0)
return;
+ // collect repositories to allow decoration of mappings (bug 369969)
+ Set<Repository> repositories = new HashSet<Repository>(projects.length);
+
// we could use DecoratableResourceAdapter for each project, but that would be too much overhead,
// as we need only very little information at all...
for(IProject prj : projects) {
@@ -64,7 +77,8 @@ public class DecoratableResourceMapping extends DecoratableResource {
// at least one contained resource is tracked for sure here.
tracked = true;
- String repoRelative = makeRepoRelative(repoMapping.getRepository(), prj) + "/"; //$NON-NLS-1$
+ Repository repository = repoMapping.getRepository();
+ String repoRelative = makeRepoRelative(repository, prj) + "/"; //$NON-NLS-1$
Set<String> modified = diffData.getModified();
Set<String> conflicting = diffData.getConflicting();
@@ -75,10 +89,44 @@ public class DecoratableResourceMapping extends DecoratableResource {
if(containsPrefix(conflicting, repoRelative))
conflicts = true;
+
+ // collect repository
+ repositories.add(repository);
+ }
+
+ // collect repository info for decoration (bug 369969)
+ if(repositories.size() == 1) {
+ // single repo, single branch --> [repo branch]
+ Repository repository = repositories.iterator().next();
+ repositoryName = DecoratableResourceHelper
+ .getRepositoryName(repository);
+ branch = DecoratableResourceHelper.getShortBranch(repository);
+ branchStatus = DecoratableResourceHelper
+ .getBranchStatus(repository);
+ } else if(repositories.size() > 1) {
+ // collect branch names but skip branch status (doesn't make sense)
+ Set<String> branches = new HashSet<String>(2);
+ for (Repository repository : repositories) {
+ branches.add(DecoratableResourceHelper
+ .getShortBranch(repository));
+ if (branches.size() > 1)
+ break;
+ }
+
+ // multiple repos, one branch --> [* branch]
+ if (branches.size() == 1) {
+ repositoryName = MULTIPLE;
+ branch = branches.iterator().next();
+ }
+
+ // we set nothing in the following case:
+ // multiple repos, multiple branches
}
}
public int getType() {
+ if (mapping.getModelObject() instanceof IWorkingSet)
+ return WORKING_SET;
return RESOURCE_MAPPING;
}

Back to the top