Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-08-15 08:25:42 -0400
committerThomas Wolf2019-08-15 12:16:19 -0400
commit2d7e27301cc89fe30abc392598a96fac2e8d299a (patch)
tree2c03b41d07dd529790040d8106af2d72a7c590bb /org.eclipse.egit.ui
parent63093b15aeb7417a0a0aed15676da116bd682c35 (diff)
downloadegit-2d7e27301cc89fe30abc392598a96fac2e8d299a.tar.gz
egit-2d7e27301cc89fe30abc392598a96fac2e8d299a.tar.xz
egit-2d7e27301cc89fe30abc392598a96fac2e8d299a.zip
Don't decorate ResourceMappings mapping only unshared resources
If a ResourceMapping has no shared resources, its state will be untracked, which would make EGit show the "?" overlay. Bug: 550082 Change-Id: I2bf6c1b7261907d8d49188317fc4a7768bc0f046 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceGroup.java42
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceMapping.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableWorkingSet.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java6
4 files changed, 59 insertions, 5 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceGroup.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceGroup.java
new file mode 100644
index 000000000..353231190
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceGroup.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (C) 2019, Thomas Wolf <thomas.wolf@paranor.ch>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.decorators;
+
+import org.eclipse.core.resources.mapping.ResourceMapping;
+
+/**
+ * Abstract base class for decoratable {@link ResourceMapping}s.
+ */
+public abstract class DecoratableResourceGroup extends DecoratableResource {
+
+ /** Set to {@code true} if there is at least one shared resource. */
+ protected boolean someShared = false;
+
+ /**
+ * Creates a new {@link DecoratableResourceGroup}.
+ *
+ * @param mapping
+ * to decorate
+ */
+ protected DecoratableResourceGroup(ResourceMapping mapping) {
+ super(null); // No resource
+ }
+
+ /**
+ * Tells whether the ResourceMapping contains shared resources at all.
+ *
+ * @return whether the resource mapping contains any shared resources
+ */
+ public boolean hasSharedResources() {
+ return someShared;
+ }
+
+}
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 4415537be..70282f320 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
@@ -26,7 +26,7 @@ import org.eclipse.jgit.lib.Repository;
/**
* Represents a decoratable resource mapping (i.e. a group of resources).
*/
-public class DecoratableResourceMapping extends DecoratableResource {
+public class DecoratableResourceMapping extends DecoratableResourceGroup {
private static final String MULTIPLE = "*"; //$NON-NLS-1$
@@ -45,7 +45,7 @@ public class DecoratableResourceMapping extends DecoratableResource {
*/
public DecoratableResourceMapping(ResourceMapping mapping)
throws IOException {
- super(null); // no resource ...
+ super(mapping);
Set<Repository> repositories = new HashSet<>();
Set<StagingState> stagingStates = new HashSet<>();
@@ -108,6 +108,10 @@ public class DecoratableResourceMapping extends DecoratableResource {
setStagingState(StagingState.MODIFIED);
}
+ if (repositories.isEmpty()) {
+ return;
+ }
+ someShared = true;
decorateRepositoryInformation(this, repositories);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableWorkingSet.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableWorkingSet.java
index 111a5244d..7d2ab09cb 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableWorkingSet.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableWorkingSet.java
@@ -31,7 +31,7 @@ import org.eclipse.ui.IWorkingSet;
/**
* Represents a decoratable resource mapping (i.e. a group of resources).
*/
-public class DecoratableWorkingSet extends DecoratableResource {
+public class DecoratableWorkingSet extends DecoratableResourceGroup {
/**
* Denotes the type of decoratable resource, used by the decoration helper.
@@ -50,7 +50,7 @@ public class DecoratableWorkingSet extends DecoratableResource {
* @throws IOException
*/
public DecoratableWorkingSet(ResourceMapping mapping) throws IOException {
- super(null); // no resource ...
+ super(mapping);
this.mapping = mapping;
IProject[] projects = mapping.getProjects();
@@ -97,6 +97,10 @@ public class DecoratableWorkingSet extends DecoratableResource {
repositories.add(repository);
}
+ if (repositories.isEmpty()) {
+ return;
+ }
+ someShared = true;
DecoratableResourceMapping.decorateRepositoryInformation(this,
repositories);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java
index 9cf415bf4..16d315e62 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java
@@ -252,7 +252,7 @@ public class GitLightweightDecorator extends GitDecorator
boolean isWorkingSet = mapping.getModelObject() instanceof IWorkingSet;
- IDecoratableResource decoRes;
+ DecoratableResourceGroup decoRes;
try {
if (isWorkingSet) {
decoRes = new DecoratableWorkingSet(mapping);
@@ -264,6 +264,10 @@ public class GitLightweightDecorator extends GitDecorator
NLS.bind(UIText.Decorator_exceptionMessage, element), e));
}
+ if (!decoRes.hasSharedResources()) {
+ return;
+ }
+
/*
* don't render question marks on working sets. !isTracked() can have two reasons:
* 1) nothing is tracked.

Back to the top