Пример #1
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;
   }
 }
  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));
    }
  }
  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));
    }
  }
  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;
  }
Пример #5
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;
   }
 }
  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;
  }
Пример #7
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;
 }
 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;
    }
  }
 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));
   }
 }
  protected static MultiStatus createStatus(
      String message, List<String> errors, List<String> warnings) {
    MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, 0, message, null);

    for (String error : errors) {
      status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, error, null));
    }
    for (String warning : warnings) {
      status.add(new Status(IStatus.WARNING, Plugin.PLUGIN_ID, 0, warning, null));
    }

    return status;
  }
Пример #12
0
  public void testExtractRootCauseFromNestedMultiStatus() throws Exception {
    MultiStatus multiStatus =
        new MultiStatus("id0", 0, "Message", new FileNotFoundException("FNFE"));
    Status status1 = new Status(IStatus.WARNING, "id1", "Test", new IOException("IO"));
    Status status2 = new Status(IStatus.ERROR, "id2", "Test", new IOException("IO"));
    Status status3 = new Status(IStatus.ERROR, "id3", "Test", null);
    multiStatus.add(status1);
    multiStatus.add(status2);
    multiStatus.add(status3);

    IStatus status = extractRootCause(multiStatus);
    assertNotNull(status);
    assertEquals("id2", status.getPlugin());
  }
 @Override
 protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor) {
   SubMonitor sub = SubMonitor.convert(monitor, 1);
   if (currentRemedy != null) {
     request = currentRemedy.getRequest();
     sub.worked(1);
     return;
   }
   try {
     status.add(computeAllRemediations(sub.newChild(1)));
   } catch (OperationCanceledException e) {
     status.add(Status.CANCEL_STATUS);
   }
   determineBestSolutions();
 }
Пример #14
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);
    }
  }
Пример #15
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);
 }
Пример #16
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());
    }
  }
  @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();
   }
 }
Пример #19
0
  /**
   * 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;
  }
Пример #20
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);
    }
  }
  /** 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);
    }
  }
Пример #22
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;
 }
 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;
 }
 protected void changed(Resource target) {
   String message = NLS.bind(Messages.localstore_resourceIsOutOfSync, target.getFullPath());
   status.add(
       new ResourceStatus(IResourceStatus.OUT_OF_SYNC_LOCAL, target.getFullPath(), message));
   if (affectedResources == null) affectedResources = new ArrayList<Resource>(20);
   affectedResources.add(target);
   resourceChanged = true;
 }
Пример #25
0
 /**
  * Instantiate the applicable analysis modules and executes the analysis modules that are meant to
  * be automatically executed
  *
  * @return An IStatus indicating whether the analysis could be run successfully or not
  * @since 3.0
  */
 protected IStatus executeAnalysis() {
   MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
   Map<String, IAnalysisModuleHelper> modules =
       TmfAnalysisManager.getAnalysisModules(this.getClass());
   for (IAnalysisModuleHelper helper : modules.values()) {
     try {
       IAnalysisModule module = helper.newModule(this);
       fAnalysisModules.put(module.getId(), module);
       if (module.isAutomatic()) {
         status.add(module.schedule());
       }
     } catch (TmfAnalysisException e) {
       status.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
     }
   }
   return status;
 }
Пример #26
0
  private File findFramework(MultiStatus status) {
    String runFramework = model.getRunFramework();
    Map<String, Map<String, String>> header = OSGiHeader.parseHeader(runFramework);
    if (header.size() != 1) {
      status.add(
          new Status(
              IStatus.ERROR,
              Plugin.PLUGIN_ID,
              0,
              "Invalid format for " + BndConstants.RUNFRAMEWORK + " header",
              null));
      return null;
    }

    Entry<String, Map<String, String>> entry = header.entrySet().iterator().next();
    VersionedClause clause = new VersionedClause(entry.getKey(), entry.getValue());

    String versionRange = clause.getVersionRange();
    if (versionRange == null) versionRange = new Version(0, 0, 0).toString();

    try {
      Container container =
          getProject().getBundle(clause.getName(), versionRange, Strategy.HIGHEST, null);
      if (container.getType() == TYPE.ERROR) {
        status.add(
            new Status(
                IStatus.ERROR,
                Plugin.PLUGIN_ID,
                0,
                "Unable to find specified OSGi framework: " + container.getError(),
                null));
        return null;
      }
      return container.getFile();
    } catch (Exception e) {
      status.add(
          new Status(
              IStatus.ERROR,
              Plugin.PLUGIN_ID,
              0,
              "Error while trying to find the specified OSGi framework.",
              e));
      return null;
    }
  }
Пример #27
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);
   }
 }
Пример #28
0
 @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;
 }
 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);
 }
Пример #30
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);
 }