Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2018-07-24 17:19:12 -0400
committerThomas Wolf2018-08-06 15:53:27 -0400
commit6ee58057c2dc1ab8498651e1ab91955289f7e981 (patch)
treea96324ec43af9989bd54840e7ddebe3d63e9f421 /org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test
parentf83e6aeca768531f345f9092afd384bf763ff7ae (diff)
downloadegit-6ee58057c2dc1ab8498651e1ab91955289f7e981.tar.gz
egit-6ee58057c2dc1ab8498651e1ab91955289f7e981.tar.xz
egit-6ee58057c2dc1ab8498651e1ab91955289f7e981.zip
Use an asynchronous lightweight decorator in the repositories view
In the previous implementation, the label provider produced styled labels that included the decorations. But label providers run in the UI thread, and expensive decorations like a branch state (N commits ahead, M behind) could thus lead to UI blocks. Newly, leverage Eclipse's built-in support. Use a lightweight decorator for RepositoryTreeNode and register it in plugin.xml. Separate out getting labels into a WorkbenchAdapter and adapt the GitAdapterFactory accordingly. (We already created a WorkbenchAdapter there, but first we always created a new one, and second, it always created a RepositoriesViewLabelProvider just to get the label text. That's terribly inefficient and the logic is completely backwards.) Also use ImageDescriptors instead of Images where possible. Factor out the handling of LabelProviderChangedEvent from GitLightweightDecorator into GitDecorator and re-use it in the new decorator for RepositoryTreeNodes. Make the RepositoriesViewLabelProvider a decorating label provider based on a WorkbenchLabelProvider, which uses the singleton RepositoryTreeNodeWorkbenchAdapter to get labels and images. Change the other uses of RepositoriesViewLabelProvider in dialogs to work with the new setup. Adapt git repositories view tests. These often use the label provider to determine expected node labels, and then try to find a node with a matching label. Decorations are now asynchronous, and thus the label returned from the label provider may or may not contain the decoration. Even with waiting for decoration jobs we may end up with the label being determined in the test and the one in the UI being different. The latter may or may not contain the decoration, which makes finding expected nodes a bit difficult. For now, use the TestUtil navigation methods, which just check for containment. This works well, but because some decorations include the repo directory path which in turn includes the test method name, some test methods and even some test repo names had to be changed to avoid false "duplicate nodes" failures. User-visible UI changes from all that: next to none. Three differences I noticed in the default theme on OS X: 1. Decorations all use the default decoration style (light brown), with the exception of the directory paths shown on repository nodes and on working tree nodes. Those are handled specially and use the qualifier style. 2. Decorations in the "File->Import...->Projects from Git->Existing git repositories" page now actually work. 3. Image decorations briefly flicker on a refresh because of the way asynchronous lightweight decorators work. The flickering is due to the repository view being wholly refreshed frequently. On such a refresh, the viewer tries to get a new decorated label, but the decoration isn't available yet. Once it is available, an event is fired, and the viewer updates the label again. For text labels, the new RepositoriesViewLabelProvider contains a work-around, but for images, that method won't work. The only image decorations (so far) are the check markers for the currently checked-out ref. Otherwise, I notice much faster Eclipse startup with the repositories view open and containing some repositories. Bug: 536814 Change-Id: Ifa8279dd6755c57696b8b64e96bc41a1f948aa59 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java15
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java11
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/FetchAndMergeActionTest.java13
3 files changed, 6 insertions, 33 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
index 12063befa..13315742c 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/BranchAndResetActionTest.java
@@ -40,13 +40,8 @@ import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider;
-import org.eclipse.egit.ui.internal.repository.tree.LocalNode;
-import org.eclipse.egit.ui.internal.repository.tree.RepositoryNode;
-import org.eclipse.egit.ui.internal.repository.tree.TagsNode;
import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.TestUtil;
-import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTestUtils;
import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jgit.lib.Constants;
@@ -100,12 +95,8 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase {
top.execute(null);
touchAndSubmit(null);
- RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils
- .createLabelProvider();
- LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(
- null, repo), repo));
- TAGS = provider.getText(new TagsNode(new RepositoryNode(null, repo),
- repo));
+ LOCAL_BRANCHES = UIText.RepositoriesViewLabelProvider_LocalNodetext;
+ TAGS = UIText.RepositoriesViewLabelProvider_TagsNodeText;
}
@Test
@@ -171,7 +162,7 @@ public class BranchAndResetActionTest extends LocalRepositoryTestCase {
.getProject(PROJ1).getFolder(FOLDER).getFile("ToBeDeleted");
toBeDeleted.create(new ByteArrayInputStream(new byte[0]), false, null);
- ArrayList<IFile> untracked = new ArrayList<IFile>();
+ ArrayList<IFile> untracked = new ArrayList<>();
untracked.add(toBeDeleted);
// commit to stable
CommitOperation op = new CommitOperation(new IFile[] { toBeDeleted },
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
index bf7514156..4724595ed 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/CompareActionsTest.java
@@ -35,13 +35,9 @@ import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.dialogs.CompareTreeView;
-import org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider;
-import org.eclipse.egit.ui.internal.repository.tree.RepositoryNode;
-import org.eclipse.egit.ui.internal.repository.tree.TagsNode;
import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.JobJoiner;
import org.eclipse.egit.ui.test.TestUtil;
-import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTestUtils;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ResetCommand.ResetType;
@@ -96,12 +92,7 @@ public class CompareActionsTest extends LocalRepositoryTestCase {
top.execute(null);
touchAndSubmit(null);
- RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils
- .createLabelProvider();
- // LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(
- // null, repo), repo));
- TAGS = provider.getText(new TagsNode(new RepositoryNode(null, repo),
- repo));
+ TAGS = UIText.RepositoriesViewLabelProvider_TagsNodeText;
}
private static void setEnabledModelProvider(String modelProviderId) {
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/FetchAndMergeActionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/FetchAndMergeActionTest.java
index 7f2464bb1..b74ebb365 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/FetchAndMergeActionTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/FetchAndMergeActionTest.java
@@ -22,14 +22,9 @@ import java.util.concurrent.TimeUnit;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.egit.ui.internal.repository.RepositoriesViewLabelProvider;
-import org.eclipse.egit.ui.internal.repository.tree.LocalNode;
-import org.eclipse.egit.ui.internal.repository.tree.RemoteTrackingNode;
-import org.eclipse.egit.ui.internal.repository.tree.RepositoryNode;
import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.JobJoiner;
import org.eclipse.egit.ui.test.TestUtil;
-import org.eclipse.egit.ui.view.repositories.GitRepositoriesViewTestUtils;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
@@ -65,13 +60,9 @@ public class FetchAndMergeActionTest extends LocalRepositoryTestCase {
public void setup() throws Exception {
repositoryFile = createProjectAndCommitToRepository();
childRepositoryFile = createChildRepository(repositoryFile);
- RepositoriesViewLabelProvider provider = GitRepositoriesViewTestUtils
- .createLabelProvider();
Repository repo = lookupRepository(childRepositoryFile);
- REMOTE_BRANCHES = provider.getText(new RemoteTrackingNode(
- new RepositoryNode(null, repo), repo));
- LOCAL_BRANCHES = provider.getText(new LocalNode(new RepositoryNode(
- null, repo), repo));
+ REMOTE_BRANCHES = UIText.RepositoriesViewLabelProvider_RemoteTrackingNodetext;
+ LOCAL_BRANCHES = UIText.RepositoriesViewLabelProvider_LocalNodetext;
ObjectId id = repo.resolve(repo.getFullBranch());
initialCommitId = id.name();
}

Back to the top