org.eclipse.emf.mapping.ecore2xml.ui_2.6.0.v20120130-0943

16:43:42.238 INFO  jd.cli.Main - Decompiling org.eclipse.emf.mapping.ecore2xml.ui_2.6.0.v20120130-0943.jar
package org.eclipse.emf.mapping.ecore2xml.action;

import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreSwitch;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xmi.XMLResource.XMLInfo;

class GenerateEcore2XMLActionDelegate$1
  extends EcoreSwitch<Object>
{
  GenerateEcore2XMLActionDelegate$1(XMLResource.XMLInfo paramXMLInfo) {}
  
  public Object caseEPackage(EPackage ePackage)
  {
    val$xmlInfo.setName(ePackage.getName());
    val$xmlInfo.setTargetNamespace(ExtendedMetaData.INSTANCE.getNamespace(ePackage));
    
    return val$xmlInfo;
  }
  
  public Object caseEClassifier(EClassifier eClassifier)
  {
    val$xmlInfo.setName(ExtendedMetaData.INSTANCE.getName(eClassifier));
    val$xmlInfo.setTargetNamespace(ExtendedMetaData.INSTANCE.getNamespace(eClassifier));
    
    return val$xmlInfo;
  }
  
  public Object caseEStructuralFeature(EStructuralFeature eStructuralFeature)
  {
    val$xmlInfo.setName(ExtendedMetaData.INSTANCE.getName(eStructuralFeature));
    val$xmlInfo.setTargetNamespace(ExtendedMetaData.INSTANCE.getNamespace(eStructuralFeature));
    val$xmlInfo.setXMLRepresentation(GenerateEcore2XMLActionDelegate.getXMLRepresentation(eStructuralFeature));
    
    return val$xmlInfo;
  }
}

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

import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreSwitch;
import org.eclipse.emf.ecore.xmi.XMLResource.XMLInfo;
import org.eclipse.emf.ecore.xmi.XMLResource.XMLMap;

class GenerateEcore2XMLActionDelegate$2
  extends EcoreSwitch<Object>
{
  GenerateEcore2XMLActionDelegate$2(EObject paramEObject, XMLResource.XMLMap paramXMLMap) {}
  
  public Object caseEPackage(EPackage ePackage)
  {
    XMLResource.XMLInfo xmlInfo = GenerateEcore2XMLActionDelegate.createXMLInfo(val$input);
    val$xmlMap.add(ePackage, xmlInfo);
    return xmlInfo;
  }
  
  public Object caseEClassifier(EClassifier eClassifier)
  {
    XMLResource.XMLInfo xmlInfo = GenerateEcore2XMLActionDelegate.createXMLInfo(val$input);
    val$xmlMap.add(eClassifier, xmlInfo);
    return xmlInfo;
  }
  
  public Object caseEStructuralFeature(EStructuralFeature eStructuralFeature)
  {
    XMLResource.XMLInfo xmlInfo = GenerateEcore2XMLActionDelegate.createXMLInfo(val$input);
    if (val$input == null)
    {
      int xmlRepresentation = GenerateEcore2XMLActionDelegate.getXMLRepresentation(eStructuralFeature);
      if (xmlRepresentation == -1) {
        xmlRepresentation = ((eStructuralFeature instanceof EReference)) && (((EReference)eStructuralFeature).isContainment()) ? 
          0 : 1;
      }
      xmlInfo.setXMLRepresentation(xmlRepresentation);
    }
    val$xmlMap.add(eStructuralFeature, xmlInfo);
    return xmlInfo;
  }
}

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

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

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

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

import java.io.IOException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.mapping.ecore2ecore.Ecore2EcoreMappingRoot;
import org.eclipse.emf.mapping.ecore2xml.ui.Ecore2XMLUIPlugin;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.ISetSelectionTarget;

class GenerateEcore2XMLActionDelegate$3
  extends WorkspaceModifyOperation
{
  GenerateEcore2XMLActionDelegate$3(GenerateEcore2XMLActionDelegate paramGenerateEcore2XMLActionDelegate, IWorkbenchWindow paramIWorkbenchWindow) {}
  
  protected void execute(IProgressMonitor progressMonitor)
  {
    try
    {
      progressMonitor.beginTask("", -1);
      
      Ecore2EcoreMappingRoot mappingRoot = this$0.getMappingRoot((IStructuredSelection)val$workbenchWindow.getSelectionService().getSelection());
      if (mappingRoot != null)
      {
        Resource ecore2ecoreResource = mappingRoot.eResource();
        
        URI ecore2xmlURI = ecore2ecoreResource.getURI().trimFileExtension().appendFileExtension("ecore2xml");
        Resource ecore2xmlResource = ecore2ecoreResource.getResourceSet().createResource(ecore2xmlURI);
        
        ecore2xmlResource.getContents().add((EObject)GenerateEcore2XMLActionDelegate.createXMLMap(mappingRoot));
        try
        {
          ecore2xmlResource.save(null);
          
          IFile file = this$0.getFile(ecore2xmlResource);
          IWorkbenchPage workbenchPage = val$workbenchWindow.getActivePage();
          
          final IWorkbenchPart activePart = workbenchPage.getActivePart();
          if ((activePart instanceof ISetSelectionTarget))
          {
            final ISelection targetSelection = new StructuredSelection(file);
            val$workbenchWindow.getShell().getDisplay().asyncExec(new Runnable()
            {
              public void run()
              {
                ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
              }
            });
          }
          try
          {
            workbenchPage.openEditor(new FileEditorInput(file), val$workbenchWindow.getWorkbench().getEditorRegistry().getDefaultEditor(file.getFullPath().toString()).getId());
          }
          catch (PartInitException pie)
          {
            Ecore2XMLUIPlugin.INSTANCE.log(pie);
          }
          localObject = finally;
        }
        catch (IOException ioe)
        {
          Ecore2XMLUIPlugin.INSTANCE.log(ioe);
        }
      }
      progressMonitor.done();
    }
    finally
    {
      progressMonitor.done();
      throw ((Throwable)localObject);
    }
  }
}

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

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
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.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
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.EcoreSwitch;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xmi.XMLResource.XMLInfo;
import org.eclipse.emf.ecore.xmi.XMLResource.XMLMap;
import org.eclipse.emf.mapping.Mapping;
import org.eclipse.emf.mapping.ecore2ecore.Ecore2EcoreMappingRoot;
import org.eclipse.emf.mapping.ecore2ecore.Ecore2EcorePackage.Literals;
import org.eclipse.emf.mapping.ecore2xml.Ecore2XMLFactory;
import org.eclipse.emf.mapping.ecore2xml.ui.Ecore2XMLUIPlugin;
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.StructuredSelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.part.ISetSelectionTarget;

public class GenerateEcore2XMLActionDelegate
  extends ActionDelegate
{
  private static final String ECORE2ECORE_FILE_EXTENSION = "ecore2ecore";
  
  protected Ecore2EcoreMappingRoot getMappingRoot(IStructuredSelection structuredSelection)
  {
    if (IFile.class.isInstance(structuredSelection.getFirstElement()))
    {
      IFile file = (IFile)structuredSelection.getFirstElement();
      if ("ecore2ecore".equals(file.getFullPath().getFileExtension())) {
        return 
          (Ecore2EcoreMappingRoot)EcoreUtil.getObjectByType(
          new ResourceSetImpl().getResource(URI.createPlatformResourceURI(file.getFullPath().toString(), true), true).getContents(), 
          Ecore2EcorePackage.Literals.ECORE2_ECORE_MAPPING_ROOT);
      }
    }
    return null;
  }
  
  protected static int getXMLRepresentation(EStructuralFeature eStructuralFeature)
  {
    switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature))
    {
    case 2: 
      return 1;
    case 4: 
      return 0;
    }
    return -1;
  }
  
  protected static XMLResource.XMLInfo createXMLInfo(EObject eObject)
  {
    XMLResource.XMLInfo xmlInfo = Ecore2XMLFactory.eINSTANCE.createXMLInfo();
    if (eObject != null) {
      new EcoreSwitch()
      {
        public Object caseEPackage(EPackage ePackage)
        {
          setName(ePackage.getName());
          setTargetNamespace(ExtendedMetaData.INSTANCE.getNamespace(ePackage));
          
          return GenerateEcore2XMLActionDelegate.this;
        }
        
        public Object caseEClassifier(EClassifier eClassifier)
        {
          setName(ExtendedMetaData.INSTANCE.getName(eClassifier));
          setTargetNamespace(ExtendedMetaData.INSTANCE.getNamespace(eClassifier));
          
          return GenerateEcore2XMLActionDelegate.this;
        }
        
        public Object caseEStructuralFeature(EStructuralFeature eStructuralFeature)
        {
          setName(ExtendedMetaData.INSTANCE.getName(eStructuralFeature));
          setTargetNamespace(ExtendedMetaData.INSTANCE.getNamespace(eStructuralFeature));
          setXMLRepresentation(GenerateEcore2XMLActionDelegate.getXMLRepresentation(eStructuralFeature));
          
          return GenerateEcore2XMLActionDelegate.this;
        }
      }.doSwitch(eObject);
    }
    return xmlInfo;
  }
  
  protected static XMLResource.XMLMap createXMLMap(Ecore2EcoreMappingRoot mappingRoot)
  {
    final XMLResource.XMLMap xmlMap = Ecore2XMLFactory.eINSTANCE.createXMLMap();
    Iterator localIterator;
    for (TreeIterator<Mapping> mappings = mappingRoot.treeIterator(); mappings.hasNext(); localIterator.hasNext())
    {
      Mapping mapping = (Mapping)mappings.next();
      EList<EObject> inputs = mapping.getInputs();
      EObject input = inputs.isEmpty() ? null : (EObject)inputs.get(0);
      
      localIterator = mapping.getOutputs().iterator(); continue;EObject output = (EObject)localIterator.next();
      
      new EcoreSwitch()
      {
        public Object caseEPackage(EPackage ePackage)
        {
          XMLResource.XMLInfo xmlInfo = GenerateEcore2XMLActionDelegate.createXMLInfo(GenerateEcore2XMLActionDelegate.this);
          xmlMap.add(ePackage, xmlInfo);
          return xmlInfo;
        }
        
        public Object caseEClassifier(EClassifier eClassifier)
        {
          XMLResource.XMLInfo xmlInfo = GenerateEcore2XMLActionDelegate.createXMLInfo(GenerateEcore2XMLActionDelegate.this);
          xmlMap.add(eClassifier, xmlInfo);
          return xmlInfo;
        }
        
        public Object caseEStructuralFeature(EStructuralFeature eStructuralFeature)
        {
          XMLResource.XMLInfo xmlInfo = GenerateEcore2XMLActionDelegate.createXMLInfo(GenerateEcore2XMLActionDelegate.this);
          if (GenerateEcore2XMLActionDelegate.this == null)
          {
            int xmlRepresentation = GenerateEcore2XMLActionDelegate.getXMLRepresentation(eStructuralFeature);
            if (xmlRepresentation == -1) {
              xmlRepresentation = ((eStructuralFeature instanceof EReference)) && (((EReference)eStructuralFeature).isContainment()) ? 
                0 : 1;
            }
            xmlInfo.setXMLRepresentation(xmlRepresentation);
          }
          xmlMap.add(eStructuralFeature, xmlInfo);
          return xmlInfo;
        }
      }.doSwitch(output);
    }
    return xmlMap;
  }
  
  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();
    try
    {
      new ProgressMonitorDialog(workbenchWindow.getShell()).run(false, true, new WorkspaceModifyOperation()
      {
        protected void execute(IProgressMonitor progressMonitor)
        {
          try
          {
            progressMonitor.beginTask("", -1);
            
            Ecore2EcoreMappingRoot mappingRoot = getMappingRoot((IStructuredSelection)workbenchWindow.getSelectionService().getSelection());
            if (mappingRoot != null)
            {
              Resource ecore2ecoreResource = mappingRoot.eResource();
              
              URI ecore2xmlURI = ecore2ecoreResource.getURI().trimFileExtension().appendFileExtension("ecore2xml");
              Resource ecore2xmlResource = ecore2ecoreResource.getResourceSet().createResource(ecore2xmlURI);
              
              ecore2xmlResource.getContents().add((EObject)GenerateEcore2XMLActionDelegate.createXMLMap(mappingRoot));
              try
              {
                ecore2xmlResource.save(null);
                
                IFile file = getFile(ecore2xmlResource);
                IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
                
                final IWorkbenchPart activePart = workbenchPage.getActivePart();
                if ((activePart instanceof ISetSelectionTarget))
                {
                  final ISelection targetSelection = new StructuredSelection(file);
                  workbenchWindow.getShell().getDisplay().asyncExec(new Runnable()
                  {
                    public void run()
                    {
                      ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
                    }
                  });
                }
                try
                {
                  workbenchPage.openEditor(new FileEditorInput(file), workbenchWindow.getWorkbench().getEditorRegistry().getDefaultEditor(file.getFullPath().toString()).getId());
                }
                catch (PartInitException pie)
                {
                  Ecore2XMLUIPlugin.INSTANCE.log(pie);
                }
                localObject = finally;
              }
              catch (IOException ioe)
              {
                Ecore2XMLUIPlugin.INSTANCE.log(ioe);
              }
            }
            progressMonitor.done();
          }
          finally
          {
            progressMonitor.done();
            throw ((Throwable)localObject);
          }
        }
      });
    }
    catch (InterruptedException localInterruptedException) {}catch (InvocationTargetException ite)
    {
      Ecore2XMLUIPlugin.INSTANCE.log(ite);
    }
  }
  
  public void selectionChanged(IAction action, ISelection selection)
  {
    action.setEnabled((IStructuredSelection.class.isInstance(selection)) && (getMappingRoot((IStructuredSelection)selection) != null));
  }
}

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

import org.eclipse.emf.mapping.ecore2xml.ui.Ecore2XMLUIPlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;

class Ecore2XMLActionBarContributor$1
  extends Action
{
  Ecore2XMLActionBarContributor$1(Ecore2XMLActionBarContributor paramEcore2XMLActionBarContributor, String $anonymous0)
  {
    super($anonymous0);
  }
  
  public void run()
  {
    try
    {
      this$0.getPage().showView("org.eclipse.ui.views.PropertySheet");
    }
    catch (PartInitException exception)
    {
      Ecore2XMLUIPlugin.INSTANCE.log(exception);
    }
  }
}

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

import org.eclipse.emf.common.ui.viewer.IViewerProvider;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.Viewer;

class Ecore2XMLActionBarContributor$2
  extends Action
{
  Ecore2XMLActionBarContributor$2(Ecore2XMLActionBarContributor paramEcore2XMLActionBarContributor, String $anonymous0)
  {
    super($anonymous0);
  }
  
  public boolean isEnabled()
  {
    return this$0.activeEditorPart instanceof IViewerProvider;
  }
  
  public void run()
  {
    if ((this$0.activeEditorPart instanceof IViewerProvider))
    {
      Viewer viewer = ((IViewerProvider)this$0.activeEditorPart).getViewer();
      if (viewer != null) {
        viewer.refresh();
      }
    }
  }
}

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

import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;

class Ecore2XMLActionBarContributor$3
  implements IMenuListener
{
  Ecore2XMLActionBarContributor$3(Ecore2XMLActionBarContributor paramEcore2XMLActionBarContributor) {}
  
  public void menuAboutToShow(IMenuManager menuManager)
  {
    menuManager.updateAll(true);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2xml.presentation.Ecore2XMLActionBarContributor.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2xml.presentation;

import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.emf.common.ui.viewer.IViewerProvider;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.action.ControlAction;
import org.eclipse.emf.edit.ui.action.CreateChildAction;
import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
import org.eclipse.emf.edit.ui.action.LoadResourceAction;
import org.eclipse.emf.edit.ui.action.ValidateAction;
import org.eclipse.emf.mapping.ecore2xml.ui.Ecore2XMLUIPlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IContributionManager;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.SubContributionItem;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PartInitException;

public class Ecore2XMLActionBarContributor
  extends EditingDomainActionBarContributor
  implements ISelectionChangedListener
{
  protected IEditorPart activeEditorPart;
  protected ISelectionProvider selectionProvider;
  protected IAction showPropertiesViewAction = new Action(Ecore2XMLUIPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item"))
  {
    public void run()
    {
      try
      {
        getPage().showView("org.eclipse.ui.views.PropertySheet");
      }
      catch (PartInitException exception)
      {
        Ecore2XMLUIPlugin.INSTANCE.log(exception);
      }
    }
  };
  protected IAction refreshViewerAction = new Action(Ecore2XMLUIPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item"))
  {
    public boolean isEnabled()
    {
      return activeEditorPart instanceof IViewerProvider;
    }
    
    public void run()
    {
      if ((activeEditorPart instanceof IViewerProvider))
      {
        Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
        if (viewer != null) {
          viewer.refresh();
        }
      }
    }
  };
  protected Collection<IAction> createChildActions;
  protected IMenuManager createChildMenuManager;
  protected Collection<IAction> createSiblingActions;
  protected IMenuManager createSiblingMenuManager;
  
  public Ecore2XMLActionBarContributor()
  {
    super(1);
    loadResourceAction = new LoadResourceAction();
    validateAction = new ValidateAction();
    controlAction = new ControlAction();
  }
  
  public void contributeToToolBar(IToolBarManager toolBarManager)
  {
    toolBarManager.add(new Separator("ecore2xml-settings"));
    toolBarManager.add(new Separator("ecore2xml-additions"));
  }
  
  public void contributeToMenu(IMenuManager menuManager)
  {
    super.contributeToMenu(menuManager);
    
    IMenuManager submenuManager = new MenuManager(Ecore2XMLUIPlugin.INSTANCE.getString("_UI_Ecore2XMLEditor_menu"), "org.eclipse.emf.mapping.ecore2xmlMenuID");
    menuManager.insertAfter("additions", submenuManager);
    submenuManager.add(new Separator("settings"));
    submenuManager.add(new Separator("actions"));
    submenuManager.add(new Separator("additions"));
    submenuManager.add(new Separator("additions-end"));
    
    createChildMenuManager = new MenuManager(Ecore2XMLUIPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
    submenuManager.insertBefore("additions", createChildMenuManager);
    
    createSiblingMenuManager = new MenuManager(Ecore2XMLUIPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
    submenuManager.insertBefore("additions", createSiblingMenuManager);
    
    submenuManager.addMenuListener(
      new IMenuListener()
      {
        public void menuAboutToShow(IMenuManager menuManager)
        {
          menuManager.updateAll(true);
        }
      });
    addGlobalActions(submenuManager);
  }
  
  public void setActiveEditor(IEditorPart part)
  {
    super.setActiveEditor(part);
    activeEditorPart = part;
    if (selectionProvider != null) {
      selectionProvider.removeSelectionChangedListener(this);
    }
    if (part == null)
    {
      selectionProvider = null;
    }
    else
    {
      selectionProvider = part.getSite().getSelectionProvider();
      selectionProvider.addSelectionChangedListener(this);
      if (selectionProvider.getSelection() != null) {
        selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
      }
    }
  }
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    if (createChildMenuManager != null) {
      depopulateManager(createChildMenuManager, createChildActions);
    }
    if (createSiblingMenuManager != null) {
      depopulateManager(createSiblingMenuManager, createSiblingActions);
    }
    Collection<?> newChildDescriptors = null;
    Collection<?> newSiblingDescriptors = null;
    
    ISelection selection = event.getSelection();
    if (((selection instanceof IStructuredSelection)) && (((IStructuredSelection)selection).size() == 1))
    {
      Object object = ((IStructuredSelection)selection).getFirstElement();
      
      EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
      
      newChildDescriptors = domain.getNewChildDescriptors(object, null);
      newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
    }
    createChildActions = generateCreateChildActions(newChildDescriptors, selection);
    createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
    if (createChildMenuManager != null)
    {
      populateManager(createChildMenuManager, createChildActions, null);
      createChildMenuManager.update(true);
    }
    if (createSiblingMenuManager != null)
    {
      populateManager(createSiblingMenuManager, createSiblingActions, null);
      createSiblingMenuManager.update(true);
    }
  }
  
  protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection)
  {
    Collection<IAction> actions = new ArrayList();
    if (descriptors != null) {
      for (Object descriptor : descriptors) {
        actions.add(new CreateChildAction(activeEditorPart, selection, descriptor));
      }
    }
    return actions;
  }
  
  protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection)
  {
    Collection<IAction> actions = new ArrayList();
    if (descriptors != null) {
      for (Object descriptor : descriptors) {
        actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor));
      }
    }
    return actions;
  }
  
  protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID)
  {
    if (actions != null) {
      for (IAction action : actions) {
        if (contributionID != null) {
          manager.insertBefore(contributionID, action);
        } else {
          manager.add(action);
        }
      }
    }
  }
  
  protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions)
  {
    if (actions != null)
    {
      IContributionItem[] items = manager.getItems();
      for (int i = 0; i < items.length; i++)
      {
        IContributionItem contributionItem = items[i];
        while ((contributionItem instanceof SubContributionItem)) {
          contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
        }
        if ((contributionItem instanceof ActionContributionItem))
        {
          IAction action = ((ActionContributionItem)contributionItem).getAction();
          if (actions.contains(action)) {
            manager.remove(contributionItem);
          }
        }
      }
    }
  }
  
  public void menuAboutToShow(IMenuManager menuManager)
  {
    super.menuAboutToShow(menuManager);
    MenuManager submenuManager = null;
    
    submenuManager = new MenuManager(Ecore2XMLUIPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
    populateManager(submenuManager, createChildActions, null);
    menuManager.insertBefore("edit", submenuManager);
    
    submenuManager = new MenuManager(Ecore2XMLUIPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
    populateManager(submenuManager, createSiblingActions, null);
    menuManager.insertBefore("edit", submenuManager);
  }
  
  protected void addGlobalActions(IMenuManager menuManager)
  {
    menuManager.insertAfter("additions-end", new Separator("ui-actions"));
    menuManager.insertAfter("ui-actions", showPropertiesViewAction);
    
    refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());
    menuManager.insertAfter("ui-actions", refreshViewerAction);
    
    super.addGlobalActions(menuManager);
  }
  
  protected boolean removeAllReferencesOnDelete()
  {
    return true;
  }
}

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

import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.eclipse.ui.views.properties.PropertySheet;

class Ecore2XMLEditor$1
  implements IPartListener
{
  Ecore2XMLEditor$1(Ecore2XMLEditor paramEcore2XMLEditor) {}
  
  public void partActivated(IWorkbenchPart p)
  {
    if ((p instanceof ContentOutline))
    {
      if (((ContentOutline)p).getCurrentPage() == this$0.contentOutlinePage)
      {
        this$0.getActionBarContributor().setActiveEditor(this$0);
        
        this$0.setCurrentViewer(this$0.contentOutlineViewer);
      }
    }
    else if ((p instanceof PropertySheet))
    {
      if (((PropertySheet)p).getCurrentPage() == this$0.propertySheetPage)
      {
        this$0.getActionBarContributor().setActiveEditor(this$0);
        this$0.handleActivate();
      }
    }
    else if (p == this$0) {
      this$0.handleActivate();
    }
  }
  
  public void partBroughtToTop(IWorkbenchPart p) {}
  
  public void partClosed(IWorkbenchPart p) {}
  
  public void partDeactivated(IWorkbenchPart p) {}
  
  public void partOpened(IWorkbenchPart p) {}
}

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

import org.eclipse.emf.common.ui.ViewerPane;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;

class Ecore2XMLEditor$10
  extends ViewerPane
{
  Ecore2XMLEditor$10(Ecore2XMLEditor paramEcore2XMLEditor, IWorkbenchPage $anonymous0, IWorkbenchPart $anonymous1)
  {
    super($anonymous0, $anonymous1);
  }
  
  public Viewer createViewer(Composite composite)
  {
    return new TreeViewer(composite);
  }
  
  public void requestActivation()
  {
    super.requestActivation();
    this$0.setCurrentViewerPane(this);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2xml.presentation.Ecore2XMLEditor.10
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2xml.presentation;

import org.eclipse.emf.common.ui.ViewerPane;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;

class Ecore2XMLEditor$11
  extends ViewerPane
{
  Ecore2XMLEditor$11(Ecore2XMLEditor paramEcore2XMLEditor, IWorkbenchPage $anonymous0, IWorkbenchPart $anonymous1)
  {
    super($anonymous0, $anonymous1);
  }
  
  public Viewer createViewer(Composite composite)
  {
    return new TableViewer(composite);
  }
  
  public void requestActivation()
  {
    super.requestActivation();
    this$0.setCurrentViewerPane(this);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2xml.presentation.Ecore2XMLEditor.11
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2xml.presentation;

import org.eclipse.emf.common.ui.ViewerPane;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;

class Ecore2XMLEditor$12
  extends ViewerPane
{
  Ecore2XMLEditor$12(Ecore2XMLEditor paramEcore2XMLEditor, IWorkbenchPage $anonymous0, IWorkbenchPart $anonymous1)
  {
    super($anonymous0, $anonymous1);
  }
  
  public Viewer createViewer(Composite composite)
  {
    return new TreeViewer(composite);
  }
  
  public void requestActivation()
  {
    super.requestActivation();
    this$0.setCurrentViewerPane(this);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2xml.presentation.Ecore2XMLEditor.12
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2xml.presentation;

class Ecore2XMLEditor$13
  implements Runnable
{
  Ecore2XMLEditor$13(Ecore2XMLEditor paramEcore2XMLEditor) {}
  
  public void run()
  {
    Ecore2XMLEditor.access$1(this$0, 0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2xml.presentation.Ecore2XMLEditor.13
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2xml.presentation;

import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;

class Ecore2XMLEditor$14
  extends ControlAdapter
{
  boolean guard = false;
  
  Ecore2XMLEditor$14(Ecore2XMLEditor paramEcore2XMLEditor) {}
  
  public void controlResized(ControlEvent event)
  {
    if (!guard)
    {
      guard = true;
      this$0.hideTabs();
      guard = false;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2xml.presentation.Ecore2XMLEditor.14
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2xml.presentation;

class Ecore2XMLEditor$15
  implements Runnable
{
  Ecore2XMLEditor$15(Ecore2XMLEditor paramEcore2XMLEditor) {}
  
  public void run()
  {
    this$0.updateProblemIndication();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2xml.presentation.Ecore2XMLEditor.15
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2xml.presentation;

import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;

class Ecore2XMLEditor$16
  implements ISelectionChangedListener
{
  Ecore2XMLEditor$16(Ecore2XMLEditor paramEcore2XMLEditor) {}
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    this$0.handleContentOutlineSelection(event.getSelection());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2xml.presentation.Ecore2XMLEditor.16
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2xml.presentation;

import java.util.List;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
import org.eclipse.ui.IActionBars;

class Ecore2XMLEditor$17
  extends ExtendedPropertySheetPage
{
  Ecore2XMLEditor$17(Ecore2XMLEditor paramEcore2XMLEditor, AdapterFactoryEditingDomain $anonymous0)
  {
    super($anonymous0);
  }
  
  public void setSelectionToViewer(List<?> selection)
  {
    this$0.setSelectionToViewer(selection);
    this$0.setFocus();
  }
  
  public void setActionBars(IActionBars actionBars)
  {
    super.setActionBars(actionBars);
    this$0.getActionBarContributor().shareGlobalActions(this, actionBars);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2xml.presentation.Ecore2XMLEditor.17
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2xml.presentation;

import java.util.Collection;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.ui.actions.WorkspaceModifyOperation;

class Ecore2XMLEditor$18
  extends WorkspaceModifyOperation
{
  Ecore2XMLEditor$18(Ecore2XMLEditor paramEcore2XMLEditor, Map paramMap) {}
  
  public void execute(IProgressMonitor monitor)
  {
    boolean first = true;
    for (Resource resource : this$0.editingDomain.getResourceSet().getResources()) {
      if (((first) || (!resource.getContents().isEmpty()) || (this$0.isPersisted(resource))) && (!this$0.editingDomain.isReadOnly(resource)))
      {
        try
        {
          long timeStamp = resource.getTimeStamp();
          resource.save(val$saveOptions);
          if (resource.getTimeStamp() != timeStamp) {
            this$0.savedResources.add(resource);
          }
        }
        catch (Exception exception)
        {
          this$0.resourceToDiagnosticMap.put(resource, this$0.analyzeResourceProblems(resource, exception));
        }
        first = false;
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.mapping.ecore2xml.presentation.Ecore2XMLEditor.18
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.mapping.ecore2xml.presentation;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;

class Ecore2XMLEditor$1MyContentOutlinePage
  extends ContentOutlinePage
{
  Ecore2XMLEditor$1MyContentOutlinePage(Ecore2XMLEditor paramEcore2XMLEditor) {}
  
  public 
1 2 3 4 5

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