Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Kubitz2021-09-14 19:27:21 +0000
committerJörg Kubitz2021-09-18 12:25:45 +0000
commit7684c7ee17d64c85798a08f9fe2aa78c1d72bed5 (patch)
tree2d58fffda4a98f7aafa5b70284148fb6e51fab9e
parent2392dcf6757ea4f1d4cccfabd18161daffdc00ae (diff)
downloadeclipse.platform.ui-7684c7ee17d64c85798a08f9fe2aa78c1d72bed5.tar.gz
eclipse.platform.ui-7684c7ee17d64c85798a08f9fe2aa78c1d72bed5.tar.xz
eclipse.platform.ui-7684c7ee17d64c85798a08f9fe2aa78c1d72bed5.zip
This speeds up repeated start of the Dialog: "Preferences/General/Editors/File Associations/Add.../External programs" It assumes OS Editor never changes. You now need to restart Eclipse after adding a new OS Editor if you need to add it in Eclipse. Like before the EditorRegistry does not know of newly created OS Editors anyway. Change-Id: I96623e7d65c38471a7ddff96f97bb36de573d102 Signed-off-by: Joerg Kubitz <jkubitz-eclipse@gmx.de> Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/184308 Tested-by: Platform Bot <platform-bot@eclipse.org>
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java27
1 files changed, 24 insertions, 3 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java
index 3244c9b6ca2..af83d76820e 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java
@@ -147,6 +147,10 @@ public class EditorRegistry extends EventManager implements IEditorRegistry, IEx
*/
private List<IEditorDescriptor> sortedEditorsFromPlugins = new ArrayList<>();
+ /** cache of OS editors **/
+ private IEditorDescriptor[] sortedEditorsFromOS;
+ final Object sortedEditorsFromOSSynchronizer = new Object();
+
// Map of EditorDescriptor - map editor id to editor.
private Map<String, IEditorDescriptor> mapIDtoInternalEditor = initialIdToEditorMap(10);
// Map of EditorDescriptor - map editor id to OS editor.
@@ -304,8 +308,8 @@ public class EditorRegistry extends EventManager implements IEditorRegistry, IEx
}
// reset external editors from OS
- synchronized(this){
- mapIDtoOSEditors=null;
+ synchronized (this) {
+ mapIDtoOSEditors = null;
}
}
@@ -494,7 +498,24 @@ public class EditorRegistry extends EventManager implements IEditorRegistry, IEx
* @return the editor descriptors
*/
public IEditorDescriptor[] getSortedEditorsFromOS() {
- return getStaticSortedEditorsFromOS();
+ synchronized (sortedEditorsFromOSSynchronizer) {
+ if (sortedEditorsFromOS == null) {
+ loadEditorsFromOS();
+ }
+ return sortedEditorsFromOS;
+ }
+ }
+
+ /**
+ * refreshes cache.
+ *
+ * @see #getSortedEditorsFromOS
+ */
+ // public just in case someone wants to reload
+ public void loadEditorsFromOS() {
+ synchronized (sortedEditorsFromOSSynchronizer) {
+ sortedEditorsFromOS = getStaticSortedEditorsFromOS();
+ }
}
private static IEditorDescriptor[] getStaticSortedEditorsFromOS() {

Back to the top