org.eclipse.pde.launching_3.6.0.v20110506

(), new Version("3.3.1")) < 0)) {
      programArgs.add("-pdelaunch");
    }
    if ((configuration.getAttribute("tracing", false)) && (!"[NONE]".equals(configuration.getAttribute("checked", null))))
    {
      programArgs.add("-debug");
      String path = getConfigurationDirectory(configuration).getPath() + '/' + ".options";
      programArgs.add(LaunchArgumentsHelper.getTracingFileArgument(configuration, path));
    }
    String[] userArgs = LaunchArgumentsHelper.getUserProgramArgumentArray(configuration);
    for (int i = 0; i < userArgs.length; i++) {
      if ((!userArgs[i].equals("-debug")) || (!programArgs.contains("-debug"))) {
        programArgs.add(userArgs[i]);
      }
    }
    if (!configuration.getAttribute("append.args", false))
    {
      if (!programArgs.contains("-os"))
      {
        programArgs.add("-os");
        programArgs.add(TargetPlatform.getOS());
      }
      if (!programArgs.contains("-ws"))
      {
        programArgs.add("-ws");
        programArgs.add(TargetPlatform.getWS());
      }
      if (!programArgs.contains("-arch"))
      {
        programArgs.add("-arch");
        programArgs.add(TargetPlatform.getOSArch());
      }
    }
    programArgs.add("-testpluginname");
    programArgs.add(getTestPluginId(configuration));
  }
  
  protected String getApplication(ILaunchConfiguration configuration)
  {
    String application = null;
    
    boolean shouldRunInUIThread = true;
    try
    {
      shouldRunInUIThread = configuration.getAttribute("run_in_ui_thread", true);
    }
    catch (CoreException localCoreException1) {}
    if (!shouldRunInUIThread) {
      return "org.eclipse.pde.junit.runtime.nonuithreadtestapplication";
    }
    try
    {
      application = configuration.getAttribute("application", null);
    }
    catch (CoreException localCoreException2) {}
    if (application == null)
    {
      IPluginModelBase model = (IPluginModelBase)fAllBundles.get("org.eclipse.pde.junit.runtime");
      BundleDescription desc = model != null ? model.getBundleDescription() : null;
      if (desc != null)
      {
        Version version = desc.getVersion();
        int major = version.getMajor();
        if ((major >= 3) && (version.getMinor() >= 3) && (!TargetPlatformHelper.usesNewApplicationModel())) {
          application = "org.eclipse.pde.junit.runtime.legacytestapplication";
        }
      }
    }
    if (application == null) {
      application = "org.eclipse.pde.junit.runtime.uitestapplication";
    }
    return application;
  }
  
  private IPluginModelBase findPlugin(String id)
    throws CoreException
  {
    IPluginModelBase model = PluginRegistry.findModel(id);
    if (model == null) {
      model = PDECore.getDefault().findPluginInHost(id);
    }
    if (model == null) {
      abort(NLS.bind(PDEMessages.JUnitLaunchConfiguration_error_missingPlugin, id), null, 0);
    }
    return model;
  }
  
  public String getProgramArguments(ILaunchConfiguration configuration)
    throws CoreException
  {
    return LaunchArgumentsHelper.getUserProgramArguments(configuration);
  }
  
  public String getVMArguments(ILaunchConfiguration configuration)
    throws CoreException
  {
    String vmArgs = LaunchArgumentsHelper.getUserVMArguments(configuration);
    
    IPluginModelBase base = (IPluginModelBase)fAllBundles.get("org.eclipse.pde.core");
    if ((base != null) && (VersionUtil.compareMacroMinorMicro(base.getBundleDescription().getVersion(), new Version("3.3.1")) >= 0)) {
      vmArgs = concatArg(vmArgs, "-Declipse.pde.launch=true");
    }
    if ((fAllBundles.containsKey("org.eclipse.equinox.p2.core")) && 
      (vmArgs.indexOf("-Declipse.p2.data.area=") < 0)) {
      vmArgs = concatArg(vmArgs, "-Declipse.p2.data.area=@config.dir" + File.separator + "p2");
    }
    return vmArgs;
  }
  
  private String concatArg(String vmArgs, String arg)
  {
    if ((vmArgs.length() > 0) && (!vmArgs.endsWith(" "))) {
      vmArgs = vmArgs.concat(" ");
    }
    return vmArgs.concat(arg);
  }
  
  public String[] getEnvironment(ILaunchConfiguration configuration)
    throws CoreException
  {
    return DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
  }
  
  public String[] getClasspath(ILaunchConfiguration configuration)
    throws CoreException
  {
    String[] classpath = LaunchArgumentsHelper.constructClasspath(configuration);
    if (classpath == null) {
      abort(PDEMessages.WorkbenchLauncherConfigurationDelegate_noStartup, null, 0);
    }
    return classpath;
  }
  
  public File getWorkingDirectory(ILaunchConfiguration configuration)
    throws CoreException
  {
    return LaunchArgumentsHelper.getWorkingDirectory(configuration);
  }
  
  public Map getVMSpecificAttributesMap(ILaunchConfiguration configuration)
    throws CoreException
  {
    return LaunchArgumentsHelper.getVMSpecificAttributesMap(configuration);
  }
  
  protected void setDefaultSourceLocator(ILaunch launch, ILaunchConfiguration configuration)
    throws CoreException
  {
    ILaunchConfigurationWorkingCopy wc = null;
    if (configuration.isWorkingCopy()) {
      wc = (ILaunchConfigurationWorkingCopy)configuration;
    } else {
      wc = configuration.getWorkingCopy();
    }
    String id = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, null);
    if (!"org.eclipse.pde.ui.workbenchClasspathProvider".equals(id))
    {
      wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, "org.eclipse.pde.ui.workbenchClasspathProvider");
      wc.doSave();
    }
    manageLaunch(launch);
  }
  
  protected File getConfigurationDirectory(ILaunchConfiguration configuration)
  {
    if (fConfigDir == null) {
      fConfigDir = LaunchConfigurationHelper.getConfigurationArea(configuration);
    }
    return fConfigDir;
  }
  
  protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode)
    throws CoreException
  {
    return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration));
  }
  
  protected IProject[] getProjectsForProblemSearch(ILaunchConfiguration configuration, String mode)
    throws CoreException
  {
    return LaunchPluginValidator.getAffectedProjects(configuration);
  }
  
  protected void manageLaunch(ILaunch launch)
  {
    PDELaunchingPlugin.getDefault().getLaunchListener().manage(launch);
  }
  
  protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor)
    throws CoreException
  {
    fWorkspaceLocation = null;
    fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false);
    fAllBundles = new HashMap(fModels.size());
    Iterator iter = fModels.keySet().iterator();
    while (iter.hasNext())
    {
      IPluginModelBase model = (IPluginModelBase)iter.next();
      fAllBundles.put(model.getPluginBase().getId(), model);
    }
    String[] requiredPlugins = getRequiredPlugins(configuration);
    for (int i = 0; i < requiredPlugins.length; i++)
    {
      String id = requiredPlugins[i];
      if (!fAllBundles.containsKey(id))
      {
        IPluginModelBase model = findPlugin(id);
        fAllBundles.put(id, model);
        fModels.put(model, "default:default");
      }
    }
    boolean autoValidate = configuration.getAttribute("automaticValidate", false);
    monitor.beginTask("", autoValidate ? 3 : 4);
    if (autoValidate) {
      validatePluginDependencies(configuration, new SubProgressMonitor(monitor, 1));
    }
    validateProjectDependencies(configuration, new SubProgressMonitor(monitor, 1));
    LauncherUtils.setLastLaunchMode(launch.getLaunchMode());
    clear(configuration, new SubProgressMonitor(monitor, 1));
    launch.setAttribute("configLocation", getConfigurationDirectory(configuration).toString());
    synchronizeManifests(configuration, new SubProgressMonitor(monitor, 1));
  }
  
  private String[] getRequiredPlugins(ILaunchConfiguration configuration)
  {
    ITestKind testKind = JUnitLaunchConfigurationConstants.getTestRunnerKind(configuration);
    if ("org.eclipse.jdt.junit.loader.junit4".equals(testKind.getId())) {
      return new String[] { "org.junit", "org.eclipse.jdt.junit.runtime", "org.eclipse.pde.junit.runtime", "org.eclipse.jdt.junit4.runtime" };
    }
    return new String[] { "org.junit", "org.eclipse.jdt.junit.runtime", "org.eclipse.pde.junit.runtime" };
  }
  
  protected void synchronizeManifests(ILaunchConfiguration configuration, IProgressMonitor monitor)
  {
    LaunchConfigurationHelper.synchronizeManifests(configuration, getConfigurationDirectory(configuration));
    monitor.done();
  }
  
  protected void clear(ILaunchConfiguration configuration, IProgressMonitor monitor)
    throws CoreException
  {
    if (fWorkspaceLocation == null) {
      fWorkspaceLocation = LaunchArgumentsHelper.getWorkspaceLocation(configuration);
    }
    if (!LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, new SubProgressMonitor(monitor, 1)))
    {
      monitor.setCanceled(true);
      return;
    }
    if (configuration.getAttribute("clearConfig", false)) {
      CoreUtility.deleteContent(getConfigurationDirectory(configuration));
    }
  }
  
  protected void validateProjectDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor)
  {
    LauncherUtils.validateProjectDependencies(configuration, monitor);
  }
  
  protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor)
    throws CoreException
  {
    EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration);
    LaunchPluginValidator.runValidationOperation(op, monitor);
  }
}

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

import org.eclipse.core.resources.IProject;
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.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
import org.eclipse.pde.internal.launching.PDEMessages;
import org.eclipse.pde.internal.launching.launcher.LaunchPluginValidator;
import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager;

public class OSGiLaunchConfigurationDelegate
  extends LaunchConfigurationDelegate
{
  public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
    throws CoreException
  {
    OSGiFrameworkManager manager = PDELaunchingPlugin.getDefault().getOSGiFrameworkManager();
    String id = configuration.getAttribute("osgi_framework_id", manager.getDefaultFramework());
    LaunchConfigurationDelegate launcher = manager.getFrameworkLauncher(id);
    if (launcher != null)
    {
      launcher.launch(configuration, mode, launch, monitor);
    }
    else
    {
      String name = manager.getFrameworkName(id);
      if (name == null) {
        name = PDEMessages.OSGiLaunchConfiguration_selected;
      }
      String message = NLS.bind(PDEMessages.OSGiLaunchConfiguration_cannotFindLaunchConfiguration, name);
      IStatus status = new Status(4, "org.eclipse.pde.launching", 0, message, null);
      throw new CoreException(status);
    }
  }
  
  protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode)
    throws CoreException
  {
    return computeBuildOrder(LaunchPluginValidator.getAffectedProjects(configuration));
  }
}

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

import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.PluginRegistry;
import org.eclipse.pde.internal.launching.launcher.BundleLauncherHelper;

public class OSGiLaunchConfigurationInitializer
{
  protected static final String DEFAULT = "default";
  
  public void initialize(ILaunchConfigurationWorkingCopy configuration)
  {
    initializeFrameworkDefaults(configuration);
    initializeBundleState(configuration);
    initializeSourcePathProvider(configuration);
  }
  
  protected void initializeSourcePathProvider(ILaunchConfigurationWorkingCopy configuration)
  {
    configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, "org.eclipse.pde.ui.workbenchClasspathProvider");
  }
  
  protected void initializeFrameworkDefaults(ILaunchConfigurationWorkingCopy configuration)
  {
    configuration.setAttribute("default_auto_start", true);
    configuration.setAttribute("default_start_level", 4);
  }
  
  protected void initializeBundleState(ILaunchConfigurationWorkingCopy configuration)
  {
    StringBuffer explugins = new StringBuffer();
    StringBuffer wsplugins = new StringBuffer();
    IPluginModelBase[] models = PluginRegistry.getActiveModels();
    for (int i = 0; i < models.length; i++)
    {
      boolean inWorkspace = models[i].getUnderlyingResource() != null;
      appendBundle(inWorkspace ? wsplugins : explugins, models[i]);
    }
    configuration.setAttribute("workspace_bundles", wsplugins.toString());
    configuration.setAttribute("target_bundles", explugins.toString());
    configuration.setAttribute("automaticAdd", true);
  }
  
  private void appendBundle(StringBuffer buffer, IPluginModelBase model)
  {
    if (buffer.length() > 0) {
      buffer.append(",");
    }
    String id = model.getPluginBase().getId();
    String value = BundleLauncherHelper.writeBundleEntry(model, getStartLevel(id), getAutoStart(id));
    buffer.append(value);
  }
  
  protected String getStartLevel(String bundleID)
  {
    return "default";
  }
  
  protected String getAutoStart(String bundleID)
  {
    return "default";
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspace.ProjectOrder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.StandardSourcePathProvider;
import org.eclipse.pde.internal.core.util.PDEJavaHelper;
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
import org.eclipse.pde.internal.launching.launcher.LaunchPluginValidator;
import org.eclipse.pde.internal.launching.launcher.VMHelper;

public class PDESourcePathProvider
  extends StandardSourcePathProvider
{
  public static final String ID = "org.eclipse.pde.ui.workbenchClasspathProvider";
  
  public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration)
    throws CoreException
  {
    List sourcePath = new ArrayList();
    sourcePath.add(getJREEntry(configuration));
    IProject[] projects = getJavaProjects(configuration);
    for (int i = 0; i < projects.length; i++) {
      sourcePath.add(JavaRuntime.newProjectRuntimeClasspathEntry(JavaCore.create(projects[i])));
    }
    return (IRuntimeClasspathEntry[])sourcePath.toArray(new IRuntimeClasspathEntry[sourcePath.size()]);
  }
  
  private IRuntimeClasspathEntry getJREEntry(ILaunchConfiguration configuration)
    throws CoreException
  {
    IVMInstall jre = VMHelper.createLauncher(configuration);
    IPath containerPath = new Path(JavaRuntime.JRE_CONTAINER);
    containerPath = containerPath.append(jre.getVMInstallType().getId());
    containerPath = containerPath.append(jre.getName());
    return JavaRuntime.newRuntimeContainerClasspathEntry(containerPath, 2);
  }
  
  private IProject[] getJavaProjects(ILaunchConfiguration configuration)
    throws CoreException
  {
    IProject[] projects = LaunchPluginValidator.getAffectedProjects(configuration);
    return getWorkspacecomputeProjectOrderprojects;
  }
  
  public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration)
    throws CoreException
  {
    List all = new ArrayList(entries.length);
    for (int i = 0; i < entries.length; i++) {
      if (entries[i].getType() == 1)
      {
        all.add(entries[i]);
        
        IResource resource = entries[i].getResource();
        if ((resource instanceof IProject)) {
          addBinaryPackageFragmentRoots(JavaCore.create((IProject)resource), all);
        }
      }
      else
      {
        IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveRuntimeClasspathEntry(entries[i], configuration);
        for (int j = 0; j < resolved.length; j++) {
          all.add(resolved[j]);
        }
      }
    }
    return (IRuntimeClasspathEntry[])all.toArray(new IRuntimeClasspathEntry[all.size()]);
  }
  
  private void addBinaryPackageFragmentRoots(IJavaProject jProject, List all)
    throws CoreException
  {
    IPackageFragmentRoot[] roots = jProject.getPackageFragmentRoots();
    for (int j = 0; j < roots.length; j++) {
      if ((roots[j].getKind() == 2) && (!PDEJavaHelper.isJRELibrary(roots[j])))
      {
        IRuntimeClasspathEntry rte = JavaRuntime.newArchiveRuntimeClasspathEntry(roots[j].getPath());
        IPath path = roots[j].getSourceAttachmentPath();
        if (path != null)
        {
          rte.setSourceAttachmentPath(path);
          rte.setSourceAttachmentRootPath(roots[j].getSourceAttachmentRootPath());
        }
        if (!all.contains(rte)) {
          all.add(rte);
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.launching.PDESourcePathProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
1 2 3 4 5 6

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