Search in sources :

Example 36 with URI

use of org.eclipse.emf.common.util.URI in project Palladio-Editors-Sirius by PalladioSimulator.

the class NewPalladioProjectWizard method computeTemplatePath.

private URI computeTemplatePath(final AT selectedTemplate) {
    final URI templateFolderURI = getRootURI(selectedTemplate).appendSegment(INITIATOR_TEMPLATES_FOLDER);
    final String[] segments = URI.createURI(selectedTemplate.getDefaultInstanceURI()).segments();
    return templateFolderURI.appendSegments(segments);
}
Also used : URI(org.eclipse.emf.common.util.URI)

Example 37 with URI

use of org.eclipse.emf.common.util.URI in project Palladio-Editors-Sirius by PalladioSimulator.

the class ResourceSelectorPage method getResult.

protected EObject getResult(Session session) {
    EObject result = null;
    URI uri = URI.createURI(path, true);
    TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
    ResourceSet resourceSet = domain.getResourceSet();
    try {
        Resource resource = resourceSet.getResource(uri, true);
        result = (EObject) resource.getContents().get(0);
    } catch (WrappedException ex) {
    // do nothing
    }
    return result;
}
Also used : WrappedException(org.eclipse.emf.common.util.WrappedException) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI)

Example 38 with URI

use of org.eclipse.emf.common.util.URI in project xtext-xtend by eclipse.

the class XtendQuickfixProvider method getExceptions.

/**
 * @param all but the last element in the issue data is considered to be a URI to an exception type.
 */
protected List<JvmType> getExceptions(String[] issueData, XtextResource resource) {
    List<JvmType> exceptions = Lists.newArrayList();
    for (int i = 0; i < issueData.length - 1; i++) {
        URI exceptionURI = URI.createURI(issueData[i]);
        EObject exception = resource.getResourceSet().getEObject(exceptionURI, true);
        if (exception instanceof JvmType) {
            exceptions.add((JvmType) exception);
        }
    }
    return exceptions;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) JvmType(org.eclipse.xtext.common.types.JvmType) URI(org.eclipse.emf.common.util.URI)

Example 39 with URI

use of org.eclipse.emf.common.util.URI in project xtext-xtend by eclipse.

the class DispatchMethodRenameStrategy method initialize.

@Override
public boolean initialize(EObject xtendMethod, IRenameElementContext context) {
    Assert.isLegal(xtendMethod instanceof XtendFunction);
    Assert.isLegal(((XtendFunction) xtendMethod).isDispatch());
    Assert.isLegal(context instanceof DispatchMethodRenameContext);
    ResourceSet resourceSet = xtendMethod.eResource().getResourceSet();
    Map<URI, IJavaElement> jvm2JavaElements = ((DispatchMethodRenameContext) context).getJvm2JavaElements();
    for (URI dispatchOperationURI : jvm2JavaElements.keySet()) {
        JvmOperation dispatchOperation = (JvmOperation) resourceSet.getEObject(dispatchOperationURI, true);
        XtendFunction xtendDispatchMethod = associations.getXtendFunction(dispatchOperation);
        if (xtendDispatchMethod != null) {
            if (equal(xtendDispatchMethod.getName(), dispatchOperation.getSimpleName())) {
                // synthetic dispatcher
                dispatchers.add(dispatchOperation);
            } else {
                // xtend dispatch method
                XtendDispatchMethodChildStrategy xtendChildStrategy = childStrategyProvider.get();
                xtendChildStrategy.initialize(xtendDispatchMethod, context);
                children.add(xtendChildStrategy);
            }
        } else {
            // a dispatch method form a Java class
            JavaDispatchMethodChildStrategy jvmChildStrategy = javaStrategyProvider.get();
            jvmChildStrategy.initialize(dispatchOperation, context);
            children.add(jvmChildStrategy);
        }
    }
    return !children.isEmpty();
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) IJavaElement(org.eclipse.jdt.core.IJavaElement) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI)

Example 40 with URI

use of org.eclipse.emf.common.util.URI 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

URI (org.eclipse.emf.common.util.URI)305 Resource (org.eclipse.emf.ecore.resource.Resource)85 Test (org.junit.Test)79 EObject (org.eclipse.emf.ecore.EObject)55 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)37 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)33 XtextResource (org.eclipse.xtext.resource.XtextResource)32 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)26 BuildRequest (org.eclipse.xtext.build.BuildRequest)23 File (java.io.File)20 AbstractIncrementalBuilderTest (org.eclipse.xtext.testing.builder.AbstractIncrementalBuilderTest)20 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)19 IOException (java.io.IOException)18 InternalEObject (org.eclipse.emf.ecore.InternalEObject)18 EPackage (org.eclipse.emf.ecore.EPackage)15 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)15 InputStream (java.io.InputStream)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13 ArrayList (java.util.ArrayList)13 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)13