Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Bossert2016-02-24 06:31:59 -0500
committerThomas Wolf2016-03-21 12:45:31 -0400
commit3705869f0523ac4b1861116159749b4dbd1b879b (patch)
tree52f9a8bd71d50c70b15afcaf951ab2c1c7d3e358
parent4f37f293a4682edd4fef8f2d5a8c143b8ae74366 (diff)
downloadegit-3705869f0523ac4b1861116159749b4dbd1b879b.tar.gz
egit-3705869f0523ac4b1861116159749b4dbd1b879b.tar.xz
egit-3705869f0523ac4b1861116159749b4dbd1b879b.zip
Cleaning up the DecoratableResourceAdapter
* IDecoratableResource, DecoratableResource etc: added isRepositoryContainer(): returns true if a resource is a repository container, like project, submodule or nested repository working tree root * GitProjectData: renamed hasSubmodules() to hasInnerRepositories() because not just submodules but all "inner" working trees (repositories) are supported Change-Id: Iec23af713554f6370dfd52c1c444cb7f41f465fd Signed-off-by: Andre Bossert <anb0s@anbos.de>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java7
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java11
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResource.java19
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java14
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/IDecoratableResource.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java8
7 files changed, 60 insertions, 14 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java
index 6bdfa6c6f..1c655b2b0 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/internal/indexdiff/GitResourceDeltaVisitor.java
@@ -7,8 +7,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * * Jens Baumgart <jens.baumgart@sap.com> - initial implementation in IndexDifCacheEntry
- * * Dariusz Luksza - extraction to separate class
+ * Jens Baumgart <jens.baumgart@sap.com> - initial implementation in IndexDifCacheEntry
+ * Dariusz Luksza - extraction to separate class
+ * Andre Bossert <anb0s@anbos.de> - Cleaning up the DecoratableResourceAdapter
*******************************************************************************/
package org.eclipse.egit.core.internal.indexdiff;
@@ -86,7 +87,7 @@ public class GitResourceDeltaVisitor implements IResourceDeltaVisitor {
return false;
}
RepositoryMapping mapping = gitData.getRepositoryMapping(resource);
- if (mapping == null || !gitData.hasSubmodules()
+ if (mapping == null || !gitData.hasInnerRepositories()
&& mapping.getRepository() != repository) {
return false;
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
index 3deb986aa..5485f91d6 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java
@@ -8,6 +8,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert <anb0s@anbos.de> - Cleaning up the DecoratableResourceAdapter
*******************************************************************************/
package org.eclipse.egit.core.project;
@@ -484,13 +487,13 @@ public class GitProjectData {
}
/**
- * Determines whether the project this instance belongs to has any
- * submodules.
+ * Determines whether the project this instance belongs to has any inner
+ * repositories like submodules or nested repositories.
*
- * @return {@code true} if the project has submodules; {@code false}
+ * @return {@code true} if the project has inner repositories; {@code false}
* otherwise.
*/
- public boolean hasSubmodules() {
+ public boolean hasInnerRepositories() {
return !protectedResources.isEmpty();
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResource.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResource.java
index f672c088a..38b9d3228 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResource.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResource.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Thomas Wolf <thomas.wolf@paranor.ch> - Factored out ResourceState
+ * Andre Bossert <anb0s@anbos.de> - Cleaning up the DecoratableResourceAdapter
*******************************************************************************/
package org.eclipse.egit.ui.internal.decorators;
@@ -48,6 +49,11 @@ public class DecoratableResource extends ResourceState
protected String branchStatus = null;
/**
+ * is resource a repository container ?
+ */
+ protected boolean isRepositoryContainer = false;
+
+ /**
* Constructs a new decoratable resource
*
* This object represents the state of a resource used as a basis for
@@ -60,6 +66,14 @@ public class DecoratableResource extends ResourceState
this.resource = resource;
}
+ /**
+ * @param isContainer
+ * set to true if the resource is a repository container
+ */
+ protected void setIsRepositoryContainer(boolean isContainer) {
+ isRepositoryContainer = isContainer;
+ }
+
@Override
public int getType() {
return resource != null ? resource.getType() : 0;
@@ -90,4 +104,9 @@ public class DecoratableResource extends ResourceState
return branchStatus;
}
+ @Override
+ public boolean isRepositoryContainer() {
+ return isRepositoryContainer;
+ }
+
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java
index ae7d53ee6..d623547a6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/DecoratableResourceAdapter.java
@@ -13,6 +13,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert <anb0s@anbos.de> - Cleaning up the DecoratableResourceAdapter
*******************************************************************************/
package org.eclipse.egit.ui.internal.decorators;
@@ -40,7 +43,7 @@ class DecoratableResourceAdapter extends DecoratableResource {
if (trace) {
GitTraceLocation.getTrace().trace(
GitTraceLocation.DECORATION.getLocation(),
- "Decorate " + resource.getFullPath()); //$NON-NLS-1$
+ "Decorate " + resourceToWrap.getFullPath()); //$NON-NLS-1$
start = System.currentTimeMillis();
}
try {
@@ -53,6 +56,7 @@ class DecoratableResourceAdapter extends DecoratableResource {
if (repository == null) {
return;
}
+ setIsRepositoryContainer(resourceToWrap.equals(mapping.getContainer()));
IResourceState baseState = ResourceStateFactory.getInstance()
.get(indexDiffData, resourceToWrap);
setTracked(baseState.isTracked());
@@ -61,10 +65,10 @@ class DecoratableResourceAdapter extends DecoratableResource {
setConflicts(baseState.hasConflicts());
setAssumeUnchanged(baseState.isAssumeUnchanged());
setStagingState(baseState.getStagingState());
- if (resource.getType() == IResource.PROJECT
- || resource.equals(mapping.getContainer())) {
- // We only need this very expensive info for project decoration,
- // and for decorating folders that are submodule roots.
+ if (isRepositoryContainer()) {
+ // We only need this very expensive info for for decorating
+ // projects and folders that are submodule or nested repository
+ // roots
repositoryName = DecoratableResourceHelper
.getRepositoryName(repository);
branch = DecoratableResourceHelper.getShortBranch(repository);
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 e8d0ed3db..c0ac55a03 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
@@ -14,6 +14,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert <anb0s@anbos.de> - Cleaning up the DecoratableResourceAdapter
*******************************************************************************/
package org.eclipse.egit.ui.internal.decorators;
@@ -449,8 +452,9 @@ public class GitLightweightDecorator extends LabelProvider implements
break;
case IResource.FOLDER:
case DecoratableResourceMapping.RESOURCE_MAPPING:
- // Use the submodule formatting if it's a submodule root
- if (resource.getBranch() != null) {
+ if (resource.isRepositoryContainer()) {
+ // Use the submodule formatting if it's a submodule or
+ // nested repository root
format = store.getString(
UIPreferences.DECORATOR_SUBMODULETEXT_DECORATION);
} else {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/IDecoratableResource.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/IDecoratableResource.java
index 48c18b01c..53912bd1e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/IDecoratableResource.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/IDecoratableResource.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Thomas Wolf <thomas.wolf@paranor.ch> - Factored out IResourceState
+ * Andre Bossert <anb0s@anbos.de> - Cleaning up the DecoratableResourceAdapter
*******************************************************************************/
package org.eclipse.egit.ui.internal.decorators;
@@ -65,4 +66,10 @@ public interface IDecoratableResource extends IResourceState {
*/
String getBranchStatus();
+ /**
+ * @return is the resource a repository container, e.g. working tree root or
+ * project ?
+ */
+ boolean isRepositoryContainer();
+
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java
index 780f2fb4a..4c6df4836 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java
@@ -8,6 +8,9 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andre Bossert <anb0s@anbos.de> - Cleaning up the DecoratableResourceAdapter
*******************************************************************************/
package org.eclipse.egit.ui.internal.staging;
@@ -354,4 +357,9 @@ public class StagingEntry extends PlatformObject
return false;
return true;
}
+
+ @Override
+ public boolean isRepositoryContainer() {
+ return false;
+ }
}

Back to the top