org.eclipse.emf.importer.ecore_2.6.0.v20120130-0943

16:43:38.955 INFO  jd.cli.Main - Decompiling org.eclipse.emf.importer.ecore_2.6.0.v20120130-0943.jar
package org.eclipse.emf.importer.ecore;

import java.util.List;
import org.eclipse.core.runtime.IPath;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticException;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.common.util.UniqueEList;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcorePackage.Literals;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.Diagnostician;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.importer.ModelImporter;
import org.osgi.framework.Bundle;

public class EcoreImporter
  extends ModelImporter
{
  public String getID()
  {
    return "org.eclipse.emf.importer.ecore";
  }
  
  protected Diagnostic doComputeEPackages(Monitor monitor)
    throws Exception
  {
    Diagnostic diagnostic = Diagnostic.OK_INSTANCE;
    
    List<URI> locationURIs = getModelLocationURIs();
    if (locationURIs.isEmpty())
    {
      diagnostic = new BasicDiagnostic(
        4, 
        EcoreImporterPlugin.getPlugin().getBundle().getSymbolicName(), 
        0, 
        EcoreImporterPlugin.INSTANCE.getString("_UI_SpecifyAValidCoreModel_message"), 
        null);
    }
    else
    {
      monitor.beginTask("", 2);
      monitor.subTask(EcoreImporterPlugin.INSTANCE.getString("_UI_Loading_message", new Object[] { locationURIs }));
      
      ResourceSet ecoreResourceSet = createResourceSet();
      for (URI ecoreModelLocation : locationURIs) {
        ecoreResourceSet.getResource(ecoreModelLocation, true);
      }
      EcoreUtil.resolveAll(ecoreResourceSet);
      for (Resource resource : ecoreResourceSet.getResources()) {
        getEPackages().addAll(EcoreUtil.getObjectsByType(resource.getContents(), EcorePackage.Literals.EPACKAGE));
      }
      BasicDiagnostic diagnosticChain = 
        new BasicDiagnostic(
        "org.eclipse.emf.converter", 
        1, 
        EcoreImporterPlugin.INSTANCE.getString("_UI_ErrorsWereDetectedEcore_message"), 
        null);
      for (EPackage ePackage : getEPackages()) {
        Diagnostician.INSTANCE.validate(ePackage, diagnosticChain);
      }
      if (diagnosticChain.getSeverity() != 0) {
        diagnostic = diagnosticChain;
      }
    }
    return diagnostic;
  }
  
  public void addToResource(EPackage ePackage, ResourceSet resourceSet)
  {
    if ((ePackage.eResource() != null) && (getGenModel().eResource() != null))
    {
      URI ePackageURI = ePackage.eResource().getURI();
      URI genModelURI = getGenModel().eResource().getURI();
      if (!ePackageURI.trimSegments(1).equals(genModelURI.trimSegments(1))) {
        ePackage.eResource().getContents().remove(ePackage);
      }
    }
    super.addToResource(ePackage, resourceSet);
  }
  
  protected void adjustGenModel(Monitor monitor)
  {
    super.adjustGenModel(monitor);
    
    URI genModelURI = createFileURI(getGenModelPath().toString());
    for (URI uri : getModelLocationURIs()) {
      getGenModel().getForeignModel().add(makeRelative(uri, genModelURI).toString());
    }
  }
  
  protected void handleOriginalGenModel()
    throws DiagnosticException
  {
    URI genModelURI = getOriginalGenModel().eResource().getURI();
    StringBuffer text = new StringBuffer();
    for (String value : getOriginalGenModel().getForeignModel()) {
      if ((value.endsWith(".ecore")) || (value.endsWith(".emof")))
      {
        text.append(makeAbsolute(URI.createURI(value), genModelURI).toString());
        text.append(" ");
      }
    }
    if (text.length() == 0)
    {
      List<URI> locations = new UniqueEList();
      for (GenPackage genPackage : getOriginalGenModel().getGenPackages())
      {
        URI ecoreURI = genPackage.getEcorePackage().eResource().getURI();
        if (locations.add(ecoreURI))
        {
          text.append(makeAbsolute(URI.createURI(ecoreURI.toString()), genModelURI).toString());
          text.append(" ");
        }
      }
    }
    setModelLocation(text.toString().trim());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.ecore.EcoreImporter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.ecore;

public class EcoreImporterApplication$PackageInfo
{
  public String nsURI;
  public String base;
  public String prefix;
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.ecore.EcoreImporterApplication.PackageInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.ecore;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.importer.ModelImporter;
import org.eclipse.emf.importer.ModelImporter.EPackageImportInfo;
import org.eclipse.emf.importer.ModelImporterApplication;

public class EcoreImporterApplication
  extends ModelImporterApplication
{
  protected Map<String, PackageInfo> nameToPackageInfo;
  
  public EcoreImporter getEcoreImporter()
  {
    return (EcoreImporter)getModelImporter();
  }
  
  protected ModelImporter createModelImporter()
  {
    return new EcoreImporter();
  }
  
  protected StringBuffer getUsage()
  {
    StringBuffer result = new StringBuffer();
    appendLine(result, "Usage: { <model.ecore> }+ [ <model.genmodel> [ -reload ] ] <OPTION>");
    appendLine(result, "<OPTION>          ::= [ <PROJECT-OPTION> ]  [ <PATHMAP> ]");
    appendLine(result, "                      { <PACKAGE> }+  { <REF-PACKAGE> }* { <REF-GEN-MODEL> }*");
    appendLine(result, "                      [ <TEMPLATE-PATH> ] [ <MODEL-PLUGIN-ID> ] [ <COPYRIGHT> ]");
    appendLine(result, "                      [ <SDO> ] [ <QUIET> ]");
    appendLine(result, "<PROJECT-OPTION>  ::= <MODEL-PROJECT> [ <EDIT-PROJECT> ] [ <EDITOR-PROJECT> ]");
    appendLine(result, "                      [ <TESTS-PROJECT> ]");
    appendLine(result, "<MODEL-PROJECT>   ::= -modelProject <model-directory> <fragment-path>");
    appendLine(result, "<EDIT-PROJECT>    ::= -editProject <edit-directory> <fragment-path>");
    appendLine(result, "<EDITOR-PROJECT>  ::= -editorProject <editor-directory> <fragment-path>");
    appendLine(result, "<TESTS-PROJECT>   ::= -testsProject <tests-directory> <fragment-path>");
    appendLine(result, "<PACKAGE>         ::= -package <nsURI> [ <base> <prefix> ]");
    appendLine(result, "<REF-GEN-MODEL>   ::= -refGenModel <model.genmodel> { <nsURI> }+");
    appendLine(result, "<TEMPLATE-PATH>   ::= -templatePath <template-directory>");
    appendLine(result, "<MODEL-PLUGIN-ID> ::= -modelPluginID <plugin-ID>");
    appendLine(result, "<COPYRIGHT>       ::= -copyright <copyright-string>");
    appendLine(result, "<JDK-LEVEL>       ::= -jdkLevel <jdk level: 1.4 5.0 6.0>");
    appendLine(result, "<VALIDATE-MODEL>  ::= -validateModel <true|false>");
    appendLine(result, "<SDO>             ::= -sdo");
    appendLine(result, "<QUIET>           ::= -quiet");
    appendLine(result, "");
    appendLine(result, "For example:");
    appendLine(result, "");
    appendLine(result, "");
    appendLine(result, "  ecore2genmodel");
    appendLine(result, "    ../../etools.company/model.ecore");
    appendLine(result, "    result/model/Extended.genmodel");
    appendLine(result, "    -modelProject result src");
    appendLine(result, "    -editProject result.edit src");
    appendLine(result, "    -editorProject result.editor src");
    appendLine(result, "    -refGenModel company.genmodel http://org.sample.company");
    return result;
  }
  
  protected int processArgument(String[] arguments, int index)
  {
    if (arguments[index].equalsIgnoreCase("-package"))
    {
      if (nameToPackageInfo == null) {
        nameToPackageInfo = new HashMap();
      }
      index = processPackageInformation(arguments, index, nameToPackageInfo);
    }
    else
    {
      return super.processArgument(arguments, index);
    }
    return index + 1;
  }
  
  protected int processPackageInformation(String[] arguments, int index, Map<String, PackageInfo> nsURIToPackageInfo)
  {
    int start = index;
    PackageInfo packageInfo = new PackageInfo();
    if ((index + 1 < arguments.length) && (!arguments[(index + 1)].startsWith("-")))
    {
      nsURI = arguments[(++index)];
      if ((index + 1 < arguments.length) && (!arguments[(index + 1)].startsWith("-")))
      {
        base = arguments[(++index)];
        if ((index + 1 < arguments.length) && (!arguments[(index + 1)].startsWith("-"))) {
          prefix = arguments[(++index)];
        }
      }
      if ((index - start != 1) && (index - start != 3)) {
        throw new IllegalArgumentException("Error: Expecting either 1 or 3 arguments for " + arguments[start]);
      }
      nsURIToPackageInfo.put(nsURI, packageInfo);
      nsURIToPackageInfo.put(nsURI.toLowerCase(), packageInfo);
      return index;
    }
    throw new IllegalArgumentException("Error: No package name was specified for " + arguments[start]);
  }
  
  /* Error */
  protected void adjustEPackages(org.eclipse.emf.common.util.Monitor monitor)
  {
    // Byte code:
    //   0: aload_1
    //   1: ldc 1
    //   3: iconst_2
    //   4: invokeinterface 264 3 0
    //   9: aload_0
    //   10: aload_1
    //   11: iconst_1
    //   12: invokestatic 238	org/eclipse/emf/codegen/util/CodeGenUtil:createMonitor	(Lorg/eclipse/emf/common/util/Monitor;I)Lorg/eclipse/emf/common/util/Monitor;
    //   15: invokespecial 245	org/eclipse/emf/importer/ModelImporterApplication:adjustEPackages	(Lorg/eclipse/emf/common/util/Monitor;)V
    //   18: aload_0
    //   19: invokevirtual 254	org/eclipse/emf/importer/ecore/EcoreImporterApplication:getEcoreImporter	()Lorg/eclipse/emf/importer/ecore/EcoreImporter;
    //   22: invokevirtual 247	org/eclipse/emf/importer/ecore/EcoreImporter:getEPackages	()Ljava/util/List;
    //   25: astore_2
    //   26: aload_0
    //   27: aload_2
    //   28: invokevirtual 250	org/eclipse/emf/importer/ecore/EcoreImporterApplication:traverseEPackages	(Ljava/util/List;)V
    //   31: aload_0
    //   32: invokevirtual 254	org/eclipse/emf/importer/ecore/EcoreImporterApplication:getEcoreImporter	()Lorg/eclipse/emf/importer/ecore/EcoreImporter;
    //   35: aload_1
    //   36: iconst_1
    //   37: invokestatic 238	org/eclipse/emf/codegen/util/CodeGenUtil:createMonitor	(Lorg/eclipse/emf/common/util/Monitor;I)Lorg/eclipse/emf/common/util/Monitor;
    //   40: invokevirtual 248	org/eclipse/emf/importer/ecore/EcoreImporter:adjustEPackages	(Lorg/eclipse/emf/common/util/Monitor;)V
    //   43: goto +12 -> 55
    //   46: astore_3
    //   47: aload_1
    //   48: invokeinterface 263 1 0
    //   53: aload_3
    //   54: athrow
    //   55: aload_1
    //   56: invokeinterface 263 1 0
    //   61: return
    // Line number table:
    //   Java source line #145	-> byte code offset #0
    //   Java source line #146	-> byte code offset #9
    //   Java source line #148	-> byte code offset #18
    //   Java source line #149	-> byte code offset #26
    //   Java source line #150	-> byte code offset #31
    //   Java source line #153	-> byte code offset #46
    //   Java source line #154	-> byte code offset #47
    //   Java source line #155	-> byte code offset #53
    //   Java source line #154	-> byte code offset #55
    //   Java source line #156	-> byte code offset #61
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	62	0	this	EcoreImporterApplication
    //   0	62	1	monitor	org.eclipse.emf.common.util.Monitor
    //   25	3	2	ePackages	List<EPackage>
    //   46	8	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	46	46	finally
  }
  
  protected void traverseEPackages(List<EPackage> ePackages)
  {
    for (EPackage ePackage : ePackages)
    {
      if (nameToPackageInfo != null)
      {
        PackageInfo packageInfo = (PackageInfo)nameToPackageInfo.get(ePackage.getNsURI());
        if (packageInfo != null)
        {
          handleEPackage(ePackage, true);
          
          ModelImporter.EPackageImportInfo ePackageInfo = getEcoreImporter().getEPackageImportInfo(ePackage);
          if (ePackageInfo.getBasePackage() == null) {
            ePackageInfo.setBasePackage(base);
          }
          if (ePackageInfo.getPrefix() == null) {
            ePackageInfo.setPrefix(prefix);
          }
        }
      }
      handleQualifiedEPackageName(ePackage);
      traverseEPackages(ePackage.getESubpackages());
    }
  }
  
  public static class PackageInfo
  {
    public String nsURI;
    public String base;
    public String prefix;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.ecore.EcoreImporterApplication
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.ecore;

import org.eclipse.emf.common.EMFPlugin.EclipsePlugin;

public class EcoreImporterPlugin$Implementation
  extends EMFPlugin.EclipsePlugin
{
  public EcoreImporterPlugin$Implementation()
  {
    EcoreImporterPlugin.access$0(this);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.ecore.EcoreImporterPlugin.Implementation
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.ecore;

import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.EMFPlugin.EclipsePlugin;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.importer.ImporterPlugin;

public final class EcoreImporterPlugin
  extends EMFPlugin
{
  public static final EcoreImporterPlugin INSTANCE = new EcoreImporterPlugin();
  private static Implementation plugin;
  
  private EcoreImporterPlugin()
  {
    super(new ResourceLocator[] { ImporterPlugin.INSTANCE });
  }
  
  public ResourceLocator getPluginResourceLocator()
  {
    return plugin;
  }
  
  public static Implementation getPlugin()
  {
    return plugin;
  }
  
  public static class Implementation
    extends EMFPlugin.EclipsePlugin
  {
    public Implementation()
    {
      EcoreImporterPlugin.plugin = this;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.ecore.EcoreImporterPlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.importer.ecore.ui;

import org.eclipse.emf.converter.ModelConverter;
import org.eclipse.emf.importer.ecore.EcoreImporter;
import org.eclipse.emf.importer.ecore.EcoreImporterPlugin;
import org.eclipse.emf.importer.ui.contribution.base.ModelImporterDetailPage;
import org.eclipse.emf.importer.ui.contribution.base.ModelImporterPackagePage;
import org.eclipse.emf.importer.ui.contribution.base.ModelImporterWizard;

public class EcoreImporterWizard
  extends ModelImporterWizard
{
  protected ModelConverter createModelConverter()
  {
    return new EcoreImporter();
  }
  
  public void addPages()
  {
    ModelImporterDetailPage detailPage = new ModelImporterDetailPage(getModelImporter(), "EcoreModel");
    detailPage.setTitle(EcoreImporterPlugin.INSTANCE.getString("_UI_EcoreImport_title"));
    detailPage.setDescription(EcoreImporterPlugin.INSTANCE.getString(detailPage.showGenModel() ? 
      "_UI_EcoreImportNewProject_description" : "_UI_EcoreImportFile_description"));
    addPage(detailPage);
    
    ModelImporterPackagePage packagePage = new ModelImporterPackagePage(getModelImporter(), "EcorePackages");
    packagePage.setShowReferencedGenModels(true);
    addPage(packagePage);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.importer.ecore.ui.EcoreImporterWizard
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd