Exemplo n.º 1
0
 public static void saveResource() {
   if (isModified()) {
     String installLocation =
         new Path(Platform.getConfigurationLocation().getURL().getPath())
             .toFile()
             .getAbsolutePath();
     try {
       Resource resource = createComponentCacheResource(installLocation);
       resource.getContents().add(cache);
       EmfHelper.saveResource(cache.eResource());
     } catch (PersistenceException e1) {
       ExceptionHandler.process(e1);
     }
     ILibraryManagerService repositoryBundleService =
         (ILibraryManagerService)
             GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
     repositoryBundleService.clearCache();
     if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
       ILibrariesService libService =
           (ILibrariesService)
               GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
       if (libService != null) {
         libService.syncLibraries();
       }
     }
     setModified(false);
   }
 }
Exemplo n.º 2
0
 /**
  * Answer the configuration location for this plug-in.
  *
  * @param none
  * @return URI The GEM plugin's configuration directory (not <code>null</code>)
  */
 public URI getConfigDir() {
   final Location location = Platform.getConfigurationLocation();
   if (location != null) {
     final URL configURL = location.getURL();
     if (configURL != null && configURL.getProtocol().startsWith("file")) { // $NON-NLS-1$
       try {
         return configURL.toURI();
       } catch (final URISyntaxException e) {
         GemUtilities.logExceptionDetail(e);
       }
     }
   }
   return null;
 }
  /**
   * Tests that a target definition equivalent to the default target platform contains the same
   * bundles as the default target platform using the platform's configuration location (which will
   * do target weaving). This is really only tested when run as a JUnit plug-in test suite from
   * within Eclipse.
   *
   * @throws Exception
   */
  public void testWovenTargetPlatform() throws Exception {
    // the new way
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container =
        getTargetService()
            .newProfileLocation(
                TargetPlatform.getDefaultLocation(),
                new File(Platform.getConfigurationLocation().getURL().getFile()).getAbsolutePath());
    definition.setTargetLocations(new ITargetLocation[] {container});
    Set urls = getAllBundleURLs(definition);

    // the old way
    URL[] pluginPaths = PluginPathFinder.getPluginPaths(TargetPlatform.getDefaultLocation());
    assertEquals("Should have same number of bundles", pluginPaths.length, urls.size());
    for (int i = 0; i < pluginPaths.length; i++) {
      URL url = pluginPaths[i];
      assertTrue("Missing plug-in " + url.toString(), urls.contains(url));
    }
  }
 private static String getConfiguration() throws IOException {
   Location configLocation = Platform.getConfigurationLocation();
   URL configURL = configLocation.getURL();
   String configuration = FileLocator.resolve(configURL).getPath();
   return configuration;
 }