org.eclipse.pde.core_3.7.1.v20120103_r372

+ ".permissions.755", "Eclipse.app/Contents/MacOS/" + getLauncherName());
      }
      else
      {
        properties.put(rootPrefix, getLauncherLocations(hasLaunchers));
        properties.put(rootPrefix + ".permissions.755", getLauncherName());
        if ((TargetPlatform.getWS().equals("motif")) && (TargetPlatform.getOS().equals("linux"))) {
          properties.put(rootPrefix + ".permissions.755", "libXm.so.2");
        }
      }
    }
    IJREInfo jreInfo = fProduct.getJREInfo();
    for (int i = 0; i < configurations.length; i++)
    {
      String[] config = configurations[i];
      File vm = jreInfo != null ? jreInfo.getJVMLocation(config[0]) : null;
      if (vm != null) {
        if ((!config[0].equals("macosx")) || (!vm.getPath().startsWith("/System/Library/Frameworks/JavaVM.framework")))
        {
          String rootPrefix = "root." + config[0] + "." + config[1] + 
            "." + config[2];
          properties.put(rootPrefix + ".folder.jre", "absolute:" + vm.getAbsolutePath());
          String perms = (String)properties.get(rootPrefix + ".permissions.755");
          if (perms != null)
          {
            StringBuffer buffer = new StringBuffer(perms);
            buffer.append(",");
            buffer.append("jre/bin/java");
            properties.put(rootPrefix + ".permissions.755", buffer.toString());
          }
        }
      }
    }
    if ((fInfo.exportSource) && (fInfo.exportSourceBundle))
    {
      properties.put("individualSourceBundles", "true");
      List workspacePlugins = Arrays.asList(PluginRegistry.getWorkspaceModels());
      for (int i = 0; i < fInfo.items.length; i++) {
        if ((fInfo.items[i] instanceof IFeatureModel))
        {
          IFeature feature = ((IFeatureModel)fInfo.items[i]).getFeature();
          properties.put("generate.feature@" + feature.getId().trim() + ".source", feature.getId());
        }
        else
        {
          BundleDescription bundle = null;
          if ((fInfo.items[i] instanceof IPluginModelBase)) {
            bundle = ((IPluginModelBase)fInfo.items[i]).getBundleDescription();
          }
          if ((bundle == null) && 
            ((fInfo.items[i] instanceof BundleDescription))) {
            bundle = (BundleDescription)fInfo.items[i];
          }
          if (bundle != null) {
            if (workspacePlugins.contains(PluginRegistry.findModel(bundle))) {
              properties.put("generate.plugin@" + bundle.getSymbolicName().trim() + ".source", bundle.getSymbolicName());
            }
          }
        }
      }
    }
    save(new File(file, "build.properties"), properties, "Build Configuration");
  }
  
  protected boolean publishingP2Metadata()
  {
    return fInfo.exportMetadata;
  }
  
  private String getLauncherLocations(boolean hasLaunchers)
  {
    StringBuffer buffer = new StringBuffer();
    if (!hasLaunchers)
    {
      File homeDir = new File(TargetPlatform.getLocation());
      if ((homeDir.exists()) && (homeDir.isDirectory()))
      {
        File file = null;
        if (System.getProperties().get("eclipse.launcher") != null)
        {
          String launcherPath = System.getProperties().get("eclipse.launcher").toString();
          file = new File(launcherPath);
        }
        if ((file != null) && (file.exists()) && (!file.isDirectory())) {
          appendAbsolutePath(buffer, file);
        } else if (TargetPlatform.getOS().equals("macosx")) {
          appendEclipsePath(buffer, new File(homeDir, "Eclipse.app/Contents/MacOS"));
        } else {
          appendEclipsePath(buffer, homeDir);
        }
      }
    }
    return buffer.toString();
  }
  
  private String getRootFileLocations(boolean hasLaunchers)
  {
    StringBuffer buffer = new StringBuffer();
    if (!hasLaunchers)
    {
      File homeDir = new File(TargetPlatform.getLocation());
      if ((homeDir.exists()) && (homeDir.isDirectory()))
      {
        File file = new File(homeDir, "startup.jar");
        if (file.exists()) {
          appendAbsolutePath(buffer, file);
        }
        file = new File(homeDir, "libXm.so.2");
        if (file.exists()) {
          appendAbsolutePath(buffer, file);
        }
      }
    }
    return buffer.toString();
  }
  
  private void appendEclipsePath(StringBuffer buffer, File homeDir)
  {
    File file = null;
    file = new File(homeDir, "eclipse");
    if (file.exists()) {
      appendAbsolutePath(buffer, file);
    }
    file = new File(homeDir, "eclipse.exe");
    if (file.exists()) {
      appendAbsolutePath(buffer, file);
    }
  }
  
  private void appendAbsolutePath(StringBuffer buffer, File file)
  {
    if (buffer.length() > 0) {
      buffer.append(",");
    }
    buffer.append("absolute:file:");
    buffer.append(file.getAbsolutePath());
  }
  
  protected HashMap createAntBuildProperties(String[][] configs)
  {
    HashMap properties = super.createAntBuildProperties(configs);
    properties.put("launcherName", getLauncherName());
    
    ILauncherInfo info = fProduct.getLauncherInfo();
    if (info != null)
    {
      String icons = "";
      for (int i = 0; i < configs.length; i++)
      {
        String images = null;
        if (configs[i][0].equals("win32")) {
          images = getWin32Images(info);
        } else if (configs[i][0].equals("solaris")) {
          images = getSolarisImages(info);
        } else if (configs[i][0].equals("linux")) {
          images = getExpandedPath(info.getIconPath("linuxIcon"));
        } else if (configs[i][0].equals("macosx")) {
          images = getExpandedPath(info.getIconPath("macosxIcon"));
        }
        if (images != null)
        {
          if (icons.length() > 0) {
            icons = icons + ",";
          }
          icons = icons + images;
        }
      }
      if ((icons != null) && (icons.length() > 0)) {
        properties.put("launcherIcons", icons);
      }
    }
    fAntBuildProperties.put("collectingFolder", fRoot);
    fAntBuildProperties.put("archivePrefix", fRoot);
    
    return properties;
  }
  
  protected void setP2MetaDataProperties(Map map)
  {
    if (fInfo.exportMetadata)
    {
      if (PDECore.getDefault().getFeatureModelManager().getDeltaPackFeature() == null) {
        map.put("launcherProvider", "org.eclipse.pde.container.feature");
      }
      map.put("generate.p2.metadata", "true");
      map.put("p2.flavor", "tooling");
      map.put("p2.publish.artifacts", "true");
      map.put("p2.compress", "true");
      map.put("p2.gathering", Boolean.toString(publishingP2Metadata()));
      try
      {
        map.put("p2.build.repo", new File(fBuildTempMetadataLocation).toURL().toString());
        map.put("p2.metadata.repo", new File(fInfo.destinationDirectory + "/repository").toURL().toString());
        map.put("p2.artifact.repo", new File(fInfo.destinationDirectory + "/repository").toURL().toString());
        map.put("p2.metadata.repo.name", NLS.bind(PDECoreMessages.ProductExportOperation_0, fProduct.getProductId()));
        map.put("p2.artifact.repo.name", NLS.bind(PDECoreMessages.ProductExportOperation_0, fProduct.getProductId()));
      }
      catch (MalformedURLException e)
      {
        PDECore.log(e);
      }
    }
  }
  
  private String getLauncherName()
  {
    ILauncherInfo info = fProduct.getLauncherInfo();
    if (info != null)
    {
      String name = info.getLauncherName();
      if ((name != null) && (name.length() > 0))
      {
        name = name.trim();
        if (name.endsWith(".exe")) {
          name = name.substring(0, name.length() - 4);
        }
        return name;
      }
    }
    return "eclipse";
  }
  
  private String getWin32Images(ILauncherInfo info)
  {
    StringBuffer buffer = new StringBuffer();
    if (info.usesWinIcoFile())
    {
      append(buffer, info.getIconPath("icoFile"));
    }
    else
    {
      append(buffer, info.getIconPath("winSmallLow"));
      append(buffer, info.getIconPath("winSmallHigh"));
      append(buffer, info.getIconPath("winMediumHigh"));
      append(buffer, info.getIconPath("winMediumLow"));
      append(buffer, info.getIconPath("winLargeHigh"));
      append(buffer, info.getIconPath("winLargeLow"));
    }
    return buffer.length() > 0 ? buffer.toString() : null;
  }
  
  private String getSolarisImages(ILauncherInfo info)
  {
    StringBuffer buffer = new StringBuffer();
    append(buffer, info.getIconPath("solarisLarge"));
    append(buffer, info.getIconPath("solarisMedium"));
    append(buffer, info.getIconPath("solarisSmall"));
    append(buffer, info.getIconPath("solarisTiny"));
    return buffer.length() > 0 ? buffer.toString() : null;
  }
  
  private void append(StringBuffer buffer, String path)
  {
    path = getExpandedPath(path);
    if (path != null)
    {
      if (buffer.length() > 0) {
        buffer.append(",");
      }
      buffer.append(path);
    }
  }
  
  private String getExpandedPath(String path)
  {
    if ((path == null) || (path.length() == 0)) {
      return null;
    }
    IResource resource = PDECore.getWorkspace().getRoot().findMember(new Path(path));
    if (resource != null)
    {
      IPath fullPath = resource.getLocation();
      return fullPath == null ? null : fullPath.toOSString();
    }
    return null;
  }
  
  protected void setupGenerator(BuildScriptGenerator generator, String featureID, String versionId, String[][] configs, String featureLocation)
    throws CoreException
  {
    super.setupGenerator(generator, featureID, versionId, configs, featureLocation);
    generator.setGenerateVersionsList(true);
    if (fProduct != null) {
      generator.setProduct(fProduct.getModel().getInstallLocation());
    }
  }
  
  private String createMacInfoPList()
  {
    String entryName = TargetPlatformHelper.getTargetVersion() >= 3.3D ? "macosx/Info.plist" : 
      "macosx/Info.plist.32";
    URL url = PDECore.getDefault().getBundle().getEntry(entryName);
    if (url == null) {
      return null;
    }
    File plist = null;
    InputStream in = null;
    String location = fFeatureLocation;
    try
    {
      in = url.openStream();
      File dir = new File(location, "Eclipse.app/Contents");
      dir.mkdirs();
      plist = new File(dir, "Info.plist");
      CoreUtility.readFile(in, plist);
      return plist.getAbsolutePath();
    }
    catch (IOException localIOException2) {}finally
    {
      try
      {
        if (in != null) {
          in.close();
        }
      }
      catch (IOException localIOException4) {}
    }
    return null;
  }
  
  protected void setAdditionalAttributes(Element plugin, BundleDescription bundle)
  {
    plugin.setAttribute("unpack", Boolean.toString(CoreUtility.guessUnpack(bundle)));
  }
}

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

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.core.runtime.jobs.MultiRule;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PDECoreMessages;
import org.eclipse.pde.internal.core.ifeature.IFeature;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.eclipse.pde.internal.core.isite.ISite;
import org.eclipse.pde.internal.core.isite.ISiteDescription;
import org.eclipse.pde.internal.core.isite.ISiteFeature;
import org.eclipse.pde.internal.core.isite.ISiteModel;
import org.eclipse.pde.internal.core.site.WorkspaceSiteModel;
import org.eclipse.pde.internal.core.util.PatternConstructor;
import org.osgi.framework.Version;

public class SiteBuildOperation
  extends FeatureBasedExportOperation
{
  private long fBuildTime;
  private IFeatureModel[] fFeatureModels;
  private ISiteModel fSiteModel;
  private IContainer fSiteContainer;
  
  public SiteBuildOperation(IFeatureModel[] features, ISiteModel site, String jobName)
  {
    super(getInfo(features, site), jobName);
    fFeatureModels = features;
    fSiteModel = site;
    fSiteContainer = site.getUnderlyingResource().getParent();
    setRule(MultiRule.combine(fSiteContainer.getProject(), getRule()));
  }
  
  private static FeatureExportInfo getInfo(IFeatureModel[] models, ISiteModel siteModel)
  {
    FeatureExportInfo info = new FeatureExportInfo();
    useJarFormat = true;
    toDirectory = true;
    allowBinaryCycles = true;
    destinationDirectory = siteModel.getUnderlyingResource().getParent().getLocation().toOSString();
    items = models;
    return info;
  }
  
  protected IStatus run(IProgressMonitor monitor)
  {
    fBuildTime = System.currentTimeMillis();
    IStatus status = super.run(monitor);
    try
    {
      fSiteContainer.refreshLocal(2, monitor);
      updateSiteFeatureVersions();
    }
    catch (CoreException ce)
    {
      return ce.getStatus();
    }
    return status;
  }
  
  private void updateSiteFeatureVersions()
    throws CoreException
  {
    for (int i = 0; i < fFeatureModels.length; i++)
    {
      IFeature feature = fFeatureModels[i].getFeature();
      Version pvi = Version.parseVersion(feature.getVersion());
      if ("qualifier".equals(pvi.getQualifier()))
      {
        String newVersion = findBuiltVersion(feature.getId(), pvi.getMajor(), pvi.getMinor(), pvi.getMicro());
        if (newVersion != null)
        {
          ISiteFeature reVersionCandidate = findSiteFeature(feature, pvi);
          if (reVersionCandidate != null)
          {
            reVersionCandidate.setVersion(newVersion);
            reVersionCandidate.setURL("features/" + feature.getId() + "_" + 
              newVersion + ".jar");
          }
        }
      }
    }
    ((WorkspaceSiteModel)fSiteModel).save();
  }
  
  private ISiteFeature findSiteFeature(IFeature feature, Version pvi)
  {
    ISiteFeature reversionCandidate = null;
    
    ISiteFeature[] siteFeatures = fSiteModel.getSite().getFeatures();
    for (int s = 0; s < siteFeatures.length; s++) {
      if ((siteFeatures[s].getId().equals(feature.getId())) && (siteFeatures[s].getVersion().equals(feature.getVersion()))) {
        return siteFeatures[s];
      }
    }
    String highestQualifier = null;
    for (int s = 0; s < siteFeatures.length; s++) {
      if (siteFeatures[s].getId().equals(feature.getId()))
      {
        Version candidatePvi = Version.parseVersion(siteFeatures[s].getVersion());
        if ((pvi.getMajor() == candidatePvi.getMajor()) && (pvi.getMinor() == candidatePvi.getMinor()) && (pvi.getMicro() == candidatePvi.getMicro()) && (
          (reversionCandidate == null) || (candidatePvi.getQualifier().compareTo(highestQualifier) > 0)))
        {
          reversionCandidate = siteFeatures[s];
          highestQualifier = candidatePvi.getQualifier();
        }
      }
    }
    return reversionCandidate;
  }
  
  private String findBuiltVersion(String id, int major, int minor, int service)
  {
    IFolder featuresFolder = fSiteContainer.getFolder(new Path("features"));
    if (!featuresFolder.exists()) {
      return null;
    }
    IResource[] featureJars = (IResource[])null;
    try
    {
      featureJars = featuresFolder.members();
    }
    catch (CoreException localCoreException)
    {
      return null;
    }
    Pattern pattern = PatternConstructor.createPattern(id + "_" + 
      major + "." + 
      minor + "." + 
      service + "*.jar", true);
    
    String newestName = null;
    long newestTime = 0L;
    for (int i = 0; i < featureJars.length; i++)
    {
      File file = new File(featureJars[i].getLocation().toOSString());
      long jarTime = file.lastModified();
      String jarName = featureJars[i].getName();
      if (jarTime >= fBuildTime) {
        if (jarTime > newestTime) {
          if (pattern.matcher(jarName).matches())
          {
            newestName = featureJars[i].getName();
            newestTime = jarTime;
          }
        }
      }
    }
    if (newestName == null) {
      return null;
    }
    return newestName.substring(id.length() + 1, newestName.length() - 4);
  }
  
  protected void createPostProcessingFiles()
  {
    createPostProcessingFile(new File(fFeatureLocation, FEATURE_POST_PROCESSING));
    createPostProcessingFile(new File(fFeatureLocation, PLUGIN_POST_PROCESSING));
  }
  
  protected boolean publishingP2Metadata()
  {
    return true;
  }
  
  protected void setP2MetaDataProperties(Map map)
  {
    if (fInfo.toDirectory)
    {
      map.put("generate.p2.metadata", "true");
      map.put("p2.flavor", "tooling");
      map.put("p2.publish.artifacts", "true");
      map.put("p2.final.mode.override", "true");
      map.put("p2.compress", "true");
      map.put("p2.gathering", Boolean.toString(publishingP2Metadata()));
      IResource siteXML = fSiteModel.getUnderlyingResource();
      if ((siteXML.exists()) && (siteXML.getLocationURI() != null)) {
        map.put("p2.category.site", URIUtil.toUnencodedString(siteXML.getLocationURI()));
      }
      ISiteDescription description = fSiteModel.getSite().getDescription();
      String name = (description != null) && (description.getName() != null) && (description.getName().length() > 0) ? description.getName() : PDECoreMessages.SiteBuildOperation_0;
      map.put("p2.metadata.repo.name", name);
      map.put("p2.artifact.repo.name", name);
      try
      {
        String destination = new File(fBuildTempMetadataLocation).toURL().toString();
        map.put("p2.build.repo", destination);
      }
      catch (MalformedURLException e)
      {
        PDECore.log(e);
      }
    }
  }
}

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

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
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.IPluginModelBase;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PluginModelManager;
import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
import org.eclipse.pde.internal.core.ifeature.IFeature;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.eclipse.pde.internal.core.ifeature.IFeaturePlugin;
import org.eclipse.pde.internal.core.project.PDEProject;

public class WorkspaceExportHelper
  extends LaunchConfigurationDelegate
{
  private IProject[] fWorkspaceProjects;
  
  public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
    throws CoreException
  {}
  
  public void buildBeforeExport(Object[] exportedItems, IProgressMonitor monitor)
    throws CoreException
  {
    IProject[] projects = getExportedWorkspaceProjects(exportedItems);
    for (int i = 0; i < projects.length; i++) {
      projects[i].build(10, monitor);
    }
  }
  
  public Set checkForErrors(Object[] exportedItems)
    throws CoreException
  {
    IProject[] projects = getExportedWorkspaceProjects(exportedItems);
    Set projectsWithErrors = new HashSet(projects.length);
    for (int i = 0; i < projects.length; i++)
    {
      IMarker[] markers = projects[i].findMarkers("org.eclipse.core.resources.problemmarker", true, 2);
      if (markers.length > 0) {
        for (int j = 0; j < markers.length; j++)
        {
          Integer severity = (Integer)markers[j].getAttribute("severity");
          if ((severity != null) && (severity.intValue() >= 2) && (
            (markers[j].getType().equals("org.eclipse.jdt.core.problem")) || (markers[j].getType().equals("org.eclipse.pde.core.problem"))))
          {
            projectsWithErrors.add(projects[i]);
            break;
          }
        }
      }
    }
    return projectsWithErrors;
  }
  
  public Map getWorkspaceOutputFolders(Object[] exportedItems)
    throws CoreException
  {
    IProject[] projects = getExportedWorkspaceProjects(exportedItems);
    Map result = new HashMap(projects.length);
    for (int i = 0; i < projects.length; i++)
    {
      IFile buildFile = PDEProject.getBuildProperties(projects[i]);
      if (buildFile.exists())
      {
        IBuildModel buildModel = new WorkspaceBuildModel(buildFile);
        buildModel.load();
        IJavaProject javaProject = JavaCore.create(projects[i]);
        if (javaProject.exists())
        {
          Map modelOutput = getPluginOutputFolders(buildModel, javaProject);
          if (!modelOutput.isEmpty())
          {
            IPluginModelBase model = PDECore.getDefault().getModelManager().findModel(projects[i]);
            if (model != null) {
              result.put(model.getBundleDescription().getSymbolicName(), modelOutput);
            }
          }
        }
      }
    }
    return result;
  }
  
  private Map getPluginOutputFolders(IBuildModel buildModel, IJavaProject javaProject)
    throws JavaModelException
  {
    Map outputEntries = new HashMap();
    
    IBuildEntry[] buildEntries = buildModel.getBuild().getBuildEntries();
    for (int i = 0; i < buildEntries.length; i++)
    {
      String name = buildEntries[i].getName();
      if (name.startsWith("source."))
      {
        Set outputPaths = new HashSet();
        
        String[] sourceFolders = buildEntries[i].getTokens();
        for (int j = 0; j < sourceFolders.length; j++)
        {
          IClasspathEntry[] classpathEntries = javaProject.getRawClasspath();
          for (int k = 0; k < classpathEntries.length; k++) {
            if (classpathEntries[k].getEntryKind() == 3)
            {
              IPath sourcePath = classpathEntries[k].getPath().removeFirstSegments(1);
              if (sourcePath.equals(new Path(sourceFolders[j])))
              {
                IPath outputPath = classpathEntries[k].getOutputLocation();
                if (outputPath == null) {
                  outputPath = javaProject.getOutputLocation();
                }
                outputPaths.add(outputPath.removeFirstSegments(1));
              }
            }
          }
        }
        if (!outputPaths.isEmpty()) {
          outputEntries.put(name.substring("source.".length()), outputPaths);
        }
      }
    }
    return outputEntries;
  }
  
  private IProject[] getExportedWorkspaceProjects(Object[] exportedItems)
    throws CoreException
  {
    if (fWorkspaceProjects == null)
    {
      Set projects = new HashSet();
      for (int i = 0; i < exportedItems.length; i++) {
        if ((exportedItems[i] instanceof IPluginModelBase))
        {
          IPath installLocation = new Path(((IPluginModelBase)exportedItems[i]).getInstallLocation());
          IProject project = PDECore.getWorkspace().getRoot().getProject(installLocation.lastSegment());
          if (project.exists()) {
            projects.add(project);
          }
        }
        else if ((exportedItems[i] instanceof IFeatureModel))
        {
          IFeatureModel feature = (IFeatureModel)exportedItems[i];
          IFeaturePlugin[] plugins = feature.getFeature().getPlugins();
          for (int j = 0; j < plugins.length; j++)
          {
            IPluginModelBase plugin = PDECore.getDefault().getModelManager().findModel(plugins[j].getId());
            if (plugin != null)
            {
              IPath installLocation = new Path(plugin.getInstallLocation());
              IProject project = PDECore.getWorkspace().getRoot().getProject(installLocation.lastSegment());
              if (project.exists()) {
                projects.add(project);
              }
            }
          }
        }
      }
      fWorkspaceProjects = computeReferencedBuildOrder((IProject[])projects.toArray(new IProject[projects.size()]));
    }
    return fWorkspaceProjects;
  }
}

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

import java.io.InputStream;
import javax.xml.parsers.SAXParser;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.core.ModelChangedEvent;
import org.eclipse.pde.internal.core.AbstractNLModel;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.XMLCopyrightHandler;
import org.eclipse.pde.internal.core.XMLDefaultHandler;
import org.eclipse.pde.internal.core.ifeature.IFeature;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.eclipse.pde.internal.core.ifeature.IFeatureModelFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

public abstract class AbstractFeatureModel
  extends AbstractNLModel
  implements IFeatureModel
{
  private static final long serialVersionUID = 1L;
  protected transient Feature feature;
  private transient IFeatureModelFactory factory;
  private boolean enabled = true;
  
  public IFeature getFeature()
  {
    if (feature == null)
    {
      Feature f = new Feature();
      model = this;
      feature = f;
    }
    return feature;
  }
  
  public IFeatureModelFactory getFactory()
  {
    if (factory == null) {
      factory = new FeatureFactory(this);
    }
    return factory;
  }
  
  public String getInstallLocation()
  {
    return null;
  }
  
  public boolean isEditable()
  {
    return true;
  }
  
  public boolean isEnabled()
  {
    return enabled;
  }
  
  public void load(InputStream stream, boolean outOfSync)
    throws CoreException
  {
    try
    {
      SAXParser parser = getSaxParser();
      XMLDefaultHandler handler = new XMLDefaultHandler();
      XMLCopyrightHandler chandler = new XMLCopyrightHandler(handler);
      parser.setProperty("http://xml.org/sax/properties/lexical-handler", chandler);
      parser.parse(stream, handler);
      if (handler.isPrepared())
      {
        processDocument(handler.getDocument());
        String copyright = chandler.getCopyright();
        if (copyright != null) {
          feature.setCopyright(copyright);
        }
        setLoaded(true);
        if (!outOfSync) {
          updateTimeStamp();
        }
      }
    }
    catch (SAXException localSAXException) {}catch (Exception e)
    {
      PDECore.logException(e);
    }
  }
  
  public boolean isValid()
  {
    if (!isLoaded()) {
      return false;
    }
    IFeature feature = getFeature();
    return (feature != null) && (feature.isValid());
  }
  
  private void processDocument(Document doc)
  {
    Node rootNode = doc.getDocumentElement();
    if (feature == null)
    {
      feature = new Feature();
      feature.model = this;
    }
    else
    {
      feature.reset();
    }
    feature.parse(rootNode);
  }
  
  public void reload(InputStream stream, boolean outOfSync)
    throws CoreException
  {
    if (feature != null) {
      feature.reset();
    }
    load(stream, outOfSync);
    fireModelChanged(new ModelChangedEvent(this, 99, new Object[] { feature }, null));
  }
  
  public void setEnabled(boolean enabled)
  {
    this.enabled = enabled;
  }
}

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

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.internal.core.NLResourceHelper;

public class ExternalFeatureModel
  extends AbstractFeatureModel
{
  private static final long serialVersionUID = 1L;
  private String location;
  
  protected void updateTimeStamp() {}
  
  public boolean isInSync()
  {
    return true;
  }
  
  public boolean isEditable()
  {
    return false;
  }
  
  public void load()
    throws CoreException
  {}
  
  public void setInstallLocation(String location)
  {
    this.location = location;
  }
  
  public String getInstallLocation()
  {
    return location;
  }
  
  protected NLResourceHelper createNLResourceHelper()
  {
    if (location != null)
    {
      URL url = getNLLookupLocation();
      return new NLResourceHelper("feature", new URL[] { url });
    }
    return null;
  }
  
  public URL getNLLookupLocation()
  {
    try
    {
      if ((location != null) && (new File(location).isDirectory()) && (!location.endsWith("/"))) {
        return new URL("file:" + location + "/");
      }
      return new URL("file:" + location);
    }
    catch (MalformedURLException localMalformedURLException) {}
    return null;
  }
}

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

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Vector;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.HostSpecification;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginImport;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.ModelEntry;
import org.eclipse.pde.core.plugin.PluginRegistry;
import org.eclipse.pde.internal.core.ifeature.IFeature;
import org.eclipse.pde.internal.core.ifeature.IFeatureChild;
import org.eclipse.pde.internal.core.ifeature.IFeatureData;
import org.eclipse.pde.internal.core.ifeature.IFeatureImport;
import org.eclipse.pde.internal.core.ifeature.IFeatureInfo;
import org.eclipse.pde.internal.core.ifeature.IFeatureInstallHandler;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.eclipse.pde.internal.core.ifeature.IFeatureModelFactory;
import org.eclipse.pde.internal.core.ifeature.IFeaturePlugin;
import org.eclipse.pde.internal.core.ifeature.IFeatureURL;
import org.eclipse.pde.internal.core.plugin.PluginBase;
import org.eclipse.pde.internal.core.util.VersionUtil;
import org.osgi.framework.Version;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Feature
  extends VersionableObject
  implements IFeature
{
  private static final long serialVersionUID = 1L;
  static final String INDENT = "   ";
  private String fProviderName;
  private IFeatureURL fUrl;
  private IFeatureInfo[] fInfos = new IFeatureInfo[3];
  private Vector fData = new Vector();
  private Vector fChildren = new Vector();
  private Vector fPlugins = new Vector();
  private Vector fImports = new Vector();
  private String fOs;
  private String fWs;
  private String fNl;
  private String fArch;
  private String fImageName;
  private IFeatureInstallHandler fHandler;
  private boolean fPrimary;
  private boolean fExclusive;
  private String fColocationAffinity;
  private String fApplication;
  private String fPlugin;
  private boolean fValid;
  private String fCopyright;
  private String fLicenseFeatureID;
  private String fLicenseFeatureVersion;
  
  public void addPlugins(IFeaturePlugin[] newPlugins)
    throws CoreException
  {
    ensureModelEditable();
    for (int i = 0; i < newPlugins.length; i++)
    {
      fPlugins.add(newPlugins[i]);
      ((FeaturePlugin)newPlugins[i]).setInTheModel(true);
    }
    fireStructureChanged(newPlugins, 1);
  }
  
  public void addData(IFeatureData[] newData)
    throws CoreException
  {
    ensureModelEditable();
    for (int i = 0; i < newData.length; i++)
    {
      fData.add(newData[i]);
      ((FeatureData)newData[i]).setInTheModel(true);
    }
    fireStructureChanged(newData, 1);
  }
  
  public void addIncludedFeatures(IFeatureChild[] features)
    throws CoreException
  {
    ensureModelEditable();
    for (int i = 0; i < features.length; i++)
    {
      fChildren.add(features[i]);
      ((FeatureChild)features[i]).setInTheModel(true);
    }
    fireStructureChanged(features, 1);
  }
  
  public void addImports(IFeatureImport[] iimports)
    throws CoreException
  {
    ensureModelEditable();
    for (int i = 0; i < iimports.length; i++)
    {
      fImports.add(iimports[i]);
      ((FeatureImport)iimports[i]).setInTheModel(true);
    }
    fireStructureChanged(iimports, 1);
  }
  
  public IFeaturePlugin[] getPlugins()
  {
    IFeaturePlugin[] result = new IFeaturePlugin[fPlugins.size()];
    fPlugins.copyInto(result);
    return result;
  }
  
  public IFeatureData[] getData()
  {
    IFeatureData[] result = new IFeatureData[fData.size()];
    fData.copyInto(result);
    return result;
  }
  
  public IFeatureChild[] getIncludedFeatures()
  {
    IFeatureChild[] result = new IFeatureChild[fChildren.size()];
    fChildren.copyInto(result);
    return result;
  }
  
  public IFeatureImport[] getImports()
  {
    IFeatureImport[] result = new IFeatureImport[fImports.size()];
    fImports.copyInto(result);
    return result;
  }
  
  public String getProviderName()
  {
    return fProviderName;
  }
  
  public void setLicenseFeatureID(String featureID)
  {
    fLicenseFeatureID = featureID;
  }
  
  public String getLicenseFeatureID()
  {
    if (fLicenseFeatureID == null) {
      fLicenseFeatureID = "";
    }
    return fLicenseFeatureID;
  }
  
  public void setLicenseFeatureVersion(String version)
  {
    fLicenseFeatureVersion = version;
  }
  
  public String getLicenseFeatureVersion()
  {
    if (fLicenseFeatureVersion == null) {
      fLicenseFeatureVersion = "";
    }
    return fLicenseFeatureVersion;
  }
  
  public String getPlugin()
  {
    return fPlugin;
  }
  
  public IPluginModelBase getReferencedModel(IFeaturePlugin reference)
  {
    IPluginModelBase model = PluginRegistry.findModel(reference.getId());
    return (model != null) && (model.isEnabled()) ? model : null;
  }
  
  public IFeatureURL getURL()
  {
    return fUrl;
  }
  
  public IFeatureInstallHandler getInstallHandler()
  {
    return fHandler;
  }
  
  public IFeatureInfo getFeatureInfo(int infoType)
  {
    if ((infoType < 0) || (infoType > fInfos.length - 1)) {
      return null;
    }
    return fInfos[infoType];
  }
  
  public boolean isPrimary()
  {
    return fPrimary;
  }
  
  public boolean isExclusive()
  {
    return fExclusive;
  }
  
  protected void parse(Node node)
  {
    super.parse(node);
    fProviderName = getNodeAttribute(node, "provider-name");
    fLicenseFeatureID = getNodeAttribute(node, "license-feature");
    fLicenseFeatureVersion = getNodeAttribute(node, "license-feature-version");
    fPlugin = getNodeAttribute(node, "plugin");
    fOs = getNodeAttribute(node, "os");
    fWs = getNodeAttribute(node, "ws");
    fNl = getNodeAttribute(node, "nl");
    fArch = getNodeAttribute(node, "arch");
    fImageName = getNodeAttribute(node, "image");
    fColocationAffinity = getNodeAttribute(node, "colocation-affinity");
    fApplication = getNodeAttribute(node, "application");
    fPrimary = getBooleanAttribute(node, "primary");
    fExclusive = getBooleanAttribute(node, "exclusive");
    NodeList children = node.getChildNodes();
    fValid = true;
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if (child.getNodeType() == 1)
      {
        String tag = child.getNodeName().toLowerCase(Locale.ENGLISH);
        if (tag.equals("description"))
        {
          IFeatureInfo info = getModel().getFactory().createInfo(0);
          ((FeatureInfo)info).setInTheModel(true);
          ((FeatureInfo)info).parse(child);
          fInfos[0] = info;
        }
        else if (tag.equals("license"))
        {
          IFeatureInfo info = getModel().getFactory().createInfo(2);
          ((FeatureInfo)info).setInTheModel(true);
          ((FeatureInfo)info).parse(child);
          fInfos[2] = info;
        }
        else if (tag.equals("copyright"))
        {
          IFeatureInfo info = getModel().getFactory().createInfo(1);
          ((FeatureInfo)info).setInTheModel(true);
          ((FeatureInfo)info).parse(child);
          fInfos[1] = info;
        }
        else if (tag.equals("url"))
        {
          if (fUrl == null)
          {
            fUrl = getModel().getFactory().createURL();
            ((FeatureURL)fUrl).setInTheModel(true);
            ((FeatureURL)fUrl).parse(child);
          }
        }
        else if (tag.equals("requires"))
        {
          parseRequires(child);
        }
        else if (tag.equals("install-handler"))
        {
          IFeatureInstallHandler handler = getModel().getFactory().createInstallHandler();
          ((FeatureInstallHandler)handler).parse(child);
          ((FeatureInstallHandler)handler).setInTheModel(true);
          fHandler = handler;
        }
        else if (tag.equals("plugin"))
        {
          IFeaturePlugin plugin = getModel().getFactory().createPlugin();
          ((FeaturePlugin)plugin).parse(child);
          ((FeaturePlugin)plugin).setInTheModel(true);
          fPlugins.add(plugin);
        }
        else if (tag.equals("data"))
        {
          IFeatureData newData = getModel().getFactory().createData();
          ((FeatureData)newData).parse(child);
          ((FeatureData)newData).setInTheModel(true);
          fData.add(newData);
        }
        else if (tag.equals("includes"))
        {
          IFeatureChild newChild = getModel().getFactory().createChild();
          ((FeatureChild)newChild).parse(child);
          ((FeatureChild)newChild).setInTheModel(true);
          fChildren.add(newChild);
        }
      }
    }
    fValid = hasRequiredAttributes();
  }
  
  private void parseRequires(Node node)
  {
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++)
    {
      Node child = children.item(i);
      if ((child.getNodeType() == 1) && 
        (child.getNodeName().equalsIgnoreCase("import")))
      {
        IFeatureImport iimport = getModel().getFactory().createImport();
        ((FeatureImport)iimport).parse(child);
        ((FeatureImport)iimport).setInTheModel(true);
        fImports.add(iimport);
      }
    }
  }
  
  public void computeImports()
    throws CoreException
  {
    Vector preservedImports = new Vector(fImports.size());
    
    ArrayList newImports = new ArrayList();
    IPluginModelBase model = null;
    for (int i = 0; i < fPlugins.size(); i++)
    {
      IFeaturePlugin fp = (IFeaturePlugin)fPlugins.get(i);
      ModelEntry entry = PluginRegistry.findEntry(fp.getId());
      if (entry != null)
      {
        IPluginModelBase[] models = entry.getActiveModels();
        for (int j = 0; j < models.length; j++)
        {
          IPluginModelBase m = models[j];
          if ((fp.getVersion().equals(m.g
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