org.eclipse.pde.launching_3.6.0.v20110506

16:47:28.287 INFO  jd.cli.Main - Decompiling org.eclipse.pde.launching_3.6.0.v20110506.jar
package org.eclipse.pde.internal.launching;

public abstract interface ILaunchingPreferenceConstants
{
  public static final String PROP_AUTO_MANAGE = "Preferences.MainPage.automanageDependencies";
  public static final String PROP_RUNTIME_WORKSPACE_LOCATION = "Preferences.MainPage.runtimeWorkspaceLocation";
  public static final String PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER = "Preferences.MainPage.runtimeWorkspaceLocationIsContainer";
  public static final String PROP_JUNIT_WORKSPACE_LOCATION = "Preferences.MainPage.junitWorkspaceLocation";
  public static final String PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER = "Preferences.MainPage.junitWorkspaceLocationIsContainer";
  public static final String DEFAULT_OSGI_FRAMEOWRK = "Preference.default.osgi.framework";
}

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

public abstract interface IPDEConstants
{
  public static final String PLUGIN_ID = "org.eclipse.pde.launching";
  public static final String UI_PLUGIN_ID = "org.eclipse.pde.ui";
  public static final String LEGACY_UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.legacytestapplication";
  public static final String NON_UI_THREAD_APPLICATION = "org.eclipse.pde.junit.runtime.nonuithreadtestapplication";
  public static final String UI_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.uitestapplication";
  public static final String CORE_TEST_APPLICATION = "org.eclipse.pde.junit.runtime.coretestapplication";
  public static final String RESTART = "restart";
  public static final String DOCLEARLOG = "clearwslog";
  public static final String LAUNCHER_PDE_VERSION = "pde.version";
  public static final String APPEND_ARGS_EXPLICITLY = "append.args";
}

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

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;

class PDELaunchingPlugin$1
  implements BundleListener
{
  final PDELaunchingPlugin this$0;
  
  PDELaunchingPlugin$1(PDELaunchingPlugin paramPDELaunchingPlugin)
  {
    this$0 = paramPDELaunchingPlugin;
  }
  
  public void bundleChanged(BundleEvent event)
  {
    if ((event.getType() == 2) && 
      ("org.eclipse.debug.core".equals(event.getBundle().getSymbolicName())))
    {
      PDELaunchingPlugin.access$0(this$0, new PDELaunchingPlugin.DebugPluginUtil(this$0, null));
      PDELaunchingPlugin.access$1(this$0).addListener();
      PDELaunchingPlugin.access$2(this$0).removeBundleListener(this);
    }
  }
}

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

import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationListener;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.pde.internal.launching.launcher.LaunchConfigurationListener;

class PDELaunchingPlugin$DebugPluginUtil
{
  private ILaunchConfigurationListener fLaunchConfigurationListener;
  final PDELaunchingPlugin this$0;
  
  private PDELaunchingPlugin$DebugPluginUtil(PDELaunchingPlugin paramPDELaunchingPlugin)
  {
    this$0 = paramPDELaunchingPlugin;
  }
  
  PDELaunchingPlugin$DebugPluginUtil(PDELaunchingPlugin paramPDELaunchingPlugin, DebugPluginUtil paramDebugPluginUtil)
  {
    this(paramPDELaunchingPlugin);
  }
  
  public void addListener()
  {
    if (fLaunchConfigurationListener == null) {
      fLaunchConfigurationListener = new LaunchConfigurationListener();
    }
    DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(
      fLaunchConfigurationListener);
  }
  
  public void removeListener()
  {
    if (fLaunchConfigurationListener != null)
    {
      DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(
        fLaunchConfigurationListener);
      fLaunchConfigurationListener = null;
    }
  }
}

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

import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.Hashtable;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationListener;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.pde.internal.core.PDEPreferencesManager;
import org.eclipse.pde.internal.launching.launcher.LaunchConfigurationListener;
import org.eclipse.pde.internal.launching.launcher.LaunchListener;
import org.eclipse.pde.internal.launching.launcher.LauncherUtils;
import org.eclipse.pde.internal.launching.launcher.OSGiFrameworkManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;

public class PDELaunchingPlugin
  extends Plugin
  implements IPDEConstants
{
  private static PDELaunchingPlugin fInstance;
  private LaunchListener fLaunchListener;
  private BundleContext fBundleContext;
  private Hashtable fCounters;
  private DebugPluginUtil fDebugPluginUtil;
  private OSGiFrameworkManager fOSGiFrameworkManager;
  private PDEPreferencesManager fPreferenceManager;
  
  public PDELaunchingPlugin()
  {
    fInstance = this;
  }
  
  public PDEPreferencesManager getPreferenceManager()
  {
    if (fPreferenceManager == null) {
      fPreferenceManager = new PDEPreferencesManager("org.eclipse.pde.launching");
    }
    return fPreferenceManager;
  }
  
  public URL getInstallURL()
  {
    return getDefault().getBundle().getEntry("/");
  }
  
  public static PDELaunchingPlugin getDefault()
  {
    return fInstance;
  }
  
  public Hashtable getDefaultNameCounters()
  {
    if (fCounters == null) {
      fCounters = new Hashtable();
    }
    return fCounters;
  }
  
  public static String getPluginId()
  {
    return getDefault().getBundle().getSymbolicName();
  }
  
  public static IWorkspace getWorkspace()
  {
    return ResourcesPlugin.getWorkspace();
  }
  
  public static void log(IStatus status)
  {
    ResourcesPlugin.getPlugin().getLog().log(status);
  }
  
  public static void logErrorMessage(String message)
  {
    log(new Status(4, getPluginId(), 4, message, 
      null));
  }
  
  public static void log(Throwable e)
  {
    if ((e instanceof InvocationTargetException)) {
      e = ((InvocationTargetException)e).getTargetException();
    }
    IStatus status = null;
    if ((e instanceof CoreException)) {
      status = ((CoreException)e).getStatus();
    } else {
      status = new Status(4, getPluginId(), 0, e
        .getMessage(), e);
    }
    log(status);
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    fBundleContext = context;
    setupLaunchConfigurationListener();
  }
  
  private void setupLaunchConfigurationListener()
  {
    boolean listenerStarted = false;
    Bundle bundle = Platform.getBundle("org.eclipse.debug.core");
    if ((bundle != null) && (bundle.getState() == 32))
    {
      fDebugPluginUtil = new DebugPluginUtil(null);
      fDebugPluginUtil.addListener();
      listenerStarted = true;
    }
    if (!listenerStarted) {
      fBundleContext.addBundleListener(new BundleListener()
      {
        public void bundleChanged(BundleEvent event)
        {
          if ((event.getType() == 2) && 
            ("org.eclipse.debug.core".equals(event.getBundle().getSymbolicName())))
          {
            fDebugPluginUtil = new PDELaunchingPlugin.DebugPluginUtil(PDELaunchingPlugin.this, null);
            fDebugPluginUtil.addListener();
            fBundleContext.removeBundleListener(this);
          }
        }
      });
    }
  }
  
  public BundleContext getBundleContext()
  {
    return fBundleContext;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    if (fLaunchListener != null) {
      fLaunchListener.shutdown();
    }
    if (fDebugPluginUtil != null) {
      fDebugPluginUtil.removeListener();
    }
    LauncherUtils.shutdown();
    super.stop(context);
  }
  
  public LaunchListener getLaunchListener()
  {
    if (fLaunchListener == null) {
      fLaunchListener = new LaunchListener();
    }
    return fLaunchListener;
  }
  
  public OSGiFrameworkManager getOSGiFrameworkManager()
  {
    if (fOSGiFrameworkManager == null) {
      fOSGiFrameworkManager = new OSGiFrameworkManager();
    }
    return fOSGiFrameworkManager;
  }
  
  private class DebugPluginUtil
  {
    private ILaunchConfigurationListener fLaunchConfigurationListener;
    
    DebugPluginUtil(DebugPluginUtil paramDebugPluginUtil)
    {
      this();
    }
    
    public void addListener()
    {
      if (fLaunchConfigurationListener == null) {
        fLaunchConfigurationListener = new LaunchConfigurationListener();
      }
      DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(
        fLaunchConfigurationListener);
    }
    
    public void removeListener()
    {
      if (fLaunchConfigurationListener != null)
      {
        DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(
          fLaunchConfigurationListener);
        fLaunchConfigurationListener = null;
      }
    }
    
    private DebugPluginUtil() {}
  }
}

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

import org.eclipse.osgi.util.NLS;

public class PDEMessages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.pde.internal.launching.pderesources";
  public static String LauncherUtils_cannotLaunchApplication;
  public static String Launcher_error_code13;
  public static String Launcher_error_code15;
  public static String EclipsePluginValidationOperation_pluginMissing;
  public static String PluginValidation_error;
  public static String WorkbenchLauncherConfigurationDelegate_noJRE;
  public static String WorkbenchLauncherConfigurationDelegate_jrePathNotFound;
  public static String WorkbenchLauncherConfigurationDelegate_badFeatureSetup;
  public static String WorkbenchLauncherConfigurationDelegate_noStartup;
  public static String JUnitLaunchConfiguration_error_notaplugin;
  public static String JUnitLaunchConfiguration_error_missingPlugin;
  public static String OSGiLaunchConfiguration_cannotFindLaunchConfiguration;
  public static String OSGiLaunchConfiguration_selected;
  public static String EquinoxLaunchConfiguration_oldTarget;
  public static String VMHelper_cannotFindExecEnv;
  
  static
  {
    NLS.initializeMessages("org.eclipse.pde.internal.launching.pderesources", PDEMessages.class);
  }
}

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

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.osgi.service.prefs.BackingStoreException;

public class PreferenceInitializer
  extends AbstractPreferenceInitializer
{
  public void initializeDefaultPreferences()
  {
    IEclipsePreferences prefs = new DefaultScope().getNode("org.eclipse.pde.launching");
    prefs.put("Preference.default.osgi.framework", "org.eclipse.pde.ui.EquinoxFramework");
    prefs.put("Preferences.MainPage.runtimeWorkspaceLocation", "${workspace_loc}/../runtime-");
    prefs.putBoolean("Preferences.MainPage.runtimeWorkspaceLocationIsContainer", true);
    prefs.put("Preferences.MainPage.junitWorkspaceLocation", "${workspace_loc}/../junit-workspace");
    prefs.putBoolean("Preferences.MainPage.junitWorkspaceLocationIsContainer", false);
    
    IEclipsePreferences oldInstancePrefs = new InstanceScope().getNode("org.eclipse.pde.ui");
    IEclipsePreferences newInstancePrefs = new InstanceScope().getNode("org.eclipse.pde.launching");
    
    String osgiFramework = oldInstancePrefs.get("Preference.default.osgi.framework", null);
    if (osgiFramework != null)
    {
      newInstancePrefs.put("Preference.default.osgi.framework", osgiFramework);
      oldInstancePrefs.remove("Preference.default.osgi.framework");
    }
    String autoManage = oldInstancePrefs.get("Preferences.MainPage.automanageDependencies", null);
    if (autoManage != null)
    {
      newInstancePrefs.put("Preferences.MainPage.automanageDependencies", autoManage);
      oldInstancePrefs.remove("Preferences.MainPage.automanageDependencies");
    }
    try
    {
      newInstancePrefs.flush();
      oldInstancePrefs.flush();
    }
    catch (BackingStoreException e)
    {
      PDELaunchingPlugin.log(e);
    }
  }
}

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.core.plugin.IPluginBase;
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.DependencyManager;
import org.eclipse.pde.internal.core.FeatureModelManager;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.TargetPlatformHelper;
import org.eclipse.pde.internal.core.ifeature.IFeature;
import org.eclipse.pde.internal.core.ifeature.IFeatureImport;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.eclipse.pde.internal.core.ifeature.IFeaturePlugin;
import org.osgi.framework.Version;

public class BundleLauncherHelper
{
  public static final String DEFAULT_UPDATE_CONFIGURATOR_START_LEVEL_TEXT = "3";
  public static final String DEFAULT_UPDATE_CONFIGURATOR_AUTO_START_TEXT = "true";
  public static final String DEFAULT_UPDATE_CONFIGURATOR_START_LEVEL = "3:true";
  public static final char VERSION_SEPARATOR = '*';
  
  public static Map getWorkspaceBundleMap(ILaunchConfiguration configuration)
    throws CoreException
  {
    return getWorkspaceBundleMap(configuration, null, "workspace_bundles");
  }
  
  public static Map getTargetBundleMap(ILaunchConfiguration configuration)
    throws CoreException
  {
    return getTargetBundleMap(configuration, null, "target_bundles");
  }
  
  public static Map getMergedBundleMap(ILaunchConfiguration configuration, boolean osgi)
    throws CoreException
  {
    Set set = new HashSet();
    Map map = new HashMap();
    if (!osgi)
    {
      checkBackwardCompatibility(configuration, true);
      if (configuration.getAttribute("default", true))
      {
        IPluginModelBase[] models = PluginRegistry.getActiveModels();
        for (int i = 0; i < models.length; i++) {
          addBundleToMap(map, models[i], "default:default");
        }
        return map;
      }
      if (configuration.getAttribute("usefeatures", false))
      {
        IPluginModelBase[] models = PluginRegistry.getWorkspaceModels();
        for (int i = 0; i < models.length; i++) {
          addBundleToMap(map, models[i], "default:default");
        }
        return map;
      }
    }
    if (configuration.getAttribute("useCustomFeatures", false))
    {
      String defaultLocation = configuration.getAttribute("featureDefaultLocation", "workspace");
      String defaultPluginResolution = configuration.getAttribute("featurePluginResolution", "workspace");
      
      HashMap workspaceFeatureMap = new HashMap();
      HashMap externalFeatureMap = new HashMap();
      
      FeatureModelManager fmm = PDECore.getDefault().getFeatureModelManager();
      IFeatureModel[] workspaceFeatureModels = fmm.getWorkspaceModels();
      for (int i = 0; i < workspaceFeatureModels.length; i++)
      {
        String id = workspaceFeatureModels[i].getFeature().getId();
        workspaceFeatureMap.put(id, workspaceFeatureModels[i]);
      }
      IFeatureModel[] externalFeatureModels = fmm.getExternalModels();
      for (int i = 0; i < externalFeatureModels.length; i++)
      {
        String id = externalFeatureModels[i].getFeature().getId();
        externalFeatureMap.put(id, externalFeatureModels[i]);
      }
      Map featureResolutionMap = new HashMap();
      Set selectedFeatures = configuration.getAttribute("selected_features", null);
      if (selectedFeatures != null) {
        for (Iterator iterator = selectedFeatures.iterator(); iterator.hasNext();)
        {
          String currentSelected = (String)iterator.next();
          String[] attributes = currentSelected.split(":");
          if (attributes.length > 1) {
            featureResolutionMap.put(attributes[0], attributes[1]);
          }
        }
      }
      Set launchPlugins = new HashSet();
      for (Iterator iterator = featureResolutionMap.keySet().iterator(); iterator.hasNext();)
      {
        String id = (String)iterator.next();
        
        IFeatureModel featureModel = null;
        if ("workspace".equalsIgnoreCase(defaultLocation)) {
          featureModel = (IFeatureModel)workspaceFeatureMap.get(id);
        }
        if (((featureModel == null) || ("external".equalsIgnoreCase(defaultLocation))) && 
          (externalFeatureMap.containsKey(id))) {
          featureModel = (IFeatureModel)externalFeatureMap.get(id);
        }
        if (featureModel != null)
        {
          IFeaturePlugin[] featurePlugins = featureModel.getFeature().getPlugins();
          String pluginResolution = (String)featureResolutionMap.get(id);
          if ("default".equalsIgnoreCase(pluginResolution)) {
            pluginResolution = defaultPluginResolution;
          }
          for (int i = 0; i < featurePlugins.length; i++)
          {
            ModelEntry modelEntry = PluginRegistry.findEntry(featurePlugins[i].getId());
            if (modelEntry != null)
            {
              IPluginModelBase model = findModel(modelEntry, featurePlugins[i].getVersion(), pluginResolution);
              if (model != null) {
                launchPlugins.add(model);
              }
            }
          }
          IFeatureImport[] featureImports = featureModel.getFeature().getImports();
          for (int i = 0; i < featureImports.length; i++) {
            if (featureImports[i].getType() == 0)
            {
              ModelEntry modelEntry = PluginRegistry.findEntry(featureImports[i].getId());
              if (modelEntry != null)
              {
                IPluginModelBase model = findModel(modelEntry, featureImports[i].getVersion(), pluginResolution);
                if (model != null) {
                  launchPlugins.add(model);
                }
              }
            }
          }
        }
      }
      HashMap additionalPlugins = getAdditionalPlugins(configuration, true);
      launchPlugins.addAll(additionalPlugins.keySet());
      if (!osgi)
      {
        String[] applicationIds = RequirementHelper.getApplicationRequirements(configuration);
        for (int i = 0; i < applicationIds.length; i++)
        {
          ModelEntry modelEntry = PluginRegistry.findEntry(applicationIds[i]);
          if (modelEntry != null)
          {
            IPluginModelBase model = findModel(modelEntry, null, defaultPluginResolution);
            if (model != null) {
              launchPlugins.add(model);
            }
          }
        }
      }
      Set additionalIds = DependencyManager.getDependencies(launchPlugins.toArray(), false, new String[] { "org.eclipse.ui.workbench.compatibility" });
      Iterator it = additionalIds.iterator();
      while (it.hasNext())
      {
        String id = (String)it.next();
        ModelEntry modelEntry = PluginRegistry.findEntry(id);
        if (modelEntry != null)
        {
          IPluginModelBase model = findModel(modelEntry, null, defaultPluginResolution);
          if (model != null) {
            launchPlugins.add(model);
          }
        }
      }
      HashMap pluginMap = new HashMap();
      List workspaceModels = null;
      for (Iterator iterator = launchPlugins.iterator(); iterator.hasNext();)
      {
        IPluginModelBase model = (IPluginModelBase)iterator.next();
        String id = model.getPluginBase().getId();
        if (pluginMap.containsKey(id))
        {
          IPluginModelBase existing = (IPluginModelBase)pluginMap.get(id);
          if ((model.getPluginBase().getVersion().equalsIgnoreCase(existing.getPluginBase().getVersion())) || ((isSingleton(model)) && (isSingleton(existing))))
          {
            if (workspaceModels == null) {
              workspaceModels = Arrays.asList(PluginRegistry.getWorkspaceModels());
            }
            if (!workspaceModels.contains(existing))
            {
              pluginMap.put(id, model);
              continue;
            }
          }
        }
        pluginMap.put(id, model);
      }
      for (Iterator iterator = pluginMap.values().iterator(); iterator.hasNext();)
      {
        IPluginModelBase model = (IPluginModelBase)iterator.next();
        addBundleToMap(map, model, "default:default");
      }
      return map;
    }
    String workspace = !osgi ? "selected_workspace_plugins" : "workspace_bundles";
    String target = !osgi ? "selected_target_plugins" : "target_bundles";
    map = getWorkspaceBundleMap(configuration, set, workspace);
    map.putAll(getTargetBundleMap(configuration, set, target));
    return map;
  }
  
  private static IPluginModelBase findModel(ModelEntry modelEntry, String version, String location)
  {
    IPluginModelBase model = null;
    if ("workspace".equalsIgnoreCase(location)) {
      model = getBestCandidateModel(modelEntry.getWorkspaceModels(), version);
    }
    if (model == null) {
      model = getBestCandidateModel(modelEntry.getExternalModels(), version);
    }
    if ((model == null) && ("external".equalsIgnoreCase(location))) {
      model = getBestCandidateModel(modelEntry.getWorkspaceModels(), version);
    }
    return model;
  }
  
  private static boolean isSingleton(IPluginModelBase model)
  {
    if ((model.getBundleDescription() == null) || (model.getBundleDescription().isSingleton())) {
      return true;
    }
    return false;
  }
  
  private static IPluginModelBase getBestCandidateModel(IPluginModelBase[] models, String version)
  {
    Version requiredVersion = version != null ? Version.parseVersion(version) : Version.emptyVersion;
    IPluginModelBase model = null;
    for (int i = 0; i < models.length; i++) {
      if ((models[i].getBundleDescription() != null) && (models[i].isEnabled())) {
        if (model == null)
        {
          model = models[i];
          if (requiredVersion.compareTo(model.getBundleDescription().getVersion()) == 0) {
            break;
          }
        }
        else if ((!model.isEnabled()) && (models[i].isEnabled()))
        {
          model = models[i];
        }
        else
        {
          BundleDescription current = model.getBundleDescription();
          BundleDescription candidate = models[i].getBundleDescription();
          if ((current != null) && (candidate != null)) {
            if ((!current.isResolved()) && (candidate.isResolved()))
            {
              model = models[i];
            }
            else
            {
              if (requiredVersion.compareTo(candidate.getVersion()) == 0)
              {
                model = models[i];
                break;
              }
              if (current.getVersion().compareTo(candidate.getVersion()) < 0) {
                model = models[i];
              }
            }
          }
        }
      }
    }
    return model;
  }
  
  public static IPluginModelBase[] getMergedBundles(ILaunchConfiguration configuration, boolean osgi)
    throws CoreException
  {
    Map map = getMergedBundleMap(configuration, osgi);
    return (IPluginModelBase[])map.keySet().toArray(new IPluginModelBase[map.size()]);
  }
  
  public static Map getWorkspaceBundleMap(ILaunchConfiguration configuration, Set set, String attribute)
    throws CoreException
  {
    String selected = configuration.getAttribute(attribute, "");
    Map map = new HashMap();
    StringTokenizer tok = new StringTokenizer(selected, ",");
    while (tok.hasMoreTokens())
    {
      String token = tok.nextToken();
      int index = token.indexOf('@');
      if (index < 0)
      {
        token = token.concat("@default:default");
        index = token.indexOf('@');
      }
      String idVersion = token.substring(0, index);
      int versionIndex = idVersion.indexOf('*');
      String id = versionIndex > 0 ? idVersion.substring(0, versionIndex) : idVersion;
      String version = versionIndex > 0 ? idVersion.substring(versionIndex + 1) : null;
      if (set != null) {
        set.add(id);
      }
      ModelEntry entry = PluginRegistry.findEntry(id);
      if (entry != null)
      {
        IPluginModelBase[] models = entry.getWorkspaceModels();
        Set versions = new HashSet();
        for (int i = 0; i < models.length; i++)
        {
          IPluginBase base = models[i].getPluginBase();
          String v = base.getVersion();
          if (versions.add(v)) {
            if ((base.getVersion().equals(version)) || (version == null) || (models.length == 1)) {
              addBundleToMap(map, models[i], token.substring(index + 1));
            }
          }
        }
      }
    }
    if (configuration.getAttribute("automaticAdd", true))
    {
      Set deselectedPlugins = LaunchPluginValidator.parsePlugins(configuration, "deselected_workspace_plugins");
      IPluginModelBase[] models = PluginRegistry.getWorkspaceModels();
      for (int i = 0; i < models.length; i++)
      {
        String id = models[i].getPluginBase().getId();
        if (id != null) {
          if (!deselectedPlugins.contains(models[i]))
          {
            if (set != null) {
              set.add(id);
            }
            if (!map.containsKey(models[i])) {
              addBundleToMap(map, models[i], "default:default");
            }
          }
        }
      }
    }
    return map;
  }
  
  public static String resolveSystemRunLevelText(IPluginModelBase model)
  {
    BundleDescription description = model.getBundleDescription();
    String modelName = description.getSymbolicName();
    if ("org.eclipse.equinox.ds".equals(modelName)) {
      return "1";
    }
    if ("org.eclipse.equinox.simpleconfigurator".equals(modelName)) {
      return "1";
    }
    if ("org.eclipse.equinox.common".equals(modelName)) {
      return "2";
    }
    if ("org.eclipse.osgi".equals(modelName)) {
      return "-1";
    }
    if ("org.eclipse.update.configurator".equals(modelName)) {
      return "3";
    }
    if ("org.eclipse.core.runtime".equals(modelName))
    {
      if (TargetPlatformHelper.getTargetVersion() > 3.1D) {
        return "default";
      }
      return "2";
    }
    return null;
  }
  
  public static String resolveSystemAutoText(IPluginModelBase model)
  {
    BundleDescription description = model.getBundleDescription();
    String modelName = description.getSymbolicName();
    if ("org.eclipse.equinox.ds".equals(modelName)) {
      return "true";
    }
    if ("org.eclipse.equinox.simpleconfigurator".equals(modelName)) {
      return "true";
    }
    if ("org.eclipse.equinox.common".equals(modelName)) {
      return "true";
    }
    if ("org.eclipse.osgi".equals(modelName)) {
      return "true";
    }
    if ("org.eclipse.update.configurator".equals(modelName)) {
      return "true";
    }
    if ("org.eclipse.core.runtime".equals(modelName))
    {
      if (TargetPlatformHelper.getTargetVersion() > 3.1D) {
        return "true";
      }
      return "true";
    }
    return null;
  }
  
  private static void addBundleToMap(Map map, IPluginModelBase bundle, String sl)
  {
    BundleDescription desc = bundle.getBundleDescription();
    boolean defaultsl = (sl == null) || (sl.equals("default:default"));
    if ((desc != null) && (defaultsl))
    {
      String runLevelText = resolveSystemRunLevelText(bundle);
      String autoText = resolveSystemAutoText(bundle);
      if ((runLevelText != null) && (autoText != null)) {
        map.put(bundle, runLevelText + ":" + autoText);
      } else {
        map.put(bundle, sl);
      }
    }
    else
    {
      map.put(bundle, sl);
    }
  }
  
  public static Map getTargetBundleMap(ILaunchConfiguration configuration, Set set, String attribute)
    throws CoreException
  {
    String selected = configuration.getAttribute(attribute, "");
    Map map = new HashMap();
    StringTokenizer tok = new StringTokenizer(selected, ",");
    while (tok.hasMoreTokens())
    {
      String token = tok.nextToken();
      int index = token.indexOf('@');
      if (index < 0)
      {
        token = token.concat("@default:default");
        index = token.indexOf('@');
      }
      String idVersion = token.substring(0, index);
      int versionIndex = idVersion.indexOf('*');
      String id = versionIndex > 0 ? idVersion.substring(0, versionIndex) : idVersion;
      String version = versionIndex > 0 ? idVersion.substring(versionIndex + 1) : null;
      if ((set == null) || (!set.contains(id)))
      {
        ModelEntry entry = PluginRegistry.findEntry(id);
        if (entry != null)
        {
          IPluginModelBase[] models = entry.getExternalModels();
          for (int i = 0; i < models.length; i++) {
            if (models[i].isEnabled())
            {
              IPluginBase base = models[i].getPluginBase();
              if ((base.getVersion().equals(version)) || (version == null) || (models.length == 1)) {
                addBundleToMap(map, models[i], token.substring(index + 1));
              }
            }
          }
        }
      }
    }
    return map;
  }
  
  public static String writeBundleEntry(IPluginModelBase model, String startLevel, String autoStart)
  {
    IPluginBase base = model.getPluginBase();
    String id = base.getId();
    StringBuffer buffer = new StringBuffer(id);
    
    ModelEntry entry = PluginRegistry.findEntry(id);
    if ((entry != null) && (entry.getActiveModels().length > 1))
    {
      buffer.append('*');
      buffer.append(model.getPluginBase().getVersion());
    }
    boolean hasStartLevel = (startLevel != null) && (startLevel.length() > 0);
    boolean hasAutoStart = (autoStart != null) && (autoStart.length() > 0);
    if ((hasStartLevel) || (hasAutoStart)) {
      buffer.append('@');
    }
    if (hasStartLevel) {
      buffer.append(startLevel);
    }
    if ((hasStartLevel) || (hasAutoStart)) {
      buffer.append(':');
    }
    if (hasAutoStart) {
      buffer.append(autoStart);
    }
    return buffer.toString();
  }
  
  public static void checkBackwardCompatibility(ILaunchConfiguration configuration, boolean save)
    throws CoreException
  {
    ILaunchConfigurationWorkingCopy wc = null;
    if (configuration.isWorkingCopy()) {
      wc = (ILaunchConfigurationWorkingCopy)configuration;
    } else {
      wc = configuration.getWorkingCopy();
    }
    String value = configuration.getAttribute("wsproject", null);
    if (value != null)
    {
      wc.setAttribute("wsproject", null);
      if (value.indexOf(';') != -1) {
        value = value.replace(';', ',');
      } else if (value.indexOf(':') != -1) {
        value = value.replace(':', ',');
      }
      value = (value.length() == 0) || (value.equals(",")) ? 
        null : 
        value.substring(0, value.length() - 1);
      
      boolean automatic = configuration.getAttribute("automaticAdd", true);
      String attr = automatic ? "deselected_workspace_plugins" : "selected_workspace_plugins";
      wc.setAttribute(attr, value);
    }
    String value2 = configuration.getAttribute("extplugins", null);
    if (value2 != null)
    {
      wc.setAttribute("extplugins", null);
      if (value2.indexOf(';') != -1) {
        value2 = value2.replace(';', ',');
      } else if (value2.indexOf(':') != -1) {
        value2 = value2.replace(':', ',');
      }
      value2 = (value2.length() == 0) || (value2.equals(",")) ? null : value2.substring(0, value2.length() - 1);
      wc.setAttribute("selected_target_plugins", value2);
    }
    String version = configuration.getAttribute("pde.version", null);
    boolean newApp = TargetPlatformHelper.usesNewApplicationModel();
    boolean upgrade = (!"3.3".equals(version)) && (newApp);
    if (!upgrade) {
      upgrade = (TargetPlatformHelper.getTargetVersion() >= 3.2D) && (version == null);
    }
    if (upgrade)
    {
      wc.setAttribute("pde.version", newApp ? "3.3" : "3.2a");
      boolean usedefault = configuration.getAttribute("default", true);
      boolean useFeatures = configuration.getAttribute("usefeatures", false);
      boolean automaticAdd = configuration.getAttribute("automaticAdd", true);
      if ((!usedefault) && (!useFeatures))
      {
        ArrayList list = new ArrayList();
        if (version == null)
        {
          list.add("org.eclipse.core.contenttype");
          list.add("org.eclipse.core.jobs");
          list.add("org.eclipse.equinox.common");
          list.add("org.eclipse.equinox.preferences");
          list.add("org.eclipse.equinox.registry");
          list.add("org.eclipse.core.runtime.compatibility.registry");
        }
        if ((!"3.3".equals(version)) && (newApp)) {
          list.add("org.eclipse.equinox.app");
        }
        StringBuffer extensions = new StringBuffer(configuration.getAttribute("selected_workspace_plugins", ""));
        StringBuffer target = new StringBuffer(configuration.getAttribute("selected_target_plugins", ""));
        for (int i = 0; i < list.size(); i++)
        {
          String plugin = list.get(i).toString();
          IPluginModelBase model = PluginRegistry.findModel(plugin);
          if (model != null) {
            if (model.getUnderlyingResource() != null)
            {
              if (!automaticAdd)
              {
                if (extensions.length() > 0) {
                  extensions.append(",");
                }
                extensions.append(plugin);
              }
            }
            else
            {
              if (target.length() > 0) {
                target.append(",");
              }
              target.append(plugin);
            }
          }
        }
        if (extensions.length() > 0) {
          wc.setAttribute("selected_workspace_plugins", extensions.toString());
        }
        if (target.length() > 0) {
          wc.setAttribute("selected_target_plugins", target.toString());
        }
      }
    }
    if ((save) && ((value != null) || (value2 != null) || (upgrade))) {
      wc.doSave();
    }
  }
  
  public static String writeAdditionalPluginsEntry(IPluginModelBase model, String pluginResolution, boolean checked)
  {
    IPluginBase base = model.getPluginBase();
    String id = base.getId();
    StringBuffer buffer = new StringBuffer(id);
    buffer.append(':');
    buffer.append(base.getVersion());
    buffer.append(':');
    buffer.append(pluginResolution);
    buffer.append(':');
    buffer.append(checked);
    return buffer.toString();
  }
  
  public static HashMap getAdditionalPlugins(ILaunchConfiguration config, boolean onlyEnabled)
    throws CoreException
  {
    HashMap resolvedAdditionalPlugins = new HashMap();
    Set userAddedPlugins = config.getAttribute("additional_plugins", null);
    String defaultPluginResolution = config.getAttribute("featurePluginResolution", "workspace");
    if (userAddedPlugins != null) {
      for (Iterator iterator = userAddedPlugins.iterator(); iterator.hasNext();)
      {
        String addedPlugin = (String)iterator.next();
        String[] pluginData = addedPlugin.split(":");
        boolean checked = Boolean.valueOf(pluginData[3]).booleanValue();
        if ((!onlyEnabled) || (checked))
        {
          String id = pluginData[0];
          String version = pluginData[1];
          String pluginResolution = pluginData[2];
          ModelEntry pluginModelEntry = PluginRegistry.findEntry(id);
          if (pluginModelEntry != null)
          {
            if ("default".equalsIgnoreCase(pluginResolution)) {
              pluginResolution = defaultPluginResolution;
            }
            IPluginModelBase model = findModel(pluginModelEntry, version, pluginResolution);
            if (model != null) {
              resolvedAdditionalPlugins.put(model, pluginData[2]);
            }
          }
        }
      }
    }
    return resolvedAdditionalPlugins;
  }
}

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

import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
import org.eclipse.pde.internal.launching.PDEMessages;

public class EclipsePluginValidationOperation
  extends LaunchValidationOperation
{
  public static final int CREATE_EXTENSION_ERROR_CODE = 1000;
  private Map fExtensionErrors = new HashMap(2);
  private static Object[] EMPTY = new Object[0];
  
  public EclipsePluginValidationOperation(ILaunchConfiguration configuration)
  {
    super(configuration);
  }
  
  protected IPluginModelBase[] getModels()
    throws CoreException
  {
    return BundleLauncherHelper.getMergedBundles(fLaunchConfiguration, false);
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    super.run(monitor);
    if (fExtensionErrors.size() > 0) {
      fExtensionErrors.clear();
    }
    validateExtensions();
  }
  
  private void validateExtensions()
  {
    try
    {
      String[] required = RequirementHelper.getApplicationRequirements(fLaunchConfiguration);
      for (int i = 0; i < required.length; i++)
      {
        BundleDescription bundle = getState().getBundle(required[i], null);
        if (bundle == null)
        {
          String message = NLS.bind(PDEMessages.EclipsePluginValidationOperation_pluginMissing, required
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-2017. Infinite Loop Ltd