Package org.eclipse.osgi.service.datalocation

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


      return true;
    if (PluginConverterImpl.getTimeStamp(bundledata.getBundleFile().getBaseFile(), getManifestType()) == getManifestTimeStamp()) {
      if ((getManifestType() & (PluginConverterImpl.MANIFEST_TYPE_JAR | PluginConverterImpl.MANIFEST_TYPE_BUNDLE)) != 0)
        return true;
      String cacheLocation = FrameworkProperties.getProperty(LocationManager.PROP_MANIFEST_CACHE);
      Location parentConfiguration = LocationManager.getConfigurationLocation().getParentLocation();
      if (parentConfiguration != null) {
        try {
          return checkManifestAndParent(cacheLocation, bundledata.getSymbolicName(), bundledata.getVersion().toString(), getManifestType()) != null;
        } catch (BundleException e) {
          return false;
View Full Code Here


  private Headers checkManifestAndParent(String cacheLocation, String symbolicName, String version, byte inputType) throws BundleException {
    Headers result = basicCheckManifest(cacheLocation, symbolicName, version, inputType);
    if (result != null)
      return result;
    Location parentConfiguration = null;
    if ((parentConfiguration = LocationManager.getConfigurationLocation().getParentLocation()) != null)
      result = basicCheckManifest(new File(parentConfiguration.getURL().getFile(), FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME + '/' + LocationManager.MANIFESTS_DIR).toString(), symbolicName, version, inputType);
    return result;
  }
View Full Code Here

  }

  private File getRSSOwlExecutable() {

    /* Retrieve Install Location */
    Location installLocation = Platform.getInstallLocation();
    if (installLocation == null || installLocation.getURL() == null)
      return null;

    /* Retrieve Program Dir as File Object */
    File programDir = toFile(installLocation.getURL());
    if (programDir == null || !programDir.isDirectory() || !programDir.exists())
      return null;

    /* Retrieve the RSSOwl Executable */
    File rssowlExe = new File(programDir, RSSOWL_EXE);
View Full Code Here

   */
  @SuppressWarnings("deprecation")
  @Override
  public void installCompleted(boolean success) throws CoreException {
    super.installCompleted(success);
    Location location = Platform.getInstallLocation();
    try {
      URL url = Platform.resolve(location.getURL());
      File installLocation = null;
      try {
        installLocation = new File(url.toURI());
      } catch(Exception e) {
        e.printStackTrace();
View Full Code Here

  private void setUserHome(String userHome) {
   
    SystemUtils.redefineUserHome(userHome);
   
    Location instanceLoc = Platform.getInstanceLocation();
    try {
      instanceLoc.set(new URL("file", null, SystemUtils.applicationDirectory), false); //$NON-NLS-1$
    } catch (Exception e) {
      Log.getInstance(CommandLineParser.class).error(e.getMessage());
    }
  }
View Full Code Here

   * @throws Exception Throws an exception if something wrong happens while setting the workspace location.
   */
  private boolean handleWorkspace(Display display) throws Exception{
    Shell shell = new Shell(display, SWT.ON_TOP);

    Location instanceLoc = Platform.getInstanceLocation();
    if(instanceLoc.isSet())
      return true;

    boolean switch_failed = false;
    if(SelectWorkspace.isSwitching()){
      String switchTo = SelectWorkspace.getSwitchingWS();
      if(switchTo == null || switchTo.isEmpty()){
        MessageDialog.openError(shell, "Error", "Error while switching workspace.");
        switch_failed = true;
      }else{
        String ret = SelectWorkspace.checkWorkspaceDirectory(Display.getDefault().getActiveShell(), switchTo, false, false);
        if (ret != null) {
          MessageDialog.openError(shell, "Error", "Error while switching workspace.\n" + ret);
          switch_failed = true;
        }
        instanceLoc.set(new URL("file", null, switchTo), false);
      }
      SelectWorkspace.resetSwitch();
      if(!switch_failed)
        return true;
    }
   
    boolean remember = SelectWorkspace.isRememberWorkspace();

    // get the last used workspace location
    String lastUsedWs = SelectWorkspace.getLastSetWorkspaceDirectory();

    // if we have a "remember" but no last used workspace, it's not much to remember
    if (remember && (lastUsedWs == null || lastUsedWs.isEmpty())) {
      remember = false;
    }

    // check to ensure the workspace location is still OK
    if (remember) {
      // if there's any problem whatsoever with the workspace, force a dialog which in its turn will tell them what's bad
      String ret = SelectWorkspace.checkWorkspaceDirectory(Display.getDefault().getActiveShell(), lastUsedWs, false, false);
      if (ret != null) {
        remember = false;
      }
    }
    // if we don't remember the workspace, show the dialog
    if (!remember || switch_failed) {
      SelectWorkspace dialog = new SelectWorkspace(shell);


      // if the user cancelled, we can't do anything as we need a workspace, so in this case, we tell them and exit
      if (dialog.open() == Window.CANCEL) {
        MessageDialog.openError(shell, "Error",
        "The application can not start without a workspace root and will now exit.");
        try {
          PlatformUI.getWorkbench().close();
        } catch (Exception err) {

        }
        return false;
      }
      // tell Eclipse what the selected location was and continue
      instanceLoc.set(new URL("file", null, dialog.getSelectedWorkspaceLocation()), false);
    }
    else {
      // set the last used location and continue
      instanceLoc.set(new URL("file", null, lastUsedWs), false);
    }
    return true;   

  }
View Full Code Here

      if (instance != null) {
        BundleContext ctx = instance.context;
        if (ctx != null) {
          ServiceReference[] refs = ctx.getServiceReferences(Location.class.getName(), Location.INSTANCE_FILTER);
          if (refs != null && refs.length == 1) {
            Location location = (Location) ctx.getService(refs[0]);
            if (location != null) {
              IPath instancePath = new Path(new File(location.getURL().getFile()).toString());
              ctx.ungetService(refs[0]);
              return instancePath.append(".metadata/.plugins").append(Policy.PI_FILE_SYSTEM); //$NON-NLS-1$
            }
          }
        }
View Full Code Here

    }
  }

  private synchronized static boolean loadData(String fileName) {
    try {
      Location location = configLocation;
      if (location == null)
        return false;
      File theStorageDir = new File(location.getURL().getPath() + '/' + Activator.PI_APP);
      if (storageManager == null) {
        boolean readOnly = location.isReadOnly();
        storageManager = new StorageManager(theStorageDir, readOnly ? "none" : null, readOnly); //$NON-NLS-1$
        storageManager.open(!readOnly);
      }
      File dataFile = storageManager.lookup(fileName, false);
      if (dataFile == null || !dataFile.isFile()) {
        Location parent = location.getParentLocation();
        if (parent != null) {
          theStorageDir = new File(parent.getURL().getPath() + '/' + Activator.PI_APP);
          StorageManager tmp = new StorageManager(theStorageDir, "none", true); //$NON-NLS-1$
          tmp.open(false);
          dataFile = tmp.lookup(fileName, false);
          tmp.close();
        }
View Full Code Here

    }
  }

  private boolean lockInstanceLocation() {
    try {
      Location workspaceLoc = Platform.getInstanceLocation();
      if (!workspaceLoc.isSet()) {
        // Use default
        workspaceLoc.set(workspaceLoc.getDefault(), false);
      }
      return workspaceLoc.lock();
    } catch (IOException e) {
      MessageDialog.openError(Display.getDefault().getActiveShell(),
          Messages.LogSawApplication_title_internalError,
          NLS.bind(Messages.LogSawApplication_message_internalError, e.getLocalizedMessage()));
      return false;
View Full Code Here

      throw new RuntimeException(e);
    }
    if (refs.isEmpty())
      throw new IOException("Framework instance location is undefined"); //$NON-NLS-1$
    ServiceReference<Location> ref = refs.iterator().next();
    Location location = context.getService(ref);
    try {
      if (location == null)
        throw new IOException("Framework instance location is undefined"); //$NON-NLS-1$
      URL root = location.getDataArea(ServerConstants.PI_SERVER_CORE);
      // strip off file: prefix from URL
      return new Path(root.toExternalForm().substring(5)).append("tasks"); //$NON-NLS-1$
    } finally {
      context.ungetService(ref);
    }
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.