コード例 #1
0
  private void init(IFile file) throws AmlUIException {
    IProject project = file.getProject();
    File propertiesFile =
        org.eclipse.gmt.weaver.plugin.util.WeaverUtil.getPropertyFilePath(file).toFile();

    // Config file

    try {
      InputStream in = AmlUIResourceManager.getDefault().getAmlFile(project).getContents();
      IModel[] amlAndProblemModels = AmlCompiler.getDefault().injectAMLTextFile(in);
      IModel amlInjected = amlAndProblemModels[0];
      // TODO centralize the logging of aml file problems
      String metametamodel =
          (String) AmlModelUtils.getDefault().getMatchingMetametamodel(amlInjected);

      String resPath = AmlUIResourceManager.getDefault().getPath(file);
      EMFModel equalModel =
          AmlResourceManager.getDefault()
              .loadModel(resPath, AmlResourceManager.getDefault().getEqualMetamodel());
      WeaverXMLMetadata xml = new WeaverXMLMetadata(propertiesFile);
      xml.createXMLConfigFile(
          getModelInfos(equalModel, metametamodel, project.getName()),
          file.getFullPath().toString(),
          weavingPanel,
          EqualModelUtils.wmodel,
          Collections.EMPTY_LIST,
          Collections.EMPTY_LIST,
          ResourceUtils.getPathWithSeparator(
              project.getFullPath().toString(),
              AmlResourceManager.metamodelsFolderName,
              AmlResourceManager.equalMMName));
      IContainer fileContainer = file.getParent();
      fileContainer.refreshLocal(IResource.DEPTH_ONE, null);
    } catch (ATLCoreException e) {
      // TODO Auto-generated catch block
      throw new AmlUIException(IStatus.ERROR, "The equal model cannot be loaded");
    } catch (Exception e) {
      // TODO Auto-generated catch block
      throw new AmlUIException(IStatus.ERROR, e);
    }
  }
コード例 #2
0
  private WovenModelDescriptor createDesc(
      EObject wModelRef, String modelRefName, String id, String metametamodel, String projectName) {

    WovenModelDescriptor desc = new WovenModelDescriptor();

    String ref = (String) WeaverUtil.get(wModelRef, "ref");
    if (AmlResourceManager.KM3MMName.startsWith(metametamodel)) {
      desc.setMetamodelFile(
          ResourceUtils.getPathWithSeparator(
              projectName, AmlResourceManager.metamodelsFolderName, AmlResourceManager.KM3MMName));
      desc.setModelFile(ref);
    } else { // Ecore
      desc.setMetamodelFile(ref);
      desc.setModelFile("null");
    }

    desc.setPanel(wModelRefPanel);
    desc.setWModelRef(EqualModelUtils.wModelRefType);
    desc.setNameProperty(modelRefName);
    desc.setReferenceName(modelRefName);
    desc.setId(id);

    return desc;
  }