Add access to PreferenceAccess/*CoreAccess via IAdaptable

Change-Id: I27dcd1495609ad154e22299c979cfa1a8c112a3b
diff --git a/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/page/RConsoleSourceUnit.java b/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/page/RConsoleSourceUnit.java
index e7cae94..1e4ced5 100644
--- a/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/page/RConsoleSourceUnit.java
+++ b/r/org.eclipse.statet.r.console.ui/src/org/eclipse/statet/internal/r/console/ui/page/RConsoleSourceUnit.java
@@ -21,6 +21,7 @@
 import org.eclipse.statet.jcommons.lang.NonNullByDefault;
 import org.eclipse.statet.jcommons.lang.Nullable;
 
+import org.eclipse.statet.ecommons.preferences.core.PreferenceAccess;
 import org.eclipse.statet.ecommons.text.core.sections.DocContentSections;
 import org.eclipse.statet.ecommons.text.core.util.AbstractFragmentDocument;
 import org.eclipse.statet.ecommons.text.core.util.TextUtils;
@@ -111,6 +112,9 @@
 		if (adapterType == RCoreAccess.class) {
 			return (T)getRCoreAccess();
 		}
+		if (adapterType == PreferenceAccess.class) {
+			return (T)getRCoreAccess().getPrefs();
+		}
 		return super.getAdapter(adapterType);
 	}
 	
diff --git a/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/BasicRResourceSourceUnit.java b/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/BasicRResourceSourceUnit.java
index f13d55a..d97b16e 100644
--- a/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/BasicRResourceSourceUnit.java
+++ b/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/BasicRResourceSourceUnit.java
@@ -21,6 +21,7 @@
 import org.eclipse.statet.jcommons.lang.NonNullByDefault;
 import org.eclipse.statet.jcommons.lang.Nullable;
 
+import org.eclipse.statet.ecommons.preferences.core.PreferenceAccess;
 import org.eclipse.statet.ecommons.text.core.sections.DocContentSections;
 
 import org.eclipse.statet.ltk.model.core.impl.AbstractFilePersistenceSourceUnitFactory;
@@ -75,6 +76,9 @@
 		if (adapterType == RCoreAccess.class) {
 			return (T)getRCoreAccess();
 		}
+		if (adapterType == PreferenceAccess.class) {
+			return (T)getRCoreAccess().getPrefs();
+		}
 		return super.getAdapter(adapterType);
 	}
 	
diff --git a/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/rmodel/RFragmentSourceUnit.java b/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/rmodel/RFragmentSourceUnit.java
index 09be3ef..e22d2ea 100644
--- a/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/rmodel/RFragmentSourceUnit.java
+++ b/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/rmodel/RFragmentSourceUnit.java
@@ -19,6 +19,7 @@
 import org.eclipse.statet.jcommons.lang.NonNullByDefault;
 import org.eclipse.statet.jcommons.lang.Nullable;
 
+import org.eclipse.statet.ecommons.preferences.core.EPreferences;
 import org.eclipse.statet.ecommons.preferences.core.PreferenceAccess;
 import org.eclipse.statet.ecommons.text.core.sections.DocContentSections;
 
@@ -127,6 +128,9 @@
 		if (adapterType == RCoreAccess.class) {
 			return (T)this;
 		}
+		if (adapterType == PreferenceAccess.class) {
+			return (T)EPreferences.getInstancePrefs();
+		}
 		return super.getAdapter(adapterType);
 	}
 	
diff --git a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/REditorUriSourceUnit.java b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/REditorUriSourceUnit.java
index e07e376..2891170 100644
--- a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/REditorUriSourceUnit.java
+++ b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/REditorUriSourceUnit.java
@@ -20,6 +20,7 @@
 import org.eclipse.core.runtime.SubMonitor;
 
 import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
 
 import org.eclipse.statet.ecommons.text.core.sections.DocContentSections;
 
@@ -98,7 +99,18 @@
 	
 	@Override
 	public RCoreAccess getRCoreAccess() {
-		return RCore.WORKBENCH_ACCESS;
+		return RCore.getWorkbenchAccess();
 	}
 	
+	
+	@Override
+	@SuppressWarnings("unchecked")
+	public <T> @Nullable T getAdapter(final Class<T> adapterType) {
+		if (adapterType == RCoreAccess.class) {
+			return (T)getRCoreAccess();
+		}
+		return super.getAdapter(adapterType);
+	}
+	
+	
 }
diff --git a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/REditorWorkingCopy.java b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/REditorWorkingCopy.java
index 6aa5f8b..be7d833 100644
--- a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/REditorWorkingCopy.java
+++ b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/REditorWorkingCopy.java
@@ -66,4 +66,5 @@
 		return ((RSourceUnit)getUnderlyingUnit()).getRCoreAccess();
 	}
 	
+	
 }
diff --git a/redocs/org.eclipse.statet.redocs.tex.r/src/org/eclipse/statet/internal/redocs/tex/r/model/LtxRweaveEditorWorkingCopy.java b/redocs/org.eclipse.statet.redocs.tex.r/src/org/eclipse/statet/internal/redocs/tex/r/model/LtxRweaveEditorWorkingCopy.java
index f0754fa..472da13 100644
--- a/redocs/org.eclipse.statet.redocs.tex.r/src/org/eclipse/statet/internal/redocs/tex/r/model/LtxRweaveEditorWorkingCopy.java
+++ b/redocs/org.eclipse.statet.redocs.tex.r/src/org/eclipse/statet/internal/redocs/tex/r/model/LtxRweaveEditorWorkingCopy.java
@@ -80,14 +80,4 @@
 	}
 	
 	
-	@Override
-	@SuppressWarnings("unchecked")
-	public <T> @Nullable T getAdapter(final Class<T> adapterType) {
-		if (adapterType == RCoreAccess.class) {
-			return (T)getRCoreAccess();
-		}
-		return super.getAdapter(adapterType);
-	}
-	
-	
 }
diff --git a/redocs/org.eclipse.statet.redocs.tex.r/src/org/eclipse/statet/internal/redocs/tex/r/model/LtxRweaveResourceSourceUnit.java b/redocs/org.eclipse.statet.redocs.tex.r/src/org/eclipse/statet/internal/redocs/tex/r/model/LtxRweaveResourceSourceUnit.java
index 3a01ba0..f3f61ac 100644
--- a/redocs/org.eclipse.statet.redocs.tex.r/src/org/eclipse/statet/internal/redocs/tex/r/model/LtxRweaveResourceSourceUnit.java
+++ b/redocs/org.eclipse.statet.redocs.tex.r/src/org/eclipse/statet/internal/redocs/tex/r/model/LtxRweaveResourceSourceUnit.java
@@ -20,6 +20,7 @@
 import org.eclipse.statet.jcommons.lang.NonNullByDefault;
 import org.eclipse.statet.jcommons.lang.Nullable;
 
+import org.eclipse.statet.ecommons.preferences.core.PreferenceAccess;
 import org.eclipse.statet.ecommons.text.core.sections.DocContentSections;
 
 import org.eclipse.statet.docmlet.tex.core.TexCore;
@@ -72,6 +73,11 @@
 		return (rProject != null) ? rProject : RCore.WORKBENCH_ACCESS;
 	}
 	
+	public TexCoreAccess getTexCoreAccess() {
+		final var texProject= TexProjects.getTexProject(getResource().getProject());
+		return (texProject != null) ? texProject : TexCore.getWorkbenchAccess();
+	}
+	
 	
 	@Override
 	protected void register() {
@@ -108,8 +114,10 @@
 	@SuppressWarnings("unchecked")
 	public <T> @Nullable T getAdapter(final Class<T> adapterType) {
 		if (adapterType == TexCoreAccess.class) {
-			final var texProject= TexProjects.getTexProject(getResource().getProject());
-			return (texProject != null) ? (T)texProject : (T)TexCore.getWorkbenchAccess();
+			return (T)getTexCoreAccess();
+		}
+		if (adapterType == PreferenceAccess.class) {
+			return (T)getTexCoreAccess().getPrefs();
 		}
 		if (adapterType == RCoreAccess.class) {
 			return (T)getRCoreAccess();
diff --git a/redocs/org.eclipse.statet.redocs.wikitext.r/src/org/eclipse/statet/internal/redocs/wikitext/r/core/model/WikidocRweaveEditorWorkingCopy.java b/redocs/org.eclipse.statet.redocs.wikitext.r/src/org/eclipse/statet/internal/redocs/wikitext/r/core/model/WikidocRweaveEditorWorkingCopy.java
index bf6ee1c..fc3d895 100644
--- a/redocs/org.eclipse.statet.redocs.wikitext.r/src/org/eclipse/statet/internal/redocs/wikitext/r/core/model/WikidocRweaveEditorWorkingCopy.java
+++ b/redocs/org.eclipse.statet.redocs.wikitext.r/src/org/eclipse/statet/internal/redocs/wikitext/r/core/model/WikidocRweaveEditorWorkingCopy.java
@@ -80,14 +80,4 @@
 	}
 	
 	
-	@Override
-	@SuppressWarnings("unchecked")
-	public <T> @Nullable T getAdapter(final Class<T> adapterType) {
-		if (adapterType == RCoreAccess.class) {
-			return (T)getRCoreAccess();
-		}
-		return super.getAdapter(adapterType);
-	}
-	
-	
 }
diff --git a/redocs/org.eclipse.statet.redocs.wikitext.r/src/org/eclipse/statet/internal/redocs/wikitext/r/core/model/WikidocRweaveResourceSourceUnit.java b/redocs/org.eclipse.statet.redocs.wikitext.r/src/org/eclipse/statet/internal/redocs/wikitext/r/core/model/WikidocRweaveResourceSourceUnit.java
index 9dfa66c..37619ef 100644
--- a/redocs/org.eclipse.statet.redocs.wikitext.r/src/org/eclipse/statet/internal/redocs/wikitext/r/core/model/WikidocRweaveResourceSourceUnit.java
+++ b/redocs/org.eclipse.statet.redocs.wikitext.r/src/org/eclipse/statet/internal/redocs/wikitext/r/core/model/WikidocRweaveResourceSourceUnit.java
@@ -20,6 +20,7 @@
 import org.eclipse.statet.jcommons.lang.NonNullByDefault;
 import org.eclipse.statet.jcommons.lang.Nullable;
 
+import org.eclipse.statet.ecommons.preferences.core.PreferenceAccess;
 import org.eclipse.statet.ecommons.text.core.sections.DocContentSections;
 
 import org.eclipse.statet.docmlet.wikitext.core.WikitextCore;
@@ -72,6 +73,11 @@
 		return (rProject != null) ? rProject : RCore.WORKBENCH_ACCESS;
 	}
 	
+	public WikitextCoreAccess getWikitextCoreAccess() {
+		final var wikitextProject= WikitextProjects.getWikitextProject(getResource().getProject());
+		return (wikitextProject != null) ? wikitextProject : WikitextCore.getWorkbenchAccess();
+	}
+	
 	
 	@Override
 	protected void register() {
@@ -108,8 +114,10 @@
 	@SuppressWarnings("unchecked")
 	public <T> @Nullable T getAdapter(final Class<T> adapterType) {
 		if (adapterType == WikitextCoreAccess.class) {
-			final var wikitextProject= WikitextProjects.getWikitextProject(getResource().getProject());
-			return (wikitextProject != null) ? (T)wikitextProject : (T)WikitextCore.getWorkbenchAccess();
+			return (T)getWikitextCoreAccess();
+		}
+		if (adapterType == PreferenceAccess.class) {
+			return (T)getWikitextCoreAccess().getPrefs();
 		}
 		if (adapterType == RCoreAccess.class) {
 			return (T)getRCoreAccess();