Exemplo n.º 1
0
  /** Initializes the Location objects for the LocationManager. */
  public static void initializeLocations() {
    // do install location initialization first since others may depend on it
    // assumes that the property is already set
    installLocation = buildLocation(PROP_INSTALL_AREA, null, "", true, false, null); // $NON-NLS-1$

    // TODO not sure what the data area prefix should be here for the user area
    Location temp =
        buildLocation(PROP_USER_AREA_DEFAULT, null, "", false, false, null); // $NON-NLS-1$
    URL defaultLocation = temp == null ? null : temp.getURL();
    if (defaultLocation == null)
      defaultLocation =
          buildURL(
              new File(FrameworkProperties.getProperty(PROP_USER_HOME), "user").getAbsolutePath(),
              true); //$NON-NLS-1$
    userLocation =
        buildLocation(PROP_USER_AREA, defaultLocation, "", false, false, null); // $NON-NLS-1$

    temp =
        buildLocation(
            PROP_INSTANCE_AREA_DEFAULT,
            null,
            "",
            false,
            false,
            INSTANCE_DATA_AREA_PREFIX); //$NON-NLS-1$
    defaultLocation = temp == null ? null : temp.getURL();
    if (defaultLocation == null)
      defaultLocation =
          buildURL(
              new File(FrameworkProperties.getProperty(PROP_USER_DIR), "workspace")
                  .getAbsolutePath(),
              true); //$NON-NLS-1$
    instanceLocation =
        buildLocation(
            PROP_INSTANCE_AREA,
            defaultLocation,
            "",
            false,
            false,
            INSTANCE_DATA_AREA_PREFIX); //$NON-NLS-1$

    mungeConfigurationLocation();
    // compute a default but it is very unlikely to be used since main will have computed everything
    temp = buildLocation(PROP_CONFIG_AREA_DEFAULT, null, "", false, false, null); // $NON-NLS-1$
    defaultLocation = temp == null ? null : temp.getURL();
    if (defaultLocation == null && FrameworkProperties.getProperty(PROP_CONFIG_AREA) == null)
      // only compute the default if the configuration area property is not set
      defaultLocation = buildURL(computeDefaultConfigurationLocation(), true);
    configurationLocation =
        buildLocation(PROP_CONFIG_AREA, defaultLocation, "", false, false, null); // $NON-NLS-1$
    // get the parent location based on the system property. This will have been set on the
    // way in either by the caller/user or by main.  There will be no parent location if we are not
    // cascaded.
    URL parentLocation = computeSharedConfigurationLocation();
    if (parentLocation != null && !parentLocation.equals(configurationLocation.getURL())) {
      Location parent = new BasicLocation(null, parentLocation, true, null);
      ((BasicLocation) configurationLocation).setParent(parent);
    }
    initializeDerivedConfigurationLocations();

    if (FrameworkProperties.getProperty(PROP_HOME_LOCATION_AREA) == null) {
      String eclipseLauncher = FrameworkProperties.getProperty(PROP_LAUNCHER);
      String eclipseHomeLocationPath = getEclipseHomeLocation(eclipseLauncher);
      if (eclipseHomeLocationPath != null)
        FrameworkProperties.setProperty(PROP_HOME_LOCATION_AREA, eclipseHomeLocationPath);
    }
    // if eclipse.home.location is not set then default to osgi.install.area
    if (FrameworkProperties.getProperty(PROP_HOME_LOCATION_AREA) == null
        && FrameworkProperties.getProperty(PROP_INSTALL_AREA) != null)
      FrameworkProperties.setProperty(
          PROP_HOME_LOCATION_AREA, FrameworkProperties.getProperty(PROP_INSTALL_AREA));
    eclipseHomeLocation =
        buildLocation(PROP_HOME_LOCATION_AREA, null, "", true, true, null); // $NON-NLS-1$
  }