Package org.eclipse.osgi.service.datalocation

Examples of org.eclipse.osgi.service.datalocation.Location


  private boolean canUpdate() {
    final AtomicBoolean canUpdate = new AtomicBoolean(true);

    SafeRunnable.run(new LoggingSafeRunnable() {
      public void run() throws Exception {
        Location installLocation = Platform.getInstallLocation();
        if (installLocation != null && installLocation.getURL() != null) {
          File installDirectory = toFile(installLocation.getURL());
          if (!installDirectory.isFile()) {
            File pluginsDir = new File(installDirectory, PLUGINS);
            File featuresDir = new File(installDirectory, FEATURES);
            if (pluginsDir.isDirectory() && featuresDir.isDirectory()) {
              try {
View Full Code Here


        }
        return matched;
    }

    public static IPath getBundleLocation(BundleContext context, String symbolicName, VersionRange range) {
        Location installLocation = Platform.getInstallLocation();
        Location configLocation = Platform.getConfigurationLocation();

        Bundle bundle = findBundle(context, symbolicName, range);
        if (bundle == null)
            return null;

        String location = bundle.getLocation();
        if (location.startsWith("file:")) { //$NON-NLS-1$
            location = location.substring(5);
        } else if (location.startsWith("reference:file:")) { //$NON-NLS-1$
            location = location.substring(15);
        }
        IPath bundlePath = new Path(location);
        if (bundlePath.isAbsolute())
            return bundlePath;

        // Try install location
        if (installLocation != null) {
            IPath installedBundlePath = new Path(installLocation.getURL().getFile()).append(bundlePath);
            if (installedBundlePath.toFile().exists())
                return installedBundlePath;
        }

        // Try config location
        if (configLocation != null) {
            IPath configuredBundlePath = new Path(configLocation.getURL().getFile()).append(bundlePath);
            if (configuredBundlePath.toFile().exists())
                return configuredBundlePath;
        }

        return null;
View Full Code Here

                    : EXIT_RESTART;
        } finally {
            if (display != null) {
        display.dispose();
      }
            Location instanceLoc = Platform.getInstanceLocation();
            if (instanceLoc != null)
              instanceLoc.release();
        }
    }
View Full Code Here

     * @return <code>null</code> if a valid instance location has been set and an exit code
     *         otherwise
     */
    private Object checkInstanceLocation(Shell shell, Map applicationArguments) {
        // -data @none was specified but an ide requires workspace
        Location instanceLoc = Platform.getInstanceLocation();
        if (instanceLoc == null) {
            MessageDialog
                    .openError(
                            shell,
                            IDEWorkbenchMessages.IDEApplication_workspaceMandatoryTitle,
                            IDEWorkbenchMessages.IDEApplication_workspaceMandatoryMessage);
            return EXIT_OK;
        }

        // -data "/valid/path", workspace already set
        if (instanceLoc.isSet()) {
            // make sure the meta data version is compatible (or the user has
            // chosen to overwrite it).
            if (!checkValidWorkspace(shell, instanceLoc.getURL())) {
        return EXIT_OK;
      }

            // at this point its valid, so try to lock it and update the
            // metadata version information if successful
            try {
                if (instanceLoc.lock()) {
                    writeWorkspaceVersion();
                    return null;
                }
               
                // we failed to create the directory. 
                // Two possibilities:
                // 1. directory is already in use
                // 2. directory could not be created
                File workspaceDirectory = new File(instanceLoc.getURL().getFile());
                if (workspaceDirectory.exists()) {
                  if (isDevLaunchMode(applicationArguments)) {
                    return EXIT_WORKSPACE_LOCKED;
                  }
                  MessageDialog.openError(
                          shell,
                          IDEWorkbenchMessages.IDEApplication_workspaceCannotLockTitle,
                          IDEWorkbenchMessages.IDEApplication_workspaceCannotLockMessage);
                } else {
                  MessageDialog.openError(
                      shell,
                      IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetTitle,
                      IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetMessage);
                }
            } catch (IOException e) {
                IDEWorkbenchPlugin.log("Could not obtain lock for workspace location", //$NON-NLS-1$
                        e);             
                MessageDialog
                .openError(
                        shell,
                        IDEWorkbenchMessages.InternalError,
                        e.getMessage());               
            }           
            return EXIT_OK;
        }

        // -data @noDefault or -data not specified, prompt and set
        ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLoc
                .getDefault());

        boolean force = false;
        while (true) {
            URL workspaceUrl = promptForWorkspace(shell, launchData, force);
            if (workspaceUrl == null) {
        return EXIT_OK;
      }

            // if there is an error with the first selection, then force the
            // dialog to open to give the user a chance to correct
            force = true;

            try {
                // the operation will fail if the url is not a valid
                // instance data area, so other checking is unneeded
                if (instanceLoc.setURL(workspaceUrl, true)) {
                    launchData.writePersistedData();
                    writeWorkspaceVersion();
                    return null;
                }
            } catch (IllegalStateException e) {
View Full Code Here

     * Write the version of the metadata into a known file overwriting any
     * existing file contents. Writing the version file isn't really crucial,
     * so the function is silent about failure
     */
    private static void writeWorkspaceVersion() {
        Location instanceLoc = Platform.getInstanceLocation();
        if (instanceLoc == null || instanceLoc.isReadOnly()) {
      return;
    }

        File versionFile = getVersionFile(instanceLoc.getURL(), true);
        if (versionFile == null) {
      return;
    }

        OutputStream output = null;
View Full Code Here

        }
        return matched;
    }

    public static IPath getBundleLocation(BundleContext context, String symbolicName, VersionRange range) {
        Location installLocation = Platform.getInstallLocation();
        Location configLocation = Platform.getConfigurationLocation();

        Bundle bundle = findBundle(context, symbolicName, range);
        if (bundle == null)
            return null;

        String location = bundle.getLocation();
        if (location.startsWith("file:")) { //$NON-NLS-1$
            location = location.substring(5);
        } else if (location.startsWith("reference:file:")) { //$NON-NLS-1$
            location = location.substring(15);
        }
        IPath bundlePath = new Path(location);
        if (bundlePath.isAbsolute())
            return bundlePath;

        // Try install location
        if (installLocation != null) {
            IPath installedBundlePath = new Path(installLocation.getURL().getFile()).append(bundlePath);
            if (installedBundlePath.toFile().exists())
                return installedBundlePath;
        }

        // Try config location
        if (configLocation != null) {
            IPath configuredBundlePath = new Path(configLocation.getURL().getFile()).append(bundlePath);
            if (configuredBundlePath.toFile().exists())
                return configuredBundlePath;
        }

        return null;
View Full Code Here

      throw new RuntimeException(e);
    }
    if (refs.isEmpty())
      return null;
    ServiceReference<Location> ref = refs.iterator().next();
    Location location = context.getService(ref);
    try {
      if (location == null)
        return null;
      URL root = location.getURL();
      if (root == null)
        return null;
      // strip off file: prefix from URL
      return new Path(root.toExternalForm().substring(5));
    } finally {
View Full Code Here

  }

  public IStorage getBaseDirectory() {
    if (userDir == null) {
      // Use the same directory as the Orion workspace
      Location instanceLoc = ConfiguratorActivator.getDefault().getInstanceLocation();
      userDir = new StorageFileSystem(instanceLoc.getURL().getFile());
    }
    return userDir;
  }
View Full Code Here

    if (location != null && initialized)
      return;
    Activator activator = Activator.getDefault();
    if (activator == null)
      throw new IllegalStateException(CommonMessages.activator_not_available);
    Location service = activator.getInstanceLocation();
    if (service == null)
      throw new IllegalStateException(CommonMessages.meta_noDataModeSpecified);
    try {
      URL url = service.getURL();
      if (url == null)
        throw new IllegalStateException(CommonMessages.meta_instanceDataUnspecified);
      // TODO assume the URL is a file:
      // Use the new File technique to ensure that the resultant string is
      // in the right format (e.g., leading / removed from /c:/foo etc)
View Full Code Here

   */
  private boolean isInstanceLocationSet() {
    Activator activator = Activator.getDefault();
    if (activator == null)
      return false;
    Location service = activator.getInstanceLocation();
    if (service == null)
      return false;
    return service.isSet();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.osgi.service.datalocation.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.