@Override
  public void revertChanges(ISemanticFileStore semanticFileStore, IProgressMonitor monitor)
      throws CoreException {

    MultiStatus status =
        new MultiStatus(
            TestPlugin.PLUGIN_ID,
            IStatus.OK,
            NLS.bind("Revert Change Result for {0}", semanticFileStore.getPath().toString()),
            null);
    dropCache(
        semanticFileStore,
        monitor,
        new IDropCacheVisitor() {

          public boolean shouldDrop(ISemanticFileStore store) {
            // TODO only files
            return !store.isLocalOnly();
          }
        },
        status);

    if (!status.isOK()) {
      throw new CoreException(status);
    }

    // this can only happen on files, no recursion
    this.setReadOnly(semanticFileStore, true, monitor);

    fillCache(semanticFileStore, monitor, status);

    if (!status.isOK()) {
      throw new CoreException(status);
    }
  }
 /*
  * @see IWorkspaceRunnable#run(IProgressMonitor)
  */
 public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
   if (monitor == null) {
     monitor = new NullProgressMonitor();
   }
   monitor.beginTask(MDEUIMessages.FeatureImportWizard_operation_creating, fModels.length);
   try {
     MultiStatus multiStatus =
         new MultiStatus(
             MDEPlugin.getPluginId(),
             IStatus.OK,
             MDEUIMessages.FeatureImportWizard_operation_multiProblem,
             null);
     for (int i = 0; i < fModels.length; i++) {
       try {
         createProject(fModels[i], new SubProgressMonitor(monitor, 1));
       } catch (CoreException e) {
         multiStatus.merge(e.getStatus());
       }
       if (monitor.isCanceled()) {
         throw new OperationCanceledException();
       }
     }
     if (!multiStatus.isOK()) {
       throw new CoreException(multiStatus);
     }
   } finally {
     monitor.done();
   }
 }
Esempio n. 3
0
  private void unzip(IProject project, IProgressMonitor monitor) throws IOException, CoreException {
    MultiStatus multiStatus =
        new MultiStatus(
            Activator.PLUGIN_ID, IStatus.OK, "Error(s) in setup mruby environment.", null);

    URL url = Activator.getContext().getBundle().getEntry("sources.zip");
    ZipInputStream zist = new ZipInputStream(url.openStream());
    ZipEntry zipEntry;
    while ((zipEntry = zist.getNextEntry()) != null) {
      try {
        String name = zipEntry.getName();
        if (zipEntry.isDirectory()) {
          unzipFolder(name, project, monitor);
        } else {
          unzipFile(name, project, zist, monitor);
        }
      } catch (CoreException e) {
        multiStatus.add(e.getStatus());
      }
      zist.closeEntry();
    }

    if (!multiStatus.isOK()) {
      throw new CoreException(multiStatus);
    }
  }
Esempio n. 4
0
 private void addToErrors(String label, List<Exception> exceptions, List<IStatus> errors) {
   MultiStatus status = new MultiStatus(PortfolioPlugin.PLUGIN_ID, IStatus.ERROR, label, null);
   for (Exception exception : exceptions)
     status.add(
         new Status(IStatus.ERROR, PortfolioPlugin.PLUGIN_ID, exception.getMessage(), exception));
   errors.add(status);
 }
  private IStatus generateFolder(String folderPath) {
    MultiStatus status =
        new MultiStatus(Plugin.PLUGIN_ID, 0, "Errors occurred during exporting.", null);

    File folder = new File(folderPath);
    File bundleFolder = new File(folder, "bundles");

    bundleFolder.mkdirs();
    if (!bundleFolder.exists()) {
      status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Unable to create folder.", null));
      return status;
    }

    ProjectLauncher launcher = null;
    try {
      launcher = bndProject.getProjectLauncher();
    } catch (Exception e) {
      status.add(
          new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error getting project launcher.", e));
    }

    // Init classpath and launch JAR
    generateLauncherJar(launcher, folder, status);
    copyRunBundles(launcher, folder, status);

    return status;
  }
  private void copyRunBundles(ProjectLauncher launcher, File folder, MultiStatus status) {
    Collection<String> bundles = launcher.getRunBundles();
    List<String> names = new ArrayList<String>(bundles.size());

    for (String bundle : bundles) {
      File bundleFile = new File(bundle);
      String name = "bundles/" + bundleFile.getName();
      File destFile = new File(folder, name);

      try {
        IO.copy(bundleFile, destFile);
        names.add(name);
      } catch (IOException e) {
        status.add(
            new Status(
                IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error copying run bundle: " + bundle, e));
      }
    }

    try {
      Properties launcherProps = new Properties();
      launcherProps.put(aQute.lib.osgi.Constants.RUNBUNDLES, Processor.join(names, ",\\\n  "));
      launcherProps.store(
          new FileOutputStream(new File(folder, "launch.properties")), "launch.properties");
    } catch (IOException e) {
      status.add(
          new Status(
              IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error generating launch properties file.", e));
    }
  }
  @Override
  protected void okPressed() {
    Iterator settingsIterator = selectedSettings.iterator();
    MultiStatus result =
        new MultiStatus(
            PlatformUI.PLUGIN_ID,
            IStatus.OK,
            IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_ProblemsTransferTitle,
            null);

    IPath path = new Path(getWorkspaceLocation());
    String[] selectionIDs = new String[selectedSettings.size()];
    int index = 0;

    while (settingsIterator.hasNext()) {
      IConfigurationElement elem = (IConfigurationElement) settingsIterator.next();
      result.add(transferSettings(elem, path));
      selectionIDs[index] = elem.getAttribute(ATT_ID);
    }
    if (result.getSeverity() != IStatus.OK) {
      ErrorDialog.openError(
          getShell(),
          IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_TransferFailedMessage,
          IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_SaveSettingsFailed,
          result);
      return;
    }

    saveSettings(selectionIDs);
    super.okPressed();
  }
 private void handleFinishedDropMove(DragSourceEvent event) {
   MultiStatus status =
       new MultiStatus(
           JavaScriptPlugin.getPluginId(),
           IJavaStatusConstants.INTERNAL_ERROR,
           JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_resource,
           null);
   List resources = convertSelection();
   for (Iterator iter = resources.iterator(); iter.hasNext(); ) {
     IResource resource = (IResource) iter.next();
     try {
       resource.delete(true, null);
     } catch (CoreException e) {
       status.add(e.getStatus());
     }
   }
   if (status.getChildren().length > 0) {
     Shell parent = SWTUtil.getShell(event.widget);
     ErrorDialog error =
         new ErrorDialog(
             parent,
             JavaUIMessages.ResourceTransferDragAdapter_moving_resource,
             JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_files,
             status,
             IStatus.ERROR);
     error.open();
   }
 }
  /**
   * Perform organize import on multiple compilation units. No editors are opened.
   *
   * @param cus The compilation units to run on
   */
  public void runOnMultiple(final ICompilationUnit[] cus) {
    try {
      String message =
          "Problems while organizing imports on some compilation units. See 'Details' for more information.";
      final MultiStatus status = new MultiStatus(JavaUI.ID_PLUGIN, IStatus.OK, message, null);

      IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
      progressService.run(
          true,
          true,
          new WorkbenchRunnableAdapter(
              new IWorkspaceRunnable() {
                public void run(IProgressMonitor monitor) {
                  doRunOnMultiple(cus, status, monitor);
                }
              })); // workspace lock
      if (!status.isOK()) {
        String title = "Organize Imports";
        ErrorDialog.openError(getShell(), title, null, status);
      }
    } catch (InvocationTargetException e) {
      ExceptionHandler.handle(
          e,
          getShell(),
          ActionMessages.OrganizeImportsAction_error_title,
          ActionMessages.OrganizeImportsAction_error_message);
    } catch (InterruptedException e) {
      // Canceled by user
    }
  }
Esempio n. 10
0
 public static IStatus createStatusWithStackTrace(String message, Throwable e) {
   MultiStatus multi = new MultiStatus(PLUGIN_ID, Status.OK, message, e);
   for (int i = 0; i < e.getStackTrace().length; i++) {
     multi.add(createStatus(e.getStackTrace()[i].toString(), null));
   }
   return multi;
 }
Esempio n. 11
0
  private void runOnMultiple(final ICompilationUnit[] cus) {
    ICleanUp[] cleanUps = getCleanUps(cus);
    if (cleanUps == null) return;

    MultiStatus status =
        new MultiStatus(
            JavaUI.ID_PLUGIN, IStatus.OK, ActionMessages.CleanUpAction_MultiStateErrorTitle, null);
    for (int i = 0; i < cus.length; i++) {
      ICompilationUnit cu = cus[i];

      if (!ActionUtil.isOnBuildPath(cu)) {
        String cuLocation = BasicElementLabels.getPathLabel(cu.getPath(), false);
        String message =
            Messages.format(ActionMessages.CleanUpAction_CUNotOnBuildpathMessage, cuLocation);
        status.add(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, IStatus.ERROR, message, null));
      }
    }
    if (!status.isOK()) {
      ErrorDialog.openError(getShell(), getActionName(), null, status);
      return;
    }

    try {
      performRefactoring(cus, cleanUps);
    } catch (InvocationTargetException e) {
      JavaPlugin.log(e);
      if (e.getCause() instanceof CoreException) showUnexpectedError((CoreException) e.getCause());
    }
  }
Esempio n. 12
0
 private static IStatus addOutOfSync(IStatus status, IResource resource) {
   IStatus entry =
       new Status(
           IStatus.ERROR,
           ResourcesPlugin.PI_RESOURCES,
           IResourceStatus.OUT_OF_SYNC_LOCAL,
           Messages.format(CorextMessages.Resources_outOfSync, resource.getFullPath().toString()),
           null);
   if (status == null) {
     return entry;
   } else if (status.isMultiStatus()) {
     ((MultiStatus) status).add(entry);
     return status;
   } else {
     MultiStatus result =
         new MultiStatus(
             ResourcesPlugin.PI_RESOURCES,
             IResourceStatus.OUT_OF_SYNC_LOCAL,
             CorextMessages.Resources_outOfSyncResources,
             null);
     result.add(status);
     result.add(entry);
     return result;
   }
 }
  /** Initializes TestRun Listener extensions */
  private void loadTestRunListeners() {
    fLegacyTestRunListeners = new ArrayList();
    IExtensionPoint extensionPoint =
        Platform.getExtensionRegistry().getExtensionPoint(ID_EXTENSION_POINT_TESTRUN_LISTENERS);
    if (extensionPoint == null) {
      return;
    }
    IConfigurationElement[] configs = extensionPoint.getConfigurationElements();
    MultiStatus status =
        new MultiStatus(
            PLUGIN_ID,
            IStatus.OK,
            "Could not load some testRunner extension points",
            null); //$NON-NLS-1$

    for (int i = 0; i < configs.length; i++) {
      try {
        Object testRunListener = configs[i].createExecutableExtension("class"); // $NON-NLS-1$
        if (testRunListener instanceof ITestRunListener) {
          fLegacyTestRunListeners.add(testRunListener);
        }
      } catch (CoreException e) {
        status.add(e.getStatus());
      }
    }
    if (!status.isOK()) {
      PHPUnitPlugin.getDefault().getLog().log(status);
    }
  }
Esempio n. 14
0
  private void scheduleIndexMaintenance(MaintainIndexType type) {
    long delay = 0L;
    switch (type) {
      case STARTUP:
        delay = startupDelay;
        break;
      case REINDEX:
        delay = reindexDelay;
    }

    if (delay == 0L) {
      // primarily for testing purposes

      maintainIndexJob.cancel();
      try {
        maintainIndexJob.join();
      } catch (InterruptedException e) {
        // ignore
      }
      try {
        maintainIndex(new NullProgressMonitor());
      } catch (CoreException e) {
        MultiStatus logStatus =
            new MultiStatus(
                TasksIndexCore.ID_PLUGIN,
                0,
                "Failed to update task list index", //$NON-NLS-1$
                e);
        logStatus.add(e.getStatus());
        StatusHandler.log(logStatus);
      }
    } else {
      maintainIndexJob.schedule(delay);
    }
  }
  /**
   * Compiles the given list of Acceleo parser messages into a single MultiStatus.
   *
   * @param errors List of the errors that arose during the compilation.
   * @param warnings List of the warnings that arose during the compilation.
   * @param infos List of the infos that arose during the compilation.
   * @return A single MultiStatus referenging all issues.
   */
  private IStatus parseProblems(
      AcceleoParserProblems errors, AcceleoParserWarnings warnings, AcceleoParserInfos infos) {
    List<IStatus> problems = new ArrayList<IStatus>();

    for (AcceleoParserProblem error : errors.getList()) {
      problems.add(new Status(IStatus.ERROR, AcceleoUIActivator.PLUGIN_ID, error.getMessage()));
    }
    for (AcceleoParserWarning warning : warnings.getList()) {
      problems.add(new Status(IStatus.WARNING, AcceleoUIActivator.PLUGIN_ID, warning.getMessage()));
    }
    for (AcceleoParserInfo info : infos.getList()) {
      problems.add(new Status(IStatus.INFO, AcceleoUIActivator.PLUGIN_ID, info.getMessage()));
    }

    if (problems.isEmpty()) {
      return null;
    }

    MultiStatus status =
        new MultiStatus(
            AcceleoUIActivator.PLUGIN_ID,
            1,
            AcceleoUIMessages.getString("acceleo.interpreter.compilation.issue"),
            null); //$NON-NLS-1$
    for (IStatus child : problems) {
      status.add(child);
    }
    return status;
  }
  private void generateLauncherJar(ProjectLauncher launcher, File folder, MultiStatus status) {
    Jar launcherJar = new Jar("launch");

    // Merge in the classpath JARs
    Collection<String> classpath = launcher.getClasspath();
    for (String classpathEntry : classpath) {
      try {
        Jar classpathJar = new Jar(new File(classpathEntry));
        launcherJar.addAll(classpathJar);
      } catch (IOException e) {
        status.add(
            new Status(
                IStatus.ERROR,
                Plugin.PLUGIN_ID,
                0,
                String.format("Failed to add classpath JAR '%s'.", classpathEntry),
                e));
      }
    }

    // Set the Main-Class
    Manifest manifest = new Manifest();
    manifest.getMainAttributes().putValue("Main-Class", "launch");
    launcherJar.setManifest(manifest);
    launcherJar.putResource(
        "launch.class",
        new URLResource(ExecutableJarExportWizard.class.getResource("launch.clazz")));

    try {
      launcherJar.write(new File(folder, "launch.jar"));
    } catch (Exception e) {
      status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error generating launch JAR.", e));
    }
  }
Esempio n. 17
0
 private static IStatus addOutOfSync(IStatus status, IResource resource) {
   IStatus entry =
       new Status(
           IStatus.ERROR,
           ResourcesPlugin.PI_RESOURCES,
           IResourceStatus.OUT_OF_SYNC_LOCAL,
           Messages.format(
               JUnitMessages.Resources_outOfSync,
               BasicElementLabels.getPathLabel(resource.getFullPath(), false)),
           null);
   if (status == null) {
     return entry;
   } else if (status.isMultiStatus()) {
     ((MultiStatus) status).add(entry);
     return status;
   } else {
     MultiStatus result =
         new MultiStatus(
             ResourcesPlugin.PI_RESOURCES,
             IResourceStatus.OUT_OF_SYNC_LOCAL,
             JUnitMessages.Resources_outOfSyncResources,
             null);
     result.add(status);
     result.add(entry);
     return result;
   }
 }
 public IStatus toStatus() {
   MultiStatus result =
       new MultiStatus(
           Main.PLUGIN_ID, 1, NLS.bind(Messages.Explanation_singleton, ""), null); // $NON-NLS-1$
   for (int i = 0; i < ius.length; i++)
     result.add(new Status(IStatus.ERROR, Main.PLUGIN_ID, getUserReadableName(ius[i])));
   return result;
 }
  public static IStatus collectProposals(
      IInvocationContext context,
      IAnnotationModel model,
      Annotation[] annotations,
      boolean addQuickFixes,
      boolean addQuickAssists,
      Collection<IDartCompletionProposal> proposals) {
    List<ProblemLocation> problems = Lists.newArrayList();

    // collect problem locations and corrections from marker annotations
    for (int i = 0; i < annotations.length; i++) {
      Annotation curr = annotations[i];
      ProblemLocation problemLocation = null;
      if (curr instanceof IJavaAnnotation) {
        problemLocation = getProblemLocation((IJavaAnnotation) curr, model);
        if (problemLocation != null) {
          problems.add(problemLocation);
        }
      }
      if (problemLocation == null && addQuickFixes && curr instanceof SimpleMarkerAnnotation) {
        collectMarkerProposals((SimpleMarkerAnnotation) curr, proposals);
      }
    }
    MultiStatus resStatus = null;

    IProblemLocation[] problemLocations = problems.toArray(new IProblemLocation[problems.size()]);
    if (addQuickFixes) {
      IStatus status = collectCorrections(context, problemLocations, proposals);
      if (!status.isOK()) {
        resStatus =
            new MultiStatus(
                DartUI.ID_PLUGIN,
                IStatus.ERROR,
                CorrectionMessages.JavaCorrectionProcessor_error_quickfix_message,
                null);
        resStatus.add(status);
      }
    }

    if (addQuickAssists) {
      IStatus status = collectAssists(context, problemLocations, proposals);
      if (!status.isOK()) {
        if (resStatus == null) {
          resStatus =
              new MultiStatus(
                  DartUI.ID_PLUGIN,
                  IStatus.ERROR,
                  CorrectionMessages.JavaCorrectionProcessor_error_quickassist_message,
                  null);
        }
        resStatus.add(status);
      }
    }
    if (resStatus != null) {
      return resStatus;
    }
    return Status.OK_STATUS;
  }
Esempio n. 20
0
 public static void logErrorStatus(String aMessage, IStatus aStatus) {
   if (aStatus == null) {
     logErrorMessage(aMessage);
   } else {
     MultiStatus multi = new MultiStatus(getPluginId(), IStatus.OK, aMessage, null);
     multi.add(aStatus);
     log(multi);
   }
 }
 @Override
 protected IStatus run(IProgressMonitor monitor) {
   MultiStatus result =
       new MultiStatus(
           ResourcesPlugin.PI_RESOURCES,
           IResourceStatus.FAILED_SETTING_CHARSET,
           Messages.resources_updatingEncoding,
           null);
   monitor = Policy.monitorFor(monitor);
   try {
     monitor.beginTask(Messages.resources_charsetUpdating, Policy.totalWork);
     final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(workspace.getRoot());
     try {
       workspace.prepareOperation(rule, monitor);
       workspace.beginOperation(true);
       Map.Entry<IProject, Boolean> next;
       while ((next = getNextChange()) != null) {
         // just exit if the system is shutting down or has been shut down
         // it is too late to change the workspace at this point anyway
         if (systemBundle.getState() != Bundle.ACTIVE) return Status.OK_STATUS;
         IProject project = next.getKey();
         try {
           if (project.isAccessible()) {
             boolean shouldDisableCharsetDeltaJob = next.getValue().booleanValue();
             // flush preferences for non-derived resources
             flushPreferences(
                 getPreferences(project, false, false, true), shouldDisableCharsetDeltaJob);
             // flush preferences for derived resources
             flushPreferences(
                 getPreferences(project, false, true, true), shouldDisableCharsetDeltaJob);
           }
         } catch (BackingStoreException e) {
           // we got an error saving
           String detailMessage = Messages.resources_savingEncoding;
           result.add(
               new ResourceStatus(
                   IResourceStatus.FAILED_SETTING_CHARSET,
                   project.getFullPath(),
                   detailMessage,
                   e));
         }
       }
       monitor.worked(Policy.opWork);
     } catch (OperationCanceledException e) {
       workspace.getWorkManager().operationCanceled();
       throw e;
     } finally {
       workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork));
     }
   } catch (CoreException ce) {
     return ce.getStatus();
   } finally {
     monitor.done();
   }
   return result;
 }
Esempio n. 22
0
 public static void logErrorStatus(final String message, final IStatus status) {
   if (status == null) {
     logErrorMessage(message);
     return;
   }
   final MultiStatus multi =
       new MultiStatus(PLUGIN_ID, ErlangStatus.INTERNAL_ERROR.getValue(), message, null);
   multi.add(status);
   log(multi);
 }
 public static void logErrorStatus(String message, IStatus status) {
   if (status == null) {
     logErrorMessage(message);
     return;
   }
   MultiStatus multi =
       new MultiStatus(getPluginId(), IStatusConstants.INTERNAL_ERROR, message, null);
   multi.add(status);
   log(multi);
 }
Esempio n. 24
0
 public static void logErrorStatus(String message, IStatus status) {
   if (status == null) {
     DLTKUIPlugin.logErrorMessage(message);
     return;
   }
   MultiStatus multi =
       new MultiStatus(DLTKUIPlugin.PLUGIN_ID, IDLTKStatusConstants.INTERNAL_ERROR, message, null);
   multi.add(status);
   DLTKUIPlugin.log(multi);
 }
Esempio n. 25
0
 @Override
 protected IStatus run(IProgressMonitor monitor) {
   status =
       new MultiStatus(
           ITasksCoreConstants.ID_PLUGIN,
           IStatus.OK,
           "Problems occurred while deleting repository tasks",
           null); //$NON-NLS-1$
   try {
     monitor.beginTask(Messages.DeleteTasksJob_Deleting_tasks, tasksToDelete.size() * 100);
     for (ITask task : tasksToDelete) {
       // delete the task on the server using the repository connector
       AbstractRepositoryConnector repositoryConnector =
           repositoryManager.getRepositoryConnector(task.getConnectorKind());
       TaskRepository repository =
           repositoryManager.getRepository(task.getConnectorKind(), task.getRepositoryUrl());
       if (repositoryConnector.canDeleteTask(repository, task)) {
         try {
           repositoryConnector.deleteTask(repository, task, subMonitorFor(monitor, 100));
         } catch (OperationCanceledException e) {
           return Status.CANCEL_STATUS;
         } catch (Exception e) {
           String taskId = task.getTaskKey();
           if (taskId == null) {
             taskId = task.getTaskId();
           }
           status.add(
               new Status(
                   IStatus.ERROR,
                   ITasksCoreConstants.ID_PLUGIN,
                   NLS.bind(
                       "Problems occurred while deleting {0} from {1}.",
                       taskId, task.getRepositoryUrl()),
                   e)); //$NON-NLS-1$
         } catch (LinkageError e) {
           String taskId = task.getTaskKey();
           if (taskId == null) {
             taskId = task.getTaskId();
           }
           status.add(
               new Status(
                   IStatus.ERROR,
                   ITasksCoreConstants.ID_PLUGIN,
                   NLS.bind(
                       "Internal Error occurred while deleting {0} from {1}.",
                       taskId, task.getRepositoryUrl()),
                   e)); //$NON-NLS-1$
         }
       }
     }
   } finally {
     monitor.done();
   }
   return Status.OK_STATUS;
 }
Esempio n. 26
0
 /**
  * Throws a core exception with an error status object built from the given message, lower level
  * exception, and error code.
  *
  * @param message the status message
  * @param exception lower level exception associated with the error, or <code>null</code> if none
  * @param code error code
  */
 private static void abort(String message, Throwable exception, int code) throws CoreException {
   MultiStatus status = new MultiStatus(GdbPlugin.PLUGIN_ID, code, message, exception);
   status.add(
       new Status(
           IStatus.ERROR,
           GdbPlugin.PLUGIN_ID,
           code,
           exception == null ? "" : exception.getLocalizedMessage(), // $NON-NLS-1$
           exception));
   throw new CoreException(status);
 }
 public IStatus toStatus() {
   MultiStatus result =
       new MultiStatus(Main.PLUGIN_ID, 1, Messages.Explanation_unsatisfied, null);
   result.add(
       new Status(
           IStatus.ERROR,
           Main.PLUGIN_ID,
           NLS.bind(Messages.Explanation_from, getUserReadableName(iu))));
   result.add(new Status(IStatus.ERROR, Main.PLUGIN_ID, NLS.bind(Messages.Explanation_to, req)));
   return result;
 }
  @Override
  public boolean performFinish() {
    MultiStatus status =
        new MultiStatus(Plugin.PLUGIN_ID, 0, "Failed to install one or more bundles", null);

    List<File> files = fileSelectionPage.getFiles();
    selectedBundles = new LinkedList<Pair<String, String>>();
    for (File file : files) {
      Jar jar = null;
      try {
        jar = new Jar(file);
        jar.setDoNotTouchManifest();

        Attributes mainAttribs = jar.getManifest().getMainAttributes();
        String bsn = BundleUtils.getBundleSymbolicName(mainAttribs);
        String version = mainAttribs.getValue(Constants.BUNDLE_VERSION);
        if (version == null) version = "0";
        selectedBundles.add(Pair.newInstance(bsn, version));
      } catch (IOException e) {
        status.add(
            new Status(
                IStatus.ERROR,
                Plugin.PLUGIN_ID,
                0,
                MessageFormat.format("Failed to analyse JAR: {0}", file.getPath()),
                e));
        continue;
      }

      try {
        File newFile = repository.put(jar);

        RefreshFileJob refreshJob = new RefreshFileJob(newFile);
        if (refreshJob.isFileInWorkspace()) refreshJob.schedule();
      } catch (Exception e) {
        status.add(
            new Status(
                IStatus.ERROR,
                Plugin.PLUGIN_ID,
                0,
                MessageFormat.format("Failed to add JAR to repository: {0}", file.getPath()),
                e));
        continue;
      }
    }

    if (status.isOK()) {
      return true;
    } else {
      ErrorDialog.openError(getShell(), "Error", null, status);
      return false;
    }
  }
 protected IStatus run(IProgressMonitor monitor) {
   MultiStatus result =
       new MultiStatus(
           CSSContentProperties.CSSCORE_ID,
           IResourceStatus.FAILED_SETTING_CHARSET,
           CSSCoreMessages.CSSContentPropertiesManager_Updating,
           null);
   monitor = monitor == null ? new NullProgressMonitor() : monitor;
   try {
     monitor.beginTask(
         CSSCoreMessages.CSSContentPropertiesManager_Updating, asyncChanges.size());
     try {
       IProject next;
       while ((next = getNextChange()) != null) {
         // just exit if the system is shutting down or has
         // been shut down
         // it is too late to change the workspace at this
         // point anyway
         if (Platform.getBundle("org.eclipse.osgi").getState() != Bundle.ACTIVE) // $NON-NLS-1$
         return Status.OK_STATUS;
         try {
           // save the preferences nodes
           if (next.isAccessible()) {
             // save css profile preferences
             Preferences projectPrefs =
                 CSSContentProperties.getPreferences(
                     next, CSSContentProperties.CSS_PROFILE, false);
             if (projectPrefs != null) projectPrefs.flush();
           }
         } catch (BackingStoreException e) {
           // we got an error saving
           String detailMessage =
               NLS.bind(
                   CSSCoreMessages.CSSContentPropertiesManager_Problems_Updating,
                   next.getFullPath());
           result.add(
               new Status(
                   1 << (IResourceStatus.FAILED_SETTING_CHARSET % 100 / 33),
                   ResourcesPlugin.PI_RESOURCES,
                   IResourceStatus.FAILED_SETTING_CHARSET,
                   detailMessage,
                   e));
         }
       }
       monitor.worked(1);
     } catch (OperationCanceledException e) {
       throw e;
     }
   } finally {
     monitor.done();
   }
   return result;
 }
 private void recursiveDeleteTree(IPath path, IProgressMonitor monitor, MultiStatus status)
     throws IOException, ParseException {
   try {
     changeCurrentDir(path);
     FTPFile[] ftpFiles = listFiles(path, monitor);
     List<String> dirs = new ArrayList<String>();
     for (FTPFile ftpFile : ftpFiles) {
       String name = ftpFile.getName();
       if (".".equals(name) || "..".equals(name)) { // $NON-NLS-1$ //$NON-NLS-2$
         continue;
       }
       if (ftpFile.isDir()) {
         dirs.add(name);
         continue;
       }
       Policy.checkCanceled(monitor);
       monitor.subTask(path.append(name).toPortableString());
       try {
         ftpClient.delete(name);
       } catch (FTPException e) {
         status.add(
             new Status(
                 IStatus.ERROR,
                 FTPPlugin.PLUGIN_ID,
                 StringUtils.format(
                     Messages.FTPConnectionFileManager_deleting_failed,
                     path.append(name).toPortableString()),
                 e));
       }
       monitor.worked(1);
     }
     for (String name : dirs) {
       monitor.subTask(path.append(name).toPortableString());
       recursiveDeleteTree(path.append(name), monitor, status);
       Policy.checkCanceled(monitor);
       changeCurrentDir(path);
       Policy.checkCanceled(monitor);
       ftpClient.rmdir(name);
       monitor.worked(1);
     }
   } catch (IOException e) {
     throw e;
   } catch (Exception e) {
     status.add(
         new Status(
             IStatus.ERROR,
             FTPPlugin.PLUGIN_ID,
             StringUtils.format(
                 Messages.FTPConnectionFileManager_deleting_failed, path.toPortableString()),
             e));
   }
 }