Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2016-03-15 18:18:34 -0400
committerThomas Wolf2016-03-15 18:58:17 -0400
commita8bcee9ea7a58e6db797b86c735f0bdb9e774c18 (patch)
treeb8cb713626ba372401373a96f96227cdff30f625
parent821fb8f9e6f6166e09c9394eaae75572151e9729 (diff)
downloadegit-a8bcee9ea7a58e6db797b86c735f0bdb9e774c18.tar.gz
egit-a8bcee9ea7a58e6db797b86c735f0bdb9e774c18.tar.xz
egit-a8bcee9ea7a58e6db797b86c735f0bdb9e774c18.zip
Refresh decorations after re-connecting a project
Re-connecting a previously connected, then disconnected project did not refresh the decorations in the project explorer. RepositoryChangeListener was unused, and likewise GitProjectData.addRepositoryChangeListener(). Therefore, all calls to RepositoryMapping.fireRepositoryChanged() had absolutely no effect. Thus I have removed all these calls and the method. Interesting bit of EGit history: the very first version (even before EGit became an Eclipse project) of GitProjectData contained what is now known as the RepositoryCache (the one in EGit). The RepositoryChangeListener indeed was notified on changes in a repository. In that original commit, there was exactly one such listener: in the git decorator. Through various refactorings, RepositoryCache was extracted from GitProjectData, and then IndexDiffChangedListener appeared. RepositoryChangeListener became unused; GitLightweightDecorator was changed to listen on index diff changes in commit f332331. Nowadays, this RepositoryChangeListener is notified not on repository changes, but whenever a new RepositoryMapping is added to the Eclipse resource tree. And that is exactly what is needed to fix bug 489696: when a previously connected, now disconnected project is re-connected, there will be no resource change events (the project is known in Eclipse's resource tree already, and adding new RepositoryMappings as session properties doesn't trigger a resource delta). There also will be no repository or index diff related events (provided the repository is still known to EGit, for instance because it is in the Repositories view, or because there are other projects from that repository.) So the GitLightweightDecorator will not refresh decorations. Using a RepositoryChangeListener (again, after 5 years) the GitLightweightDecorator can correctly refresh the project explorer in this case. Since this listener is no longer invoked when a repository changes, but when a new RepositoryMapping appears, I have renamed and re-purposed the interface to RepositoryMappingChangeListener. Bug: 489696 Change-Id: I2b59cea1f1500cbdde554fff28b676456c8462d8 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/RemoveFromIndexOperation.java7
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java2
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/GitProjectData.java20
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java9
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMappingChangeListener.java (renamed from org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryChangeListener.java)15
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/submodules/SubmoduleFolderTest.java17
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java6
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/DisconnectConnectTest.java33
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java5
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/decorators/GitLightweightDecorator.java15
13 files changed, 82 insertions, 61 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
index 06479ee0f..4ac4f0d8b 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AddToIndexOperation.java
@@ -81,8 +81,6 @@ public class AddToIndexOperation implements IEGitOperation {
} catch (GitAPIException e) {
throw new CoreException(Activator.error(CoreText.AddToIndexOperation_failed, e));
} finally {
- for (final RepositoryMapping rm : addCommands.keySet())
- rm.fireRepositoryChanged();
monitor.done();
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java
index f401a2c77..1fcfc854c 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/AssumeUnchangedOperation.java
@@ -100,8 +100,6 @@ public class AssumeUnchangedOperation implements IEGitOperation {
} catch (IOException e) {
throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, e));
} finally {
- for (final RepositoryMapping rm : mappings.keySet())
- rm.fireRepositoryChanged();
for (DirCache cache:caches.values())
cache.unlock();
caches.clear();
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RemoveFromIndexOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RemoveFromIndexOperation.java
index 4002a0444..052f0fffd 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RemoveFromIndexOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/RemoveFromIndexOperation.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.egit.core.op;
-import static org.eclipse.egit.core.project.RepositoryMapping.findRepositoryMapping;
import static org.eclipse.jgit.lib.Constants.HEAD;
import java.io.IOException;
@@ -27,7 +26,6 @@ import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.internal.CoreText;
import org.eclipse.egit.core.internal.job.RuleUtil;
import org.eclipse.egit.core.internal.util.ResourceUtil;
-import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.GitCommand;
import org.eclipse.jgit.api.ResetCommand;
@@ -83,11 +81,6 @@ public class RemoveFromIndexOperation implements IEGitOperation {
monitor.worked(1);
} catch (GitAPIException e) {
Activator.logError(e.getMessage(), e);
- } finally {
- RepositoryMapping mapping = findRepositoryMapping(repository);
- if (mapping != null) {
- mapping.fireRepositoryChanged();
- }
}
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java
index 566e7071e..f6aaf8518 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/UntrackOperation.java
@@ -95,8 +95,6 @@ public class UntrackOperation implements IEGitOperation {
} catch (IOException e) {
throw new CoreException(Activator.error(CoreText.UntrackOperation_failed, e));
} finally {
- for (final RepositoryMapping rm : mappings.keySet())
- rm.fireRepositoryChanged();
for (DirCacheEditor editor:edits.values())
if (editor.getDirCache() != null)
editor.getDirCache().unlock();
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 e7b2852d9..f337a0e8b 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
@@ -70,7 +70,7 @@ public class GitProjectData {
private static final Map<IProject, GitProjectData> projectDataCache = new HashMap<IProject, GitProjectData>();
- private static Set<RepositoryChangeListener> repositoryChangeListeners = new HashSet<RepositoryChangeListener>();
+ private static Set<RepositoryMappingChangeListener> repositoryChangeListeners = new HashSet<RepositoryMappingChangeListener>();
@SuppressWarnings("synthetic-access")
private static final IResourceChangeListener rcl = new RCL();
@@ -133,25 +133,25 @@ public class GitProjectData {
* the new listener to register. Must not be null.
*/
public static synchronized void addRepositoryChangeListener(
- final RepositoryChangeListener objectThatCares) {
+ final RepositoryMappingChangeListener objectThatCares) {
if (objectThatCares == null)
throw new NullPointerException();
repositoryChangeListeners.add(objectThatCares);
}
/**
- * Remove a registered {@link RepositoryChangeListener}
+ * Remove a registered {@link RepositoryMappingChangeListener}
*
* @param objectThatCares
* The listener to remove
*/
public static synchronized void removeRepositoryChangeListener(
- final RepositoryChangeListener objectThatCares) {
+ final RepositoryMappingChangeListener objectThatCares) {
repositoryChangeListeners.remove(objectThatCares);
}
/**
- * Notify registered {@link RepositoryChangeListener}s of a change.
+ * Notify registered {@link RepositoryMappingChangeListener}s of a change.
*
* @param which
* the repository which has had changes occur within it.
@@ -161,12 +161,12 @@ public class GitProjectData {
@Override
protected IStatus run(IProgressMonitor monitor) {
- RepositoryChangeListener[] listeners = getRepositoryChangeListeners();
+ RepositoryMappingChangeListener[] listeners = getRepositoryChangeListeners();
monitor.beginTask(
CoreText.GitProjectData_repositoryChangedTaskName,
listeners.length);
- for (RepositoryChangeListener listener : listeners) {
+ for (RepositoryMappingChangeListener listener : listeners) {
listener.repositoryChanged(which);
monitor.worked(1);
}
@@ -195,9 +195,9 @@ public class GitProjectData {
*
* @return a copy of the current repository change listeners
*/
- private static synchronized RepositoryChangeListener[] getRepositoryChangeListeners() {
+ private static synchronized RepositoryMappingChangeListener[] getRepositoryChangeListeners() {
return repositoryChangeListeners
- .toArray(new RepositoryChangeListener[repositoryChangeListeners
+ .toArray(new RepositoryMappingChangeListener[repositoryChangeListeners
.size()]);
}
@@ -628,7 +628,7 @@ public class GitProjectData {
return;
}
- m.fireRepositoryChanged();
+ fireRepositoryChanged(m);
trace("map " //$NON-NLS-1$
+ c
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
index 098da9062..57f9a2a2e 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMapping.java
@@ -211,15 +211,6 @@ public class RepositoryMapping {
container = c;
}
- /**
- * Notify registered {@link RepositoryChangeListener}s of a change.
- *
- * @see GitProjectData#addRepositoryChangeListener(RepositoryChangeListener)
- */
- public void fireRepositoryChanged() {
- GitProjectData.fireRepositoryChanged(this);
- }
-
synchronized void store(final Properties p) {
p.setProperty(containerPathString + ".gitdir", gitDirPathString); //$NON-NLS-1$
}
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryChangeListener.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMappingChangeListener.java
index d07fb8ed5..13ea4b289 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryChangeListener.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/project/RepositoryMappingChangeListener.java
@@ -1,5 +1,6 @@
/*******************************************************************************
* Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
+ * Copyright (C) 2016, 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 v1.0
@@ -8,8 +9,11 @@
*******************************************************************************/
package org.eclipse.egit.core.project;
+import org.eclipse.jgit.annotations.NonNull;
+
/**
- * Receives notification of a repository change event.
+ * Receives notification when a new {@link RepositoryMapping} appears in the
+ * Eclipse resource tree.
* <p>
* A change listener may be called from any thread, especially background job
* threads, but also from the UI thread. Implementors are encouraged to complete
@@ -17,12 +21,13 @@ package org.eclipse.egit.core.project;
* necessary.
* </p>
*/
-public interface RepositoryChangeListener {
+public interface RepositoryMappingChangeListener {
/**
- * Invoked when a repository has had some or all of its contents change.
+ * Invoked when a new {@link RepositoryMapping} appears in the Eclipse
+ * resource tree.
*
* @param which
- * the affected repository. Never null.
+ * the new {@link RepositoryMapping}
*/
- public void repositoryChanged(RepositoryMapping which);
+ public void repositoryChanged(@NonNull RepositoryMapping which);
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/submodules/SubmoduleFolderTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/submodules/SubmoduleFolderTest.java
index 7b77a7fa4..ece1f6ab9 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/submodules/SubmoduleFolderTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/submodules/SubmoduleFolderTest.java
@@ -195,7 +195,7 @@ public class SubmoduleFolderTest extends LocalRepositoryTestCase {
SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
SWTBotTreeItem node = TestUtil.navigateTo(projectExplorerTree,
file.getFullPath().segments());
- waitForDecorations();
+ TestUtil.waitForDecorations();
assertTrue(node.getText().startsWith("> " + file.getName()));
node.select();
ContextMenuHelper.clickContextMenuSync(projectExplorerTree, "Team",
@@ -207,7 +207,7 @@ public class SubmoduleFolderTest extends LocalRepositoryTestCase {
IResourceState state = ResourceStateFactory.getInstance()
.get(cache.getIndexDiff(), file);
assertTrue("File should be staged", state.isStaged());
- waitForDecorations();
+ TestUtil.waitForDecorations();
assertFalse(node.getText().startsWith("> "));
ContextMenuHelper.clickContextMenuSync(projectExplorerTree, "Team",
util.getPluginLocalizedValue("RemoveFromIndexAction_label"));
@@ -216,7 +216,7 @@ public class SubmoduleFolderTest extends LocalRepositoryTestCase {
file);
assertFalse("File should not be staged", state.isStaged());
assertTrue("File should be dirty", state.isDirty());
- waitForDecorations();
+ TestUtil.waitForDecorations();
assertTrue(node.getText().startsWith("> " + file.getName()));
}
@@ -267,15 +267,15 @@ public class SubmoduleFolderTest extends LocalRepositoryTestCase {
SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
SWTBotTreeItem node = TestUtil.navigateTo(projectExplorerTree,
childFolder.getFullPath().segments());
- waitForDecorations();
+ TestUtil.waitForDecorations();
assertTrue("Folder should have repo/branch decoration",
node.getText().contains("[master"));
node = TestUtil.getChildNode(node.expand(), CHILDPROJECT);
- waitForDecorations();
+ TestUtil.waitForDecorations();
assertFalse("Folder should not have repo/branch decoration",
node.getText().contains("["));
node = TestUtil.navigateTo(projectExplorerTree, CHILDPROJECT);
- waitForDecorations();
+ TestUtil.waitForDecorations();
assertTrue("Project should have subrepo/branch decoration",
node.getText().contains("[child"));
}
@@ -344,9 +344,4 @@ public class SubmoduleFolderTest extends LocalRepositoryTestCase {
historyBot.bot().table().rowCount());
}
- @SuppressWarnings("restriction")
- private void waitForDecorations() throws Exception {
- TestUtil.joinJobs(
- org.eclipse.ui.internal.decorators.DecoratorManager.FAMILY_DECORATE);
- }
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
index 7cc571ac7..5f47d337b 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/TestUtil.java
@@ -195,6 +195,12 @@ public class TestUtil {
TestUtil.processUIEvents();
}
+ @SuppressWarnings("restriction")
+ public static void waitForDecorations() throws InterruptedException {
+ TestUtil.joinJobs(
+ org.eclipse.ui.internal.decorators.DecoratorManager.FAMILY_DECORATE);
+ }
+
/**
* Utility for waiting until the execution of jobs of any family has
* finished or timeout is reached. If no jobs are running, the method waits
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/DisconnectConnectTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/DisconnectConnectTest.java
index cc2fd3e27..4a55ea656 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/DisconnectConnectTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/DisconnectConnectTest.java
@@ -10,12 +10,15 @@
*******************************************************************************/
package org.eclipse.egit.ui.test.team.actions;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.UIText;
@@ -25,6 +28,7 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -69,6 +73,35 @@ public class DisconnectConnectTest extends LocalRepositoryTestCase {
assertNotNull(mapping);
}
+ @Test
+ public void testDecorations() throws Exception {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(PROJ1);
+ RepositoryMapping mapping = RepositoryMapping.getMapping(project);
+ assertNotNull(mapping);
+ SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ TestUtil.navigateTo(projectExplorerTree,
+ new Path(FILE1_PATH).segments());
+ touch("File modified");
+ clickOnDisconnect();
+ TestUtil.waitForJobs(500, 5000);
+ TestUtil.waitForDecorations();
+ assertFalse("Project should not have git decorations",
+ getProjectItem(projectExplorerTree, PROJ1).getText()
+ .contains("["));
+ SWTBotShell connectDialog = openConnectDialog();
+ connectDialog.bot().button(IDialogConstants.FINISH_LABEL).click();
+ TestUtil.waitForJobs(500, 5000);
+ TestUtil.waitForDecorations();
+ assertTrue("Project should have git decorations",
+ getProjectItem(projectExplorerTree, PROJ1).getText()
+ .contains("[FirstRepository"));
+ SWTBotTreeItem fileNode = TestUtil.navigateTo(projectExplorerTree,
+ new Path(FILE1_PATH).segments());
+ assertTrue("File should have git decorations",
+ fileNode.getText().startsWith(">"));
+ }
+
private void clickOnDisconnect() throws Exception {
SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
getProjectItem(projectExplorerTree, PROJ1).select();
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
index 0399bed31..89a9fbf4c 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java
@@ -165,7 +165,7 @@ public class GitRepositoriesViewRepoDeletionTest extends
assertTrue(repositoryFile.exists());
assertTrue(
new File(repositoryFile.getParentFile(), PROJ1).isDirectory());
- waitForDecorations();
+ TestUtil.waitForDecorations();
closeGitViews();
TestUtil.waitForJobs(500, 5000);
// Session properties are stored in the Eclipse resource tree as part of
@@ -228,7 +228,7 @@ public class GitRepositoriesViewRepoDeletionTest extends
org.eclipse.egit.core.JobFamilies.INDEX_DIFF_CACHE_UPDATE);
// Is this job doing something when the view is hidden?
TestUtil.joinJobs(JobFamilies.REPO_VIEW_REFRESH);
- waitForDecorations();
+ TestUtil.waitForDecorations();
} catch (InterruptedException e) {
results[0] = "Interrupted";
Thread.currentThread().interrupt();
@@ -317,12 +317,6 @@ public class GitRepositoriesViewRepoDeletionTest extends
assertFalse(subRepo.getWorkTree().exists());
}
- @SuppressWarnings("restriction")
- private void waitForDecorations() throws InterruptedException {
- TestUtil.joinJobs(
- org.eclipse.ui.internal.decorators.DecoratorManager.FAMILY_DECORATE);
- }
-
/**
* Best-effort attempt to get finalization to occur.
*
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java
index 04c533018..835f1b91e 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java
@@ -20,7 +20,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.egit.core.op.CommitOperation;
-import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.internal.UIText;
@@ -112,10 +111,6 @@ public class CommitJob extends Job {
commitOperation.execute(monitor);
commit = commitOperation.getCommit();
CommitMessageComponentStateManager.deleteState(repository);
- RepositoryMapping mapping = RepositoryMapping
- .findRepositoryMapping(repository);
- if (mapping != null)
- mapping.fireRepositoryChanged();
} catch (CoreException e) {
if (e.getCause() instanceof JGitInternalException) {
return Activator.createErrorStatus(e.getLocalizedMessage(),
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 67cffdaf3..e8d0ed3db 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
@@ -36,6 +36,9 @@ import org.eclipse.egit.core.AdapterUtils;
import org.eclipse.egit.core.internal.indexdiff.IndexDiffChangedListener;
import org.eclipse.egit.core.internal.indexdiff.IndexDiffData;
import org.eclipse.egit.core.internal.util.ExceptionCollector;
+import org.eclipse.egit.core.project.GitProjectData;
+import org.eclipse.egit.core.project.RepositoryMappingChangeListener;
+import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.internal.UIIcons;
@@ -104,6 +107,15 @@ public class GitLightweightDecorator extends LabelProvider implements
private static RGB defaultBackgroundRgb;
+ private RepositoryMappingChangeListener mappingChangeListener = new RepositoryMappingChangeListener() {
+
+ @Override
+ public void repositoryChanged(RepositoryMapping which) {
+ fireLabelEvent();
+ }
+
+ };
+
/**
* Constructs a new Git resource decorator
*/
@@ -117,6 +129,7 @@ public class GitLightweightDecorator extends LabelProvider implements
.addPropertyChangeListener(this);
org.eclipse.egit.core.Activator.getDefault().getIndexDiffCache().addIndexDiffChangedListener(this);
+ GitProjectData.addRepositoryChangeListener(mappingChangeListener);
}
/**
@@ -155,6 +168,8 @@ public class GitLightweightDecorator extends LabelProvider implements
TeamUI.removePropertyChangeListener(this);
Activator.removePropertyChangeListener(this);
org.eclipse.egit.core.Activator.getDefault().getIndexDiffCache().removeIndexDiffChangedListener(this);
+ GitProjectData.removeRepositoryChangeListener(mappingChangeListener);
+ mappingChangeListener = null;
}
/**

Back to the top