Examples of MultiStatus


Examples of org.eclipse.core.runtime.MultiStatus

  /**
   * 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

Examples of org.eclipse.core.runtime.MultiStatus

        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

Examples of org.eclipse.core.runtime.MultiStatus

        return status.isOK();
    }

    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");

        if (!bundleFolder.exists() && !bundleFolder.mkdirs()) {
            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));
            return status;
        }

        // Init classpath and launch JAR
        generateLauncherJar(launcher, folder, status);
View Full Code Here

Examples of org.eclipse.core.runtime.MultiStatus

        return status;
    }

    private IStatus generateJar(String jarPath) {
        MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, 0, "Errors occurred during exporting.", null);
        try {
            ProjectLauncher launcher = bndProject.getProjectLauncher();
            Jar jar = launcher.executable();
            jar.write(jarPath);
        } catch (Exception e) {
            status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error generating executable JAR.", e));
        }
        return status;
    }
View Full Code Here

Examples of org.eclipse.core.runtime.MultiStatus

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

                        try {
                            ByteArrayInputStream input = new ByteArrayInputStream(pkg.formatVersionSpec().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

Examples of org.eclipse.core.runtime.MultiStatus

    }

    @Override
    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<Coordinator> coordSvcRef = bc.getServiceReference(Coordinator.class);
        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 {
            BndResolver bndResolver = new BndResolver(logger);

            //
            // Make sure we do macro expansion properly
            //

            File resource = model.getBndResource();
            if (model.isProjectFile()) {
                Project project = Central.getProject(resource.getParentFile());
                //
                // run's in projects are based on the project
                // and implicitly the ws
                //
                model.setProject(project);
            } else {
                //
                // run's in bndrun files are the bndrun + workspace
                //
                Run run = new Run(Central.getWorkspace(), resource.getParentFile(), resource);
                model.setProject(run);
            }

            ReporterLogService log = new ReporterLogService(Central.getWorkspace());
            Map<Resource,List<Wire>> wirings = resolve.resolveRequired(model, Central.getWorkspace(), bndResolver, 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, e, 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

Examples of org.eclipse.core.runtime.MultiStatus

            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

Examples of org.eclipse.core.runtime.MultiStatus

  protected static void throwException(List<IStatus> status, String message) throws CoreException {
    if (status == null || status.size() == 0) {
      return;
    }
    throw new CoreException(new MultiStatus(CloudFoundryPlugin.PLUGIN_ID, 0, status.toArray(new IStatus[0]),
        message, null));
  }
View Full Code Here

Examples of org.eclipse.core.runtime.MultiStatus

    }

    @Override
    public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException
    {
        MultiStatus status = new MultiStatus(SigilCore.PLUGIN_ID, 0,
            "Error resolving Sigil projects", null);

        boolean flush = sigilProjects.size() > 0;

        for (ISigilProjectModel sigilProject : sigilProjects)
        {
            try
            {
                if (isDependent(sigilProject))
                {
                    if (flush)
                        sigilProject.flushDependencyState();
                    sigilProject.rebuildDependencies(monitor);
                }
            }
            catch (CoreException e)
            {
                status.add(e.getStatus());
            }
        }

        return status;
    }
View Full Code Here

Examples of org.eclipse.core.runtime.MultiStatus

       
//        monitor = ProgressUtil.getMonitorFor(monitor); //TODO
        String mainTaskMsg = "Publishing to "+getServer().getName();//NLS.bind(Messages.publishing, getServer().getName());
        monitor.beginTask(mainTaskMsg, size);
       
        MultiStatus tempMulti = new MultiStatus(Activator.PLUGIN_ID, 0, "", null);
       
        if (monitor.isCanceled())
            return Status.CANCEL_STATUS;
       
        try {
            Activator.getDefault().getPluginLogger().trace("Starting publish");
            publishStart(monitor);//ProgressUtil.getSubMonitorFor(monitor, 1000)); //TODO
           
            if (monitor.isCanceled())
                return Status.CANCEL_STATUS;
           
            // execute tasks
            MultiStatus taskStatus = performTasks(tasks, monitor);
            monitor.setTaskName(mainTaskMsg);
            if (taskStatus != null && !taskStatus.isOK())
                tempMulti.addAll(taskStatus);
           
            // execute publishers
            taskStatus = executePublishers(kind, moduleList, deltaKindList, monitor, info3);
            monitor.setTaskName(mainTaskMsg);
            if (taskStatus != null && !taskStatus.isOK())
                tempMulti.addAll(taskStatus);
           
            if (monitor.isCanceled())
                return Status.CANCEL_STATUS;
           
            // publish the server
            publishServer(kind, monitor);//ProgressUtil.getSubMonitorFor(monitor, 1000));//TODO
            monitor.setTaskName(mainTaskMsg);
           
            if (monitor.isCanceled())
                return Status.CANCEL_STATUS;
           
            // publish modules
            publishModules(kind, moduleList, deltaKindList, tempMulti, monitor);
           
            if (monitor.isCanceled())
                return Status.CANCEL_STATUS;
           
            monitor.done();
        } catch (CoreException ce) {
            Activator.getDefault().getPluginLogger().error("CoreException publishing to " + toString(), ce);
            return ce.getStatus();
        } catch (Exception e) {
            Activator.getDefault().getPluginLogger().error( "Error publishing  to " + toString(), e);
            tempMulti.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "Error publishing", e));
        } finally {
            // end the publishing
            try {
                publishFinish(monitor);//ProgressUtil.getSubMonitorFor(monitor, 500));
            } catch (CoreException ce) {
                Activator.getDefault().getPluginLogger().error("CoreException publishing to " + toString(), ce);
                tempMulti.add(ce.getStatus());
            } catch (Exception e) {
                Activator.getDefault().getPluginLogger().error("Error stopping publish to " + toString(), e);
                tempMulti.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "Error publishing", e));
            }
        }
       
        Activator.getDefault().getPluginLogger().trace("--<-- Done publishing --<--");
       
        if (tempMulti.getChildren().length == 1)
            return tempMulti.getChildren()[0];
       
        MultiStatus multi = null;
        if (tempMulti.getSeverity() == IStatus.OK)
            return Status.OK_STATUS;
        else if (tempMulti.getSeverity() == IStatus.INFO)
            multi = new MultiStatus(Activator.PLUGIN_ID, 0, "Publishing completed with information", null);
        else if (tempMulti.getSeverity() == IStatus.WARNING)
            multi = new MultiStatus(Activator.PLUGIN_ID, 0, "Publishing completed with a warning", null);
        else if (tempMulti.getSeverity() == IStatus.ERROR)
            multi = new MultiStatus(Activator.PLUGIN_ID, 0, "Publishing failed", null);
       
        if (multi != null)
            multi.addAll(tempMulti);
       
        return multi;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.