Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2019-04-27 05:16:51 -0400
committerMichael Keppler2019-04-28 11:38:14 -0400
commitb83ddfeb998a88539f870cfb4785ff1d672b9ac5 (patch)
tree149b50a59a57bf28c6dc76d7eb256b8b6aaecc1d
parent14de490552d01303eae08bb97b97f4c2441b7e12 (diff)
downloadegit-b83ddfeb998a88539f870cfb4785ff1d672b9ac5.tar.gz
egit-b83ddfeb998a88539f870cfb4785ff1d672b9ac5.tar.xz
egit-b83ddfeb998a88539f870cfb4785ff1d672b9ac5.zip
Register progress icons from UI thread
The UIIcons initialization code can be called from other threads as shown in the bug, therefore move the jface resource related code to the activator of the UI bundle, to more easily synchronize on the UI thread. Bug:546750 Change-Id: I46369472c4748787c582351b051bea10d009ac53 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
-rwxr-xr-xorg.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java31
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java13
2 files changed, 29 insertions, 15 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
index 2b752393d..b04824be2 100755
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java
@@ -50,6 +50,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.egit.core.JobFamilies;
import org.eclipse.egit.core.RepositoryCache;
import org.eclipse.egit.core.RepositoryUtil;
import org.eclipse.egit.core.internal.job.RuleUtil;
@@ -58,6 +59,7 @@ import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.internal.ConfigurationChecker;
import org.eclipse.egit.ui.internal.KnownHosts;
import org.eclipse.egit.ui.internal.RepositoryCacheRule;
+import org.eclipse.egit.ui.internal.UIIcons;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider;
import org.eclipse.egit.ui.internal.trace.GitTraceLocation;
@@ -87,6 +89,7 @@ import org.eclipse.ui.IWindowListener;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.progress.IProgressService;
import org.eclipse.ui.progress.WorkbenchJob;
import org.eclipse.ui.statushandlers.StatusManager;
import org.eclipse.ui.themes.ITheme;
@@ -454,12 +457,36 @@ public class Activator extends AbstractUIPlugin implements DebugOptionsListener
Job job = new Job(UIText.Activator_setupFocusListener) {
@Override
protected IStatus run(IProgressMonitor monitor) {
- if (PlatformUI.isWorkbenchRunning())
+ if (PlatformUI.isWorkbenchRunning()) {
PlatformUI.getWorkbench().addWindowListener(focusListener);
- else
+ registerCoreJobFamilyIcons();
+ } else {
schedule(1000L);
+ }
return Status.OK_STATUS;
}
+
+ /**
+ * register progress icons for jobs from core plugin
+ */
+ private void registerCoreJobFamilyIcons() {
+ PlatformUI.getWorkbench().getDisplay()
+ .asyncExec(() -> {
+ IProgressService service = PlatformUI.getWorkbench()
+ .getProgressService();
+
+ service.registerIconForFamily(UIIcons.PULL,
+ JobFamilies.PULL);
+ service.registerIconForFamily(UIIcons.REPOSITORY,
+ JobFamilies.AUTO_IGNORE);
+ service.registerIconForFamily(UIIcons.REPOSITORY,
+ JobFamilies.AUTO_SHARE);
+ service.registerIconForFamily(UIIcons.REPOSITORY,
+ JobFamilies.INDEX_DIFF_CACHE_UPDATE);
+ service.registerIconForFamily(UIIcons.REPOSITORY,
+ JobFamilies.REPOSITORY_CHANGED);
+ });
+ }
};
job.setSystem(true);
job.setUser(false);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java
index efc0606a3..a217e0280 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIIcons.java
@@ -22,14 +22,11 @@ import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.egit.core.JobFamilies;
import org.eclipse.egit.ui.Activator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
import org.osgi.framework.Version;
/**
@@ -487,16 +484,6 @@ public class UIIcons {
OVR_CHECKEDOUT, IDecoration.TOP_LEFT);
SIGN_COMMIT = map("obj16/sign-commit.png"); //$NON-NLS-1$
MERGE_TOOL = map("obj16/mergetool.png"); //$NON-NLS-1$
- IProgressService service = PlatformUI.getWorkbench()
- .getProgressService();
-
- service.registerIconForFamily(PULL, JobFamilies.PULL);
- service.registerIconForFamily(REPOSITORY, JobFamilies.AUTO_IGNORE);
- service.registerIconForFamily(REPOSITORY, JobFamilies.AUTO_SHARE);
- service.registerIconForFamily(REPOSITORY,
- JobFamilies.INDEX_DIFF_CACHE_UPDATE);
- service.registerIconForFamily(REPOSITORY,
- JobFamilies.REPOSITORY_CHANGED);
}
private static ImageDescriptor map(final String icon) {

Back to the top