org.eclipse.emf.mapping.ecore2ecore.editor_2.5.0.v20120130-0943

16:43:41.306 INFO  jd.cli.Main - Decompiling org.eclipse.emf.mapping.ecore2ecore.editor_2.5.0.v20120130-0943.jar
package org.eclipse.emf.mapping.ecore2ecore.action;

import java.util.Collection;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.presentation.EcoreActionBarContributor.ExtendedLoadResourceAction.ExtendedLoadResourceDialog;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.mapping.ecore2ecore.presentation.Ecore2EcoreEditor;
import org.eclipse.emf.mapping.ecore2ecore.presentation.Ecore2EcoreEditorPlugin;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;

class AddInputRootAction$1
  extends EcoreActionBarContributor.ExtendedLoadResourceAction.ExtendedLoadResourceDialog
{
  AddInputRootAction$1(Shell $anonymous0, EditingDomain $anonymous1, Collection paramCollection, IWorkbenchPart paramIWorkbenchPart)
  {
    super($anonymous0, $anonymous1);
  }
  
  protected boolean processResources()
  {
    if (domain != null) {
      for (URI uri : getURIs()) {
        try
        {
          val$objects.addAll(((Ecore2EcoreEditor)val$workbenchPart).getEditingDomain().getResourceSet().getResource(uri, true).getContents());
        }
        catch (RuntimeException exception)
        {
          Ecore2EcoreEditorPlugin.INSTANCE.log(exception);
        }
      }
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2ecore.action.AddInputRootAction.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2ecore.action;

import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.presentation.EcoreActionBarContributor.ExtendedLoadResourceAction.ExtendedLoadResourceDialog;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.mapping.action.AddRootTopAction;
import org.eclipse.emf.mapping.ecore2ecore.presentation.Ecore2EcoreEditor;
import org.eclipse.emf.mapping.ecore2ecore.presentation.Ecore2EcoreEditorPlugin;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;

public class AddInputRootAction
  extends AddRootTopAction
{
  protected Collection<?> getTopsToAdd()
  {
    return getRootsToAdd(workbenchPart, editingDomain);
  }
  
  static Collection<?> getRootsToAdd(final IWorkbenchPart workbenchPart, EditingDomain editingDomain)
  {
    final Collection<Object> objects = new ArrayList();
    EcoreActionBarContributor.ExtendedLoadResourceAction.ExtendedLoadResourceDialog loadEcoreResourceDialog = 
      new EcoreActionBarContributor.ExtendedLoadResourceAction.ExtendedLoadResourceDialog(workbenchPart.getSite().getShell(), editingDomain)
      {
        protected boolean processResources()
        {
          if (domain != null) {
            for (URI uri : getURIs()) {
              try
              {
                objects.addAll(((Ecore2EcoreEditor)workbenchPart).getEditingDomain().getResourceSet().getResource(uri, true).getContents());
              }
              catch (RuntimeException exception)
              {
                Ecore2EcoreEditorPlugin.INSTANCE.log(exception);
              }
            }
          }
          return true;
        }
      };
      loadEcoreResourceDialog.open();
      return objects;
    }
  }

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2ecore.action.AddInputRootAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2ecore.action;

import java.util.Collection;
import org.eclipse.emf.mapping.action.AddRootBottomAction;

public class AddOutputRootAction
  extends AddRootBottomAction
{
  protected Collection<?> getBottomsToAdd()
  {
    return AddInputRootAction.getRootsToAdd(workbenchPart, editingDomain);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2ecore.action.AddOutputRootAction
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2ecore.action;

import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

class MapToEcoreActionDelegate$1
  extends ViewerFilter
{
  MapToEcoreActionDelegate$1(MapToEcoreActionDelegate paramMapToEcoreActionDelegate, IFile paramIFile) {}
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    if ((element instanceof IFile))
    {
      IFile file = (IFile)element;
      
      return (MapToEcoreActionDelegate.access$0().contains(file.getFileExtension())) && ((val$selectedEcoreFile == null) || (!val$selectedEcoreFile.getFullPath().equals(file.getFullPath())));
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2ecore.action.MapToEcoreActionDelegate.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2ecore.action;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.ISetSelectionTarget;

class MapToEcoreActionDelegate$2$1
  implements Runnable
{
  MapToEcoreActionDelegate$2$1(MapToEcoreActionDelegate.2 param2, IWorkbenchPart paramIWorkbenchPart, ISelection paramISelection) {}
  
  public void run()
  {
    ((ISetSelectionTarget)val$activePart).selectReveal(val$targetSelection);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2ecore.action.MapToEcoreActionDelegate.2.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2ecore.action;

import org.eclipse.core.resources.IFile;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.part.ISetSelectionTarget;

class MapToEcoreActionDelegate$2
  extends WorkspaceModifyOperation
{
  MapToEcoreActionDelegate$2(MapToEcoreActionDelegate paramMapToEcoreActionDelegate, IFile[] paramArrayOfIFile, Resource paramResource, EPackage paramEPackage, IWorkbenchWindow paramIWorkbenchWindow) {}
  
  /* Error */
  protected void execute(org.eclipse.core.runtime.IProgressMonitor progressMonitor)
  {
    // Byte code:
    //   0: aload_1
    //   1: ldc 1
    //   3: aload_0
    //   4: getfield 236	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$files	[Lorg/eclipse/core/resources/IFile;
    //   7: arraylength
    //   8: invokeinterface 268 3 0
    //   13: iconst_0
    //   14: istore_2
    //   15: goto +383 -> 398
    //   18: aload_0
    //   19: getfield 238	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$inputResource	Lorg/eclipse/emf/ecore/resource/Resource;
    //   22: invokeinterface 273 1 0
    //   27: aload_0
    //   28: getfield 236	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$files	[Lorg/eclipse/core/resources/IFile;
    //   31: iload_2
    //   32: aaload
    //   33: invokeinterface 264 1 0
    //   38: invokeinterface 265 1 0
    //   43: iconst_1
    //   44: invokestatic 252	org/eclipse/emf/common/util/URI:createPlatformResourceURI	(Ljava/lang/String;Z)Lorg/eclipse/emf/common/util/URI;
    //   47: iconst_1
    //   48: invokeinterface 275 3 0
    //   53: astore_3
    //   54: aload_3
    //   55: invokeinterface 271 1 0
    //   60: getstatic 235	org/eclipse/emf/ecore/EcorePackage$Literals:EPACKAGE	Lorg/eclipse/emf/ecore/EClass;
    //   63: invokestatic 253	org/eclipse/emf/ecore/util/EcoreUtil:getObjectByType	(Ljava/util/Collection;Lorg/eclipse/emf/ecore/EClassifier;)Ljava/lang/Object;
    //   66: checkcast 112	org/eclipse/emf/ecore/EPackage
    //   69: astore 4
    //   71: new 105	java/lang/StringBuilder
    //   74: dup
    //   75: aload_0
    //   76: getfield 238	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$inputResource	Lorg/eclipse/emf/ecore/resource/Resource;
    //   79: invokeinterface 272 1 0
    //   84: invokevirtual 248	org/eclipse/emf/common/util/URI:trimFileExtension	()Lorg/eclipse/emf/common/util/URI;
    //   87: invokevirtual 247	org/eclipse/emf/common/util/URI:lastSegment	()Ljava/lang/String;
    //   90: invokestatic 242	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   93: invokespecial 244	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   96: ldc 2
    //   98: invokevirtual 245	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   101: aload_3
    //   102: invokeinterface 272 1 0
    //   107: invokevirtual 248	org/eclipse/emf/common/util/URI:trimFileExtension	()Lorg/eclipse/emf/common/util/URI;
    //   110: invokevirtual 247	org/eclipse/emf/common/util/URI:lastSegment	()Ljava/lang/String;
    //   113: invokevirtual 245	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   116: invokevirtual 243	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   119: astore 5
    //   121: aload_3
    //   122: invokeinterface 272 1 0
    //   127: iconst_1
    //   128: invokevirtual 249	org/eclipse/emf/common/util/URI:trimSegments	(I)Lorg/eclipse/emf/common/util/URI;
    //   131: aload 5
    //   133: invokevirtual 251	org/eclipse/emf/common/util/URI:appendSegment	(Ljava/lang/String;)Lorg/eclipse/emf/common/util/URI;
    //   136: ldc 4
    //   138: invokevirtual 250	org/eclipse/emf/common/util/URI:appendFileExtension	(Ljava/lang/String;)Lorg/eclipse/emf/common/util/URI;
    //   141: astore 6
    //   143: aload_0
    //   144: getfield 238	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$inputResource	Lorg/eclipse/emf/ecore/resource/Resource;
    //   147: invokeinterface 273 1 0
    //   152: aload 6
    //   154: invokeinterface 274 2 0
    //   159: astore 7
    //   161: aload_1
    //   162: getstatic 241	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:INSTANCE	Lorg/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin;
    //   165: ldc 3
    //   167: invokevirtual 258	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:getString	(Ljava/lang/String;)Ljava/lang/String;
    //   170: iconst_2
    //   171: anewarray 103	java/lang/Object
    //   174: dup
    //   175: iconst_0
    //   176: aload_0
    //   177: getfield 238	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$inputResource	Lorg/eclipse/emf/ecore/resource/Resource;
    //   180: invokeinterface 272 1 0
    //   185: invokevirtual 247	org/eclipse/emf/common/util/URI:lastSegment	()Ljava/lang/String;
    //   188: aastore
    //   189: dup
    //   190: iconst_1
    //   191: aload_3
    //   192: invokeinterface 272 1 0
    //   197: invokevirtual 247	org/eclipse/emf/common/util/URI:lastSegment	()Ljava/lang/String;
    //   200: aastore
    //   201: invokestatic 246	java/text/MessageFormat:format	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   204: invokeinterface 267 2 0
    //   209: aload 7
    //   211: invokeinterface 271 1 0
    //   216: aload_0
    //   217: getfield 237	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$inputEPackage	Lorg/eclipse/emf/ecore/EPackage;
    //   220: aload 4
    //   222: invokestatic 255	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate:createMappingRoot	(Lorg/eclipse/emf/ecore/EPackage;Lorg/eclipse/emf/ecore/EPackage;)Lorg/eclipse/emf/mapping/ecore2ecore/Ecore2EcoreMappingRoot;
    //   225: invokeinterface 269 2 0
    //   230: pop
    //   231: aload 7
    //   233: aconst_null
    //   234: invokeinterface 270 2 0
    //   239: aload_0
    //   240: getfield 239	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:this$0	Lorg/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate;
    //   243: aload 7
    //   245: invokevirtual 254	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate:getFile	(Lorg/eclipse/emf/ecore/resource/Resource;)Lorg/eclipse/core/resources/IFile;
    //   248: astore 8
    //   250: aload_0
    //   251: getfield 240	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$workbenchWindow	Lorg/eclipse/ui/IWorkbenchWindow;
    //   254: invokeinterface 283 1 0
    //   259: astore 9
    //   261: aload 9
    //   263: invokeinterface 279 1 0
    //   268: astore 10
    //   270: aload 10
    //   272: instanceof 132
    //   275: ifeq +41 -> 316
    //   278: new 121	org/eclipse/jface/viewers/StructuredSelection
    //   281: dup
    //   282: aload 8
    //   284: invokespecial 259	org/eclipse/jface/viewers/StructuredSelection:<init>	(Ljava/lang/Object;)V
    //   287: astore 11
    //   289: aload_0
    //   290: getfield 240	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$workbenchWindow	Lorg/eclipse/ui/IWorkbenchWindow;
    //   293: invokeinterface 281 1 0
    //   298: invokevirtual 261	org/eclipse/swt/widgets/Shell:getDisplay	()Lorg/eclipse/swt/widgets/Display;
    //   301: new 119	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2$1
    //   304: dup
    //   305: aload_0
    //   306: aload 10
    //   308: aload 11
    //   310: invokespecial 256	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2$1:<init>	(Lorg/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2;Lorg/eclipse/ui/IWorkbenchPart;Lorg/eclipse/jface/viewers/ISelection;)V
    //   313: invokevirtual 260	org/eclipse/swt/widgets/Display:asyncExec	(Ljava/lang/Runnable;)V
    //   316: aload 9
    //   318: new 131	org/eclipse/ui/part/FileEditorInput
    //   321: dup
    //   322: aload 8
    //   324: invokespecial 263	org/eclipse/ui/part/FileEditorInput:<init>	(Lorg/eclipse/core/resources/IFile;)V
    //   327: aload_0
    //   328: getfield 240	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$workbenchWindow	Lorg/eclipse/ui/IWorkbenchWindow;
    //   331: invokeinterface 282 1 0
    //   336: invokeinterface 278 1 0
    //   341: aload 8
    //   343: invokeinterface 264 1 0
    //   348: invokeinterface 265 1 0
    //   353: invokeinterface 277 2 0
    //   358: invokeinterface 276 1 0
    //   363: invokeinterface 280 3 0
    //   368: pop
    //   369: goto +26 -> 395
    //   372: astore 11
    //   374: getstatic 241	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:INSTANCE	Lorg/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin;
    //   377: aload 11
    //   379: invokevirtual 257	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:log	(Ljava/lang/Object;)V
    //   382: goto +13 -> 395
    //   385: astore 8
    //   387: getstatic 241	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:INSTANCE	Lorg/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin;
    //   390: aload 8
    //   392: invokevirtual 257	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:log	(Ljava/lang/Object;)V
    //   395: iinc 2 1
    //   398: iload_2
    //   399: aload_0
    //   400: getfield 236	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$files	[Lorg/eclipse/core/resources/IFile;
    //   403: arraylength
    //   404: if_icmplt -386 -> 18
    //   407: goto +14 -> 421
    //   410: astore 12
    //   412: aload_1
    //   413: invokeinterface 266 1 0
    //   418: aload 12
    //   420: athrow
    //   421: aload_1
    //   422: invokeinterface 266 1 0
    //   427: return
    // Line number table:
    //   Java source line #158	-> byte code offset #0
    //   Java source line #160	-> byte code offset #13
    //   Java source line #162	-> byte code offset #18
    //   Java source line #163	-> byte code offset #27
    //   Java source line #164	-> byte code offset #47
    //   Java source line #162	-> byte code offset #48
    //   Java source line #165	-> byte code offset #54
    //   Java source line #167	-> byte code offset #71
    //   Java source line #168	-> byte code offset #101
    //   Java source line #167	-> byte code offset #116
    //   Java source line #169	-> byte code offset #121
    //   Java source line #171	-> byte code offset #143
    //   Java source line #173	-> byte code offset #161
    //   Java source line #174	-> byte code offset #162
    //   Java source line #175	-> byte code offset #170
    //   Java source line #173	-> byte code offset #201
    //   Java source line #177	-> byte code offset #209
    //   Java source line #181	-> byte code offset #231
    //   Java source line #183	-> byte code offset #239
    //   Java source line #184	-> byte code offset #250
    //   Java source line #186	-> byte code offset #261
    //   Java source line #187	-> byte code offset #270
    //   Java source line #189	-> byte code offset #278
    //   Java source line #190	-> byte code offset #289
    //   Java source line #200	-> byte code offset #316
    //   Java source line #201	-> byte code offset #372
    //   Java source line #202	-> byte code offset #374
    //   Java source line #205	-> byte code offset #385
    //   Java source line #207	-> byte code offset #387
    //   Java source line #160	-> byte code offset #395
    //   Java source line #212	-> byte code offset #410
    //   Java source line #213	-> byte code offset #412
    //   Java source line #214	-> byte code offset #418
    //   Java source line #213	-> byte code offset #421
    //   Java source line #215	-> byte code offset #427
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	428	0	this	2
    //   0	428	1	progressMonitor	org.eclipse.core.runtime.IProgressMonitor
    //   14	385	2	i	int
    //   53	139	3	outputResource	Resource
    //   69	152	4	outputEPackage	EPackage
    //   119	13	5	base	String
    //   141	12	6	mappingURI	org.eclipse.emf.common.util.URI
    //   159	85	7	mappingResource	Resource
    //   248	94	8	file	IFile
    //   385	6	8	ioe	java.io.IOException
    //   259	58	9	workbenchPage	org.eclipse.ui.IWorkbenchPage
    //   268	39	10	activePart	IWorkbenchPart
    //   287	22	11	targetSelection	ISelection
    //   372	6	11	pie	org.eclipse.ui.PartInitException
    //   410	9	12	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   316	369	372	org/eclipse/ui/PartInitException
    //   231	382	385	java/io/IOException
    //   0	410	410	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2ecore.action.MapToEcoreActionDelegate.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2ecore.action;

import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EcorePackage.Literals;
import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
import org.eclipse.emf.mapping.domain.PluginAdapterFactoryMappingDomain;
import org.eclipse.emf.mapping.ecore2ecore.Ecore2EcoreFactory;
import org.eclipse.emf.mapping.ecore2ecore.Ecore2EcoreMappingRoot;
import org.eclipse.emf.mapping.ecore2ecore.presentation.Ecore2EcoreEditorPlugin;
import org.eclipse.emf.mapping.provider.MappingItemProviderAdapterFactory;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.part.ISetSelectionTarget;

public class MapToEcoreActionDelegate
  extends ActionDelegate
{
  private static final List<String> FILE_EXTENSIONS = Arrays.asList(new String[] { "ecore", "emof" });
  private static final String ECORE2ECORE_FILE_EXTENSION = "ecore2ecore";
  
  protected EPackage getInputEPackage(IStructuredSelection structuredSelection)
  {
    if (IFile.class.isInstance(structuredSelection.getFirstElement()))
    {
      IFile file = (IFile)structuredSelection.getFirstElement();
      if (FILE_EXTENSIONS.contains(file.getFullPath().getFileExtension())) {
        return 
          (EPackage)EcoreUtil.getObjectByType(
          new ResourceSetImpl().getResource(URI.createPlatformResourceURI(file.getFullPath().toString(), true), true).getContents(), 
          EcorePackage.Literals.EPACKAGE);
      }
    }
    return null;
  }
  
  protected IFile getFile(Resource resource)
  {
    URI uri = resource.getURI();
    uri = resource.getResourceSet().getURIConverter().normalize(uri);
    String platformResourceString = uri.toPlatformString(true);
    return platformResourceString != null ? 
      ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformResourceString)) : 
      null;
  }
  
  public void run(IAction action)
  {
    final IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    Object selection = ((IStructuredSelection)workbenchWindow.getSelectionService().getSelection()).getFirstElement();
    final IFile selectedEcoreFile = 
      ((selection instanceof IFile)) && (FILE_EXTENSIONS.contains(((IFile)selection).getFileExtension())) ? 
      (IFile)selection : 
      null;
    
    ViewerFilter viewerFilter = new ViewerFilter()
    {
      public boolean select(Viewer viewer, Object parentElement, Object element)
      {
        if ((element instanceof IFile))
        {
          IFile file = (IFile)element;
          
          return (MapToEcoreActionDelegate.FILE_EXTENSIONS.contains(file.getFileExtension())) && ((selectedEcoreFile == null) || (!selectedEcoreFile.getFullPath().equals(file.getFullPath())));
        }
        return true;
      }
    };
    final IFile[] files = WorkspaceResourceDialog.openFileSelection(
      workbenchWindow.getShell(), 
      null, 
      Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_SelectOutputEcoreModels_label"), 
      true, 
      null, 
      Collections.singletonList(viewerFilter));
    if (files.length > 0)
    {
      final EPackage inputEPackage = getInputEPackage((IStructuredSelection)workbenchWindow.getSelectionService().getSelection());
      final Resource inputResource = inputEPackage.eResource();
      
      ProgressMonitorDialog dialog = new ProgressMonitorDialog(workbenchWindow.getShell());
      try
      {
        dialog.run(false, true, 
          new WorkspaceModifyOperation()
          {
            /* Error */
            protected void execute(org.eclipse.core.runtime.IProgressMonitor progressMonitor)
            {
              // Byte code:
              //   0: aload_1
              //   1: ldc 1
              //   3: aload_0
              //   4: getfield 236	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$files	[Lorg/eclipse/core/resources/IFile;
              //   7: arraylength
              //   8: invokeinterface 268 3 0
              //   13: iconst_0
              //   14: istore_2
              //   15: goto +383 -> 398
              //   18: aload_0
              //   19: getfield 238	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$inputResource	Lorg/eclipse/emf/ecore/resource/Resource;
              //   22: invokeinterface 273 1 0
              //   27: aload_0
              //   28: getfield 236	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$files	[Lorg/eclipse/core/resources/IFile;
              //   31: iload_2
              //   32: aaload
              //   33: invokeinterface 264 1 0
              //   38: invokeinterface 265 1 0
              //   43: iconst_1
              //   44: invokestatic 252	org/eclipse/emf/common/util/URI:createPlatformResourceURI	(Ljava/lang/String;Z)Lorg/eclipse/emf/common/util/URI;
              //   47: iconst_1
              //   48: invokeinterface 275 3 0
              //   53: astore_3
              //   54: aload_3
              //   55: invokeinterface 271 1 0
              //   60: getstatic 235	org/eclipse/emf/ecore/EcorePackage$Literals:EPACKAGE	Lorg/eclipse/emf/ecore/EClass;
              //   63: invokestatic 253	org/eclipse/emf/ecore/util/EcoreUtil:getObjectByType	(Ljava/util/Collection;Lorg/eclipse/emf/ecore/EClassifier;)Ljava/lang/Object;
              //   66: checkcast 112	org/eclipse/emf/ecore/EPackage
              //   69: astore 4
              //   71: new 105	java/lang/StringBuilder
              //   74: dup
              //   75: aload_0
              //   76: getfield 238	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$inputResource	Lorg/eclipse/emf/ecore/resource/Resource;
              //   79: invokeinterface 272 1 0
              //   84: invokevirtual 248	org/eclipse/emf/common/util/URI:trimFileExtension	()Lorg/eclipse/emf/common/util/URI;
              //   87: invokevirtual 247	org/eclipse/emf/common/util/URI:lastSegment	()Ljava/lang/String;
              //   90: invokestatic 242	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
              //   93: invokespecial 244	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
              //   96: ldc 2
              //   98: invokevirtual 245	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
              //   101: aload_3
              //   102: invokeinterface 272 1 0
              //   107: invokevirtual 248	org/eclipse/emf/common/util/URI:trimFileExtension	()Lorg/eclipse/emf/common/util/URI;
              //   110: invokevirtual 247	org/eclipse/emf/common/util/URI:lastSegment	()Ljava/lang/String;
              //   113: invokevirtual 245	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
              //   116: invokevirtual 243	java/lang/StringBuilder:toString	()Ljava/lang/String;
              //   119: astore 5
              //   121: aload_3
              //   122: invokeinterface 272 1 0
              //   127: iconst_1
              //   128: invokevirtual 249	org/eclipse/emf/common/util/URI:trimSegments	(I)Lorg/eclipse/emf/common/util/URI;
              //   131: aload 5
              //   133: invokevirtual 251	org/eclipse/emf/common/util/URI:appendSegment	(Ljava/lang/String;)Lorg/eclipse/emf/common/util/URI;
              //   136: ldc 4
              //   138: invokevirtual 250	org/eclipse/emf/common/util/URI:appendFileExtension	(Ljava/lang/String;)Lorg/eclipse/emf/common/util/URI;
              //   141: astore 6
              //   143: aload_0
              //   144: getfield 238	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$inputResource	Lorg/eclipse/emf/ecore/resource/Resource;
              //   147: invokeinterface 273 1 0
              //   152: aload 6
              //   154: invokeinterface 274 2 0
              //   159: astore 7
              //   161: aload_1
              //   162: getstatic 241	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:INSTANCE	Lorg/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin;
              //   165: ldc 3
              //   167: invokevirtual 258	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:getString	(Ljava/lang/String;)Ljava/lang/String;
              //   170: iconst_2
              //   171: anewarray 103	java/lang/Object
              //   174: dup
              //   175: iconst_0
              //   176: aload_0
              //   177: getfield 238	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$inputResource	Lorg/eclipse/emf/ecore/resource/Resource;
              //   180: invokeinterface 272 1 0
              //   185: invokevirtual 247	org/eclipse/emf/common/util/URI:lastSegment	()Ljava/lang/String;
              //   188: aastore
              //   189: dup
              //   190: iconst_1
              //   191: aload_3
              //   192: invokeinterface 272 1 0
              //   197: invokevirtual 247	org/eclipse/emf/common/util/URI:lastSegment	()Ljava/lang/String;
              //   200: aastore
              //   201: invokestatic 246	java/text/MessageFormat:format	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
              //   204: invokeinterface 267 2 0
              //   209: aload 7
              //   211: invokeinterface 271 1 0
              //   216: aload_0
              //   217: getfield 237	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$inputEPackage	Lorg/eclipse/emf/ecore/EPackage;
              //   220: aload 4
              //   222: invokestatic 255	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate:createMappingRoot	(Lorg/eclipse/emf/ecore/EPackage;Lorg/eclipse/emf/ecore/EPackage;)Lorg/eclipse/emf/mapping/ecore2ecore/Ecore2EcoreMappingRoot;
              //   225: invokeinterface 269 2 0
              //   230: pop
              //   231: aload 7
              //   233: aconst_null
              //   234: invokeinterface 270 2 0
              //   239: aload_0
              //   240: getfield 239	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:this$0	Lorg/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate;
              //   243: aload 7
              //   245: invokevirtual 254	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate:getFile	(Lorg/eclipse/emf/ecore/resource/Resource;)Lorg/eclipse/core/resources/IFile;
              //   248: astore 8
              //   250: aload_0
              //   251: getfield 240	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$workbenchWindow	Lorg/eclipse/ui/IWorkbenchWindow;
              //   254: invokeinterface 283 1 0
              //   259: astore 9
              //   261: aload 9
              //   263: invokeinterface 279 1 0
              //   268: astore 10
              //   270: aload 10
              //   272: instanceof 132
              //   275: ifeq +41 -> 316
              //   278: new 121	org/eclipse/jface/viewers/StructuredSelection
              //   281: dup
              //   282: aload 8
              //   284: invokespecial 259	org/eclipse/jface/viewers/StructuredSelection:<init>	(Ljava/lang/Object;)V
              //   287: astore 11
              //   289: aload_0
              //   290: getfield 240	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$workbenchWindow	Lorg/eclipse/ui/IWorkbenchWindow;
              //   293: invokeinterface 281 1 0
              //   298: invokevirtual 261	org/eclipse/swt/widgets/Shell:getDisplay	()Lorg/eclipse/swt/widgets/Display;
              //   301: new 119	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2$1
              //   304: dup
              //   305: aload_0
              //   306: aload 10
              //   308: aload 11
              //   310: invokespecial 256	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2$1:<init>	(Lorg/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2;Lorg/eclipse/ui/IWorkbenchPart;Lorg/eclipse/jface/viewers/ISelection;)V
              //   313: invokevirtual 260	org/eclipse/swt/widgets/Display:asyncExec	(Ljava/lang/Runnable;)V
              //   316: aload 9
              //   318: new 131	org/eclipse/ui/part/FileEditorInput
              //   321: dup
              //   322: aload 8
              //   324: invokespecial 263	org/eclipse/ui/part/FileEditorInput:<init>	(Lorg/eclipse/core/resources/IFile;)V
              //   327: aload_0
              //   328: getfield 240	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$workbenchWindow	Lorg/eclipse/ui/IWorkbenchWindow;
              //   331: invokeinterface 282 1 0
              //   336: invokeinterface 278 1 0
              //   341: aload 8
              //   343: invokeinterface 264 1 0
              //   348: invokeinterface 265 1 0
              //   353: invokeinterface 277 2 0
              //   358: invokeinterface 276 1 0
              //   363: invokeinterface 280 3 0
              //   368: pop
              //   369: goto +26 -> 395
              //   372: astore 11
              //   374: getstatic 241	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:INSTANCE	Lorg/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin;
              //   377: aload 11
              //   379: invokevirtual 257	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:log	(Ljava/lang/Object;)V
              //   382: goto +13 -> 395
              //   385: astore 8
              //   387: getstatic 241	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:INSTANCE	Lorg/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin;
              //   390: aload 8
              //   392: invokevirtual 257	org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreEditorPlugin:log	(Ljava/lang/Object;)V
              //   395: iinc 2 1
              //   398: iload_2
              //   399: aload_0
              //   400: getfield 236	org/eclipse/emf/mapping/ecore2ecore/action/MapToEcoreActionDelegate$2:val$files	[Lorg/eclipse/core/resources/IFile;
              //   403: arraylength
              //   404: if_icmplt -386 -> 18
              //   407: goto +14 -> 421
              //   410: astore 12
              //   412: aload_1
              //   413: invokeinterface 266 1 0
              //   418: aload 12
              //   420: athrow
              //   421: aload_1
              //   422: invokeinterface 266 1 0
              //   427: return
              // Line number table:
              //   Java source line #158	-> byte code offset #0
              //   Java source line #160	-> byte code offset #13
              //   Java source line #162	-> byte code offset #18
              //   Java source line #163	-> byte code offset #27
              //   Java source line #164	-> byte code offset #47
              //   Java source line #162	-> byte code offset #48
              //   Java source line #165	-> byte code offset #54
              //   Java source line #167	-> byte code offset #71
              //   Java source line #168	-> byte code offset #101
              //   Java source line #167	-> byte code offset #116
              //   Java source line #169	-> byte code offset #121
              //   Java source line #171	-> byte code offset #143
              //   Java source line #173	-> byte code offset #161
              //   Java source line #174	-> byte code offset #162
              //   Java source line #175	-> byte code offset #170
              //   Java source line #173	-> byte code offset #201
              //   Java source line #177	-> byte code offset #209
              //   Java source line #181	-> byte code offset #231
              //   Java source line #183	-> byte code offset #239
              //   Java source line #184	-> byte code offset #250
              //   Java source line #186	-> byte code offset #261
              //   Java source line #187	-> byte code offset #270
              //   Java source line #189	-> byte code offset #278
              //   Java source line #190	-> byte code offset #289
              //   Java source line #200	-> byte code offset #316
              //   Java source line #201	-> byte code offset #372
              //   Java source line #202	-> byte code offset #374
              //   Java source line #205	-> byte code offset #385
              //   Java source line #207	-> byte code offset #387
              //   Java source line #160	-> byte code offset #395
              //   Java source line #212	-> byte code offset #410
              //   Java source line #213	-> byte code offset #412
              //   Java source line #214	-> byte code offset #418
              //   Java source line #213	-> byte code offset #421
              //   Java source line #215	-> byte code offset #427
              // Local variable table:
              //   start	length	slot	name	signature
              //   0	428	0	this	2
              //   0	428	1	progressMonitor	org.eclipse.core.runtime.IProgressMonitor
              //   14	385	2	i	int
              //   53	139	3	outputResource	Resource
              //   69	152	4	outputEPackage	EPackage
              //   119	13	5	base	String
              //   141	12	6	mappingURI	URI
              //   159	85	7	mappingResource	Resource
              //   248	94	8	file	IFile
              //   385	6	8	ioe	java.io.IOException
              //   259	58	9	workbenchPage	org.eclipse.ui.IWorkbenchPage
              //   268	39	10	activePart	IWorkbenchPart
              //   287	22	11	targetSelection	ISelection
              //   372	6	11	pie	org.eclipse.ui.PartInitException
              //   410	9	12	localObject	Object
              // Exception table:
              //   from	to	target	type
              //   316	369	372	org/eclipse/ui/PartInitException
              //   231	382	385	java/io/IOException
              //   0	410	410	finally
            }
          });
      }
      catch (InterruptedException localInterruptedException) {}catch (InvocationTargetException ite)
      {
        Ecore2EcoreEditorPlugin.INSTANCE.log(ite);
      }
    }
  }
  
  protected static Ecore2EcoreMappingRoot createMappingRoot(EPackage inputEPackage, EPackage outputEPackage)
  {
    Ecore2EcoreMappingRoot mappingRoot = Ecore2EcoreFactory.eINSTANCE.createEcore2EcoreMappingRoot();
    mappingRoot.setTopToBottom(true);
    
    AdapterFactory ecoreAdapterFactory = new EcoreItemProviderAdapterFactory();
    AdapterFactory composedAdapterFactory = new ComposedAdapterFactory(
    
      new AdapterFactory[] {
      new ResourceItemProviderAdapterFactory(), 
      new MappingItemProviderAdapterFactory(), 
      ecoreAdapterFactory });
    
    mappingRoot.setDomain(new PluginAdapterFactoryMappingDomain(composedAdapterFactory, ecoreAdapterFactory, null, null));
    
    mappingRoot.getInputs().add(inputEPackage);
    mappingRoot.getOutputs().add(outputEPackage);
    
    return mappingRoot;
  }
  
  public void selectionChanged(IAction action, ISelection selection)
  {
    action.setEnabled((IStructuredSelection.class.isInstance(selection)) && (getInputEPackage((IStructur
1 2 3

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