@Override
  protected URI createScriptUri(String scriptName) {
    if (myUseFilename) {
      return URI.createPlatformPluginURI(
          "/"
              + TestUtil.BUNDLE
              + "/"
              + ROOT_DIR_NAME //$NON-NLS-1$ //$NON-NLS-2$
              + "/"
              + scriptName
              + "/"
              + scriptName
              + MDAConstants.QVTO_FILE_EXTENSION_WITH_DOT,
          false); //$NON-NLS-1$ //$NON-NLS-2$
    }

    return URI.createPlatformPluginURI(
        "/"
            + ROOT_DIR_NAME //$NON-NLS-1$
            + "."
            + scriptName
            + "."
            + scriptName,
        false); //$NON-NLS-1$ //$NON-NLS-2$
  }
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain();
    refreshEditorsPrecommitListener = new RefreshEditorsPrecommitListener(domain);

    resourceSet = domain.getResourceSet();
    sessionResourceURI =
        URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + PATH + "vp1753.aird", true);
    semanticResourceURI =
        URI.createPlatformPluginURI(SiriusTestsPlugin.PLUGIN_ID + PATH + "vp1753.ecore", true);

    sessionResource = resourceSet.getResource(sessionResourceURI, true);

    final DRepresentation firstDRepresentation =
        getFirstElement(sessionResource, DRepresentation.class);
    refreshFilterStub = new RefreshFilterStub(firstDRepresentation);
    RefreshFilterManager.INSTANCE.addRefreshFilter(refreshFilterStub);

    oldRefreshAutoMode =
        Platform.getPreferencesService()
            .getBoolean(
                SiriusPlugin.ID, SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), false, null);
    InstanceScope.INSTANCE
        .getNode(SiriusPlugin.ID)
        .putBoolean(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), true);
  }
  /** @return a list of uris of all xmi files registered */
  public static Map<URI, Map<String, String>> getExtensionURIS() {
    final Map<URI, Map<String, String>> ret = new LinkedHashMap<URI, Map<String, String>>();
    final IConfigurationElement[] files =
        Platform.getExtensionRegistry().getConfigurationElementsFor(FILE_EXTENSION);
    final URIConverter converter = new ResourceSetImpl().getURIConverter();
    for (final IConfigurationElement file : files) {
      final String filePath = file.getAttribute(FILEPATH_ATTRIBUTE);

      final IConfigurationElement[] children = file.getChildren(FILTER_ELEMENT);
      final Map<String, String> keyValuePairs = new LinkedHashMap<String, String>();
      for (final IConfigurationElement child : children) {
        final String key = child.getAttribute(FILTER_KEY_ATTRIBUTE);
        final String value = child.getAttribute(FILTER_VALUE_ATTRIBUTE);
        keyValuePairs.put(key, value);
      }

      URI uri;
      final String bundleName = file.getContributor().getName();
      final String path = bundleName + '/' + filePath;
      uri = URI.createPlatformPluginURI(path, false);
      if (converter.exists(uri, null)) {
        ret.put(uri, keyValuePairs);
      } else {
        uri = URI.createPlatformResourceURI(filePath, false);
        if (converter.exists(uri, null)) {
          ret.put(uri, keyValuePairs);
        }
      }
    }
    return ret;
  }
 @Override
 public String softwareProfile() {
   URI uri =
       URI.createPlatformPluginURI(
           "gov.redhawk.ide.tests.ui/resources/analogDevice/analogDevice.spd.xml", true);
   return uri.toString();
 }
  @Test
  public void test() throws IOException {
    URI traceMMURI = URI.createPlatformPluginURI(FUML_TRACE_MM_PATH, true);
    URI xmofModelURI = URI.createPlatformPluginURI(FUML_XMOF_MODEL_PATH, true);

    URI tracingPaOriginalLocationURI =
        URI.createPlatformPluginURI(FUML_TRACING_PA_ORIGINAL_PATH, true);
    URI tracingPaNewLocationURI = URI.createPlatformResourceURI(FUML_TRACING_PA_NEW_PATH, true);

    copyProfileApplicationViaFileStream(tracingPaOriginalLocationURI, tracingPaNewLocationURI);

    XMOFTraceMMSlicer slicer =
        new XMOFTraceMMSlicer(traceMMURI, xmofModelURI, tracingPaNewLocationURI);
    boolean sliceCreated = slicer.computeSlice();
    assertTrue(sliceCreated);
  }
  /**
   * @param appContext
   * @return
   */
  private URI determineApplicationModelURI(IApplicationContext appContext) {
    Optional<String> appModelPath = getArgValue(IWorkbench.XMI_URI_ARG, appContext, false);

    String appModelPathValue =
        appModelPath
            .filter(path -> !path.isEmpty())
            .orElseGet(
                () -> {
                  Bundle brandingBundle = appContext.getBrandingBundle();
                  if (brandingBundle != null) {
                    return brandingBundle.getSymbolicName()
                        + "/"
                        + E4Application.APPLICATION_MODEL_PATH_DEFAULT;
                  } else {
                    Logger logger = new WorkbenchLogger(PLUGIN_ID);
                    logger.error(
                        new Exception(),
                        "applicationXMI parameter not set and no branding plugin defined. "); //$NON-NLS-1$
                  }
                  return null;
                });

    URI applicationModelURI = null;

    // check if the appModelPath is already a platform-URI and if so use it
    if (URIHelper.isPlatformURI(appModelPathValue)) {
      applicationModelURI = URI.createURI(appModelPathValue, true);
    } else {
      applicationModelURI = URI.createPlatformPluginURI(appModelPathValue, true);
    }
    return applicationModelURI;
  }
Пример #7
0
 @Test
 public void testAccessToUnresolvedURI() throws Exception {
   URI uri =
       URI.createPlatformPluginURI(
           "/org.eclipse.m2m.tests.qvt.oml/deployed/a/T1_NeverFindMe.qvto", false);
   UnitProxy unit = UnitResolverFactory.Registry.INSTANCE.getUnit(uri);
   assertNull("Must not be resolved", unit); // $NON-NLS-1$
 }
 public URI getUri() {
   DeployedImportResolver importResolver = DeployedImportResolver.INSTANCE;
   CFile srcFile = importResolver.resolveImport(myId);
   if (srcFile != null) {
     return EmfUtil.makeUri(srcFile.toString());
   }
   return URI.createPlatformPluginURI(myId, false);
 }
Пример #9
0
  /** Initializes all plugin stores by inspecting all extensions. */
  public static void init() {
    if (Platform.isRunning()) {
      IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_STORE_EP_ID);
      IConfigurationElement[] entries = ep.getConfigurationElements();

      List<URI> existingURIs = new ArrayList<URI>();

      for (int i = 0; i < entries.length; i++) {
        String path = entries[i].getAttribute("folder");
        String bundleID = entries[i].getDeclaringExtension().getNamespaceIdentifier();
        Bundle bundle = Platform.getBundle(bundleID);

        String updateString = entries[i].getAttribute("update");
        boolean update = false;
        if ("true".equals(updateString) || "TRUE".equals(updateString)) {
          update = true;
        }

        if (path != null && bundle != null) {
          String storeURI = "/" + bundleID + "/" + path;
          while (storeURI.endsWith("/")) {
            storeURI = storeURI.substring(0, storeURI.length() - 1);
          }
          registerStore(URI.createPlatformPluginURI(storeURI, true));

          @SuppressWarnings("unchecked")
          Enumeration<URL> urlEnum = bundle.findEntries(path, null, true);
          while (urlEnum.hasMoreElements()) {
            URL url = urlEnum.nextElement();
            String uriString = url.toExternalForm();
            if (!uriString.endsWith("/") && !uriString.contains("/.")) {
              uriString = uriString.substring("bundleentry://".length());
              uriString = uriString.substring(uriString.indexOf("/"));
              uriString = "/" + bundleID + uriString;
              URI uri = URI.createPlatformPluginURI(uriString, true);
              addOrUpdateArtifact(uri, update);
              existingURIs.add(uri);
            }
          }
        }
      }

      removeOldArtifacts(existingURIs);
    }
  }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.acceleo.parser.compiler.AbstractAcceleoCompiler#computeDependencies(java.util.List,
  *     java.util.Map)
  */
 protected void computeDependencies(List<URI> dependenciesURIs, Map<URI, URI> mapURIs) {
   // USED TO FIX COMPILER WITH TYCHO
   Iterator<String> identifiersIt = dependenciesIDs.iterator();
   for (Iterator<File> dependenciesIt = dependencies.iterator();
       dependenciesIt.hasNext() && identifiersIt.hasNext(); ) {
     File requiredFolder = dependenciesIt.next();
     String identifier = identifiersIt.next();
     if (requiredFolder != null && requiredFolder.exists() && requiredFolder.isDirectory()) {
       List<File> emtlFiles = new ArrayList<File>();
       members(emtlFiles, requiredFolder, IAcceleoConstants.EMTL_FILE_EXTENSION);
       for (File emtlFile : emtlFiles) {
         String requiredFolderAbsolutePath = requiredFolder.getAbsolutePath();
         if (requiredFolderAbsolutePath.endsWith("target/classes")) {
           // using tycho
           String[] splited = requiredFolderAbsolutePath.split("\\/");
           StringBuffer buf = new StringBuffer(requiredFolderAbsolutePath.length());
           for (int i = 0; i < splited.length - 3; i++) {
             buf.append(splited[i]);
             buf.append("/");
           }
           requiredFolderAbsolutePath = buf.toString();
           String emtlAbsolutePath = emtlFile.getAbsolutePath();
           URI emtlFileURI = URI.createFileURI(emtlAbsolutePath);
           dependenciesURIs.add(emtlFileURI);
           String emtlModifiedPath = emtlAbsolutePath.replaceAll("target\\/|classes\\/", "");
           IPath relativePath =
               new Path(emtlModifiedPath.substring(requiredFolderAbsolutePath.length()));
           URI relativeURI = URI.createPlatformPluginURI(relativePath.toString(), false);
           mapURIs.put(emtlFileURI, relativeURI);
         } else {
           // normal behavior
           String emtlAbsolutePath = emtlFile.getAbsolutePath();
           URI emtlFileURI = URI.createFileURI(emtlAbsolutePath);
           dependenciesURIs.add(emtlFileURI);
           IPath relativePath =
               new Path(identifier)
                   .append(emtlAbsolutePath.substring(requiredFolderAbsolutePath.length()));
           mapURIs.put(emtlFileURI, URI.createPlatformPluginURI(relativePath.toString(), false));
         }
       }
     }
   }
 }
Пример #11
0
 private URI createPlatformUri(String fileName) {
   return URI.createPlatformPluginURI(
       "/"
           + AllTests.BUNDLE_ID
           + "/"
           + ROOT_DIR_NAME //$NON-NLS-1$ //$NON-NLS-2$
           + "/"
           + getData().getName()
           + "/"
           + fileName,
       false); //$NON-NLS-1$ //$NON-NLS-2$
 }
Пример #12
0
  @Test
  public void testAccessByPlatformPluginURI() throws Exception {
    URI uri =
        URI.createPlatformPluginURI("/org.eclipse.m2m.tests.qvt.oml/deployed/a/T1.qvto", false);
    UnitProxy unit = UnitResolverFactory.Registry.INSTANCE.getUnit(uri);
    assertResolvedCompiledUnit(unit);

    // 'deployed' part of the namespace as there is no knowledge about source container
    assertEquals("deployed.a", unit.getNamespace());
    assertEquals("T1", unit.getName());
    assertEquals(uri, unit.getURI());
    assertNotNull(unit);
  }
Пример #13
0
  public void testTransformationLoadFailure() throws Exception {
    URI uri =
        URI.createPlatformPluginURI(
            "org.eclipse.m2m.tests.qvt.oml/deployed/callapi/NotExisting.qvto",
            false); //$NON-NLS-1$
    fExecutor = new TransformationExecutor(uri);

    final ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
    assertEquals(Diagnostic.ERROR, diagnostic.getSeverity());
    assertEquals(ExecutionDiagnostic.TRANSFORMATION_LOAD_FAILED, diagnostic.getCode());
    assertUnchangedInput();
    assertTrue(fOutput.getContents().isEmpty());
  }
Пример #14
0
  public void testCompilationErrors() throws Exception {
    URI uri =
        URI.createPlatformPluginURI(
            "org.eclipse.m2m.tests.qvt.oml/deployed/callapi/CompilationErrors.qvto",
            false); //$NON-NLS-1$
    fExecutor = new TransformationExecutor(uri);

    final ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
    assertEquals(Diagnostic.ERROR, diagnostic.getSeverity());
    assertEquals(ExecutionDiagnostic.VALIDATION, diagnostic.getCode());
    assertFalse(diagnostic.getChildren().isEmpty());
    assertTrue(diagnostic.getChildren().get(0).getMessage().contains("(at:")); // $NON-NLS-1$

    assertUnchangedInput();
    assertTrue(fOutput.getContents().isEmpty());
  }
  @Before
  public void createFixture() throws Exception {
    URI profileURI =
        URI.createPlatformPluginURI(
            "org.eclipse.papyrus.uml.modelrepair.tests/resources/profile/myprofile.profile.uml",
            true);
    profile = UML2Util.load(modelSet.getResourceSet(), profileURI, UMLPackage.Literals.PROFILE);
    stereotype = profile.getOwnedStereotype("Stereo");
    class1 = (Class) modelSet.getModel().getOwnedType("Class1");

    fixture =
        houseKeeper.cleanUpLater(
            new StereotypeApplicationRepairSnippet(Functions.constant(profile)),
            "dispose",
            modelSet.getResourceSet());
    fixture.start(modelSet.getResourceSet());
    houseKeeper.setField(
        "zombies", fixture.getZombieStereotypes(modelSet.getModelResource(), modelSet.getModel()));
  }
Пример #16
0
 /**
  * Finds the template in the plug-in. Returns the template plug-in URI.
  *
  * @param bundleID is the plug-in ID
  * @param relativePath is the relative path of the template in the plug-in
  * @return the template URI
  * @throws IOException
  * @generated
  */
 @SuppressWarnings({"unused"})
 private URI getTemplateURI(String bundleID, IPath relativePath) throws IOException {
   Bundle bundle = Platform.getBundle(bundleID);
   if (bundle == null) {
     // no need to go any further
     return URI.createPlatformResourceURI(
         new Path(bundleID).append(relativePath).toString(), false);
   }
   URL url = bundle.getEntry(relativePath.toString());
   if (url == null && relativePath.segmentCount() > 1) {
     Enumeration<URL> entries = bundle.findEntries("/", "*.emtl", true);
     if (entries != null) {
       String[] segmentsRelativePath = relativePath.segments();
       while (url == null && entries.hasMoreElements()) {
         URL entry = entries.nextElement();
         IPath path = new Path(entry.getPath());
         if (path.segmentCount() > relativePath.segmentCount()) {
           path = path.removeFirstSegments(path.segmentCount() - relativePath.segmentCount());
         }
         String[] segmentsPath = path.segments();
         boolean equals = segmentsPath.length == segmentsRelativePath.length;
         for (int i = 0; equals && i < segmentsPath.length; i++) {
           equals = segmentsPath[i].equals(segmentsRelativePath[i]);
         }
         if (equals) {
           url = bundle.getEntry(entry.getPath());
         }
       }
     }
   }
   URI result;
   if (url != null) {
     result =
         URI.createPlatformPluginURI(
             new Path(bundleID).append(new Path(url.getPath())).toString(), false);
   } else {
     result =
         URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
   }
   return result;
 }
Пример #17
0
 private ResourceSet createResourceSet(URI genModelUri) {
   ResourceSetImpl resourceSet;
   if (genModelUri.fileExtension().equals("xcore")) {
     IResourceServiceProvider resourceServiceProvider =
         IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(genModelUri);
     IStorage2UriMapper storage2UriMapper = resourceServiceProvider.get(IStorage2UriMapper.class);
     IProject project = storage2UriMapper.getStorages(genModelUri).iterator().next().getSecond();
     resourceSet =
         (ResourceSetImpl) resourceServiceProvider.get(IResourceSetProvider.class).get(project);
   } else {
     resourceSet = new ResourceSetImpl();
   }
   Resource ecorePackageResource = EcorePackage.eINSTANCE.eResource();
   Map<URI, Resource> uriResourceMap = Maps.newHashMap();
   uriResourceMap.put(
       URI.createPlatformResourceURI(PATH_TO_ECORE_ECORE, true), ecorePackageResource);
   uriResourceMap.put(
       URI.createPlatformPluginURI(PATH_TO_ECORE_ECORE, true), ecorePackageResource);
   resourceSet.setURIResourceMap(uriResourceMap);
   return resourceSet;
 }
 private GenModel loadGenmodel(String resourceOrNsURI, ResourceSet resourceSet) {
   URI uri = null;
   try {
     uri = URI.createURI(resourceOrNsURI);
     if (uri.fragment() == null) {
       Resource resource = resourceSet.getResource(uri, true);
       return (GenModel) resource.getContents().get(0);
     }
     return (GenModel) resourceSet.getEObject(uri, true);
   } catch (IllegalArgumentException ex) {
     LOG.trace("Invalid package URI: '" + resourceOrNsURI + "'", ex);
     return null;
   } catch (RuntimeException ex) {
     if (uri != null && uri.isPlatformResource()) {
       String platformString = uri.toPlatformString(true);
       URI platformPluginURI = URI.createPlatformPluginURI(platformString, true);
       return loadGenmodel(platformPluginURI.toString(), resourceSet);
     }
     LOG.trace("Cannot load package with URI '" + resourceOrNsURI + "'", ex);
     return null;
   }
 }
Пример #19
0
public class ConvertEcore2UML {

  public static final URI transformationURI =
      URI.createPlatformPluginURI("/qvto.ecore2uml/transforms/Ecore2UML.qvto", true);

  public static void convertEcore2UML(Resource ecoreResource, Resource umlResource) {

    TransformationExecutor executor = new TransformationExecutor(transformationURI);

    ModelExtent input = new BasicModelExtent(ecoreResource.getContents());
    ModelExtent output = new BasicModelExtent();

    ExecutionContextImpl context = new ExecutionContextImpl();
    ExecutionDiagnostic diagnostic = executor.execute(context, input, output);

    if (diagnostic.getSeverity() == Diagnostic.OK) {
      umlResource.getContents().addAll(output.getContents());
    } else {
      IStatus status = BasicDiagnostic.toIStatus(diagnostic);
      InvokeActivator.getDefault().getLog().log(status);
    }
  }
}
Пример #20
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    URI uri =
        URI.createPlatformPluginURI(
            "org.eclipse.m2m.tests.qvt.oml/deployed/callapi/Ecore2Ecore.qvto",
            false); //$NON-NLS-1$
    fExecutor = new TransformationExecutor(uri);

    fInput = new BasicModelExtent();
    EPackage inObject = EcoreFactory.eINSTANCE.createEPackage();
    inObject.setName("input"); // $NON-NLS-1$
    fInput.add(inObject);

    fInitialInputContents = new ArrayList<EObject>(fInput.getContents());

    fOutput = new BasicModelExtent();
    fContext = new ExecutionContextImpl();

    assertFalse(fInput.getContents().isEmpty());
    assertTrue(fOutput.getContents().isEmpty());
  }
Пример #21
0
 private URI getTransformLocation(final String name) {
   return URI.createPlatformPluginURI(PLUGIN_ID + "/src/main/qvt/" + name + ".qvto", true);
 }