浏览代码

refactored xtext gmf/jface utils to ease extensibility (no semantic change) (#1630)

* refactored xtext gmf/jface utils to ease extensibility (no semantic change)

* added handling of URIEditorInput (as used by Sirius) to ActiveEditorTracker

* implemented changes proposed by @andreasmuelder (better way to retrieve the project from an URI)
enikao 7 年之前
父节点
当前提交
18f7dc1878

+ 4 - 4
plugins/org.yakindu.base.xtext.utils.gmf/src/org/yakindu/base/xtext/utils/gmf/viewers/XtextStyledTextCellEditorEx.java

@@ -47,18 +47,18 @@ public class XtextStyledTextCellEditorEx extends XtextStyledTextCellEditor {
 	 *            Value to set the cell editor to.
 	 * 
 	 *            Note: This happens address defect RATLC00522324. For our
-	 *            topgraphical edit parts we delagate the direct edit request to
+	 *            topgraphical edit parts we delegate the direct edit request to
 	 *            a primary edit part and set focus on that. The issue is that
 	 *            if the user has typed in an initial character when setting
 	 *            focus to the edit part, which typically is a
-	 *            TextCompartmentEditPart then setting that intial value does
+	 *            TextCompartmentEditPart then setting that initial value does
 	 *            not fire the necessary change events that need to occur in
-	 *            order for that value to be recongnized. If you don't use this
+	 *            order for that value to be recognized. If you don't use this
 	 *            method then the result is that if you just type in the initial
 	 *            character and that is it then the text compartment loses focus
 	 *            then the value will not be saved. This is because setting the
 	 *            value of the cell doesn't think its value has changed since
-	 *            the first character is not recongized as a change.
+	 *            the first character is not recognized as a change.
 	 */
 	public void setValueAndProcessEditOccured(Object value) {
 		setValue(value);

+ 120 - 77
plugins/org.yakindu.base.xtext.utils.jface/src/org/yakindu/base/xtext/utils/jface/viewers/StyledTextXtextAdapter.java

@@ -12,12 +12,7 @@ package org.yakindu.base.xtext.utils.jface.viewers;
 
 import java.util.List;
 
-import org.eclipse.core.internal.jobs.JobManager;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.jface.bindings.keys.KeyStroke;
 import org.eclipse.jface.fieldassist.ControlDecoration;
@@ -84,12 +79,7 @@ import com.google.inject.Provider;
  */
 @SuppressWarnings("restriction")
 public class StyledTextXtextAdapter {
-
-	protected XtextSourceViewer sourceviewer;
-
-	private ValidationJob validationJob;
-
-	private IssueResolutionProvider resolutionProvider = new IssueResolutionProvider.NullImpl();
+	
 	@Inject
 	private IPreferenceStoreAccess preferenceStoreAccess;
 	@Inject
@@ -104,8 +94,15 @@ public class StyledTextXtextAdapter {
 	private Provider<IDocumentPartitioner> documentPartitioner;
 	@Inject
 	private XtextDocument document;
-	private XtextFakeResourceContext fakeResourceContext;
+
+	private final IssueResolutionProvider resolutionProvider = new IssueResolutionProvider.NullImpl();
 	private final IXtextFakeContextResourcesProvider contextFakeResourceProvider;
+	private final XtextFakeResourceContext fakeResourceContext;
+
+	private XtextSourceViewer sourceviewer;
+
+	private ValidationJob validationJob;
+
 
 	private StyledText styledText;
 
@@ -118,7 +115,7 @@ public class StyledTextXtextAdapter {
 		injector.injectMembers(this);
 
 		// create fake resource and containing resource set
-		createFakeResourceContext(injector);
+		this.fakeResourceContext = createFakeResourceContext(injector);
 	}
 
 	public StyledTextXtextAdapter(Injector injector) {
@@ -132,20 +129,22 @@ public class StyledTextXtextAdapter {
 		updateFakeResourceContext();
 
 		// connect Xtext document to fake resource
-		initXtextDocument(fakeResourceContext);
+		initXtextDocument(getFakeResourceContext());
 
 		// connect xtext document to xtext source viewer
-		createXtextSourceViewer();
+		this.sourceviewer = createXtextSourceViewer();
+		this.decorationSupport = createSourceViewerDecorationSupport();
+		configureSourceViewerDecorationSupport(getDecorationSupport());
 
 		// install semantic highlighting support
 		installHighlightingHelper();
 
-		validationJob = createValidationJob();
-		document.setValidationJob(validationJob);
+		this.validationJob = createValidationJob();
+		getXtextDocument().setValidationJob(getValidationJob());
 
 		styledText.setData(StyledTextXtextAdapter.class.getCanonicalName(), this);
 
-		final IContentAssistant contentAssistant = sourceviewer.getContentAssistant();
+		final IContentAssistant contentAssistant = getXtextSourceviewer().getContentAssistant();
 		final CompletionProposalAdapter completionProposalAdapter = new CompletionProposalAdapter(styledText,
 				contentAssistant, KeyStroke.getInstance(SWT.CTRL, SWT.SPACE), null);
 
@@ -173,7 +172,7 @@ public class StyledTextXtextAdapter {
 		service.addFocusTracker(styledText, StyledText.class.getCanonicalName());
 
 		// add JDT Style code completion hint decoration
-		createContentAssistDecoration(styledText);
+		this.decoration = createContentAssistDecoration(styledText);
 
 		initSelectionProvider();
 	}
@@ -187,53 +186,52 @@ public class StyledTextXtextAdapter {
 			XtextStyledTextSelectionProvider xtextStyledTextSelectionProvider = new XtextStyledTextSelectionProvider();
 			ChangeSelectionProviderOnFocusGain listener = new ChangeSelectionProviderOnFocusGain(site,
 					xtextStyledTextSelectionProvider);
-			styledText.addFocusListener(listener);
-			styledText.addDisposeListener(listener);
+			getStyledText().addFocusListener(listener);
+			getStyledText().addDisposeListener(listener);
 		} catch (NullPointerException ex) {
 			// Do nothing, not opened within editor context
 		}
 
 	}
 
-	private void createContentAssistDecoration(StyledText styledText) {
-		decoration = new ControlDecoration(styledText, SWT.TOP | SWT.LEFT);
-		decoration.setShowHover(true);
-		decoration.setShowOnlyOnFocus(true);
+	private ControlDecoration createContentAssistDecoration(StyledText styledText) {
+		final ControlDecoration result = new ControlDecoration(styledText, SWT.TOP | SWT.LEFT);
+		result.setShowHover(true);
+		result.setShowOnlyOnFocus(true);
 
 		final Image image = ImageDescriptor
 				.createFromFile(XtextStyledTextCellEditor.class, "images/content_assist_cue.gif").createImage();
-		decoration.setImage(image);
-		decoration.setDescriptionText("Content Assist Available (CTRL + Space)");
-		decoration.setMarginWidth(2);
+		result.setImage(image);
+		result.setDescriptionText("Content Assist Available (CTRL + Space)");
+		result.setMarginWidth(2);
 		styledText.addDisposeListener(new DisposeListener() {
 			public void widgetDisposed(DisposeEvent e) {
-				if (decoration != null) {
-					decoration.dispose();
+				if (getDecoration() != null) {
+					getDecoration().dispose();
 				}
 				if (image != null) {
 					image.dispose();
 				}
 			}
 		});
+		return result;
 	}
 
 	protected ValidationJob createValidationJob() {
-		return new ValidationJob(validator, document,
-				new AnnotationIssueProcessor(document, sourceviewer.getAnnotationModel(), resolutionProvider),
+		return new ValidationJob(getValidator(), getXtextDocument(),
+				new AnnotationIssueProcessor(getXtextDocument(), getXtextSourceviewer().getAnnotationModel(), getResolutionProvider()),
 				CheckMode.FAST_ONLY);
 	}
 
-	protected void createFakeResourceContext(Injector injector) {
-		this.fakeResourceContext = new XtextFakeResourceContext(injector);
+	protected XtextFakeResourceContext createFakeResourceContext(Injector injector) {
+		return new XtextFakeResourceContext(injector);
 	}
 
-	protected void createXtextSourceViewer() {
-		sourceviewer = new XtextSourceViewerEx(styledText, preferenceStoreAccess.getPreferenceStore());
-		sourceviewer.configure(configuration);
-		sourceviewer.setDocument(document, new AnnotationModel());
-		decorationSupport = new SourceViewerDecorationSupport(sourceviewer, null, new DefaultMarkerAnnotationAccess(),
-				getSharedColors());
-		configureSourceViewerDecorationSupport(decorationSupport);
+	protected XtextSourceViewer createXtextSourceViewer() {
+		final XtextSourceViewer result = new XtextSourceViewerEx(getStyledText(), getPreferenceStoreAccess().getPreferenceStore());
+		result.configure(getXtextSourceViewerConfiguration());
+		result.setDocument(getXtextDocument(), new AnnotationModel());
+		return result;
 	}
 
 	protected ISharedTextColors getSharedColors() {
@@ -252,11 +250,11 @@ public class StyledTextXtextAdapter {
 			support.setAnnotationPreference(annotationPreference);
 		}
 
-		support.setCharacterPairMatcher(characterPairMatcher);
+		support.setCharacterPairMatcher(getCharacterPairMatcher());
 		support.setMatchingCharacterPainterPreferenceKeys(BracketMatchingPreferencesInitializer.IS_ACTIVE_KEY,
 				BracketMatchingPreferencesInitializer.COLOR_KEY);
 
-		support.install(preferenceStoreAccess.getPreferenceStore());
+		support.install(getPreferenceStoreAccess().getPreferenceStore());
 	}
 
 	protected void unconfigureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
@@ -264,54 +262,54 @@ public class StyledTextXtextAdapter {
 	}
 
 	protected void initXtextDocument(XtextFakeResourceContext context) {
-		document.setInput(context.getFakeResource());
-		IDocumentPartitioner partitioner = documentPartitioner.get();
-		partitioner.connect(document);
-		document.setDocumentPartitioner(partitioner);
+		getXtextDocument().setInput(context.getFakeResource());
+		IDocumentPartitioner partitioner = getDocumentPartitioner().get();
+		partitioner.connect(getXtextDocument());
+		getXtextDocument().setDocumentPartitioner(partitioner);
 	}
 
 	public void setVisibleRegion(int start, int length) {
-		sourceviewer.setVisibleRegion(start, length);
+		getXtextSourceviewer().setVisibleRegion(start, length);
 	}
 
 	public void resetVisibleRegion() {
-		sourceviewer.resetVisibleRegion();
+		getXtextSourceviewer().resetVisibleRegion();
 	}
 
 	private void installHighlightingHelper() {
-		if (xtextStyledTextHighlightingHelper != null) {
-			xtextStyledTextHighlightingHelper.install(this, sourceviewer);
+		if (getXtextStyledTextHighlightingHelper() != null) {
+			getXtextStyledTextHighlightingHelper().install(this, getXtextSourceviewer());
 		}
 	}
 
 	private void uninstallHighlightingHelper() {
-		if (xtextStyledTextHighlightingHelper != null) {
-			xtextStyledTextHighlightingHelper.uninstall();
+		if (getXtextStyledTextHighlightingHelper() != null) {
+			getXtextStyledTextHighlightingHelper().uninstall();
 		}
 	}
 
 	public void dispose() {
-		document.setOutdated(true);
-		if (decorationSupport != null) {
-			unconfigureSourceViewerDecorationSupport(decorationSupport);
+		getXtextDocument().setOutdated(true);
+		if (getDecorationSupport() != null) {
+			unconfigureSourceViewerDecorationSupport(getDecorationSupport());
 		}
 		uninstallHighlightingHelper();
 	}
 
 	protected XtextSourceViewerConfiguration getXtextSourceViewerConfiguration() {
-		return configuration;
+		return this.configuration;
 	}
 
 	protected XtextDocument getXtextDocument() {
-		return document;
+		return this.document;
 	}
 
 	protected XtextSourceViewer getXtextSourceviewer() {
-		return sourceviewer;
+		return this.sourceviewer;
 	}
 
 	public IParseResult getXtextParseResult() {
-		return document.readOnly(new IUnitOfWork<IParseResult, XtextResource>() {
+		return getXtextDocument().readOnly(new IUnitOfWork<IParseResult, XtextResource>() {
 
 			public IParseResult exec(XtextResource state) throws Exception {
 				return state.getParseResult();
@@ -324,23 +322,68 @@ public class StyledTextXtextAdapter {
 	}
 
 	public List<Issue> getXtextValidationIssues() {
-		return validationJob.createIssues(new NullProgressMonitor());
+		return getValidationJob().createIssues(new NullProgressMonitor());
 	}
 
 	public void updateFakeResourceContext() {
-		fakeResourceContext.updateFakeResourceContext(contextFakeResourceProvider);
+		getFakeResourceContext().updateFakeResourceContext(getFakeResourceContextProvider());
 	}
 
 	protected IXtextFakeContextResourcesProvider getFakeResourceContextProvider() {
-		return contextFakeResourceProvider;
+		return this.contextFakeResourceProvider;
 	}
 
 	public XtextFakeResourceContext getFakeResourceContext() {
-		return fakeResourceContext;
+		return this.fakeResourceContext;
+	}
+
+	protected SourceViewerDecorationSupport createSourceViewerDecorationSupport() {
+		return new SourceViewerDecorationSupport(getXtextSourceviewer(), null, new DefaultMarkerAnnotationAccess(),
+				getSharedColors());
+	}
+
+	protected ValidationJob getValidationJob() {
+		return this.validationJob;
+	}
+
+	protected IssueResolutionProvider getResolutionProvider() {
+		return this.resolutionProvider;
+	}
+
+	protected StyledText getStyledText() {
+		return this.styledText;
+	}
+
+	protected ControlDecoration getDecoration() {
+		return this.decoration;
+	}
+
+	protected SourceViewerDecorationSupport getDecorationSupport() {
+		return this.decorationSupport;
+	}
+
+	protected IResourceValidator getValidator() {
+		return this.validator;
+	}
+
+	protected IPreferenceStoreAccess getPreferenceStoreAccess() {
+		return this.preferenceStoreAccess;
+	}
+
+	protected ICharacterPairMatcher getCharacterPairMatcher() {
+		return this.characterPairMatcher;
+	}
+
+	protected Provider<IDocumentPartitioner> getDocumentPartitioner() {
+		return this.documentPartitioner;
 	}
 
-	private class XtextStyledTextSelectionProvider implements ISelectionProvider {
+	protected XtextStyledTextHighlightingHelper getXtextStyledTextHighlightingHelper() {
+		return this.xtextStyledTextHighlightingHelper;
+	}
 
+	protected class XtextStyledTextSelectionProvider implements ISelectionProvider {
+		
 		public void setSelection(ISelection selection) {
 		}
 
@@ -351,9 +394,9 @@ public class StyledTextXtextAdapter {
 		}
 
 		public ISelection getSelection() {
-			if (styledText.isDisposed())
+			if (getStyledText().isDisposed())
 				return StructuredSelection.EMPTY;
-			int offset = styledText.getCaretOffset() - 1;
+			int offset = getStyledText().getCaretOffset() - 1;
 			XtextResource fakeResource = StyledTextXtextAdapter.this.getFakeResourceContext().getFakeResource();
 			IParseResult parseResult = fakeResource.getParseResult();
 			if (parseResult == null)
@@ -368,11 +411,11 @@ public class StyledTextXtextAdapter {
 		}
 	}
 
-	private class ChangeSelectionProviderOnFocusGain implements FocusListener, DisposeListener {
+	protected class ChangeSelectionProviderOnFocusGain implements FocusListener, DisposeListener {
 
-		private ISelectionProvider selectionProviderOnFocusGain;
-		private ISelectionProvider selectionProviderOnFocusLost;
-		private IWorkbenchPartSite site;
+		protected ISelectionProvider selectionProviderOnFocusGain;
+		protected ISelectionProvider selectionProviderOnFocusLost;
+		protected IWorkbenchPartSite site;
 
 		public ChangeSelectionProviderOnFocusGain(IWorkbenchPartSite site,
 				ISelectionProvider selectionProviderOnFocusGain) {
@@ -381,19 +424,19 @@ public class StyledTextXtextAdapter {
 		}
 
 		public void focusLost(FocusEvent e) {
-			if (selectionProviderOnFocusLost != null) {
-				site.setSelectionProvider(selectionProviderOnFocusLost);
+			if (this.selectionProviderOnFocusLost != null) {
+				this.site.setSelectionProvider(this.selectionProviderOnFocusLost);
 			}
 		}
 
 		public void focusGained(FocusEvent e) {
-			selectionProviderOnFocusLost = site.getSelectionProvider();
-			site.setSelectionProvider(selectionProviderOnFocusGain);
+			this.selectionProviderOnFocusLost = this.site.getSelectionProvider();
+			this.site.setSelectionProvider(this.selectionProviderOnFocusGain);
 		}
 
 		public void widgetDisposed(DisposeEvent e) {
-			if (selectionProviderOnFocusLost != null) {
-				site.setSelectionProvider(selectionProviderOnFocusLost);
+			if (this.selectionProviderOnFocusLost != null) {
+				this.site.setSelectionProvider(this.selectionProviderOnFocusLost);
 			}
 			((StyledText) e.getSource()).removeFocusListener(this);
 			((StyledText) e.getSource()).removeDisposeListener(this);

+ 4 - 4
plugins/org.yakindu.base.xtext.utils.jface/src/org/yakindu/base/xtext/utils/jface/viewers/XtextSourceViewerEx.java

@@ -30,7 +30,7 @@ import org.eclipse.xtext.ui.editor.XtextSourceViewer;
  * @author alexander.nyssen@itemis.de
  * 
  */
-class XtextSourceViewerEx extends XtextSourceViewer {
+public class XtextSourceViewerEx extends XtextSourceViewer {
 
 	private final StyledText styledText;
 	private final IPreferenceStore preferenceStore;
@@ -53,7 +53,7 @@ class XtextSourceViewerEx extends XtextSourceViewer {
 
 	@Override
 	protected StyledText createTextWidget(Composite parent, int styles) {
-		return styledText;
+		return this.styledText;
 	}
 
 	/**
@@ -99,7 +99,7 @@ class XtextSourceViewerEx extends XtextSourceViewer {
 			declaredField = TextSourceViewerConfiguration.class
 					.getDeclaredField("fPreferenceStore");
 			declaredField.setAccessible(true);
-			declaredField.set(configuration, preferenceStore);
+			declaredField.set(configuration, this.preferenceStore);
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
@@ -112,7 +112,7 @@ class XtextSourceViewerEx extends XtextSourceViewer {
 	 * @param value
 	 *            the new value.
 	 */
-	private void setPrivateHandleProjectionChangesField(boolean value) {
+	protected void setPrivateHandleProjectionChangesField(boolean value) {
 		try {
 			Field declaredField = ProjectionViewer.class
 					.getDeclaredField("fHandleProjectionChanges");

+ 51 - 23
plugins/org.yakindu.base.xtext.utils.jface/src/org/yakindu/base/xtext/utils/jface/viewers/XtextStyledTextCellEditor.java

@@ -55,7 +55,7 @@ import com.google.inject.Injector;
  */
 public class XtextStyledTextCellEditor extends StyledTextCellEditor {
 
-	private Injector injector;
+	private final Injector injector;
 	private StyledTextXtextAdapter xtextAdapter;
 	private IXtextFakeContextResourcesProvider contextFakeResourceProvider;
 	private final static String CONTEXTMENUID = "org.yakindu.base.xtext.utils.jface.viewers.StyledTextXtextAdapterContextMenu";
@@ -86,20 +86,17 @@ public class XtextStyledTextCellEditor extends StyledTextCellEditor {
 		});
 
 		// adapt to xtext
-		xtextAdapter = new StyledTextXtextAdapter(injector,
-				contextFakeResourceProvider == null ? IXtextFakeContextResourcesProvider.NULL_CONTEXT_PROVIDER
-						: contextFakeResourceProvider);
-		xtextAdapter.adapt(styledText);
+		this.xtextAdapter = createXtextAdapter();
+		getXtextAdapter().adapt(styledText);
 
 		// configure content assist
-		final IContentAssistant contentAssistant = xtextAdapter.getContentAssistant();
+		final IContentAssistant contentAssistant = getXtextAdapter().getContentAssistant();
 
-		completionProposalAdapter = new CompletionProposalAdapter(styledText, contentAssistant, KeyStroke.getInstance(
-				SWT.CTRL, SWT.SPACE), null);
+		this.completionProposalAdapter = createCompletionProposalAdapter(styledText, contentAssistant);
 
 		// This listener notifies the modification, when text is selected via
 		// proposal. A ModifyEvent is not thrown by the StyledText in this case.
-		xtextAdapter.getXtextSourceviewer().addTextListener(new ITextListener() {
+		getXtextAdapter().getXtextSourceviewer().addTextListener(new ITextListener() {
 			public void textChanged(TextEvent event) {
 				editOccured(null);
 			}
@@ -112,7 +109,7 @@ public class XtextStyledTextCellEditor extends StyledTextCellEditor {
 			// event early enough!
 			styledText.addListener(3005, new Listener() {
 				public void handleEvent(Event event) {
-					if (event.character == SWT.CR && !completionProposalAdapter.isProposalPopupOpen()) {
+					if (event.character == SWT.CR && !getCompletionProposalAdapter().isProposalPopupOpen()) {
 						focusLost();
 					}
 				}
@@ -121,7 +118,7 @@ public class XtextStyledTextCellEditor extends StyledTextCellEditor {
 		styledText.addListener(3005, new Listener() {
 			public void handleEvent(Event event) {
 				if (event.character == '\u001b' // ESC
-						&& !completionProposalAdapter.isProposalPopupOpen()) {
+						&& !getCompletionProposalAdapter().isProposalPopupOpen()) {
 					XtextStyledTextCellEditor.this.fireCancelEditor();
 				}
 			}
@@ -155,9 +152,9 @@ public class XtextStyledTextCellEditor extends StyledTextCellEditor {
 	@Override
 	protected void doSetValue(Object value) {
 		super.doSetValue(value);
-		// Reset the undo manager to prevend deletion of complete text if the
+		// Reset the undo manager to prevent deletion of complete text if the
 		// user hits ctrl+z after cell editor opens
-		xtextAdapter.sourceviewer.getUndoManager().reset();
+		getXtextAdapter().getXtextSourceviewer().getUndoManager().reset();
 	}
 
 	@Override
@@ -167,7 +164,7 @@ public class XtextStyledTextCellEditor extends StyledTextCellEditor {
 
 	@Override
 	public void performUndo() {
-		xtextAdapter.sourceviewer.getUndoManager().undo();
+		getXtextAdapter().getXtextSourceviewer().getUndoManager().undo();
 	}
 
 	@Override
@@ -177,7 +174,7 @@ public class XtextStyledTextCellEditor extends StyledTextCellEditor {
 
 	@Override
 	public void performRedo() {
-		xtextAdapter.sourceviewer.getUndoManager().redo();
+		getXtextAdapter().getXtextSourceviewer().getUndoManager().redo();
 	}
 
 	@Override
@@ -197,24 +194,25 @@ public class XtextStyledTextCellEditor extends StyledTextCellEditor {
 	@Override
 	protected void focusLost() {
 		if (SWT.getPlatform().equals("gtk")) {
-			if (ignoreNextFocusLost) {
-				ignoreNextFocusLost = false;
+			if (isIgnoreNextFocusLost()) {
+				setIgnoreNextFocusLost(false);
 				return;
 			}
 
-			if (completionProposalAdapter.isProposalPopupOpen()) {
-				ignoreNextFocusLost = true;
+			if (getCompletionProposalAdapter().isProposalPopupOpen()) {
+				setIgnoreNextFocusLost(true);
 				return;
 			}
 		}
 
-		if (!completionProposalAdapter.isProposalPopupOpen())
+		if (!getCompletionProposalAdapter().isProposalPopupOpen()) {
 			super.focusLost();
+		}
 	}
 
 	@Override
 	public void dispose() {
-		xtextAdapter.dispose();
+		getXtextAdapter().dispose();
 		super.dispose();
 	}
 
@@ -228,11 +226,41 @@ public class XtextStyledTextCellEditor extends StyledTextCellEditor {
 	}
 
 	public void setVisibleRegion(int start, int length) {
-		xtextAdapter.setVisibleRegion(start, length);
+		getXtextAdapter().setVisibleRegion(start, length);
 	}
 	
 	public StyledTextXtextAdapter getXtextAdapter() {
-		return xtextAdapter;
+		return this.xtextAdapter;
+	}
+
+	protected CompletionProposalAdapter getCompletionProposalAdapter() {
+		return this.completionProposalAdapter;
+	}
+
+	protected IXtextFakeContextResourcesProvider getContextFakeResourceProvider() {
+		return this.contextFakeResourceProvider;
+	}
+
+	protected CompletionProposalAdapter createCompletionProposalAdapter(StyledText styledText, final IContentAssistant contentAssistant) {
+		return new CompletionProposalAdapter(styledText, contentAssistant, KeyStroke.getInstance(
+				SWT.CTRL, SWT.SPACE), null);
+	}
+
+	protected StyledTextXtextAdapter createXtextAdapter() {
+		return new StyledTextXtextAdapter(this.getInjector(),
+				getContextFakeResourceProvider() == null ? IXtextFakeContextResourcesProvider.NULL_CONTEXT_PROVIDER
+						: getContextFakeResourceProvider());
+	}
+
+	protected boolean isIgnoreNextFocusLost() {
+		return this.ignoreNextFocusLost;
+	}
+
+	protected void setIgnoreNextFocusLost(boolean ignoreNextFocusLost) {
+		this.ignoreNextFocusLost = ignoreNextFocusLost;
 	}
 
+	protected Injector getInjector() {
+		return this.injector;
+	}
 }

+ 9 - 0
plugins/org.yakindu.base.xtext.utils.jface/src/org/yakindu/base/xtext/utils/jface/viewers/util/ActiveEditorTracker.java

@@ -15,6 +15,9 @@ import java.util.Map;
 import java.util.Map.Entry;
 
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.resource.ResourceSet;
 import org.eclipse.emf.edit.domain.EditingDomain;
 import org.eclipse.emf.edit.domain.IEditingDomainProvider;
@@ -150,6 +153,12 @@ public class ActiveEditorTracker implements IPageListener, IPartListener,
 		if (editorInput instanceof IFileEditorInput) {
 			final IFileEditorInput input = (IFileEditorInput) editorInput;
 			return input.getFile().getProject();
+		} else if (editorInput instanceof URIEditorInput) {
+			final URI uri = ((URIEditorInput) editorInput).getURI();
+			if (uri.isPlatformResource()) {
+				final String platformString = uri.toPlatformString(true);
+				return ResourcesPlugin.getWorkspace().getRoot().findMember(platformString).getProject();
+			}
 		}
 		return null;
 	}