org.eclipse.pde.core_3.7.1.v20120103_r372

BundleClasspathEntry
{
  public abstract IPath getSourcePath();
  
  public abstract IPath getBinaryPath();
  
  public abstract IPath getLibrary();
}

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

import java.net.URI;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.osgi.framework.Version;

public abstract interface IBundleProjectDescription
{
  public static final String VERSION_3_0 = "3.0";
  public static final String VERSION_3_1 = "3.1";
  public static final String VERSION_3_2 = "3.2";
  public static final String VERSION_3_3 = "3.3";
  public static final String VERSION_3_4 = "3.4";
  public static final String VERSION_3_5 = "3.5";
  public static final String VERSION_3_6 = "3.6";
  public static final String VERSION_3_7 = "3.7";
  public static final String PLUGIN_NATURE = "org.eclipse.pde.PluginNature";
  
  public abstract void apply(IProgressMonitor paramIProgressMonitor)
    throws CoreException;
  
  public abstract void setSymbolicName(String paramString);
  
  public abstract String getSymbolicName();
  
  public abstract void setLocationURI(URI paramURI);
  
  public abstract URI getLocationURI();
  
  public abstract void setBundleName(String paramString);
  
  public abstract String getBundleName();
  
  public abstract void setBundleVendor(String paramString);
  
  public abstract String getBundleVendor();
  
  public abstract void setBundleVersion(Version paramVersion);
  
  public abstract Version getBundleVersion();
  
  public abstract void setSingleton(boolean paramBoolean);
  
  public abstract boolean isSingleton();
  
  public abstract void setLocalization(IPath paramIPath);
  
  public abstract IPath getLocalization();
  
  public abstract String[] getNatureIds();
  
  public abstract void setNatureIds(String[] paramArrayOfString);
  
  public abstract boolean hasNature(String paramString);
  
  public abstract void setHost(IHostDescription paramIHostDescription);
  
  public abstract IHostDescription getHost();
  
  public abstract void setDefaultOutputFolder(IPath paramIPath);
  
  public abstract IPath getDefaultOutputFolder();
  
  public abstract void setExecutionEnvironments(String[] paramArrayOfString);
  
  public abstract String[] getExecutionEnvironments();
  
  /**
   * @deprecated
   */
  public abstract void setBundleClassath(IBundleClasspathEntry[] paramArrayOfIBundleClasspathEntry);
  
  public abstract void setBundleClasspath(IBundleClasspathEntry[] paramArrayOfIBundleClasspathEntry);
  
  public abstract IBundleClasspathEntry[] getBundleClasspath();
  
  public abstract void setActivator(String paramString);
  
  public abstract String getActivator();
  
  public abstract void setTargetVersion(String paramString);
  
  public abstract String getTargetVersion();
  
  public abstract void setEquinox(boolean paramBoolean);
  
  public abstract boolean isEquinox();
  
  public abstract void setActivationPolicy(String paramString);
  
  public abstract String getActivationPolicy();
  
  public abstract void setExtensionRegistry(boolean paramBoolean);
  
  public abstract boolean isExtensionRegistry();
  
  public abstract void setRequiredBundles(IRequiredBundleDescription[] paramArrayOfIRequiredBundleDescription);
  
  public abstract IRequiredBundleDescription[] getRequiredBundles();
  
  public abstract void setPackageImports(IPackageImportDescription[] paramArrayOfIPackageImportDescription);
  
  public abstract IPackageImportDescription[] getPackageImports();
  
  public abstract void setPackageExports(IPackageExportDescription[] paramArrayOfIPackageExportDescription);
  
  public abstract IPackageExportDescription[] getPackageExports();
  
  public abstract IProject getProject();
  
  public abstract void setBinIncludes(IPath[] paramArrayOfIPath);
  
  public abstract IPath[] getBinIncludes();
  
  public abstract void setBundleRoot(IPath paramIPath);
  
  public abstract IPath getBundleRoot();
  
  public abstract String[] getLaunchShortcuts();
  
  public abstract void setLaunchShortcuts(String[] paramArrayOfString);
  
  public abstract String getExportWizardId();
  
  public abstract void setExportWizardId(String paramString);
  
  public abstract void setHeader(String paramString1, String paramString2);
  
  public abstract String getHeader(String paramString);
}

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

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.osgi.framework.Version;

public abstract interface IBundleProjectService
{
  public abstract IBundleProjectDescription getDescription(IProject paramIProject)
    throws CoreException;
  
  public abstract IHostDescription newHost(String paramString, VersionRange paramVersionRange);
  
  public abstract IPackageImportDescription newPackageImport(String paramString, VersionRange paramVersionRange, boolean paramBoolean);
  
  public abstract IPackageExportDescription newPackageExport(String paramString, Version paramVersion, boolean paramBoolean, String[] paramArrayOfString);
  
  public abstract IRequiredBundleDescription newRequiredBundle(String paramString, VersionRange paramVersionRange, boolean paramBoolean1, boolean paramBoolean2);
  
  public abstract IBundleClasspathEntry newBundleClasspathEntry(IPath paramIPath1, IPath paramIPath2, IPath paramIPath3);
  
  public abstract void setBundleRoot(IProject paramIProject, IPath paramIPath)
    throws CoreException;
}

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

import org.eclipse.osgi.service.resolver.VersionRange;

public abstract interface IHostDescription
{
  public abstract String getName();
  
  public abstract VersionRange getVersionRange();
}

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

import org.osgi.framework.Version;

public abstract interface IPackageExportDescription
{
  public abstract String getName();
  
  public abstract Version getVersion();
  
  public abstract String[] getFriends();
  
  public abstract boolean isApi();
}

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

import org.eclipse.osgi.service.resolver.VersionRange;

public abstract interface IPackageImportDescription
{
  public abstract String getName();
  
  public abstract VersionRange getVersionRange();
  
  public abstract boolean isOptional();
}

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

import org.eclipse.osgi.service.resolver.VersionRange;

public abstract interface IRequiredBundleDescription
{
  public abstract String getName();
  
  public abstract VersionRange getVersionRange();
  
  public abstract boolean isExported();
  
  public abstract boolean isOptional();
}

/* Location:
 * Qualified Name:     org.eclipse.pde.core.project.IRequiredBundleDescription
 * 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.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.Status;
import org.eclipse.pde.core.IModel;
import org.eclipse.pde.core.IModelChangedEvent;
import org.eclipse.pde.core.IModelChangedListener;
import org.eclipse.pde.core.ModelChangedEvent;
import org.xml.sax.SAXException;

public abstract class AbstractModel
  extends PlatformObject
  implements IModel, IModelChangeProviderExtension, Serializable
{
  private static final long serialVersionUID = 1L;
  private transient List fListeners;
  private boolean fLoaded;
  protected boolean fDisposed;
  private long fTimestamp;
  private Exception fException;
  
  public AbstractModel()
  {
    fListeners = Collections.synchronizedList(new ArrayList());
  }
  
  public void addModelChangedListener(IModelChangedListener listener)
  {
    fListeners.add(listener);
  }
  
  public void transferListenersTo(IModelChangeProviderExtension target, IModelChangedListenerFilter filter)
  {
    ArrayList removed = new ArrayList();
    for (int i = 0; i < fListeners.size(); i++)
    {
      IModelChangedListener listener = (IModelChangedListener)fListeners.get(i);
      if ((filter == null) || (filter.accept(listener)))
      {
        target.addModelChangedListener(listener);
        removed.add(listener);
      }
    }
    fListeners.removeAll(removed);
  }
  
  public void dispose()
  {
    fDisposed = true;
  }
  
  public void fireModelChanged(IModelChangedEvent event)
  {
    IModelChangedListener[] list = (IModelChangedListener[])fListeners.toArray(new IModelChangedListener[fListeners.size()]);
    for (int i = 0; i < list.length; i++)
    {
      IModelChangedListener listener = list[i];
      listener.modelChanged(event);
    }
  }
  
  public void fireModelObjectChanged(Object object, String property, Object oldValue, Object newValue)
  {
    fireModelChanged(new ModelChangedEvent(this, object, property, oldValue, newValue));
  }
  
  public String getResourceString(String key)
  {
    return key;
  }
  
  public IResource getUnderlyingResource()
  {
    return null;
  }
  
  protected boolean isInSync(File localFile)
  {
    return (localFile.exists()) && (localFile.lastModified() == getTimeStamp());
  }
  
  public boolean isValid()
  {
    return (!isDisposed()) && (isLoaded());
  }
  
  public final long getTimeStamp()
  {
    return fTimestamp;
  }
  
  protected abstract void updateTimeStamp();
  
  protected void updateTimeStamp(File localFile)
  {
    if (localFile.exists()) {
      fTimestamp = localFile.lastModified();
    }
  }
  
  public boolean isDisposed()
  {
    return fDisposed;
  }
  
  public boolean isLoaded()
  {
    return fLoaded;
  }
  
  public void setLoaded(boolean loaded)
  {
    fLoaded = loaded;
  }
  
  public void setException(Exception e)
  {
    fException = e;
  }
  
  public Exception getException()
  {
    return fException;
  }
  
  public void removeModelChangedListener(IModelChangedListener listener)
  {
    fListeners.remove(listener);
  }
  
  public void throwParseErrorsException(Throwable e)
    throws CoreException
  {
    Status status = new Status(4, "org.eclipse.pde.core", 0, "Error in the manifest file", 
      e);
    throw new CoreException(status);
  }
  
  protected SAXParser getSaxParser()
    throws ParserConfigurationException, SAXException, FactoryConfigurationError
  {
    return SAXParserFactory.newInstance().newSAXParser();
  }
  
  public boolean isReconcilingModel()
  {
    return false;
  }
}

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

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

public abstract class AbstractModelManager
{
  private ListenerList fListeners = new ListenerList();
  
  public synchronized void removeModelProviderListener(IModelProviderListener listener)
  {
    if (listener != null) {
      fListeners.remove(listener);
    }
  }
  
  public synchronized void addModelProviderListener(IModelProviderListener listener)
  {
    fListeners.add(listener);
  }
  
  public void fireModelProviderEvent(IModelProviderEvent event)
  {
    Object[] listeners = fListeners.getListeners();
    for (int i = 0; i < listeners.length; i++) {
      ((IModelProviderListener)listeners[i]).modelsChanged(event);
    }
  }
  
  public void shutdown()
  {
    removeListeners();
  }
  
  protected void removeListeners()
  {
    fListeners.clear();
  }
}

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

import org.eclipse.core.resources.IResource;

public abstract class AbstractNLModel
  extends AbstractModel
{
  private static final long serialVersionUID = 1L;
  protected transient NLResourceHelper fNLHelper;
  
  public NLResourceHelper getNLResourceHelper()
  {
    if (fNLHelper == null) {
      fNLHelper = createNLResourceHelper();
    }
    return fNLHelper;
  }
  
  public void resetNLResourceHelper()
  {
    fNLHelper = null;
  }
  
  public void dispose()
  {
    if (fNLHelper != null)
    {
      fNLHelper.dispose();
      fNLHelper = null;
    }
    super.dispose();
  }
  
  public String getResourceString(String key)
  {
    if (key == null) {
      return "";
    }
    if (fNLHelper == null) {
      fNLHelper = createNLResourceHelper();
    }
    return fNLHelper != null ? fNLHelper.getResourceString(key) : key;
  }
  
  protected abstract NLResourceHelper createNLResourceHelper();
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == IResource.class)
    {
      IResource resource = getUnderlyingResource();
      return resource == null ? null : resource.getProject();
    }
    return super.getAdapter(adapter);
  }
}

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.team.FileModificationValidationContext;
import org.eclipse.core.resources.team.FileModificationValidator;
import org.eclipse.core.runtime.IStatus;

class BinaryRepositoryProvider$BinaryFileModificationValidator
  extends FileModificationValidator
{
  final BinaryRepositoryProvider this$0;
  
  BinaryRepositoryProvider$BinaryFileModificationValidator(BinaryRepositoryProvider paramBinaryRepositoryProvider)
  {
    this$0 = paramBinaryRepositoryProvider;
  }
  
  public IStatus validateEdit(IFile[] files, FileModificationValidationContext context)
  {
    for (int i = 0; i < files.length; i++) {
      if (BinaryRepositoryProvider.access$0(this$0, files[i], false)) {
        return BinaryRepositoryProvider.access$1(this$0);
      }
    }
    return BinaryRepositoryProvider.access$2(this$0);
  }
  
  public IStatus validateSave(IFile file)
  {
    if (BinaryRepositoryProvider.access$0(this$0, file, false)) {
      return BinaryRepositoryProvider.access$1(this$0);
    }
    return BinaryRepositoryProvider.access$2(this$0);
  }
}

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

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.team.IMoveDeleteHook;
import org.eclipse.core.resources.team.IResourceTree;
import org.eclipse.core.runtime.IProgressMonitor;

class BinaryRepositoryProvider$BinaryMoveDeleteHook
  implements IMoveDeleteHook
{
  final BinaryRepositoryProvider this$0;
  
  BinaryRepositoryProvider$BinaryMoveDeleteHook(BinaryRepositoryProvider paramBinaryRepositoryProvider)
  {
    this$0 = paramBinaryRepositoryProvider;
  }
  
  public boolean deleteFile(IResourceTree tree, IFile file, int updateFlags, IProgressMonitor monitor)
  {
    if (BinaryRepositoryProvider.access$0(this$0, file, true)) {
      tree.failed(BinaryRepositoryProvider.access$1(this$0));
    } else {
      tree.standardDeleteFile(file, updateFlags, monitor);
    }
    return true;
  }
  
  public boolean deleteFolder(IResourceTree tree, IFolder folder, int updateFlags, IProgressMonitor monitor)
  {
    if (BinaryRepositoryProvider.access$0(this$0, folder, true)) {
      tree.failed(BinaryRepositoryProvider.access$1(this$0));
    } else {
      tree.standardDeleteFolder(folder, updateFlags, monitor);
    }
    return true;
  }
  
  public boolean deleteProject(IResourceTree tree, IProject project, int updateFlags, IProgressMonitor monitor)
  {
    return false;
  }
  
  public boolean moveFile(IResourceTree tree, IFile source, IFile destination, int updateFlags, IProgressMonitor monitor)
  {
    if (BinaryRepositoryProvider.access$0(this$0, source, false)) {
      tree.failed(BinaryRepositoryProvider.access$1(this$0));
    } else {
      tree.standardMoveFile(source, destination, updateFlags, monitor);
    }
    return true;
  }
  
  public boolean moveFolder(IResourceTree tree, IFolder source, IFolder destination, int updateFlags, IProgressMonitor monitor)
  {
    if (BinaryRepositoryProvider.access$0(this$0, source, false)) {
      tree.failed(BinaryRepositoryProvider.access$1(this$0));
    } else {
      tree.standardMoveFolder(source, destination, updateFlags, monitor);
    }
    return true;
  }
  
  public boolean moveProject(IResourceTree tree, IProject source, IProjectDescription description, int updateFlags, IProgressMonitor monitor)
  {
    return false;
  }
}

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

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.team.FileModificationValidationContext;
import org.eclipse.core.resources.team.FileModificationValidator;
import org.eclipse.core.resources.team.IMoveDeleteHook;
import org.eclipse.core.resources.team.IResourceTree;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.team.core.RepositoryProvider;

public class BinaryRepositoryProvider
  extends RepositoryProvider
{
  private IMoveDeleteHook moveDeleteHook;
  private FileModificationValidator fileModificationValidator;
  public static final String EXTERNAL_PROJECT_VALUE = "external";
  
  class BinaryMoveDeleteHook
    implements IMoveDeleteHook
  {
    BinaryMoveDeleteHook() {}
    
    public boolean deleteFile(IResourceTree tree, IFile file, int updateFlags, IProgressMonitor monitor)
    {
      if (BinaryRepositoryProvider.this.isBinaryResource(file, true)) {
        tree.failed(BinaryRepositoryProvider.this.createProblemStatus());
      } else {
        tree.standardDeleteFile(file, updateFlags, monitor);
      }
      return true;
    }
    
    public boolean deleteFolder(IResourceTree tree, IFolder folder, int updateFlags, IProgressMonitor monitor)
    {
      if (BinaryRepositoryProvider.this.isBinaryResource(folder, true)) {
        tree.failed(BinaryRepositoryProvider.this.createProblemStatus());
      } else {
        tree.standardDeleteFolder(folder, updateFlags, monitor);
      }
      return true;
    }
    
    public boolean deleteProject(IResourceTree tree, IProject project, int updateFlags, IProgressMonitor monitor)
    {
      return false;
    }
    
    public boolean moveFile(IResourceTree tree, IFile source, IFile destination, int updateFlags, IProgressMonitor monitor)
    {
      if (BinaryRepositoryProvider.this.isBinaryResource(source, false)) {
        tree.failed(BinaryRepositoryProvider.this.createProblemStatus());
      } else {
        tree.standardMoveFile(source, destination, updateFlags, monitor);
      }
      return true;
    }
    
    public boolean moveFolder(IResourceTree tree, IFolder source, IFolder destination, int updateFlags, IProgressMonitor monitor)
    {
      if (BinaryRepositoryProvider.this.isBinaryResource(source, false)) {
        tree.failed(BinaryRepositoryProvider.this.createProblemStatus());
      } else {
        tree.standardMoveFolder(source, destination, updateFlags, monitor);
      }
      return true;
    }
    
    public boolean moveProject(IResourceTree tree, IProject source, IProjectDescription description, int updateFlags, IProgressMonitor monitor)
    {
      return false;
    }
  }
  
  class BinaryFileModificationValidator
    extends FileModificationValidator
  {
    BinaryFileModificationValidator() {}
    
    public IStatus validateEdit(IFile[] files, FileModificationValidationContext context)
    {
      for (int i = 0; i < files.length; i++) {
        if (BinaryRepositoryProvider.this.isBinaryResource(files[i], false)) {
          return BinaryRepositoryProvider.this.createProblemStatus();
        }
      }
      return BinaryRepositoryProvider.this.createOKStatus();
    }
    
    public IStatus validateSave(IFile file)
    {
      if (BinaryRepositoryProvider.this.isBinaryResource(file, false)) {
        return BinaryRepositoryProvider.this.createProblemStatus();
      }
      return BinaryRepositoryProvider.this.createOKStatus();
    }
  }
  
  public BinaryRepositoryProvider()
  {
    moveDeleteHook = new BinaryMoveDeleteHook();
    fileModificationValidator = new BinaryFileModificationValidator();
  }
  
  public void configureProject()
    throws CoreException
  {
    IProject project = getProject();
    project.setPersistentProperty(PDECore.EXTERNAL_PROJECT_PROPERTY, "external");
  }
  
  public void deconfigure()
    throws CoreException
  {
    IProject project = getProject();
    project.setPersistentProperty(PDECore.EXTERNAL_PROJECT_PROPERTY, null);
  }
  
  public FileModificationValidator getFileModificationValidator2()
  {
    return fileModificationValidator;
  }
  
  public String getID()
  {
    return "org.eclipse.pde.core.BinaryRepositoryProvider";
  }
  
  public IMoveDeleteHook getMoveDeleteHook()
  {
    return moveDeleteHook;
  }
  
  private boolean isBinaryResource(IResource resource, boolean excludeProjectChildren)
  {
    IContainer parent = resource.getParent();
    if (((!excludeProjectChildren) || (!(parent instanceof IProject))) && 
      (resource.isLinked())) {
      return true;
    }
    while ((parent instanceof IFolder))
    {
      IFolder folder = (IFolder)parent;
      if (folder.isLinked()) {
        return true;
      }
      parent = folder.getParent();
    }
    return false;
  }
  
  private IStatus createProblemStatus()
  {
    String message = PDECoreMessages.BinaryRepositoryProvider_veto;
    return new Status(4, "org.eclipse.pde.core", 0, message, null);
  }
  
  private IStatus createOKStatus()
  {
    return new Status(0, "org.eclipse.pde.core", 0, "", 
      null);
  }
  
  public boolean canHandleLinkedResources()
  {
    return true;
  }
  
  public boolean canHandleLinkedResourcesURI()
  {
    return true;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.BinaryRepositoryProvider
 * 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.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.internal.core.plugin.PluginBase;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;

public class BundleManifestSourceLocationManager
{
  private Map fPluginToSourceBundle = new HashMap(0);
  
  public SourceLocation getSourceLocation(String pluginName, Version pluginVersion)
  {
    IPluginModelBase plugin = (IPluginModelBase)fPluginToSourceBundle.get(new SourceLocationKey(pluginName, pluginVersion));
    if (plugin != null)
    {
      SourceLocation location = new SourceLocation(new Path(plugin.getInstallLocation()));
      location.setUserDefined(false);
      return location;
    }
    return null;
  }
  
  public Collection getSourceLocations()
  {
    Collection result = new ArrayList(fPluginToSourceBundle.values().size());
    for (Iterator iterator = fPluginToSourceBundle.values().iterator(); iterator.hasNext();)
    {
      IPluginModelBase currentBundle = (IPluginModelBase)iterator.next();
      SourceLocation currentLocation = new SourceLocation(new Path(currentBundle.getInstallLocation()));
      currentLocation.setUserDefined(false);
      result.add(currentLocation);
    }
    return result;
  }
  
  public boolean hasValidSourceLocation(String pluginName, Version pluginVersion)
  {
    return fPluginToSourceBundle.containsKey(new SourceLocationKey(pluginName, pluginVersion));
  }
  
  public Set getSourceRoots(String pluginName, Version pluginVersion)
  {
    Set pluginSourceRoots = new HashSet();
    ManifestElement[] manifestElements = getSourceEntries(pluginName, pluginVersion);
    if (manifestElements != null) {
      for (int j = 0; j < manifestElements.length; j++)
      {
        ManifestElement currentElement = manifestElements[j];
        String binaryPluginName = currentElement.getValue();
        String versionEntry = currentElement.getAttribute("version");
        if ((binaryPluginName != null) && (binaryPluginName.equals(pluginName)) && 
          (versionEntry != null) && (versionEntry.length() > 0))
        {
          Version version = null;
          try
          {
            version = new Version(versionEntry);
          }
          catch (IllegalArgumentException e)
          {
            PDECore.log(new Status(4, "org.eclipse.pde.core", PDECoreMessages.SourceLocationManager_problemProcessingBundleManifestSourceHeader, e));
          }
          if (pluginVersion.equals(version))
          {
            addSourceRoots(currentElement.getDirective("roots"), pluginSourceRoots);
            return pluginSourceRoots;
          }
        }
      }
    }
    return pluginSourceRoots;
  }
  
  public Set getAllSourceRoots(String pluginName, Version pluginVersion)
  {
    Set pluginSourceRoots = new HashSet();
    ManifestElement[] manifestElements = getSourceEntries(pluginName, pluginVersion);
    if (manifestElements != null) {
      for (int j = 0; j < manifestElements.length; j++)
      {
        ManifestElement currentElement = manifestElements[j];
        addSourceRoots(currentElement.getDirective("roots"), pluginSourceRoots);
      }
    }
    return pluginSourceRoots;
  }
  
  private ManifestElement[] getSourceEntries(String pluginName, Version pluginVersion)
  {
    IPluginModelBase sourceBundle = (IPluginModelBase)fPluginToSourceBundle.get(new SourceLocationKey(pluginName, pluginVersion));
    if ((sourceBundle != null) && 
      ((sourceBundle.getPluginBase() instanceof PluginBase)))
    {
      String bundleSourceEntry = ((PluginBase)sourceBundle.getPluginBase()).getBundleSourceEntry();
      if (bundleSourceEntry != null) {
        try
        {
          return ManifestElement.parseHeader("Eclipse-SourceBundle", bundleSourceEntry);
        }
        catch (BundleException e)
        {
          PDECore.log(new Status(4, "org.eclipse.pde.core", PDECoreMessages.SourceLocationManager_problemProcessingBundleManifestSourceHeader, e));
        }
      }
    }
    return null;
  }
  
  private void addSourceRoots(String rootEntryDirective, Set pluginSourceRoots)
  {
    if (rootEntryDirective != null)
    {
      String[] roots = rootEntryDirective.split(",");
      for (int k = 0; k < roots.length; k++) {
        pluginSourceRoots.add(roots[k]);
      }
    }
    else
    {
      pluginSourceRoots.add(".");
    }
  }
  
  public void setPlugins(IPluginModelBase[] externalModels)
  {
    fPluginToSourceBundle = new HashMap();
    for (int i = 0; i < externalModels.length; i++)
    {
      IPluginBase currentPlugin = externalModels[i].getPluginBase();
      if ((currentPlugin instanceof PluginBase))
      {
        String bundleSourceEntry = ((PluginBase)currentPlugin).getBundleSourceEntry();
        if (bundleSourceEntry != null)
        {
          ManifestElement[] manifestElements = (ManifestElement[])null;
          try
          {
            manifestElements = ManifestElement.parseHeader("Eclipse-SourceBundle", bundleSourceEntry);
          }
          catch (BundleException e)
          {
            PDECore.log(new Status(4, "org.eclipse.pde.core", PDECoreMessages.SourceLocationManager_problemProcessingBundleManifestSourceHeader, e));
            manifestElements = (ManifestElement[])null;
          }
          if (manifestElements != null)
          {
            IPath path = new Path(externalModels[i].getInstallLocation());
            if (path.toFile().exists()) {
              for (int j = 0; j < manifestElements.length; j++)
              {
                ManifestElement currentElement = manifestElements[j];
                String binaryPluginName = currentElement.getValue();
                String versionEntry = currentElement.getAttribute("version");
                if ((binaryPluginName != null) && (binaryPluginName.length() > 0) && (versionEntry != null) && (versionEntry.length() > 0))
                {
                  Version version = null;
                  try
                  {
                    version = new Version(versionEntry);
                  }
                  catch (IllegalArgumentException e)
                  {
                    PDECore.log(new Status(4, "org.eclipse.pde.core", NLS.bind(PDECoreMessages.SourceLocationManager_problemProcessingBundleManifestSourceHeader, new Object[] { currentPlugin.getName(), versionEntry, path.toString() }), e));
                  }
                  fPluginToSourceBundle.put(new SourceLocationKey(binaryPluginName, version), externalModels[i]);
                }
                else
                {
                  PDECore.log(new Status(2, "org.eclipse.pde.core", NLS.bind(PDECoreMessages.BundleManifestSourceLocationManager_problemProcessBundleManifestHeaderAttributeMissing, currentPlugin.getName())));
                }
              }
            }
          }
        }
      }
    }
  }
}

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

import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateObjectFactory;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.core.plugin.IPluginModelBase;

public class BundleValidationOperation
  implements IWorkspaceRunnable
{
  private static StateObjectFactory FACTORY;
  private IPluginModelBase[] fModels;
  private Dictionary[] fProperties;
  private State fState;
  
  public BundleValidationOperation(IPluginModelBase[] models)
  {
    this(models, new Dictionary[] { TargetPlatformHelper.getTargetEnvironment() });
  }
  
  public BundleValidationOperation(IPluginModelBase[] models, Dictionary[] properties)
  {
    fModels = models;
    fProperties = properties;
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    if (FACTORY == null) {
      FACTORY = Platform.getPlatformAdmin().getFactory();
    }
    monitor.beginTask("", fModels.length + 1);
    fState = FACTORY.createState(true);
    for (int i = 0; i < fModels.length; i++)
    {
      BundleDescription bundle = fModels[i].getBundleDescription();
      if (bundle != null) {
        fState.addBundle(FACTORY.createBundleDescription(bundle));
      }
      monitor.worked(1);
    }
    fState.setPlatformProperties(fProperties);
    fState.resolve(false);
    monitor.done();
  }
  
  public Map getResolverErrors()
  {
    Set alreadyDuplicated = new HashSet();
    Map map = new HashMap();
    BundleDescription[] bundles = fState.getBundles();
    for (int i = 0; i < bundles.length; i++)
    {
      BundleDescription desc = bundles[i];
      if (!desc.isResolved())
      {
        map.put(desc, fState.getResolverErrors(desc));
      }
      else if ((desc.isSingleton()) && (!alreadyDuplicated.contains(desc.getSymbolicName())))
      {
        BundleDescription[] dups = fState.getBundles(desc.getSymbolicName());
        if (dups.length > 1)
        {
          alreadyDuplicated.add(desc.getSymbolicName());
          MultiStatus status = new MultiStatus("org.eclipse.pde.core", 0, NLS.bind(PDECoreMessages.BundleValidationOperation_multiple_singletons, new String[] { Integer.toString(dups.length), desc.getSymbolicName() }), null);
          for (int j = 0; j < dups.length; j++) {
            status.add(new Status(4, "org.eclipse.pde.core", dups[j].getLocation()));
          }
          map.put(desc, new Object[] { status });
        }
      }
    }
    return map;
  }
  
  public State getState()
  {
    return fState;
  }
  
  public boolean hasErrors()
  {
    if (fState.getHighestBundleId() > -1L)
    {
      BundleDescription[] bundles = fState.getBundles();
      for (int i = 0; i < bundles.length; i++)
      {
        BundleDescription desc = bundles[i];
        if (!desc.isResolved()) {
          return true;
        }
        if (desc.isSingleton())
        {
          BundleDescription[] dups = fState.getBundles(desc.getSymbolicName());
          if (dups.length > 1) {
            return true;
          }
        }
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.BundleValidationOperation
 * 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.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IAccessRule;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaModelStatus;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.core.build.IBuild;
import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.core.build.IBuildModel;
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.build.WorkspaceBuildModel;
import org.eclipse.pde.internal.core.project.PDEProject;
import org.eclipse.pde.internal.core.util.CoreUtility;
import org.eclipse.team.core.RepositoryProvider;

public class ClasspathComputer
{
  private static Map fSeverityTable = null;
  private static final int SEVERITY_ERROR = 3;
  private static final int SEVERITY_WARNING = 2;
  private static final int SEVERITY_IGNORE = 1;
  
  public static void setClasspath(IProject project, IPluginModelBase model)
    throws CoreException
  {
    IClasspathEntry[] entries = getClasspath(project, model, null, false, true);
    JavaCore.create(project).setRawClasspath(entries, null);
  }
  
  public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase model, Map sourceLibraryMap, boolean clear, boolean overrideCompliance)
    throws CoreException
  {
    IJavaProject javaProject = JavaCore.create(project);
    ArrayList result = new ArrayList();
    IBuild build = getBuild(project);
    
    String ee = getExecutionEnvironment(model.getBundleDescription());
    result.add(createEntryUsingPreviousEntry(javaProject, ee, PDECore.JRE_CONTAINER_PATH));
    setComplianceOptions(JavaCore.create(project), ee, overrideCompliance);
    
    result.add(createEntryUsingPreviousEntry(javaProject, ee, PDECore.REQUIRED_PLUGINS_CONTAINER_PATH));
    
    addSourceAndLibraries(project, model, build, clear, sourceLibraryMap, result);
    
    IClasspathEntry[] entries = (IClasspathEntry[])result.toArray(new IClasspathEntry[result.size()]);
    IJavaModelStatus validation = JavaConventions.validateClasspath(javaProject, entries, javaProject.getOutputLocation());
    if (!validation.isOK())
    {
      PDECore.logErrorMessage(validation.getMessage());
      throw new CoreException(validation);
    }
    return (IClasspathEntry[])result.toArray(new IClasspathEntry[result.size()]);
  }
  
  private static void addSourceAndLibraries(IProject project, IPluginModelBase model, IBuild build, boolean clear, Map sourceLibraryMap, ArrayList result)
    throws CoreException
  {
    HashSet paths = new HashSet();
    if (!clear)
    {
      IClasspathEntry[] entries = JavaCore.create(project).getRawClasspath();
      for (int i = 0; i < entries.length; i++)
      {
        IClasspathEntry entry = entries[i];
        if ((entry.getEntryKind() == 3) && 
          (paths.add(entry.getPath()))) {
          result.add(entry);
        }
      }
    }
    IClasspathAttribute[] attrs = getClasspathAttributes(project, model);
    IPluginLibrary[] libraries = model.getPluginBase().getLibraries();
    for (int i = 0; i < libraries.length; i++)
    {
      IBuildEntry buildEntry = build == null ? null : build.getEntry("source." + libraries[i].getName());
      if (buildEntry != null)
      {
        addSourceFolder(buildEntry, project, paths, result);
      }
      else
      {
        IPath sourceAttachment = sourceLibraryMap != null ? (IPath)sourceLibraryMap.get(libraries[i].getName()) : null;
        if (libraries[i].getName().equals(".")) {
          addJARdPlugin(project, ClasspathUtilCore.getFilename(model), sourceAttachment, attrs, result);
        } else {
          addLibraryEntry(project, libraries[i], sour
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-2017. Infinite Loop Ltd