org.eclipse.emf.converter_2.5.0.v20120130-0943

16:43:27.905 INFO  jd.cli.Main - Decompiling org.eclipse.emf.converter_2.5.0.v20120130-0943.jar
package org.eclipse.emf.converter;

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

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

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

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

public final class ConverterPlugin
  extends EMFPlugin
{
  public static final ConverterPlugin INSTANCE = new ConverterPlugin();
  private static Implementation plugin;
  public static final String ID = "org.eclipse.emf.converter";
  
  private ConverterPlugin()
  {
    super(new ResourceLocator[0]);
  }
  
  public ResourceLocator getPluginResourceLocator()
  {
    return plugin;
  }
  
  public static Implementation getPlugin()
  {
    return plugin;
  }
  
  public static class Implementation
    extends EMFPlugin.EclipsePlugin
  {
    public Implementation()
    {
      ConverterPlugin.plugin = this;
    }
  }
}

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

import java.util.Collection;
import java.util.Iterator;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.util.EcoreUtil.ContentTreeIterator;

class ModelConverter$1
  extends EcoreUtil.ContentTreeIterator<EPackage>
{
  private static final long serialVersionUID = 1L;
  
  ModelConverter$1(ModelConverter paramModelConverter, Collection $anonymous0)
  {
    super($anonymous0);
  }
  
  protected Iterator<? extends EObject> getEObjectChildren(EObject eObject)
  {
    return ((EPackage)eObject).getESubpackages().iterator();
  }
}

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

public class ModelConverter$EPackageConvertInfo
{
  protected boolean convert = false;
  protected String convertData;
  
  public boolean isConvert()
  {
    return convert;
  }
  
  public void setConvert(boolean convert)
  {
    this.convert = convert;
  }
  
  public String getConvertData()
  {
    return convertData;
  }
  
  public void setConvertData(String convertData)
  {
    this.convertData = convertData;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.converter.ModelConverter.EPackageConvertInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.converter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
import org.eclipse.emf.converter.util.ConverterUtil.EPackageList;
import org.eclipse.emf.converter.util.ConverterUtil.GenPackageList;
import org.eclipse.emf.ecore.EPackage;

public class ModelConverter$ReferencedEPackageFilter
{
  protected ModelConverter$ReferencedEPackageFilter(ModelConverter paramModelConverter) {}
  
  public List<GenPackage> computeValidReferencedGenPackages()
  {
    List<GenPackage> genPackages = new ConverterUtil.GenPackageList();
    for (GenPackage genPackage : this$0.getReferencedGenPackages())
    {
      EPackage ePackage = getReferredEPackage(genPackage);
      if (ePackage != null) {
        genPackages.add(genPackage);
      }
    }
    return genPackages;
  }
  
  public List<EPackage> filterReferencedEPackages(Collection<EPackage> ePackages, List<GenPackage> referencedGenPackages)
  {
    if (referencedGenPackages == null) {
      referencedGenPackages = this$0.getReferencedGenPackages();
    }
    if (ePackages.isEmpty()) {
      return Collections.emptyList();
    }
    if (referencedGenPackages.isEmpty()) {
      return new ArrayList(ePackages);
    }
    List<EPackage> filteredEPackages = new ConverterUtil.EPackageList(ePackages);
    for (GenPackage genPackage : referencedGenPackages)
    {
      EPackage ePackage = getReferredEPackage(genPackage);
      if (ePackage != null) {
        filteredEPackages.remove(ePackage);
      }
    }
    return filteredEPackages;
  }
  
  protected EPackage getReferredEPackage(GenPackage genPackage)
  {
    return isValidReference(genPackage) ? 
      this$0.getReferredEPackage(genPackage) : 
      null;
  }
  
  protected boolean isValidReference(GenPackage genPackage)
  {
    return this$0.getReferenceGenPackageConvertInfo(genPackage).isValidReference();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.converter.ModelConverter.ReferencedEPackageFilter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.converter;

public class ModelConverter$ReferencedGenPackageConvertInfo
{
  protected boolean validReference = true;
  
  public boolean isValidReference()
  {
    return validReference;
  }
  
  public void setValidReference(boolean validReference)
  {
    this.validReference = validReference;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.converter.ModelConverter.ReferencedGenPackageConvertInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.converter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
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.common.util.UniqueEList.FastCompare;
import org.eclipse.emf.converter.util.ConverterUtil;
import org.eclipse.emf.converter.util.ConverterUtil.EPackageList;
import org.eclipse.emf.converter.util.ConverterUtil.GenPackageList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil.ContentTreeIterator;

public abstract class ModelConverter
{
  protected GenModel genModel;
  protected List<EPackage> ePackages;
  protected Map<EPackage, EPackageConvertInfo> ePackageToInfoMap;
  protected List<GenPackage> referencedGenPackages;
  protected Map<GenPackage, ReferencedGenPackageConvertInfo> referencedGenPackageToInfoMap;
  protected ResourceSet externalGenModelResourceSet;
  protected List<GenModel> externalGenModelList;
  protected ReferencedEPackageFilter referencedEPackageFilter;
  protected ReferencedEPackageFilter referencedEPackageFilterToConvert;
  
  public static class EPackageConvertInfo
  {
    protected boolean convert = false;
    protected String convertData;
    
    public boolean isConvert()
    {
      return convert;
    }
    
    public void setConvert(boolean convert)
    {
      this.convert = convert;
    }
    
    public String getConvertData()
    {
      return convertData;
    }
    
    public void setConvertData(String convertData)
    {
      this.convertData = convertData;
    }
  }
  
  public static class ReferencedGenPackageConvertInfo
  {
    protected boolean validReference = true;
    
    public boolean isValidReference()
    {
      return validReference;
    }
    
    public void setValidReference(boolean validReference)
    {
      this.validReference = validReference;
    }
  }
  
  protected class ReferencedEPackageFilter
  {
    protected ReferencedEPackageFilter() {}
    
    public List<GenPackage> computeValidReferencedGenPackages()
    {
      List<GenPackage> genPackages = new ConverterUtil.GenPackageList();
      for (GenPackage genPackage : getReferencedGenPackages())
      {
        EPackage ePackage = getReferredEPackage(genPackage);
        if (ePackage != null) {
          genPackages.add(genPackage);
        }
      }
      return genPackages;
    }
    
    public List<EPackage> filterReferencedEPackages(Collection<EPackage> ePackages, List<GenPackage> referencedGenPackages)
    {
      if (referencedGenPackages == null) {
        referencedGenPackages = getReferencedGenPackages();
      }
      if (ePackages.isEmpty()) {
        return Collections.emptyList();
      }
      if (referencedGenPackages.isEmpty()) {
        return new ArrayList(ePackages);
      }
      List<EPackage> filteredEPackages = new ConverterUtil.EPackageList(ePackages);
      for (GenPackage genPackage : referencedGenPackages)
      {
        EPackage ePackage = getReferredEPackage(genPackage);
        if (ePackage != null) {
          filteredEPackages.remove(ePackage);
        }
      }
      return filteredEPackages;
    }
    
    protected EPackage getReferredEPackage(GenPackage genPackage)
    {
      return isValidReference(genPackage) ? 
        ModelConverter.this.getReferredEPackage(genPackage) : 
        null;
    }
    
    protected boolean isValidReference(GenPackage genPackage)
    {
      return getReferenceGenPackageConvertInfo(genPackage).isValidReference();
    }
  }
  
  public void dispose()
  {
    clearEPackagesCollections();
    if (referencedGenPackages != null)
    {
      referencedGenPackages.clear();
      referencedGenPackages = null;
    }
    if (referencedGenPackageToInfoMap != null)
    {
      referencedGenPackageToInfoMap.clear();
      referencedGenPackageToInfoMap = null;
    }
    genModel = null;
    referencedEPackageFilter = null;
    referencedEPackageFilterToConvert = null;
  }
  
  public abstract String getID();
  
  protected String getConverterGenAnnotationSource()
  {
    return "http://www.eclipse.org/emf/2002/GenModel" + getID();
  }
  
  public GenModel getGenModel()
  {
    return genModel;
  }
  
  public List<EPackage> getEPackages()
  {
    if (ePackages == null) {
      ePackages = createEPackagesList();
    }
    return ePackages;
  }
  
  protected List<EPackage> createEPackagesList()
  {
    return new ConverterUtil.EPackageList();
  }
  
  public List<GenPackage> getReferencedGenPackages()
  {
    if (referencedGenPackages == null) {
      referencedGenPackages = createReferencedGenPackagesList();
    }
    return referencedGenPackages;
  }
  
  protected List<GenPackage> createReferencedGenPackagesList()
  {
    return new ConverterUtil.GenPackageList();
  }
  
  public void clearEPackagesCollections()
  {
    if (ePackages != null)
    {
      ePackages.clear();
      ePackages = null;
    }
    if (ePackageToInfoMap != null)
    {
      ePackageToInfoMap.clear();
      ePackageToInfoMap = null;
    }
    if (externalGenModelList != null)
    {
      externalGenModelList.clear();
      externalGenModelList = null;
    }
  }
  
  public ResourceSet createResourceSet()
  {
    return ConverterUtil.createResourceSet();
  }
  
  protected Map<EPackage, EPackageConvertInfo> getEPackageToInfoMap()
  {
    if (ePackageToInfoMap == null) {
      ePackageToInfoMap = new HashMap();
    }
    return ePackageToInfoMap;
  }
  
  public EPackageConvertInfo getEPackageConvertInfo(EPackage ePackage)
  {
    EPackageConvertInfo ePackageInfo = (EPackageConvertInfo)getEPackageToInfoMap().get(ePackage);
    if (ePackageInfo == null)
    {
      ePackageInfo = createEPackageInfo(ePackage);
      getEPackageToInfoMap().put(ePackage, ePackageInfo);
    }
    return ePackageInfo;
  }
  
  public void clearEPackageConvertInfoCache()
  {
    getEPackageToInfoMap().clear();
  }
  
  protected EPackageConvertInfo createEPackageInfo(EPackage ePackage)
  {
    return new EPackageConvertInfo();
  }
  
  protected Map<GenPackage, ReferencedGenPackageConvertInfo> getReferencedGenPackageToInfoMap()
  {
    if (referencedGenPackageToInfoMap == null) {
      referencedGenPackageToInfoMap = new HashMap();
    }
    return referencedGenPackageToInfoMap;
  }
  
  public ReferencedGenPackageConvertInfo getReferenceGenPackageConvertInfo(GenPackage genPackage)
  {
    ReferencedGenPackageConvertInfo genPackageConvertInfo = (ReferencedGenPackageConvertInfo)getReferencedGenPackageToInfoMap().get(genPackage);
    if (genPackageConvertInfo == null)
    {
      genPackageConvertInfo = createGenPackageConvertInfo(genPackage);
      getReferencedGenPackageToInfoMap().put(genPackage, genPackageConvertInfo);
    }
    return genPackageConvertInfo;
  }
  
  public void clearReferenceGenPackageConvertInfoCache()
  {
    getReferencedGenPackageToInfoMap().clear();
  }
  
  protected ReferencedGenPackageConvertInfo createGenPackageConvertInfo(GenPackage genPackage)
  {
    return new ReferencedGenPackageConvertInfo();
  }
  
  public List<EPackage> filterReferencedEPackages(Collection<EPackage> ePackages, List<GenPackage> referencedGenPackages)
  {
    if (referencedEPackageFilter == null) {
      referencedEPackageFilter = createReferencedEPackageFilter();
    }
    return referencedEPackageFilter.filterReferencedEPackages(ePackages, referencedGenPackages);
  }
  
  protected ReferencedEPackageFilter createReferencedEPackageFilter()
  {
    return new ReferencedEPackageFilter();
  }
  
  protected List<EPackage> computeEPackagesToConvert()
  {
    List<EPackage> ePackages = new ConverterUtil.EPackageList();
    for (EPackage ePackage : getEPackages()) {
      if (canConvert(ePackage)) {
        ePackages.add(ePackage);
      }
    }
    return filterReferencedEPackagesToConvert(ePackages, null);
  }
  
  protected List<EPackage> filterReferencedEPackagesToConvert(Collection<EPackage> ePackages, List<GenPackage> referencedGenPackages)
  {
    if (referencedEPackageFilterToConvert == null) {
      referencedEPackageFilterToConvert = createReferencedEPackageFilterToConvert();
    }
    return referencedEPackageFilterToConvert.filterReferencedEPackages(ePackages, referencedGenPackages);
  }
  
  protected List<GenPackage> computeValidReferencedGenPackages()
  {
    if (referencedEPackageFilterToConvert == null) {
      referencedEPackageFilterToConvert = createReferencedEPackageFilterToConvert();
    }
    return referencedEPackageFilterToConvert.computeValidReferencedGenPackages();
  }
  
  protected ReferencedEPackageFilter createReferencedEPackageFilterToConvert()
  {
    return new ReferencedEPackageFilter();
  }
  
  protected boolean canConvert(EPackage ePackage)
  {
    return getEPackageConvertInfo(ePackage).isConvert();
  }
  
  public EPackage getReferredEPackage(GenPackage genPackage)
  {
    String nsURI = genPackage.getEcorePackage().getNsURI();
    if (nsURI != null) {
      for (EPackage ePackage : getEPackages()) {
        if (nsURI.equals(ePackage.getNsURI())) {
          return ePackage;
        }
      }
    }
    return null;
  }
  
  public List<GenModel> getExternalGenModels()
  {
    if (externalGenModelList == null)
    {
      externalGenModelList = new UniqueEList.FastCompare();
      if (externalGenModelResourceSet == null) {
        externalGenModelResourceSet = createExternalGenModelResourceSet();
      }
      Map<String, URI> ePackageToGenModelMap = EcorePlugin.getEPackageNsURIToGenModelLocationMap();
      for (TreeIterator<EPackage> i = 
            new EcoreUtil.ContentTreeIterator(getEPackages())
          {
            private static final long serialVersionUID = 1L;
            
            protected Iterator<? extends EObject> getEObjectChildren(EObject eObject)
            {
              return ((EPackage)eObject).getESubpackages().iterator();
            }
          }; 
          
            i.hasNext();)
      {
        EPackage ePackage = (EPackage)i.next();
        URI genModelURI = (URI)ePackageToGenModelMap.get(ePackage.getNsURI());
        if (genModelURI != null)
        {
          try
          {
            Resource genModelResource = externalGenModelResourceSet.getResource(genModelURI, false);
            if (genModelResource == null)
            {
              genModelResource = externalGenModelResourceSet.getResource(genModelURI, true);
              externalGenModelList.add((GenModel)genModelResource.getContents().get(0));
            }
          }
          catch (Exception exception)
          {
            ConverterPlugin.INSTANCE.log(exception);
          }
          i.prune();
        }
      }
    }
    return externalGenModelList;
  }
  
  protected ResourceSet createExternalGenModelResourceSet()
  {
    return createResourceSet();
  }
  
  @Deprecated
  protected Map<?, ?> getGenmodelSaveOptions()
  {
    Map<Object, Object> result = new HashMap();
    result.put("SAVE_ONLY_IF_CHANGED", "MEMORY_BUFFER");
    return result;
  }
  
  protected Map<?, ?> getGenModelSaveOptions()
  {
    return getGenmodelSaveOptions();
  }
  
  public void makeEPackageConvertDataUnique()
  {
    if (!getEPackageToInfoMap().isEmpty())
    {
      Map<String, Integer> dataToCounter = new HashMap();
      List<EPackage> ePackages = filterReferencedEPackages(getEPackageToInfoMap().keySet(), null);
      if (!ePackages.isEmpty())
      {
        List<EPackageConvertInfo> packageInfos = new ArrayList(ePackages.size());
        for (EPackage ePackage : ePackages) {
          if ((ePackage.getESuperPackage() == null) || (!ePackages.contains(ePackage.getESuperPackage())))
          {
            EPackageConvertInfo packageInfo = (EPackageConvertInfo)getEPackageToInfoMap().get(ePackage);
            if (packageInfo.isConvert()) {
              packageInfos.add(0, packageInfo);
            } else {
              packageInfos.add(packageInfo);
            }
            String data = packageInfo.getConvertData();
            if (data != null) {
              dataToCounter.put(data, null);
            }
          }
        }
        for (EPackageConvertInfo packageInfo : packageInfos)
        {
          String data = packageInfo.getConvertData();
          if (data != null)
          {
            Integer counterObject = (Integer)dataToCounter.get(data);
            if (counterObject != null)
            {
              int counter = counterObject.intValue();
              int index = data.lastIndexOf(".");
              StringBuffer newValue = null;
              do
              {
                newValue = new StringBuffer(data).insert(index, counter++);
              } while (
              
                dataToCounter.containsKey(newValue.toString()));
              packageInfo.setConvertData(newValue.toString());
              counterObject = Integer.valueOf(counter);
              dataToCounter.put(newValue.toString(), Integer.valueOf(1));
            }
            else
            {
              counterObject = Integer.valueOf(1);
            }
            dataToCounter.put(data, counterObject);
          }
        }
      }
    }
  }
}

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

import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.wizard.IWizardContainer;

class ModelConverterDescriptorSelectionPage$1
  implements IDoubleClickListener
{
  ModelConverterDescriptorSelectionPage$1(ModelConverterDescriptorSelectionPage paramModelConverterDescriptorSelectionPage) {}
  
  public void doubleClick(DoubleClickEvent event)
  {
    if (this$0.canFlipToNextPage()) {
      ModelConverterDescriptorSelectionPage.access$0(this$0).showPage(this$0.getNextPage());
    }
  }
}

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

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.emf.codegen.ecore.genmodel.provider.GenModelEditPlugin;
import org.eclipse.emf.converter.ConverterPlugin;
import org.eclipse.emf.converter.ui.contribution.ModelConverterDescriptor;
import org.eclipse.emf.converter.ui.contribution.ModelConverterManager;
import org.eclipse.emf.converter.ui.contribution.ModelConverterManager.ModelConverterDescriptorLabelProvider;
import org.eclipse.emf.converter.ui.contribution.ModelConverterManager.ModelConverterDescriptorWizardNode;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.IWizardNode;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardSelectionPage;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWizard;
import org.osgi.service.prefs.BackingStoreException;

public abstract class ModelConverterDescriptorSelectionPage
  extends WizardSelectionPage
  implements ISelectionChangedListener
{
  protected ModelConverterManager<?> modelConverterManager;
  protected ModelConverterDescriptor descriptor;
  protected TableViewer descriptorTableViewer;
  protected ImageDescriptor modeConverterWizardDefaultImageDescriptor;
  protected Map<? extends ModelConverterDescriptor, ModelConverterManager.ModelConverterDescriptorWizardNode> modelConverterWizardNodeMap;
  protected IStructuredSelection selection;
  protected IWorkbench workbench;
  protected boolean firstTime = true;
  protected Set<IWizard> initializedWizards = new HashSet();
  
  public ModelConverterDescriptorSelectionPage(String pageId, ModelConverterManager<?> modelConverterManager, IWorkbench workbench, IStructuredSelection selection)
  {
    super(pageId);
    this.modelConverterManager = modelConverterManager;
    this.workbench = workbench;
    this.selection = selection;
  }
  
  public void dispose()
  {
    if (descriptorTableViewer != null)
    {
      descriptorTableViewer.removeSelectionChangedListener(this);
      descriptorTableViewer = null;
    }
    if (initializedWizards != null)
    {
      initializedWizards.clear();
      initializedWizards = null;
    }
    modeConverterWizardDefaultImageDescriptor = null;
    
    descriptor = null;
    modelConverterManager = null;
    
    clearCache();
    
    super.dispose();
  }
  
  public void clearCache()
  {
    if (modelConverterWizardNodeMap != null)
    {
      for (IWizardNode wizardNode : modelConverterWizardNodeMap.values()) {
        wizardNode.dispose();
      }
      modelConverterWizardNodeMap.clear();
      modelConverterWizardNodeMap = null;
    }
    selection = null;
    workbench = null;
  }
  
  public void setModeConverterWizardDefaultImageDescriptor(ImageDescriptor imageDescriptor)
  {
    modeConverterWizardDefaultImageDescriptor = imageDescriptor;
  }
  
  public String getLastModelConverterDescriptorId()
  {
    return Platform.getPreferencesService().getString("org.eclipse.emf.converter", modelConverterManager.getClass().getName(), "", null);
  }
  
  public void performFinish()
  {
    if (descriptor != null)
    {
      IEclipsePreferences node = new InstanceScope().getNode("org.eclipse.emf.converter");
      node.put(modelConverterManager.getClass().getName(), descriptor.getID());
      try
      {
        node.flush();
      }
      catch (BackingStoreException exception)
      {
        ConverterPlugin.INSTANCE.log(exception);
      }
    }
  }
  
  public void setModelConverterDescriptor(ModelConverterDescriptor descriptor)
  {
    if (getModelConverterDescriptor() != descriptor)
    {
      this.descriptor = descriptor;
      if (descriptorTableViewer != null) {
        if (descriptor != null) {
          descriptorTableViewer.setSelection(new StructuredSelection(descriptor), true);
        } else {
          descriptorTableViewer.setSelection(StructuredSelection.EMPTY);
        }
      }
    }
  }
  
  public ModelConverterDescriptor getModelConverterDescriptor()
  {
    return descriptor;
  }
  
  public void setVisible(boolean visible)
  {
    super.setVisible(visible);
    if ((visible) && (firstTime))
    {
      firstTime = false;
      Table table = descriptorTableViewer.getTable();
      firstTimeVisible(table);
      table.setFocus();
    }
  }
  
  protected void firstTimeVisible(Table descriptorTable)
  {
    if (descriptorTable.getItemCount() > 0)
    {
      ModelConverterDescriptor descriptor = getModelConverterDescriptor();
      if (descriptor == null)
      {
        descriptor = modelConverterManager.getModelConverterDescriptor(getLastModelConverterDescriptorId());
        if (descriptor == null) {
          descriptor = (ModelConverterDescriptor)descriptorTable.getItem(0).getData();
        }
        setModelConverterDescriptor(descriptor);
      }
    }
    else
    {
      setErrorMessage(getNoModelConverterMessage());
    }
  }
  
  protected String getNoModelConverterMessage()
  {
    return GenModelEditPlugin.INSTANCE.getString("_UI_NoModelConverter_error");
  }
  
  protected abstract String getSelectModelConverterLabel();
  
  protected abstract Object[] getTableInput();
  
  public void createControl(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    
    GridLayout layout = new GridLayout();
    numColumns = 1;
    verticalSpacing = 12;
    composite.setLayout(layout);
    
    GridData data = new GridData();
    verticalAlignment = 4;
    grabExcessVerticalSpace = true;
    horizontalAlignment = 4;
    composite.setLayoutData(data);
    
    Label label = new Label(composite, 0);
    label.setText(getSelectModelConverterLabel());
    
    GridData data = new GridData();
    verticalAlignment = 4;
    horizontalAlignment = 4;
    label.setLayoutData(data);
    
    Table descriptorTable = new Table(composite, 67588);
    
    GridData data = new GridData();
    widthHint = (getCurrentgetBoundswidth / 5);
    heightHint = (getCurrentgetBoundsheight / 3);
    verticalAlignment = 4;
    horizontalAlignment = 4;
    grabExcessHorizontalSpace = true;
    grabExcessVerticalSpace = true;
    descriptorTable.setLayoutData(data);
    
    descriptorTableViewer = new TableViewer(descriptorTable);
    descriptorTableViewer.setContentProvider(new ArrayContentProvider());
    descriptorTableViewer.setLabelProvider(new ModelConverterManager.ModelConverterDescriptorLabelProvider());
    descriptorTableViewer.setSorter(new ViewerSorter());
    
    descriptorTableViewer.addDoubleClickListener(new IDoubleClickListener()
    {
      public void doubleClick(DoubleClickEvent event)
      {
        if (canFlipToNextPage()) {
          getContainer().showPage(getNextPage());
        }
      }
    });
    descriptorTableViewer.setInput(getTableInput());
    descriptorTableViewer.addSelectionChangedListener(this);
    if (getModelConverterDescriptor() != null) {
      descriptorTableViewer.setSelection(new StructuredSelection(getModelConverterDescriptor()), true);
    }
    setControl(composite);
  }
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    ISelection selection = event.getSelection();
    if ((!selection.isEmpty()) && ((selection instanceof IStructuredSelection)))
    {
      Object selectedObject = ((IStructuredSelection)selection).getFirstElement();
      if ((selectedObject instanceof ModelConverterDescriptor))
      {
        descriptor = ((ModelConverterDescriptor)selectedObject);
        if (modelConverterWizardNodeMap == null) {
          modelConverterWizardNodeMap = modelConverterManager.createModelConverterDescriptorWizardNodeMap();
        }
        setMessage(descriptor.getDescription(), 0);
        setSelectedNode((IWizardNode)modelConverterWizardNodeMap.get(descriptor));
        return;
      }
    }
    setPageComplete(false);
  }
  
  public boolean isPageComplete()
  {
    return descriptor != null;
  }
  
  public IWizardPage getNextPage()
  {
    IWizard modelConverterWizard = getSelectedNode().getWizard();
    if (initializedWizards.add(modelConverterWizard))
    {
      if ((modelConverterWizard instanceof Wizard))
      {
        Wizard wizard = (Wizard)modelConverterWizard;
        if (modeConverterWizardDefaultImageDescriptor != null) {
          wizard.setDefaultPageImageDescriptor(modeConverterWizardDefaultImageDescriptor);
        }
        if (wizard.getWindowTitle() == null) {
          wizard.setWindowTitle(getWizard().getWindowTitle());
        }
      }
      if ((modelConverterWizard instanceof IWorkbenchWizard)) {
        ((IWorkbenchWizard)modelConverterWizard).init(workbench, selection);
      }
    }
    adjustModelConverterWizard(modelConverterWizard);
    IWizardPage wizardPage = super.getNextPage();
    
    IWizardNode wizardNode = getSelectedNode();
    if ((wizardNode instanceof ModelConverterManager.ModelConverterDescriptorWizardNode)) {
      ((ModelConverterManager.ModelConverterDescriptorWizardNode)wizardNode).setContentCreated(true);
    }
    return wizardPage;
  }
  
  protected void adjustModelConverterWizard(IWizard modelConverterWizard) {}
}

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

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.Path;
import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionDelegate;

public abstract class OpenWizardActionDelegate
  extends ActionDelegate
  implements IEditorActionDelegate
{
  protected boolean fixedFile = false;
  protected IFile file;
  
  public OpenWizardActionDelegate() {}
  
  public OpenWizardActionDelegate(IEditorPart editorPart)
  {
    this();
  }
  
  public void dispose()
  {
    file = null;
    super.dispose();
  }
  
  public void selectionChanged(IAction action, ISelection selection)
  {
    if (fixedFile) {
      return;
    }
    if ((selection instanceof IStructuredSelection))
    {
      Object object = ((IStructuredSelection)selection).getFirstElement();
      if ((object instanceof IFile))
      {
        file = ((IFile)object);
        action.setEnabled(true);
        return;
      }
      if ((object instanceof GenModel))
      {
        GenModel genModel = (GenModel)object;
        Resource resource = genModel.eResource();
        if (resource != null)
        {
          URI uri = resource.getURI();
          if (uri.isPlatformResource())
          {
            file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true)));
            if (file.exists())
            {
              action.setEnabled(true);
              return;
            }
          }
        }
      }
    }
    file = null;
    action.setEnabled(false);
  }
  
  public void setActiveEditor(IAction action, IEditorPart targetEditor)
  {
    if (targetEditor != null)
    {
      IEditorInput input = targetEditor.getEditorInput();
      if ((input instanceof IFileEditorInput))
      {
        file = ((IFileEditorInput)input).getFile();
        fixedFile = true;
        action.setEnabled(true);
        return;
      }
    }
    file = null;
    action.setEnabled(false);
  }
  
  public void run(IAction action)
  {
    run(PlatformUI.getWorkbench(), PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), file);
  }
  
  protected void run(IWorkbench workbench, Shell shell, IFile file)
  {
    IWizard wizard = createWizard(workbench, shell, file);
    
    WizardDialog wizardDialog = new WizardDialog(shell, wizard);
    wizardDialog.create();
    wizardDialog.getShell().setSize(Math.max(540, getShellgetSizex), 580);
    wizardDialog.open();
  }
  
  protected abstract IWizard createWizard(IWorkbench paramIWorkbench, Shell paramShell, IFile paramIFile);
}

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

import org.eclipse.swt.graphics.Image;

public abstract interface ModelConverterDescriptor
{
  public abstract String getID();
  
  public abstract String getName();
  
  public abstract Image getIcon();
  
  public abstract String getDescription();
}

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

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.swt.graphics.Image;

public class ModelConverterManager$ModelConverterDescriptorImpl
  implements ModelConverterDescriptor
{
  protected String id;
  protected String name;
  protected Image icon;
  protected String description;
  protected IConfigurationElement configurationElement;
  
  public String getID()
  {
    return id;
  }
  
  public void setID(String id)
  {
    this.id = id;
  }
  
  public Image getIcon()
  {
    return icon;
  }
  
  public void setIcon(Image icon)
  {
    this.icon = icon;
  }
  
  public String getName()
  {
    return name;
  }
  
  public void setName(String name)
  {
    this.name = name;
  }
  
  public String getDescription()
  {
    return description;
  }
  
  public void setDescription(String description)
  {
    this.description = description;
  }
  
  protected Object createExecutableExtension(String attribute)
  {
    if (configurationElement != null) {
      try
      {
        return configurationElement.createExecutableExtension(attribute);
      }
      catch (Exception localException) {}
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.converter.ui.contribution.ModelConverterManager.ModelConverterDescriptorImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.converter.ui.contribution;

import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

public class ModelConverterManager$ModelConverterDescriptorLabelProvider
  extends LabelProvider
{
  public Image getImage(Object element)
  {
    if ((element instanceof ModelConverterDescriptor)) {
      return ((ModelConverterDescriptor)element).getIcon();
    }
    return super.getImage(element);
  }
  
  public String getText(Object element)
  {
    if ((element instanceof ModelConverterDescriptor)) {
      return ((ModelConverterDescriptor)element).getName();
    }
    return super.getText(element);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.converter.ui.contribution.ModelConverterManager.ModelConverterDescriptorLabelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.converter.ui.contribution;

import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardNode;
import org.eclipse.swt.graphics.Point;

public abstract class ModelConverterManager$ModelConverterDescriptorWizardNode
  implements IWizardNode
{
  protected boolean contentCreated = false;
  protected ModelConverterDescriptor descriptor;
  protected IWizard wizard;
  protected Point point;
  
  public ModelConverterManager$ModelConverterDescriptorWizardNode(ModelConverterDescriptor descriptor)
  {
    this.descriptor = descriptor;
  }
  
  public void dispose()
  {
    wizard = null;
    descriptor = null;
    point = null;
  }
  
  public IWizard getWizard()
  {
    if (wizard == null) {
      if (descriptor != null) {
        wizard = createWizard();
      }
    }
    return wizard;
  }
  
  protected abstract IWizard createWizard();
  
  public boolean isContentCreated()
  {
    return contentCreated;
  }
  
  public void setContentCreated(boolean contentCreated)
  {
    this.contentCreated = contentCreated;
  }
  
  public Point getExtent()
  {
    if (point == null) {
      point = new Point(-1, -1);
    }
    return point;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.emf.converter.ui.contribution.ModelConverterManager.ModelConverterDescriptorWizardNode
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.emf.converter.ui.contribution;

import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardNode;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;

public abstract class ModelConverterManager<D extends ModelConverterDescriptor>
{
  protected List<D> descriptors;
  
  public static class ModelConverterDescriptorImpl
    implements ModelConverterDescriptor
  {
    protected String id;
    protected String name;
    protected Image icon;
    protected String description;
    protected IConfigurationElement configurationElement;
    
    public String getID()
    {
      return id;
    }
    
    public void setID(String id)
    {
      this.id = id;
    }
    
    public Image getIcon()
    {
      return icon;
    }
    
    public void setIcon(Image icon)
    {
      this.icon = icon;
    }
    
    public String getName()
    {
      return name;
    }
    
    public void setName(String name)
    {
      this.name = name;
    }
    
    public String getDescription()
    {
      return description;
    }
    
    public void setDescription(String description)
    {
      this.description = description;
    }
    
    protected Object createExecutableExtension(String attribute)
 
1 2 3 4

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