Search in sources :

Example 1 with IEditedResourceProvider

use of org.eclipse.xtext.ui.editor.embedded.IEditedResourceProvider in project xtext-xtend by eclipse.

the class ExtractMethodUserInputPage method createSignaturePreview.

protected void createSignaturePreview(Composite composite) {
    Label previewLabel = new Label(composite, SWT.NONE);
    previewLabel.setText("Method signature preview:");
    GridData gridData = new GridData(SWT.FILL);
    gridData.horizontalSpan = 2;
    previewLabel.setLayoutData(gridData);
    signaturePreview = editorFactory.newEditor(new IEditedResourceProvider() {

        @Override
        public XtextResource createResource() {
            URI resourceURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(refactoring.getXtendClass()).trimFragment();
            IProject project = projectUtil.getProject(resourceURI);
            ResourceSet resourceSet = resourceSetProvider.get(project);
            return (XtextResource) resourceSet.getResource(resourceURI, true);
        }
    }).readOnly().withParent(composite);
    GridData gridData2 = new GridData(GridData.FILL_HORIZONTAL);
    gridData2.horizontalSpan = 2;
    signaturePreview.getViewer().getControl().setLayoutData(gridData2);
    partialEditor = signaturePreview.createPartialEditor(getPartialEditorModelPrefix(), refactoring.getMethodSignature(), getPartialEditorModelSuffix(), true);
}
Also used : IEditedResourceProvider(org.eclipse.xtext.ui.editor.embedded.IEditedResourceProvider) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) XtextResource(org.eclipse.xtext.resource.XtextResource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) IProject(org.eclipse.core.resources.IProject)

Aggregations

IProject (org.eclipse.core.resources.IProject)1 URI (org.eclipse.emf.common.util.URI)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 GridData (org.eclipse.swt.layout.GridData)1 Label (org.eclipse.swt.widgets.Label)1 XtextResource (org.eclipse.xtext.resource.XtextResource)1 IEditedResourceProvider (org.eclipse.xtext.ui.editor.embedded.IEditedResourceProvider)1