Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.MultiStatus


  /*
   * Restores the state of the previously saved workbench
   */
  private IStatus restoreState(final IMemento memento) {

    final MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID,
        IStatus.OK, WorkbenchMessages.Workbench_problemsRestoring, null);

    final boolean showProgress = PrefUtil.getAPIPreferenceStore()
        .getBoolean(
            IWorkbenchPreferenceConstants.SHOW_PROGRESS_ON_STARTUP);
View Full Code Here


  /*
   * Saves the current state of the workbench so it can be restored later on
   */
  private IStatus saveState(IMemento memento) {
    MultiStatus result = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK,
        WorkbenchMessages.Workbench_problemsSaving, null);

    // Save the version number.
    memento.putString(IWorkbenchConstants.TAG_VERSION, VERSION_STRING[1]);

    // Save how many plug-ins were loaded while restoring the workbench
    if (progressCount != -1) {
      memento.putInteger(IWorkbenchConstants.TAG_PROGRESS_COUNT,
          progressCount);
    }

    // Save the advisor state.
    IMemento advisorState = memento
        .createChild(IWorkbenchConstants.TAG_WORKBENCH_ADVISOR);
    result.add(getAdvisor().saveState(advisorState));

    // Save the workbench windows.
    IWorkbenchWindow[] windows = getWorkbenchWindows();
    for (int nX = 0; nX < windows.length; nX++) {
      WorkbenchWindow window = (WorkbenchWindow) windows[nX];
      IMemento childMem = memento
          .createChild(IWorkbenchConstants.TAG_WINDOW);
      result.merge(window.saveState(childMem));
    }
    result.add(getEditorHistory().saveState(
        memento.createChild(IWorkbenchConstants.TAG_MRU_LIST)));
    return result;
  }
View Full Code Here

   */
  protected static final void logWarnings(final List warningsToLog,
      final String message) {
    // If there were any warnings, then log them now.
    if ((warningsToLog != null) && (!warningsToLog.isEmpty())) {
      final IStatus status = new MultiStatus(
          WorkbenchPlugin.PI_WORKBENCH, 0, (IStatus[]) warningsToLog
              .toArray(new IStatus[warningsToLog.size()]),
          message, null);
      WorkbenchPlugin.log(status);
    }
View Full Code Here

   
    if (monitor.isCanceled())
      return Status.CANCEL_STATUS;
   
    // now, for each of them, migrate and load them
    MultiStatus status = AbstractIAMLJob.multiStatus("Could not migrate all models successfully", null);
    IProgressMonitor m2 = new SubProgressMonitor(monitor, 70);
    m2.beginTask("Migrating models", models.size());
    for (IFile model : models) {
      if (monitor.isCanceled())
        return Status.CANCEL_STATUS;

      try {
        migrateAndLoad(status, model, new SubProgressMonitor(m2, 1));
      } catch (CoreException e) {
        // save to status
        status.add(AbstractIAMLJob.errorStatus("When migrating " + model + ": " + e.getMessage(), e));
        // and continue
      }
    }
   
    m2.done();
    monitor.done();
   
    // any errors?
    if (status.getChildren().length != 0) {
      return status;
    }
   
    return Status.OK_STATUS;
  }
View Full Code Here

      monitor.subTask("Migrating " + model);
      IStatus s = migrator.migrateModel(backup, model, new SubProgressMonitor(monitor, 1));
     
      // was it OK?
      if (!s.isOK()) {
        MultiStatus s2 = AbstractIAMLJob.multiStatus("Could not migrate model " + model + ": " + s.getMessage(), null);
        s2.add(s);
        status.add(s2);
      }
     
      if (model.exists()) {
        // then try and load it
View Full Code Here

 
  /**
   * Construct a new empty MultiStatus with the given message.
   */
  public static  MultiStatus multiStatus(String message, Throwable e) {
    return new MultiStatus(IamlActionsPlugin.PLUGIN_ID, IStatus.ERROR, message, e);
  }
View Full Code Here

      return AbstractIAMLJob.errorStatus(e1);
    }
   
    monitor.beginTask(getProgressMessage(), models.size());
   
    MultiStatus status = AbstractIAMLJob.multiStatus("Could not load all models successfully", null);
   
    for (IFile f : models) {
      if (monitor.isCanceled())
        return Status.CANCEL_STATUS;
     
      monitor.subTask("Loading model " + f.getName());
      try {
        EObject obj = ModelLoader.load(f);
        try {
          // ask EMF to re-save it
          obj.eResource().save( ModelLoader.getSaveOptions() );
        } catch (IOException e) {
          // IO exception during save
          status.add(AbstractIAMLJob.errorStatus("Could not save loaded model " + f + ": " + e.getMessage(), e));
        }
      } catch (ModelLoadException e) {
        // loading failed; add error status
        status.add(AbstractIAMLJob.errorStatus("Could not load migrated model " + f + ": " + e.getMessage(), e));
      } catch (WrappedException e) {     
        // loading failed; add error status
        status.add(AbstractIAMLJob.errorStatus("Could not load migrated model " + f + ": " + e.getMessage(), e));
      }
    }
   
    monitor.done();
   
    // any errors?
    if (status.getChildren().length != 0) {
      return status;
    }
   
    return Status.OK_STATUS;
   
View Full Code Here

   * @return
   */
  private String getErrorMessage(IStatus status) {
    if (status.isMultiStatus()) {
      // get the first 4 errors
      MultiStatus multi = (MultiStatus) status;
      String result = "";
      for (int i = 0; i < 4 && i < multi.getChildren().length; i++) {
        result += (i == 0 ? "" : "\n") + multi.getChildren()[i].getMessage();
      }
      if (multi.getChildren().length > 4) {
        result += "\n(... " + (multi.getChildren().length - 4) + " more)";
      }
      return result;
    } else {
      return status.getMessage();
    }
View Full Code Here

            IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1 * scale);
           
          final IStatus status = execute(individual, subMonitor);
          if (!status.isOK()) {
            // make a status to wrap it around
            IStatus multi = new MultiStatus(
                PLUGIN_ID,
                Status.ERROR,
                new IStatus[] { status },
                getErrorMessage(individual, status.getMessage()),
                status.getException());
View Full Code Here

                    message += "\n - " + exceptionMessage; //$NON-NLS-1$
                }
            }

            // create main status
            MultiStatus multiStatus = new MultiStatus( pluginId, IStatus.ERROR, message, null );

            // append child status
            for ( Status status : errorStatusList )
            {
                String statusMessage = status.getMessage();
                if ( status.getException() != null )
                {
                    StringWriter sw = new StringWriter();
                    PrintWriter pw = new PrintWriter( sw );
                    status.getException().printStackTrace( pw );
                    statusMessage = sw.toString();
                }
                multiStatus.add( new Status( status.getSeverity(), status.getPlugin(), status.getCode(), statusMessage,
                    status.getException() ) );
            }

            return multiStatus;
        }
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.