Search in sources :

Example 1 with ContextElementAdapter

use of org.yakindu.sct.model.sgraph.util.ContextElementAdapter in project statecharts by Yakindu.

the class AbstractEditorPropertySection method enableXtext.

protected void enableXtext(Control styledText, Injector injector) {
    final StyledTextXtextAdapter xtextAdapter = new StyledTextXtextAdapter(injector);
    xtextAdapter.getFakeResourceContext().getFakeResource().eAdapters().add(new ContextElementAdapter(this));
    xtextAdapter.adapt((StyledText) styledText);
    initContextMenu(styledText);
    completionProposalAdapter = new CompletionProposalAdapter(styledText, xtextAdapter.getContentAssistant(), KeyStroke.getInstance(SWT.CTRL, SWT.SPACE), null);
}
Also used : CompletionProposalAdapter(org.yakindu.base.xtext.utils.jface.fieldassist.CompletionProposalAdapter) StyledTextXtextAdapter(org.yakindu.base.xtext.utils.jface.viewers.StyledTextXtextAdapter) ContextElementAdapter(org.yakindu.sct.model.sgraph.util.ContextElementAdapter)

Example 2 with ContextElementAdapter

use of org.yakindu.sct.model.sgraph.util.ContextElementAdapter in project statecharts by Yakindu.

the class SCTResourceTest method setUp.

@Before
public void setUp() throws Exception {
    Injector injector = STextActivator.getInstance().getInjector(STextActivator.ORG_YAKINDU_SCT_MODEL_STEXT_STEXT);
    ResourceSet resourceSet = new ResourceSetImpl();
    res = new StextResource(URI.createURI("test.test"));
    res.eAdapters().add(new ContextElementAdapter(new IContextElementProvider() {

        public EObject getContextObject() {
            return res.getContents().get(0);
        }
    }));
    resourceSet.getResources().add(res);
    injector.injectMembers(res);
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) StextResource(org.yakindu.sct.model.stext.resource.StextResource) Injector(com.google.inject.Injector) IContextElementProvider(org.yakindu.sct.model.sgraph.util.ContextElementAdapter.IContextElementProvider) ContextElementAdapter(org.yakindu.sct.model.sgraph.util.ContextElementAdapter) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) Before(org.junit.Before)

Example 3 with ContextElementAdapter

use of org.yakindu.sct.model.sgraph.util.ContextElementAdapter in project statecharts by Yakindu.

the class StatechartDefinitionSection method getXtextResourceProvider.

protected IEditedResourceProvider getXtextResourceProvider(Injector injector) {
    return new IEditedResourceProvider() {

        @Override
        public XtextResource createResource() {
            XtextFakeResourceContext resource = new XtextFakeResourceContext(injector);
            xtextResource = resource.getFakeResource();
            xtextResource.eAdapters().add(new ContextElementAdapter(StatechartDefinitionSection.this));
            return xtextResource;
        }
    };
}
Also used : IEditedResourceProvider(org.eclipse.xtext.ui.editor.embedded.IEditedResourceProvider) ContextElementAdapter(org.yakindu.sct.model.sgraph.util.ContextElementAdapter) XtextFakeResourceContext(org.yakindu.base.xtext.utils.jface.viewers.context.XtextFakeResourceContext)

Example 4 with ContextElementAdapter

use of org.yakindu.sct.model.sgraph.util.ContextElementAdapter in project statecharts by Yakindu.

the class STextExpressionParser method getResource.

public StextResource getResource() {
    final StextResource resource = new StextResource();
    injector.injectMembers(resource);
    resource.eAdapters().add(new ContextElementAdapter(new ContextElementAdapter.IContextElementProvider() {

        public EObject getContextObject() {
            return (EObject) EcoreUtil.getObjectByType(resource.getContents(), SGraphPackage.Literals.STATECHART);
        }
    }));
    ResourceSet set = new ResourceSetImpl();
    set.getResources().add(resource);
    return resource;
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) StextResource(org.yakindu.sct.model.stext.resource.StextResource) EObject(org.eclipse.emf.ecore.EObject) ContextElementAdapter(org.yakindu.sct.model.sgraph.util.ContextElementAdapter) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet)

Aggregations

ContextElementAdapter (org.yakindu.sct.model.sgraph.util.ContextElementAdapter)4 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)2 StextResource (org.yakindu.sct.model.stext.resource.StextResource)2 Injector (com.google.inject.Injector)1 EObject (org.eclipse.emf.ecore.EObject)1 IEditedResourceProvider (org.eclipse.xtext.ui.editor.embedded.IEditedResourceProvider)1 Before (org.junit.Before)1 CompletionProposalAdapter (org.yakindu.base.xtext.utils.jface.fieldassist.CompletionProposalAdapter)1 StyledTextXtextAdapter (org.yakindu.base.xtext.utils.jface.viewers.StyledTextXtextAdapter)1 XtextFakeResourceContext (org.yakindu.base.xtext.utils.jface.viewers.context.XtextFakeResourceContext)1 IContextElementProvider (org.yakindu.sct.model.sgraph.util.ContextElementAdapter.IContextElementProvider)1