org.eclipse.pde.core_3.7.1.v20120103_r372

moved = removed;
  }
  
  public IPluginModelBase[] getAddedModels()
  {
    return added;
  }
  
  public IPluginModelBase[] getChangedModels()
  {
    return changed;
  }
  
  public IPluginModelBase[] getRemovedModels()
  {
    return removed;
  }
  
  public int getEventTypes()
  {
    return types;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.ExtensionDeltaEvent
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.pde.core.IModelProviderEvent;
import org.eclipse.pde.core.IModelProviderListener;
import org.eclipse.pde.internal.core.feature.ExternalFeatureModel;
import org.eclipse.pde.internal.core.ifeature.IFeature;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.osgi.framework.Version;

public class ExternalFeatureModelManager
{
  public static IFeatureModel createModel(File manifest)
  {
    ExternalFeatureModel model = new ExternalFeatureModel();
    model.setInstallLocation(manifest.getParent());
    InputStream stream = null;
    try
    {
      stream = new BufferedInputStream(new FileInputStream(manifest));
      model.load(stream, false);
      return model;
    }
    catch (Exception localException) {}finally
    {
      if (stream != null) {
        try
        {
          stream.close();
        }
        catch (IOException localIOException3) {}
      }
    }
    return null;
  }
  
  public static IFeatureModel[] createModels(String platformHome, ArrayList additionalLocations, IProgressMonitor monitor)
  {
    if ((platformHome != null) && (platformHome.length() > 0))
    {
      URL[] featureURLs = PluginPathFinder.getFeaturePaths(platformHome);
      if (additionalLocations.size() == 0) {
        return createModels(featureURLs, monitor);
      }
      File[] dirs = new File[additionalLocations.size()];
      for (int i = 0; i < dirs.length; i++)
      {
        String directory = additionalLocations.get(i).toString();
        File dir = new File(directory, "features");
        if (!dir.exists()) {
          dir = new File(directory);
        }
        dirs[i] = dir;
      }
      URL[] newUrls = PluginPathFinder.scanLocations(dirs);
      
      URL[] result = new URL[featureURLs.length + newUrls.length];
      System.arraycopy(featureURLs, 0, result, 0, featureURLs.length);
      System.arraycopy(newUrls, 0, result, featureURLs.length, newUrls.length);
      return createModels(result, monitor);
    }
    return new IFeatureModel[0];
  }
  
  private static IFeatureModel[] createModels(URL[] featurePaths, IProgressMonitor monitor)
  {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    monitor.beginTask("", featurePaths.length);
    Map uniqueFeatures = new HashMap();
    for (int i = 0; i < featurePaths.length; i++)
    {
      File manifest = new File(featurePaths[i].getFile(), "feature.xml");
      if ((!manifest.exists()) || (!manifest.isFile()))
      {
        monitor.worked(1);
      }
      else
      {
        IFeatureModel model = createModel(manifest);
        if ((model != null) && (model.isLoaded()))
        {
          IFeature feature = model.getFeature();
          uniqueFeatures.put(feature.getId() + "_" + feature.getVersion(), model);
        }
        monitor.worked(1);
      }
    }
    Collection models = uniqueFeatures.values();
    return (IFeatureModel[])models.toArray(new IFeatureModel[models.size()]);
  }
  
  private ListenerList fListeners = new ListenerList();
  private IFeatureModel[] fModels;
  private PDEPreferencesManager fPref;
  
  public ExternalFeatureModelManager()
  {
    fPref = PDECore.getDefault().getPreferencesManager();
  }
  
  public void addModelProviderListener(IModelProviderListener listener)
  {
    fListeners.add(listener);
  }
  
  private void fireModelProviderEvent(IModelProviderEvent e)
  {
    Object[] listeners = fListeners.getListeners();
    for (int i = 0; i < listeners.length; i++)
    {
      IModelProviderListener listener = (IModelProviderListener)listeners[i];
      listener.modelsChanged(e);
    }
  }
  
  public void initialize()
  {
    String platformHome = fPref.getString("platform_path");
    String additionalLocations = fPref.getString("additional_locations");
    String externalFeaturesString = fPref.getString("external_features");
    
    IFeatureModel[] oldModels = (IFeatureModel[])null;
    IFeatureModel[] newModels = (IFeatureModel[])null;
    synchronized (this)
    {
      oldModels = fModels != null ? fModels : new IFeatureModel[0];
      IFeatureModel[] allModels = createModels(platformHome, parseAdditionalLocations(additionalLocations), null);
      if ((externalFeaturesString == null) || (externalFeaturesString.trim().length() == 0))
      {
        fModels = allModels;
      }
      else
      {
        Map modelMap = new HashMap();
        for (int i = 0; i < allModels.length; i++)
        {
          String id = allModels[i].getFeature().getId();
          if (modelMap.containsKey(id))
          {
            List list = (List)modelMap.get(id);
            list.add(allModels[i]);
          }
          else
          {
            List list = new ArrayList();
            list.add(allModels[i]);
            modelMap.put(id, list);
          }
        }
        Set filteredModels = new HashSet();
        String[] entries = externalFeaturesString.split(",");
        for (int i = 0; i < entries.length; i++)
        {
          String[] parts = entries[i].split("@");
          if (parts.length > 0)
          {
            String id = parts[0];
            List possibilities = (List)modelMap.get(id);
            if (possibilities != null)
            {
              IFeatureModel candidate = null;
              for (Iterator iterator = possibilities.iterator(); iterator.hasNext();)
              {
                IFeatureModel current = (IFeatureModel)iterator.next();
                if (candidate == null)
                {
                  candidate = current;
                }
                else if ((parts.length > 1) && (parts[1].equals(current.getFeature().getVersion())))
                {
                  candidate = current;
                }
                else
                {
                  Version currentVersion = Version.parseVersion(current.getFeature().getVersion());
                  Version candidateVersion = Version.parseVersion(candidate.getFeature().getVersion());
                  if (currentVersion.compareTo(candidateVersion) == 1) {
                    candidate = current;
                  }
                }
              }
              if (candidate != null) {
                filteredModels.add(candidate);
              }
            }
          }
        }
        fModels = ((IFeatureModel[])filteredModels.toArray(new IFeatureModel[filteredModels.size()]));
      }
      newModels = new IFeatureModel[fModels.length];
      System.arraycopy(fModels, 0, newModels, 0, fModels.length);
    }
    notifyListeners(oldModels, newModels);
  }
  
  private ArrayList parseAdditionalLocations(String additionalLocations)
  {
    ArrayList result = new ArrayList();
    StringTokenizer tokenizer = new StringTokenizer(additionalLocations, ",");
    while (tokenizer.hasMoreTokens()) {
      result.add(tokenizer.nextToken().trim());
    }
    return result;
  }
  
  private void notifyListeners(IFeatureModel[] oldModels, IFeatureModel[] newFeatureModels)
  {
    if ((oldModels.length > 0) || (newFeatureModels.length > 0))
    {
      int type = 0;
      if (oldModels.length > 0) {
        type |= 0x2;
      }
      if (newFeatureModels.length > 0) {
        type |= 0x1;
      }
      ModelProviderEvent replacedFeatures = new ModelProviderEvent(this, type, newFeatureModels, oldModels, null);
      fireModelProviderEvent(replacedFeatures);
    }
  }
  
  public void removeModelProviderListener(IModelProviderListener listener)
  {
    fListeners.remove(listener);
  }
  
  public IFeatureModel[] getModels()
  {
    return fModels;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.ExternalFeatureModelManager
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;

public class ExternalJavaSearchClasspathContainer
  implements IClasspathContainer
{
  private IClasspathEntry[] fEntries;
  
  public IClasspathEntry[] getClasspathEntries()
  {
    if (fEntries == null) {
      try
      {
        SearchablePluginsManager manager = PDECore.getDefault().getSearchablePluginsManager();
        fEntries = manager.computeContainerClasspathEntries();
      }
      catch (CoreException e)
      {
        PDECore.logException(e);
      }
    }
    return fEntries;
  }
  
  public String getDescription()
  {
    return PDECoreMessages.ExternalJavaSearchClasspathContainer_description;
  }
  
  public int getKind()
  {
    return 1;
  }
  
  public IPath getPath()
  {
    return PDECore.JAVA_SEARCH_CONTAINER_PATH;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.ExternalJavaSearchClasspathContainer
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.ClasspathContainerInitializer;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;

public class ExternalJavaSearchInitializer
  extends ClasspathContainerInitializer
{
  ExternalJavaSearchClasspathContainer fContainer;
  
  public void initialize(IPath containerPath, IJavaProject javaProject)
    throws CoreException
  {
    try
    {
      JavaCore.setClasspathContainer(PDECore.JAVA_SEARCH_CONTAINER_PATH, new IJavaProject[] { javaProject }, new IClasspathContainer[] { new ExternalJavaSearchClasspathContainer() }, null);
    }
    catch (OperationCanceledException e)
    {
      throw e;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.ExternalJavaSearchInitializer
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import org.eclipse.core.runtime.IPath;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginLibrary;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.internal.core.util.CoreUtility;

class ExternalLibraryCache
{
  private static final String LIB_CACHE_DIR = ".external_libraries";
  
  public File[] getExtractedLibraries(IPluginModelBase model)
  {
    File fJarFile = new File(model.getInstallLocation());
    if (!fJarFile.isFile()) {
      return new File[0];
    }
    BundleDescription desc = model.getBundleDescription();
    IPluginLibrary[] libs = model.getPluginBase().getLibraries();
    
    File fCacheDir = new File(getLibraryCacheDir(), getBundleLibsCacheDirName(desc));
    
    List files = new ArrayList();
    for (int i = 0; i < libs.length; i++)
    {
      String libName = libs[i].getName();
      if (!".".equals(libName))
      {
        libName = ClasspathUtilCore.expandLibraryName(libName);
        File fDestFile = new File(fCacheDir, libName);
        if (!fDestFile.isFile()) {
          try
          {
            File extractedLib = extractJar(fJarFile, libName, fDestFile);
            if (extractedLib == null) {
              continue;
            }
            files.add(extractedLib);
          }
          catch (IOException ie)
          {
            PDECore.logException(ie, "Could not extract library from jarred bundle " + desc.getSymbolicName());
          }
        } else {
          files.add(fDestFile);
        }
      }
    }
    return (File[])files.toArray(new File[0]);
  }
  
  public void cleanExtractedLibraries(IPluginModelBase[] targetModels)
  {
    File fCacheDir = getLibraryCacheDir();
    if (!fCacheDir.isDirectory()) {
      return;
    }
    Set bundleKeys = new HashSet();
    for (int i = 0; i < targetModels.length; i++) {
      if (targetModels[i].isEnabled())
      {
        BundleDescription desc = targetModels[i].getBundleDescription();
        bundleKeys.add(getBundleLibsCacheDirName(desc));
      }
    }
    File[] fDirs = fCacheDir.listFiles();
    for (int i = 0; i < fDirs.length; i++) {
      if ((fDirs[i].isDirectory()) && (!bundleKeys.contains(fDirs[i].getName()))) {
        CoreUtility.deleteContent(fDirs[i]);
      }
    }
    fCacheDir.delete();
  }
  
  private File getLibraryCacheDir()
  {
    IPath path = PDECore.getDefault().getStateLocation();
    return new File(path.toFile(), ".external_libraries");
  }
  
  private String getBundleLibsCacheDirName(BundleDescription desc)
  {
    return desc.getSymbolicName() + "_" + desc.getVersion();
  }
  
  private File extractJar(File fJarFile, String libName, File fTargetFile)
    throws IOException
  {
    JarFile f = new JarFile(fJarFile);
    InputStream in = null;
    try
    {
      ZipEntry libEntry = f.getEntry(libName);
      if ((libEntry == null) || (libEntry.isDirectory())) {
        return null;
      }
      ZipEntry libEntry;
      fTargetFile.getParentFile().mkdirs();
      in = f.getInputStream(libEntry);
      if (in == null) {
        throw new IOException();
      }
      CoreUtility.readFile(in, fTargetFile);
      return fTargetFile;
    }
    finally
    {
      try
      {
        f.close();
      }
      catch (Exception localException5) {}
      try
      {
        if (in != null) {
          in.close();
        }
      }
      catch (Exception localException6) {}
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.ExternalLibraryCache
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.internal.core.target.P2TargetUtils;
import org.eclipse.pde.internal.core.target.provisional.NameVersionDescriptor;

public class ExternalModelManager
  extends AbstractModelManager
{
  private IPluginModelBase[] fModels = new IPluginModelBase[0];
  private ExternalLibraryCache fLibCache = new ExternalLibraryCache();
  
  protected IPluginModelBase[] getAllModels()
  {
    return fModels;
  }
  
  protected void initializeModels(IPluginModelBase[] models)
  {
    fModels = models;
    PDEPreferencesManager pref = PDECore.getDefault().getPreferencesManager();
    String saved = pref.getString("checkedPlugins");
    if (saved.equals("[savedAll]"))
    {
      for (int i = 0; i < fModels.length; i++) {
        fModels[i].setEnabled(true);
      }
    }
    else if (!saved.equals("[savedNone]"))
    {
      String versionString = pref.getString("checkedVersionPlugins");
      Set versions = new HashSet();
      Set versionIds = new HashSet();
      if ((versionString != null) && (versionString.trim().length() > 0) && 
        (!versionString.equals("[savedNone]")))
      {
        StringTokenizer stok = new StringTokenizer(versionString);
        while (stok.hasMoreTokens())
        {
          NameVersionDescriptor desc = NameVersionDescriptor.fromPortableString(stok.nextToken());
          versions.add(desc);
          versionIds.add(desc.getId());
        }
      }
      Vector result = new Vector();
      StringTokenizer stok = new StringTokenizer(saved);
      while (stok.hasMoreTokens()) {
        result.add(stok.nextToken());
      }
      for (int i = 0; i < fModels.length; i++)
      {
        String id = fModels[i].getPluginBase().getId();
        if (versionIds.contains(id)) {
          fModels[i].setEnabled(!versions.contains(new NameVersionDescriptor(id, fModels[i].getPluginBase().getVersion())));
        } else {
          fModels[i].setEnabled(!result.contains(id));
        }
      }
    }
    fLibCache.cleanExtractedLibraries(fModels);
  }
  
  public void setModels(IPluginModelBase[] models)
  {
    fModels = models;
    fLibCache.cleanExtractedLibraries(fModels);
  }
  
  public URL[] getPluginPaths()
  {
    PDEPreferencesManager pref = PDECore.getDefault().getPreferencesManager();
    boolean addPool = false;
    String baseLocation = pref.getString("platform_path");
    URL[] base = (URL[])null;
    if (P2TargetUtils.BUNDLE_POOL.isPrefixOf(new Path(baseLocation)))
    {
      addPool = true;
      base = new URL[0];
    }
    else
    {
      base = PluginPathFinder.getPluginPaths(baseLocation);
    }
    String value = pref.getString("additional_locations");
    StringTokenizer tokenizer = new StringTokenizer(value, ",");
    if ((!addPool) && (tokenizer.countTokens() == 0)) {
      return base;
    }
    List extraLocations = new ArrayList(tokenizer.countTokens());
    while (tokenizer.hasMoreTokens())
    {
      String location = tokenizer.nextToken();
      if (P2TargetUtils.BUNDLE_POOL.isPrefixOf(new Path(location)))
      {
        addPool = true;
      }
      else
      {
        File dir = new File(location, "plugins");
        if ((!dir.exists()) || (!dir.isDirectory())) {
          dir = new File(location);
        }
        extraLocations.add(dir);
      }
    }
    URL[] additional = PluginPathFinder.scanLocations((File[])extraLocations.toArray(new File[extraLocations.size()]));
    URL[] result = append(base, additional);
    if (addPool)
    {
      String pooled = pref.getString("pooled_urls");
      if ((pooled != null) && (pooled.trim().length() > 0) && 
        (!"[savedNone]".equals(pooled)))
      {
        tokenizer = new StringTokenizer(pooled, ",");
        List urls = new ArrayList(tokenizer.countTokens());
        while (tokenizer.hasMoreTokens())
        {
          String fileName = tokenizer.nextToken();
          try
          {
            urls.add(P2TargetUtils.BUNDLE_POOL.append("plugins").append(fileName).toFile().toURL());
          }
          catch (MalformedURLException e)
          {
            PDECore.log(e);
          }
        }
        additional = (URL[])urls.toArray(new URL[urls.size()]);
        result = append(result, additional);
      }
    }
    return result;
  }
  
  public File[] getExtractedLibraries(IPluginModelBase model)
  {
    return fLibCache.getExtractedLibraries(model);
  }
  
  private URL[] append(URL[] base, URL[] additional)
  {
    if (additional.length == 0) {
      return base;
    }
    URL[] result = new URL[base.length + additional.length];
    System.arraycopy(base, 0, result, 0, base.length);
    System.arraycopy(additional, 0, result, base.length, additional.length);
    return result;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.ExternalModelManager
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.util.ArrayList;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;

public class FeatureModelDelta
  implements IFeatureModelDelta
{
  private ArrayList fAdded;
  private ArrayList fRemoved;
  private ArrayList fChanged;
  private int kind = 0;
  
  public int getKind()
  {
    return kind;
  }
  
  public IFeatureModel[] getAdded()
  {
    return get(fAdded);
  }
  
  public IFeatureModel[] getRemoved()
  {
    return get(fRemoved);
  }
  
  public IFeatureModel[] getChanged()
  {
    return get(fChanged);
  }
  
  private IFeatureModel[] get(ArrayList list)
  {
    if (list == null) {
      return new IFeatureModel[0];
    }
    return (IFeatureModel[])list.toArray(new IFeatureModel[list.size()]);
  }
  
  void add(IFeatureModel model, int type)
  {
    switch (type)
    {
    case 1: 
      fAdded = add(fAdded, model);
      break;
    case 2: 
      fRemoved = add(fRemoved, model);
      break;
    case 4: 
      fChanged = add(fChanged, model);
    }
    kind = (kind | type);
  }
  
  private ArrayList add(ArrayList list, IFeatureModel model)
  {
    if (list == null) {
      list = new ArrayList();
    }
    list.add(model);
    return list;
  }
  
  boolean contains(IFeatureModel model, int type)
  {
    if (((type & 0x1) != 0) && (fAdded != null) && (fAdded.contains(model))) {
      return true;
    }
    if (((type & 0x2) != 0) && (fRemoved != null) && (fRemoved.contains(model))) {
      return true;
    }
    if (((type & 0x4) != 0) && (fChanged != null) && (fChanged.contains(model))) {
      return true;
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.FeatureModelDelta
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import org.eclipse.pde.core.IModelProviderEvent;
import org.eclipse.pde.core.IModelProviderListener;

class FeatureModelManager$1
  implements IModelProviderListener
{
  final FeatureModelManager this$0;
  
  FeatureModelManager$1(FeatureModelManager paramFeatureModelManager)
  {
    this$0 = paramFeatureModelManager;
  }
  
  public void modelsChanged(IModelProviderEvent e)
  {
    FeatureModelManager.access$0(this$0, e);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.FeatureModelManager.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.pde.core.IModel;
import org.eclipse.pde.core.IModelProviderEvent;
import org.eclipse.pde.core.IModelProviderListener;
import org.eclipse.pde.internal.core.ifeature.IFeature;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.eclipse.pde.internal.core.util.VersionUtil;
import org.osgi.framework.Version;

public class FeatureModelManager
{
  private FeatureTable fActiveModels;
  private FeatureTable fInactiveModels;
  private ExternalFeatureModelManager fExternalManager;
  private boolean fReloadExternalNeeded = false;
  private WorkspaceFeatureModelManager fWorkspaceManager;
  private IModelProviderListener fProviderListener;
  private ArrayList fListeners;
  
  public FeatureModelManager()
  {
    fWorkspaceManager = new WorkspaceFeatureModelManager();
    fListeners = new ArrayList();
  }
  
  public synchronized void shutdown()
  {
    if (fWorkspaceManager != null) {
      fWorkspaceManager.removeModelProviderListener(fProviderListener);
    }
    if (fExternalManager != null) {
      fExternalManager.removeModelProviderListener(fProviderListener);
    }
  }
  
  private synchronized void init()
  {
    if (fActiveModels != null)
    {
      if (fReloadExternalNeeded)
      {
        fReloadExternalNeeded = false;
        fExternalManager.initialize();
      }
      return;
    }
    fActiveModels = new FeatureTable();
    fInactiveModels = new FeatureTable();
    
    fProviderListener = new IModelProviderListener()
    {
      public void modelsChanged(IModelProviderEvent e)
      {
        FeatureModelManager.this.handleModelsChanged(e);
      }
    };
    fWorkspaceManager.addModelProviderListener(fProviderListener);
    
    IFeatureModel[] models = fWorkspaceManager.getFeatureModels();
    for (int i = 0; i < models.length; i++) {
      fActiveModels.add(models[i]);
    }
    fExternalManager = new ExternalFeatureModelManager();
    fExternalManager.addModelProviderListener(fProviderListener);
    fReloadExternalNeeded = false;
    fExternalManager.initialize();
  }
  
  public IFeatureModel[] getModels()
  {
    init();
    IFeatureModel[] allModels = fActiveModels.getAll();
    ArrayList valid = new ArrayList(allModels.length);
    for (int i = 0; i < allModels.length; i++) {
      if (allModels[i].isValid()) {
        valid.add(allModels[i]);
      }
    }
    return (IFeatureModel[])valid.toArray(new IFeatureModel[valid.size()]);
  }
  
  public IFeatureModel[] getWorkspaceModels()
  {
    init();
    return fWorkspaceManager.getFeatureModels();
  }
  
  public IFeatureModel[] getExternalModels()
  {
    init();
    return fExternalManager.getModels();
  }
  
  public IFeatureModel getFeatureModel(IProject project)
  {
    init();
    return fWorkspaceManager.getFeatureModel(project);
  }
  
  public IFeatureModel findFeatureModel(String id, String version)
  {
    init();
    IFeatureModel[] models = fActiveModels.get(id, version);
    if (VersionUtil.isEmptyVersion(version)) {
      return findFeatureModel(id);
    }
    for (int i = 0; i < models.length; i++) {
      if (models[i].isValid()) {
        return models[i];
      }
    }
    return null;
  }
  
  public IFeatureModel findFeatureModelRelaxed(String id, String version)
  {
    IFeatureModel model = findFeatureModel(id, version);
    if (model != null) {
      return model;
    }
    try
    {
      Version pvi = Version.parseVersion(version);
      return findFeatureModel(id, pvi.getMajor() + "." + 
        pvi.getMinor() + "." + 
        pvi.getMicro() + ".qualifier");
    }
    catch (IllegalArgumentException localIllegalArgumentException) {}
    return null;
  }
  
  public IFeatureModel[] findFeatureModels(String id)
  {
    init();
    IFeatureModel[] models = fActiveModels.get(id);
    ArrayList valid = new ArrayList(models.length);
    for (int i = 0; i < models.length; i++) {
      if (models[i].isValid()) {
        valid.add(models[i]);
      }
    }
    return (IFeatureModel[])valid.toArray(new IFeatureModel[valid.size()]);
  }
  
  public IFeatureModel findFeatureModel(String id)
  {
    IFeatureModel[] models = findFeatureModels(id);
    IFeatureModel model = null;
    for (int i = 0; i < models.length; i++) {
      if (model == null)
      {
        model = models[i];
      }
      else
      {
        String version = model.getFeature().getVersion();
        String version2 = models[i].getFeature().getVersion();
        Version vid = Version.parseVersion(version);
        Version vid2 = Version.parseVersion(version2);
        if (VersionUtil.isGreaterOrEqualTo(vid2, vid)) {
          model = models[i];
        }
      }
    }
    return model;
  }
  
  private void handleModelsChanged(IModelProviderEvent e)
  {
    init();
    IFeatureModelDelta delta = processEvent(e);
    
    Object[] entries = fListeners.toArray();
    for (int i = 0; i < entries.length; i++) {
      ((IFeatureModelListener)entries[i]).modelsChanged(delta);
    }
  }
  
  private synchronized IFeatureModelDelta processEvent(IModelProviderEvent e)
  {
    FeatureModelDelta delta = new FeatureModelDelta();
    
    Set affectedIdVers = null;
    if ((e.getEventTypes() & 0x2) != 0)
    {
      IModel[] removed = e.getRemovedModels();
      for (int i = 0; i < removed.length; i++) {
        if ((removed[i] instanceof IFeatureModel))
        {
          IFeatureModel model = (IFeatureModel)removed[i];
          FeatureTable.Idver idver = fActiveModels.remove(model);
          if (idver != null)
          {
            if (affectedIdVers == null) {
              affectedIdVers = new HashSet();
            }
            affectedIdVers.add(idver);
            delta.add(model, 2);
          }
          else
          {
            fInactiveModels.remove(model);
          }
        }
      }
    }
    if ((e.getEventTypes() & 0x1) != 0)
    {
      IModel[] added = e.getAddedModels();
      for (int i = 0; i < added.length; i++) {
        if ((added[i] instanceof IFeatureModel))
        {
          IFeatureModel model = (IFeatureModel)added[i];
          if (model.getUnderlyingResource() != null)
          {
            FeatureTable.Idver idver = fActiveModels.add(model);
            delta.add(model, 1);
            if (affectedIdVers == null) {
              affectedIdVers = new HashSet();
            }
            affectedIdVers.add(idver);
          }
          else if (model.isValid())
          {
            String id = model.getFeature().getId();
            String version = model.getFeature().getVersion();
            if (fInactiveModels.get(id, version).length <= 0)
            {
              IFeatureModel[] activeModels = fActiveModels.get(id, version);
              for (int j = 0; j < activeModels.length; j++) {
                if (activeModels[j].getUnderlyingResource() != null) {}
              }
              FeatureTable.Idver idver = fInactiveModels.add(model);
              if (affectedIdVers == null) {
                affectedIdVers = new HashSet();
              }
              affectedIdVers.add(idver);
            }
          }
        }
      }
    }
    if ((e.getEventTypes() & 0x4) != 0)
    {
      IModel[] changed = e.getChangedModels();
      for (int i = 0; i < changed.length; i++) {
        if ((changed[i] instanceof IFeatureModel))
        {
          IFeatureModel model = (IFeatureModel)changed[i];
          
          String id = model.getFeature().getId();
          String version = model.getFeature().getVersion();
          
          FeatureTable.Idver oldIdver = fActiveModels.get(model);
          if ((oldIdver != null) && (!oldIdver.equals(id, version)))
          {
            FeatureTable.Idver idver = fActiveModels.add(model);
            if (affectedIdVers == null) {
              affectedIdVers = new HashSet();
            }
            affectedIdVers.add(oldIdver);
            affectedIdVers.add(idver);
          }
        }
      }
    }
    adjustExternalVisibility(delta, affectedIdVers);
    if ((e.getEventTypes() & 0x4) != 0)
    {
      IModel[] changed = e.getChangedModels();
      for (int i = 0; i < changed.length; i++) {
        if ((changed[i] instanceof IFeatureModel))
        {
          IFeatureModel model = (IFeatureModel)changed[i];
          if (!delta.contains(model, 3)) {
            delta.add(model, 4);
          }
        }
      }
    }
    return delta;
  }
  
  private void adjustExternalVisibility(FeatureModelDelta delta, Set affectedIdVers)
  {
    if (affectedIdVers != null) {
      for (Iterator it = affectedIdVers.iterator(); it.hasNext();)
      {
        FeatureTable.Idver idver = (FeatureTable.Idver)it.next();
        IFeatureModel[] affectedModels = fActiveModels.get(idver);
        if (affectedModels.length > 1) {
          for (int j = 0; j < affectedModels.length; j++) {
            if (affectedModels[j].getUnderlyingResource() == null)
            {
              fActiveModels.remove(affectedModels[j]);
              fInactiveModels.add(affectedModels[j]);
              delta.add(affectedModels[j], 2);
            }
          }
        }
        if (affectedModels.length <= 0)
        {
          IFeatureModel[] models = fInactiveModels.get(idver);
          if (models.length > 0)
          {
            fInactiveModels.remove(models[0]);
            fActiveModels.add(models[0]);
            delta.add(models[0], 1);
          }
        }
      }
    }
  }
  
  public void addFeatureModelListener(IFeatureModelListener listener)
  {
    if (!fListeners.contains(listener)) {
      fListeners.add(listener);
    }
  }
  
  public void removeFeatureModelListener(IFeatureModelListener listener)
  {
    if (fListeners.contains(listener)) {
      fListeners.remove(listener);
    }
  }
  
  public void targetReloaded()
  {
    fReloadExternalNeeded = true;
  }
  
  public IFeatureModel getDeltaPackFeature()
  {
    IFeatureModel model = findFeatureModel("org.eclipse.equinox.executable");
    if (model == null) {
      model = findFeatureModel("org.eclipse.platform.launchers");
    }
    return model;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.FeatureModelManager
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

public class FeatureTable$Idver
{
  private final String fId;
  private final String fVer;
  final FeatureTable this$0;
  
  public FeatureTable$Idver(FeatureTable paramFeatureTable, String id, String version)
  {
    this$0 = paramFeatureTable;
    fId = id;
    fVer = version;
  }
  
  public String getId()
  {
    return fId;
  }
  
  public String getVer()
  {
    return fVer;
  }
  
  public int hashCode()
  {
    int code = 0;
    if (fId != null) {
      code += fId.hashCode();
    }
    if (fVer != null) {
      code += fVer.hashCode();
    }
    return code;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (!(obj instanceof Idver)) {
      return false;
    }
    return equals(((Idver)obj).getId(), ((Idver)obj).getVer());
  }
  
  public boolean equals(String id, String version)
  {
    boolean sameId = ((fId == null) && (id == null)) || ((fId != null) && (fId.equals(id)));
    boolean sameVer = ((fVer == null) && (version == null)) || ((fVer != null) && (fVer.equals(version)));
    return (sameId) && (sameVer);
  }
  
  public String toString()
  {
    return fId + "_" + fVer;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.FeatureTable.Idver
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.eclipse.pde.internal.core.ifeature.IFeature;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;

class FeatureTable
{
  public class Idver
  {
    private final String fId;
    private final String fVer;
    
    public Idver(String id, String version)
    {
      fId = id;
      fVer = version;
    }
    
    public String getId()
    {
      return fId;
    }
    
    public String getVer()
    {
      return fVer;
    }
    
    public int hashCode()
    {
      int code = 0;
      if (fId != null) {
        code += fId.hashCode();
      }
      if (fVer != null) {
        code += fVer.hashCode();
      }
      return code;
    }
    
    public boolean equals(Object obj)
    {
      if (this == obj) {
        return true;
      }
      if (!(obj instanceof Idver)) {
        return false;
      }
      return equals(((Idver)obj).getId(), ((Idver)obj).getVer());
    }
    
    public boolean equals(String id, String version)
    {
      boolean sameId = ((fId == null) && (id == null)) || ((fId != null) && (fId.equals(id)));
      boolean sameVer = ((fVer == null) && (version == null)) || ((fVer != null) && (fVer.equals(version)));
      return (sameId) && (sameVer);
    }
    
    public String toString()
    {
      return fId + "_" + fVer;
    }
  }
  
  private static final IFeatureModel[] NO_MODELS = new IFeatureModel[0];
  private Map fModel2idver;
  private Map fIdver2models;
  private Map fId2idvers;
  
  public FeatureTable()
  {
    fModel2idver = new HashMap();
    fIdver2models = new HashMap();
    fId2idvers = new HashMap();
  }
  
  public synchronized Idver get(IFeatureModel model)
  {
    return (Idver)fModel2idver.get(model);
  }
  
  public synchronized IFeatureModel[] get(String id, String version)
  {
    return getImpl(new Idver(id, version));
  }
  
  public synchronized IFeatureModel[] get(Idver idver)
  {
    return getImpl(idver);
  }
  
  private IFeatureModel[] getImpl(Idver idver)
  {
    ArrayList models = (ArrayList)fIdver2models.get(idver);
    if (models == null) {
      return NO_MODELS;
    }
    return (IFeatureModel[])models.toArray(new IFeatureModel[models.size()]);
  }
  
  public synchronized IFeatureModel[] get(String id)
  {
    ArrayList idvers = (ArrayList)fId2idvers.get(id);
    if (idvers == null) {
      return NO_MODELS;
    }
    ArrayList allModels = new ArrayList();
    for (int i = 0; i < idvers.size(); i++)
    {
      Idver idver = (Idver)idvers.get(i);
      ArrayList models = (ArrayList)fIdver2models.get(idver);
      if (models != null) {
        allModels.addAll(models);
      }
    }
    return (IFeatureModel[])allModels.toArray(new IFeatureModel[allModels.size()]);
  }
  
  public synchronized IFeatureModel[] getAll()
  {
    return getAllImpl();
  }
  
  private IFeatureModel[] getAllImpl()
  {
    return (IFeatureModel[])fModel2idver.keySet().toArray(new IFeatureModel[fModel2idver.size()]);
  }
  
  public synchronized Idver remove(IFeatureModel model)
  {
    return removeImpl(model);
  }
  
  private Idver removeImpl(IFeatureModel model)
  {
    Idver idver = (Idver)fModel2idver.remove(model);
    if (idver == null) {
      return null;
    }
    ArrayList models = (ArrayList)fIdver2models.get(idver);
    for (int i = 0; i < models.size(); i++) {
      if (models.get(i) == model)
      {
        models.remove(i);
        break;
      }
    }
    if (models.size() <= 0)
    {
      fIdver2models.remove(idver);
      
      ArrayList idvers = (ArrayList)fId2idvers.get(idver.getId());
      for (int i = 0; i < idvers.size(); i++) {
        if (idvers.get(i).equals(idver))
        {
          idvers.remove(i);
          break;
        }
      }
      if (idvers.size() <= 0) {
        fId2idvers.remove(idver.getId());
      }
    }
    return idver;
  }
  
  public synchronized Idver add(IFeatureModel model)
  {
    removeImpl(model);
    
    IFeature feature = model.getFeature();
    String id = feature.getId();
    String ver = feature.getVersion();
    Idver idver = new Idver(id, ver);
    
    fModel2idver.put(model, idver);
    
    ArrayList models = (ArrayList)fIdver2models.get(idver);
    if (models == null)
    {
      models = new ArrayList(1);
      fIdver2models.put(idver, models);
    }
    models.add(model);
    
    ArrayList idvers = (ArrayList)fId2idvers.get(id);
    if (idvers == null)
    {
      idvers = new ArrayList(1);
      fId2idvers.put(id, idvers);
    }
    idvers.add(idver);
    
    return idver;
  }
  
  public synchronized String toString()
  {
    IFeatureModel[] models = getAllImpl();
    StringBuffer buf = new StringBuffer(30 * models.length);
    buf.append("[");
    for (int i = 0; i < models.length; i++)
    {
      if (i > 0) {
        buf.append(",  ");
      }
      buf.append(get(models[i]));
      buf.append("@");
      buf.append(models[i].getFeature().getId());
      buf.append("_");
      buf.append(models[i].getFeature().getVersion());
    }
    buf.append("]");
    return buf.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.FeatureTable
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.io.File;
import java.util.Locale;
import org.eclipse.core.runtime.PlatformObject;

public class FileAdapter
  extends PlatformObject
{
  private File fFile;
  private Object[] fChildren;
  private FileAdapter fParent;
  private String fEditorId;
  private IFileAdapterFact
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

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-2019. Infinite Loop Ltd