ISourceContainer[] getSourceContainers(String location, String id) throws CoreException {

    ISourceContainer[] containers = (ISourceContainer[]) fSourceContainerMap.get(location);
    if (containers != null) {
      return containers;
    }

    ArrayList result = new ArrayList();
    ModelEntry entry = MonitorRegistry.findEntry(id);

    boolean match = false;

    IMonitorModelBase[] models = entry.getWorkspaceModels();
    for (int i = 0; i < models.length; i++) {
      if (isPerfectMatch(models[i], new Path(location))) {
        IResource resource = models[i].getUnderlyingResource();
        // if the plug-in matches a workspace model,
        // add the project and any libraries not coming via a container
        // to the list of source containers, in that order
        if (resource != null) {
          addProjectSourceContainers(resource.getProject(), result);
        }
        match = true;
        break;
      }
    }

    if (!match) {
      File file = new File(location);
      if (file.isFile()) {
        // in case of linked plug-in projects that map to an external JARd plug-in,
        // use source container that maps to the library in the linked project.
        ISourceContainer container = getArchiveSourceContainer(location);
        if (container != null) {
          containers = new ISourceContainer[] {container};
          fSourceContainerMap.put(location, containers);
          return containers;
        }
      }

      models = entry.getExternalModels();
      for (int i = 0; i < models.length; i++) {
        if (isPerfectMatch(models[i], new Path(location))) {
          // try all source zips found in the source code locations
          IClasspathEntry[] entries = MDEClasspathContainer.getExternalEntries(models[i]);
          for (int j = 0; j < entries.length; j++) {
            IRuntimeClasspathEntry rte = convertClasspathEntry(entries[j]);
            if (rte != null) result.add(rte);
          }
          break;
        }
      }
    }

    IRuntimeClasspathEntry[] entries =
        (IRuntimeClasspathEntry[]) result.toArray(new IRuntimeClasspathEntry[result.size()]);
    containers = JavaRuntime.getSourceContainers(entries);
    fSourceContainerMap.put(location, containers);
    return containers;
  }
 /* (non-Javadoc)
  * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#dispose()
  */
 public synchronized void dispose() {
   Iterator iterator = fSourceContainerMap.values().iterator();
   while (iterator.hasNext()) {
     ISourceContainer[] containers = (ISourceContainer[]) iterator.next();
     for (int i = 0; i < containers.length; i++) {
       containers[i].dispose();
     }
   }
   fSourceContainerMap.clear();
   super.dispose();
 }
  private String getBundles(boolean defaultAuto) {
    StringBuffer buffer = new StringBuffer();
    Iterator iter = fModels.keySet().iterator();
    while (iter.hasNext()) {
      IMonitorModelBase model = (IMonitorModelBase) iter.next();
      String id = model.getMonitorBase().getId();
      if (!IPDEBuildConstants.BUNDLE_OSGI.equals(id)) {
        if (buffer.length() > 0) buffer.append(","); // $NON-NLS-1$
        buffer.append(LaunchConfigurationHelper.getBundleURL(model, true));

        // fragments must not be started or have a start level
        if (model instanceof IFragmentModel) continue;

        String data = fModels.get(model).toString();
        appendStartData(buffer, data, defaultAuto);
      }
    }
    return buffer.toString();
  }
  private static synchronized String getSymbolicName(String path) {
    if (fCachedLocations == null) fCachedLocations = new HashMap();

    File file = new File(path);
    if (file.exists() && !fCachedLocations.containsKey(path)) {
      try {
        Dictionary dictionary = MinimalState.loadManifest(file);
        String value = (String) dictionary.get(Constants.BUNDLE_SYMBOLICNAME);
        if (value != null) {
          ManifestElement[] elements =
              ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, value);
          String id = elements.length > 0 ? elements[0].getValue() : null;
          if (id != null) fCachedLocations.put(path, elements[0].getValue());
        }
      } catch (IOException e) {
      } catch (BundleException e) {
      }
    }
    return (String) fCachedLocations.get(path);
  }
 private void validateIdentifierAttribute(Element element, Attr attr, ISchemaAttribute attInfo) {
   int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_IDENTIFIER);
   if (severity != CompilerFlags.IGNORE) {
     String value = attr.getValue();
     String basedOn = attInfo.getBasedOn();
     // only validate if we have a valid value and basedOn value
     if (value != null && basedOn != null && value.length() > 0 && basedOn.length() > 0) {
       Map attributes = PDESchemaHelper.getValidAttributes(attInfo);
       if (!attributes.containsKey(value)) { // report error if we are missing something
         report(
             NLS.bind(
                 MDECoreMessages.ExtensionsErrorReporter_unknownIdentifier,
                 (new String[] {attr.getValue(), attr.getName()})),
             getLine(element, attr.getName()),
             severity,
             MDEMarkerFactory.CAT_OTHER);
       }
     }
   }
 }
 public static void checkPluginPropertiesConsistency(Map map, File configDir) {
   File runtimeDir = new File(configDir, IPDEBuildConstants.BUNDLE_CORE_RUNTIME);
   if (runtimeDir.exists() && runtimeDir.isDirectory()) {
     long timestamp = runtimeDir.lastModified();
     Iterator iter = map.values().iterator();
     while (iter.hasNext()) {
       if (hasChanged((IMonitorModelBase) iter.next(), timestamp)) {
         CoreUtility.deleteContent(runtimeDir);
         break;
       }
     }
   }
 }
  /*
   * (non-Javadoc)
   * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
   */
  protected void preLaunchCheck(
      ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor)
      throws CoreException {
    fModels = BundleLauncherHelper.getMergedBundleMap(configuration, true);
    fAllBundles = new HashMap(fModels.size());
    Iterator iter = fModels.keySet().iterator();
    while (iter.hasNext()) {
      IMonitorModelBase model = (IMonitorModelBase) iter.next();
      fAllBundles.put(model.getMonitorBase().getId(), model);
    }

    if (!fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_OSGI)) {
      // implicitly add it
      IMonitorModelBase model = MonitorRegistry.findModel(IPDEBuildConstants.BUNDLE_OSGI);
      if (model != null) {
        fModels.put(model, "default:default"); // $NON-NLS-1$
        fAllBundles.put(IPDEBuildConstants.BUNDLE_OSGI, model);
      } else {
        String message = MDEMessages.EquinoxLaunchConfiguration_oldTarget;
        throw new CoreException(LauncherUtils.createErrorStatus(message));
      }
    }
    super.preLaunchCheck(configuration, launch, monitor);
  }
  private void saveConfigurationFile(ILaunchConfiguration configuration) throws CoreException {
    Properties properties = new Properties();
    properties.setProperty(
        "osgi.install.area", "file:" + TargetPlatform.getLocation()); // $NON-NLS-1$ //$NON-NLS-2$
    properties.setProperty("osgi.configuration.cascaded", "false"); // $NON-NLS-1$ //$NON-NLS-2$
    properties.put(
        "osgi.framework",
        LaunchConfigurationHelper.getBundleURL(
            IPDEBuildConstants.BUNDLE_OSGI, fAllBundles, false)); // $NON-NLS-1$
    int start = configuration.getAttribute(IPDELauncherConstants.DEFAULT_START_LEVEL, 4);
    properties.put("osgi.bundles.defaultStartLevel", Integer.toString(start)); // $NON-NLS-1$
    boolean autostart = configuration.getAttribute(IPDELauncherConstants.DEFAULT_AUTO_START, true);

    String bundles = null;
    if (fAllBundles.containsKey(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR)) {

      // If update configurator is set to its default start level, override it as simple/update
      // configurators should not be autostarted together
      Object updateConfiguratorBundle =
          fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR);
      if (updateConfiguratorBundle != null) {
        String startLevel = (String) fModels.get(updateConfiguratorBundle);
        if (startLevel != null
            && startLevel.equals(BundleLauncherHelper.DEFAULT_UPDATE_CONFIGURATOR_START_LEVEL)) {
          fModels.put(updateConfiguratorBundle, "4:false"); // $NON-NLS-1$
        }
      }

      // If simple configurator is being used, we need to write out the bundles.txt instead of
      // writing out the list in the config.ini
      URL bundlesTxt =
          P2Utils.writeBundlesTxt(fModels, start, autostart, getConfigDir(configuration), null);
      if (bundlesTxt != null) {
        properties.setProperty(
            "org.eclipse.equinox.simpleconfigurator.configUrl",
            bundlesTxt.toString()); // $NON-NLS-1$
        if (fAllBundles.get(IPDEBuildConstants.BUNDLE_UPDATE_CONFIGURATOR) != null) {
          properties.setProperty(
              "org.eclipse.update.reconcile", "false"); // $NON-NLS-1$ //$NON-NLS-2$
        }
      }
      StringBuffer buffer = new StringBuffer();
      IMonitorModelBase model =
          (IMonitorModelBase) fAllBundles.get(IPDEBuildConstants.BUNDLE_SIMPLE_CONFIGURATOR);
      buffer.append(LaunchConfigurationHelper.getBundleURL(model, true));
      appendStartData(buffer, (String) fModels.get(model), autostart);
      bundles = buffer.toString();
    } else {
      bundles = getBundles(autostart);
    }
    if (bundles.length() > 0) properties.put("osgi.bundles", bundles); // $NON-NLS-1$

    if (!"3.3"
        .equals(
            configuration.getAttribute(
                IPDEConstants.LAUNCHER_PDE_VERSION, ""))) { // $NON-NLS-1$ //$NON-NLS-2$
      properties.put("eclipse.ignoreApp", "true"); // $NON-NLS-1$ //$NON-NLS-2$
      properties.put("osgi.noShutdown", "true"); // $NON-NLS-1$ //$NON-NLS-2$
    }

    LaunchConfigurationHelper.save(
        new File(getConfigDir(configuration), "config.ini"), properties); // $NON-NLS-1$
  }