Пример #1
0
 @Override
 public String getSourceLocation() {
   IResource sourceResource;
   String sourceLocation = null;
   if (fFileSystemObject.isDirectory()) {
     sourceResource =
         ResourcesPlugin.getWorkspace()
             .getRoot()
             .getContainerForLocation(Path.fromOSString(fFileSystemObject.getAbsolutePath()));
   } else {
     sourceResource =
         ResourcesPlugin.getWorkspace()
             .getRoot()
             .getFileForLocation(Path.fromOSString(fFileSystemObject.getAbsolutePath()));
   }
   if (sourceResource != null && sourceResource.exists()) {
     try {
       sourceLocation = sourceResource.getPersistentProperty(TmfCommonConstants.SOURCE_LOCATION);
     } catch (CoreException e) {
       // Something went wrong with the already existing resource.
       // This is not a problem, we'll assign a new location below.
     }
   }
   if (sourceLocation == null) {
     try {
       sourceLocation = URIUtil.toUnencodedString(fFileSystemObject.getCanonicalFile().toURI());
     } catch (IOException e) {
       // Something went wrong canonicalizing the file. We can still
       // use the URI but there might be extra ../ in it.
       sourceLocation = URIUtil.toUnencodedString(fFileSystemObject.toURI());
     }
   }
   return sourceLocation;
 }
Пример #2
0
 public static void updateRepositoryUsingElements(
     final ProvisioningUI ui, final MetadataRepositoryElement[] elements) {
   ui.signalRepositoryOperationStart();
   IMetadataRepositoryManager metaManager = ProvUI.getMetadataRepositoryManager(ui.getSession());
   IArtifactRepositoryManager artManager = ProvUI.getArtifactRepositoryManager(ui.getSession());
   try {
     int visibilityFlags = ui.getRepositoryTracker().getMetadataRepositoryFlags();
     URI[] currentlyEnabled = metaManager.getKnownRepositories(visibilityFlags);
     URI[] currentlyDisabled =
         metaManager.getKnownRepositories(
             IRepositoryManager.REPOSITORIES_DISABLED | visibilityFlags);
     for (int i = 0; i < elements.length; i++) {
       URI location = elements[i].getLocation();
       if (elements[i].isEnabled()) {
         if (containsURI(currentlyDisabled, location))
           // It should be enabled and is not currently
           setColocatedRepositoryEnablement(ui, location, true);
         else if (!containsURI(currentlyEnabled, location)) {
           // It is not known as enabled or disabled.  Add it.
           metaManager.addRepository(location);
           artManager.addRepository(location);
         }
       } else {
         if (containsURI(currentlyEnabled, location))
           // It should be disabled, and is currently enabled
           setColocatedRepositoryEnablement(ui, location, false);
         else if (!containsURI(currentlyDisabled, location)) {
           // It is not known as enabled or disabled.  Add it and then disable it.
           metaManager.addRepository(location);
           artManager.addRepository(location);
           setColocatedRepositoryEnablement(ui, location, false);
         }
       }
       String name = elements[i].getName();
       if (name != null && name.length() > 0) {
         metaManager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
         artManager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
       }
     }
     // Are there any elements that need to be deleted?  Go over the original state
     // and remove any elements that weren't in the elements we were given
     Set<String> nowKnown = new HashSet<String>();
     for (int i = 0; i < elements.length; i++)
       nowKnown.add(URIUtil.toUnencodedString(elements[i].getLocation()));
     for (int i = 0; i < currentlyEnabled.length; i++) {
       if (!nowKnown.contains(URIUtil.toUnencodedString(currentlyEnabled[i]))) {
         metaManager.removeRepository(currentlyEnabled[i]);
         artManager.removeRepository(currentlyEnabled[i]);
       }
     }
     for (int i = 0; i < currentlyDisabled.length; i++) {
       if (!nowKnown.contains(URIUtil.toUnencodedString(currentlyDisabled[i]))) {
         metaManager.removeRepository(currentlyDisabled[i]);
         artManager.removeRepository(currentlyDisabled[i]);
       }
     }
   } finally {
     ui.signalRepositoryOperationComplete(null, true);
   }
 }
 /**
  * Returns the file path where the given resolved bundle can be found. Used to group bundles by
  * file path in the tree.
  *
  * @param bundle bundle to lookup parent path for
  * @return path of parent directory, if unknown it will be a path object containing "Unknown"
  */
 private IPath getParentPath(IResolvedBundle bundle) {
   URI location = bundle.getBundleInfo().getLocation();
   if (location == null) {
     return new Path(Messages.TargetContentsGroup_8);
   }
   IPath path = new Path(URIUtil.toUnencodedString(location));
   path = path.removeLastSegments(1);
   return path;
 }
Пример #4
0
  public URI map(
      URI repositoryLocation, String classifier, String id, String version, String format) {
    String locationString = URIUtil.toUnencodedString(repositoryLocation);
    Dictionary<String, Object> values = new Hashtable<String, Object>(5);
    if (repositoryLocation != null) values.put(REPOURL, locationString);

    if (classifier != null) values.put(CLASSIFIER, classifier);

    if (id != null) values.put(ID, id);

    if (version != null) values.put(VERSION, version);

    if (format != null) values.put(FORMAT, format);

    for (int i = 0; i < filters.length; i++) {
      if (filters[i].match(values))
        return doReplacement(outputStrings[i], locationString, classifier, id, version, format);
    }
    return null;
  }
  protected void scheduleExportJob() {
    // NOTE: Any changes to the content here must also be copied to generateAntTask() and
    // FeatureExportTask
    final FeatureExportInfo info = new FeatureExportInfo();
    info.toDirectory = fPage.doExportToDirectory();
    info.useJarFormat = fPage.useJARFormat();
    info.exportSource = fPage.doExportSource();
    info.exportSourceBundle = fPage.doExportSourceBundles();
    info.allowBinaryCycles = fPage.allowBinaryCycles();
    info.useWorkspaceCompiledClasses = fPage.useWorkspaceCompiledClasses();
    info.destinationDirectory = fPage.getDestination();
    info.zipFileName = fPage.getFileName();
    if (fPage2 != null && ((FeatureExportWizardPage) fPage).doMultiPlatform())
      info.targets = fPage2.getTargets();
    info.exportMetadata = ((FeatureExportWizardPage) fPage).doExportMetadata();
    info.items = fPage.getSelectedItems();
    info.signingInfo = fPage.getSigningInfo();
    info.jnlpInfo = ((FeatureExportWizardPage) fPage).getJNLPInfo();
    info.qualifier = fPage.getQualifier();
    if (((FeatureExportWizardPage) fPage).getCategoryDefinition() != null)
      info.categoryDefinition =
          URIUtil.toUnencodedString(((FeatureExportWizardPage) fPage).getCategoryDefinition());

    final boolean installAfterExport = fPage.doInstall();
    if (installAfterExport) {
      info.useJarFormat = true;
      info.exportMetadata = true;
      if (info.qualifier == null) {
        // Set the date explicitly since the time can change before the install job runs
        info.qualifier = QualifierReplacer.getDateQualifier();
      }
    }

    final FeatureExportOperation job =
        new FeatureExportOperation(info, PDEUIMessages.FeatureExportJob_name);
    job.setUser(true);
    job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ);
    job.addJobChangeListener(
        new JobChangeAdapter() {
          public void done(IJobChangeEvent event) {
            if (job.hasAntErrors()) {
              // If there were errors when running the ant scripts, inform the user where the logs
              // can be found.
              final File logLocation =
                  new File(info.destinationDirectory, "logs.zip"); // $NON-NLS-1$
              if (logLocation.exists()) {
                PlatformUI.getWorkbench()
                    .getDisplay()
                    .syncExec(
                        new Runnable() {
                          public void run() {
                            AntErrorDialog dialog = new AntErrorDialog(logLocation);
                            dialog.open();
                          }
                        });
              }
            } else if (event.getResult().isOK() && installAfterExport) {
              // Install the export into the current running platform
              RuntimeInstallJob installJob =
                  new RuntimeInstallJob(PDEUIMessages.PluginExportWizard_InstallJobName, info);
              installJob.setUser(true);
              installJob.setProperty(
                  IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ);
              installJob.schedule();
            }
          }
        });
    job.schedule();
  }