Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.MultiStatus


        this.model = model;
        this.callbacks = callbacks;
    }

    public void run(IProgressMonitor monitor) {
        MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, 0, Messages.ResolveOperation_errorOverview, null);

        // Start a coordination
        BundleContext bc = Plugin.getDefault().getBundleContext();
        ServiceReference coordSvcRef = bc.getServiceReference(Coordinator.class.getName());
        Coordinator coordinator = coordSvcRef != null ? (Coordinator) bc.getService(coordSvcRef) : null;
        Coordination coordination = coordinator != null ? coordinator.begin(ResolveOperation.class.getName(), 0) : null;

        // Begin resolve
        ResolveProcess resolve = new ResolveProcess();
        ResolverLogger logger = new ResolverLogger();
        try {
            ResolverImpl felixResolver = new ResolverImpl(logger);

            ReporterLogService log = new ReporterLogService(Central.getWorkspace());
            Map<Resource,List<Wire>> wirings = resolve.resolveRequired(model, Central.getWorkspace(), felixResolver, callbacks, log);
            result = new ResolutionResult(Outcome.Resolved, wirings, null, status, logger.getLog());
            if (coordination != null)
                coordination.end();
        } catch (ResolveCancelledException e) {
            result = new ResolutionResult(Outcome.Cancelled, null, null, status, logger.getLog());

            if (coordination != null)
                coordination.fail(e);
        } catch (ResolutionException e) {
            status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, e.getLocalizedMessage(), e));
            result = new ResolutionResult(Outcome.Unresolved, null, null, status, logger.getLog());

            if (coordination != null)
                coordination.fail(e);
        } catch (Exception e) {
            status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Exception during resolution.", e));
            result = new ResolutionResult(Outcome.Error, null, null, status, logger.getLog());

            if (coordination != null)
                coordination.fail(e);
        } finally {
View Full Code Here


    private static void generatePackageInfos(final Collection< ? extends File> pkgDirs) throws CoreException {
        final IWorkspaceRunnable wsOperation = new IWorkspaceRunnable() {
            public void run(IProgressMonitor monitor) throws CoreException {
                SubMonitor progress = SubMonitor.convert(monitor, pkgDirs.size());
                MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, 0, "Errors occurred while creating packageinfo files.", null);
                for (File pkgDir : pkgDirs) {
                    IContainer[] locations = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(pkgDir.toURI());
                    if (locations != null && locations.length > 0) {
                        IFile pkgInfoFile = locations[0].getFile(new Path(PACKAGEINFO));

                        try {
                            ByteArrayInputStream input = new ByteArrayInputStream("version 1.0".getBytes("UTF-8"));
                            pkgInfoFile.create(input, false, progress.newChild(1, 0));
                        } catch (CoreException e) {
                            status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error creating file " + pkgInfoFile.getFullPath(), e));
                        } catch (UnsupportedEncodingException e) {
                            /* just ignore, should never happen */
                        }
                    }
                }

                if (!status.isOK())
                    throw new CoreException(status);
            }
        };
        IRunnableWithProgress uiOperation = new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
View Full Code Here

            indirectResources = new HashSet<SearchableRepository.ResourceDescriptor>(depsPage.getIndirectResources());
            indirectResources.removeAll(result);
        } else {
            indirectResources = Collections.<ResourceDescriptor> emptySet();
        }
        final MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, 0, "Errors occurred while processing JPM4J dependencies.", null);
        IRunnableWithProgress runnable = new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                SubMonitor progress = SubMonitor.convert(monitor, result.size() + indirectResources.size());
                progress.setTaskName("Processing dependencies...");

                // Process all resources (including non-selected ones) into the repository
                for (ResourceDescriptor resource : result)
                    processResource(resource, status, progress.newChild(1));
                for (ResourceDescriptor resource : indirectResources)
                    processResource(resource, status, progress.newChild(1));
            }
        };

        try {
            getContainer().run(true, true, runnable);

            if (!status.isOK())
                ErrorDialog.openError(getShell(), "Errors", null, status);

            return true;
        } catch (InvocationTargetException e) {
            MessageDialog.openError(getShell(), "Error", e.getCause().getMessage());
View Full Code Here

        logLevel = prefs.getBuildLogging();
        projectPrefs = new ScopedPreferenceStore(new ProjectScope(getProject()), BndtoolsConstants.CORE_PLUGIN_ID);

        // Prepare validations
        classpathErrors = new LinkedList<String>();
        validationResults = new MultiStatus(PLUGIN_ID, 0, "Validation errors in bnd project", null);
        buildLog = new ArrayList<String>(5);

        nrFilesBuilt = 0;

        try {
View Full Code Here

        addPage(fileSelectionPage);
    }

    @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 (Exception e) {
                status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Failed to analyse JAR: {0}", file.getPath()), e));
                continue;
            } finally {
                if (jar != null)
                    jar.close();
            }

            try {
                RepositoryPlugin.PutResult result = repository.put(new BufferedInputStream(new FileInputStream(file)), new RepositoryPlugin.PutOptions());
                if (result.artifact != null && result.artifact.getScheme().equals("file")) {
                    File newFile = new File(result.artifact);

                    RefreshFileJob refreshJob = new RefreshFileJob(newFile, false);
                    if (refreshJob.needsToSchedule())
                        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;
        }
        ErrorDialog.openError(getShell(), "Error", null, status);
        return false;
    }
View Full Code Here

        logLevel = prefs.getBuildLogging();
        projectPrefs = new ScopedPreferenceStore(new ProjectScope(getProject()), BndtoolsConstants.CORE_PLUGIN_ID);

        // Prepare validations
        classpathErrors = new LinkedList<String>();
        validationResults = new MultiStatus(PLUGIN_ID, 0, "Validation errors in bnd project", null);
        buildLog = new ArrayList<String>(5);

        try {
            // Prepare build listeners and build error handlers
            listeners = new BuildListeners();
View Full Code Here

            }

            if (!reports.isEmpty()) {
                IStatus[] reportsArray = new IStatus[reports.size()];
                reports.toArray(reportsArray);
                status = new MultiStatus(NewBuilder.PLUGIN_ID, 0, reportsArray, "Project paths mismatch" + (reports.size() > 1 ? "es" : ""), null);
            }
        } catch (Throwable e) {
            Logger.getLogger(this.getClass()).logError("Error during project paths validation", e);
        }
View Full Code Here

            }

            if (!reports.isEmpty()) {
                IStatus[] reportsArray = new IStatus[reports.size()];
                reports.toArray(reportsArray);
                status = new MultiStatus(NewBuilder.PLUGIN_ID, 0, reportsArray, "Project paths mismatch" + (reports.size() > 1 ? "es" : ""), null);
            }
        } catch (Throwable e) {
            Logger.getLogger(this.getClass()).logError("Error during java versions validation", e);
        }
View Full Code Here

  /**
   * Disconnect from the core workspace.
   */
  private void disconnectFromWorkspace() {
    // save the workspace
    final MultiStatus status = new MultiStatus(
        IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
        IDEWorkbenchMessages.ProblemSavingWorkbench, null);
    try {
      final ProgressMonitorJobsDialog p = new CancelableProgressMonitorJobsDialog(
          null);

      final boolean applyPolicy = ResourcesPlugin.getWorkspace()
          .getDescription().isApplyFileStatePolicy();

      IRunnableWithProgress runnable = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
          try {
            if (applyPolicy)
              monitor = new CancelableProgressMonitorWrapper(
                  monitor, p);

            status.merge(((Workspace) ResourcesPlugin
                .getWorkspace()).save(true, true, monitor));
          } catch (CoreException e) {
            status.merge(e.getStatus());
          }
        }
      };

      p.run(true, false, runnable);
    } catch (InvocationTargetException e) {
      status
          .merge(new Status(IStatus.ERROR,
              IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
              IDEWorkbenchMessages.InternalError, e
                  .getTargetException()));
    } catch (InterruptedException e) {
      status.merge(new Status(IStatus.ERROR,
          IDEWorkbenchPlugin.IDE_WORKBENCH, 1,
          IDEWorkbenchMessages.InternalError, e));
    }
    ErrorDialog.openError(null,
        IDEWorkbenchMessages.ProblemsSavingWorkspace, null, status,
        IStatus.ERROR | IStatus.WARNING);
    if (!status.isOK()) {
      IDEWorkbenchPlugin.log(
          IDEWorkbenchMessages.ProblemsSavingWorkspace, status);
    }
  }
View Full Code Here

        job.schedule();
        return true;
    }

    private IStatus performFinishAddFiles(IProgressMonitor monitor) {
        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>>();
        monitor.beginTask("Processing files", files.size());
        for (File file : files) {
            monitor.subTask(file.getName());

            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 (Exception e) {
                status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Failed to analyse JAR: {0}", file.getPath()), e));
                continue;
            } finally {
                if (jar != null)
                    jar.close();
            }

            try {
                RepositoryPlugin.PutResult result = repository.put(new BufferedInputStream(new FileInputStream(file)), new RepositoryPlugin.PutOptions());
                if (result.artifact != null && result.artifact.getScheme().equals("file")) {
                    File newFile = new File(result.artifact);

                    RefreshFileJob refreshJob = new RefreshFileJob(newFile, false);
                    if (refreshJob.needsToSchedule())
                        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;
            }
            monitor.worked(1);
        }
        return status;
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.MultiStatus

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.