Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.MultiStatus


    public void logErrorStatus(final String message, final IStatus status) {
        if (status == null) {
            logErrorMessage(message);
            return;
        }
        final MultiStatus multi = new MultiStatus(plugin.getBundle().getSymbolicName(),
                ErlangStatus.INTERNAL_ERROR.getValue(), message, null);
        multi.add(status);
        log(multi);
    }
View Full Code Here


      } else {
        possibleBindings.put(trigger, binding);
      }
    }

    MultiStatus conflicts = new MultiStatus("org.eclipse.jface", 0, //$NON-NLS-1$
        "Keybinding conflicts occurred.  They may interfere with normal accelerator operation.", //$NON-NLS-1$
        null);
    /*
     * THIRD PASS: In this pass, we move any non-conflicting bindings
     * directly into the map. In the case of conflicts, we apply some
     * further logic to try to resolve them. If the conflict can't be
     * resolved, then we log the problem.
     */
    final Iterator possibleBindingItr = possibleBindings.entrySet()
        .iterator();
    while (possibleBindingItr.hasNext()) {
      final Map.Entry entry = (Map.Entry) possibleBindingItr.next();
      final TriggerSequence trigger = (TriggerSequence) entry.getKey();
      final Object match = entry.getValue();
      /*
       * What we do depends slightly on whether we are trying to build a
       * list of all possible bindings (disregarding context), or a flat
       * map given the currently active contexts.
       */
      if (activeContextTree == null) {
        // We are building the list of all possible bindings.
        final Collection bindings = new ArrayList();
        if (match instanceof Binding) {
          bindings.add(match);
          bindingsByTrigger.put(trigger, bindings);
          addReverseLookup(triggersByCommandId, ((Binding) match)
              .getParameterizedCommand(), trigger);

        } else if (match instanceof Collection) {
          bindings.addAll((Collection) match);
          bindingsByTrigger.put(trigger, bindings);

          final Iterator matchItr = bindings.iterator();
          while (matchItr.hasNext()) {
            addReverseLookup(triggersByCommandId,
                ((Binding) matchItr.next())
                    .getParameterizedCommand(), trigger);
          }
        }

      } else {
        // We are building the flat map of trigger to commands.
        if (match instanceof Binding) {
          final Binding binding = (Binding) match;
          bindingsByTrigger.put(trigger, binding);
          addReverseLookup(triggersByCommandId, binding
              .getParameterizedCommand(), trigger);

        } else if (match instanceof Collection) {
          final Binding winner = resolveConflicts((Collection) match,
              activeContextTree);
          if (winner == null) {
            // warn once ... so as not to flood the logs
            conflictsByTrigger.put(trigger, match);
            if (triggerConflicts.add(trigger)) {
              final StringWriter sw = new StringWriter();
              final BufferedWriter buffer = new BufferedWriter(sw);
              try {
                buffer.write("A conflict occurred for "); //$NON-NLS-1$
                buffer.write(trigger.toString());
                buffer.write(':');
                Iterator i = ((Collection) match).iterator();
                while (i.hasNext()) {
                  buffer.newLine();
                  buffer.write(i.next().toString());
                }
                buffer.flush();
              } catch (IOException e) {
                // we should not get this
              }
              conflicts.add(new Status(IStatus.WARNING,
                  "org.eclipse.jface", //$NON-NLS-1$
                  sw.toString()));
            }
            if (DEBUG) {
              Tracing.printTrace("BINDINGS", //$NON-NLS-1$
                  "A conflict occurred for " + trigger); //$NON-NLS-1$
              Tracing.printTrace("BINDINGS", "    " + match); //$NON-NLS-1$ //$NON-NLS-2$
            }
          } else {
            bindingsByTrigger.put(trigger, winner);
            addReverseLookup(triggersByCommandId, winner
                .getParameterizedCommand(), trigger);
          }
        }
      }
    }
    if (conflicts.getSeverity() != IStatus.OK) {
      Policy.getLog().log(conflicts);
    }
  }
View Full Code Here

  // If not, we should open an eclipse bug or add a similar utility to
  // baseExtensionsUI.
  //
  private static IStatus createStatus(String reason, String msg) {
    String pluginId = XMLUIPlugin.getDefault().getBundle().getSymbolicName();
    MultiStatus multiStatus = new MultiStatus(pluginId, 0, reason, null);
    Status status = new Status(IStatus.ERROR, pluginId, 0, msg, null);
    multiStatus.add(status);
    return multiStatus;
  }
View Full Code Here

        Map/* <ModuleDescriptor, List<ResolveRequest>> */inworkspaceModules = new LinkedHashMap();
        List/* <ResolveRequest> */otherModules = new ArrayList();
        Map/* <ResolveRequest, Ivy> */ivys = new HashMap();
        Map/* <ResolveRequest, ModuleDescriptor> */mds = new HashMap();

        final MultiStatus errorsStatus = new MultiStatus(IvyPlugin.ID, IStatus.ERROR,
                "Some projects fail to be resolved", null);

        int step = IVY_LOAD_LENGTH / toResolve.size();

        boolean forceFailOnError = false;

        // Ivy use the SaxParserFactory, and we want it to instanciate the xerces parser which is in
        // the dependencies of IvyDE, so accessible via the current classloader
        ClassLoader old = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(IvyResolveJob.class.getClassLoader());
        try {
            Iterator itRequests = toResolve.iterator();
            while (itRequests.hasNext()) {
                ResolveRequest request = (ResolveRequest) itRequests.next();

                IvyDEMessage.info("Processing resolve request " + request.toString());

                forceFailOnError = forceFailOnError || request.isForceFailOnError();
                monitor.subTask("loading " + request.getResolver().toString());
                IProject project = request.getResolver().getProject();
                if (project != null && !project.isAccessible()) {
                    IvyDEMessage.warn("Skipping resolve on closed project " + project.getName());
                    monitor.worked(step);
                    continue;
                }
                IvyDEMessage.verbose("Loading ivysettings for " + request.toString());
                CachedIvy cachedIvy = request.getCachedIvy();
                Ivy ivy;
                try {
                    ivy = cachedIvy.getIvy();
                } catch (IvyDEException e) {
                    cachedIvy.setErrorMarker(e);
                    IvyDEMessage.error("Failed to configure Ivy for " + request + ": "
                            + e.getMessage());
                    errorsStatus.add(e.asStatus(IStatus.ERROR, "Failed to configure Ivy for "
                            + request));
                    monitor.worked(step);
                    continue;
                }
                cachedIvy.setErrorMarker(null);
                ivys.put(request, ivy);
                // IVYDE-168 : Ivy needs the IvyContext in the threadlocal in order to found the
                // default branch
                ivy.pushContext();
                ModuleDescriptor md;
                try {
                    md = cachedIvy.getModuleDescriptor(ivy);
                } catch (IvyDEException e) {
                    cachedIvy.setErrorMarker(e);
                    IvyDEMessage.error("Failed to load the descriptor for " + request + ": "
                            + e.getMessage());
                    errorsStatus.add(e.asStatus(IStatus.ERROR, "Failed to load the descriptor for "
                            + request));
                    monitor.worked(step);
                    continue;
                } finally {
                    ivy.popContext();
                }
                cachedIvy.setErrorMarker(null);
                mds.put(request, md);
                if (request.isInWorkspace()) {
                    List requests = (List) inworkspaceModules.get(md);
                    if (requests == null) {
                        requests = new ArrayList();
                        inworkspaceModules.put(md, requests);
                    }
                    requests.add(request);
                } else {
                    otherModules.add(request);
                }
                monitor.worked(step);
            }
        } finally {
            Thread.currentThread().setContextClassLoader(old);
        }

        step = (MONITOR_LENGTH - IVY_LOAD_LENGTH - POST_RESOLVE_LENGTH) / toResolve.size();

        if (inworkspaceModules.isEmpty()) {
            IvyDEMessage.verbose("No module to resolve in workspace");
        } else {
            IvyDEMessage.info(inworkspaceModules.size() + " module(s) to resolve in workspace");
            // for the modules which are using the workspace resolver, make sure
            // we resolve them in the correct order

            // The version matcher used will be the one configured for the first project
            ResolveRequest request = (ResolveRequest) ((List) inworkspaceModules.values()
                    .iterator().next()).get(0);
            VersionMatcher versionMatcher = ((Ivy) ivys.get(request)).getSettings()
                    .getVersionMatcher();

            WarningNonMatchingVersionReporter vReporter = new WarningNonMatchingVersionReporter();
            CircularDependencyStrategy circularDependencyStrategy = WarnCircularDependencyStrategy
                    .getInstance();
            ModuleDescriptorSorter sorter = new ModuleDescriptorSorter(inworkspaceModules.keySet(),
                    versionMatcher, vReporter, circularDependencyStrategy);
            List sortedModuleDescriptors = sorter.sortModuleDescriptors();

            Iterator it = sortedModuleDescriptors.iterator();
            while (it.hasNext()) {
                ModuleDescriptor module = (ModuleDescriptor) it.next();
                List requests = (List) inworkspaceModules.get(module);
                IvyDEMessage.info(requests.size() + " container(s) of module " + module
                        + " to resolve in workspace");
                for (int i = 0; i < requests.size(); i++) {
                    request = (ResolveRequest) requests.get(i);
                    Ivy ivy = (Ivy) ivys.get(request);
                    ModuleDescriptor md = (ModuleDescriptor) mds.get(request);
                    boolean canceled = launchResolveThread(request, monitor, step, errorsStatus,
                        ivy, md);
                    if (canceled) {
                        IvyDEMessage.warn("Resolve job canceled");
                        return Status.CANCEL_STATUS;
                    }
                }
            }
        }

        if (otherModules.isEmpty()) {
            IvyDEMessage.verbose("No module to resolve outside the workspace");
        } else {
            IvyDEMessage.info(otherModules.size() + " module(s) to resolve outside the workspace");

            Iterator it = otherModules.iterator();
            while (it.hasNext()) {
                ResolveRequest request = (ResolveRequest) it.next();
                Ivy ivy = (Ivy) ivys.get(request);
                ModuleDescriptor md = (ModuleDescriptor) mds.get(request);
                boolean canceled = launchResolveThread(request, monitor, step, errorsStatus, ivy,
                    md);
                if (canceled) {
                    IvyDEMessage.warn("Resolve job canceled");
                    return Status.CANCEL_STATUS;
                }
            }
        }

        step = POST_RESOLVE_LENGTH / toResolve.size();

        monitor.setTaskName("Post resolve");

        // launch every post batch resolve
        Iterator itRequests = toResolve.iterator();
        while (itRequests.hasNext()) {
            ResolveRequest request = (ResolveRequest) itRequests.next();
            if (!request.isResolveFailed()) {
                monitor.setTaskName(request.getResolver().toString());
                request.getResolver().postBatchResolve();
            }
            monitor.worked(step);
        }

        if (errorsStatus.getChildren().length != 0) {
            // some errors happend, stop here
            if (forceFailOnError || IvyPlugin.getPreferenceStoreHelper().isErrorPopup()) {
                return errorsStatus;
            }
            return Status.OK_STATUS;
View Full Code Here

                Thread.currentThread().setContextClassLoader(old);
                ivy.getEventManager().removeIvyListener(ivyResolveJobListener);
            }

            if (!result.getProblemMessages().isEmpty()) {
                MultiStatus multiStatus = new MultiStatus(IvyPlugin.ID, IStatus.ERROR,
                        "Impossible to resolve dependencies of " + md.getModuleRevisionId(), null);
                for (Iterator iter = result.getProblemMessages().iterator(); iter.hasNext();) {
                    multiStatus.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
                            (String) iter.next(), null));
                }
                return multiStatus;
            }
View Full Code Here

        super("Synchronizing Ivy Files");
        this.multiRevisionDependencies = multiRevisionDependencies;
    }

    protected IStatus executeJob(IProgressMonitor monitor) {
        MultiStatus errorStatuses = new MultiStatus(IvyPlugin.ID, IStatus.ERROR,
                "Failed to update one or more Ivy files.  See details.", null);

        IvyClasspathContainerImpl[] containers = getIvyClasspathContainers();
        for (int i = 0; i < containers.length; i++) {
            IvyClasspathContainerImpl container = containers[i];

            ModuleDescriptor md = container.getState().getCachedModuleDescriptor();
            if (md == null) {
                continue;
            }

            Map/* <ModuleRevisionId, String> */newRevisions = new HashMap();

            DependencyDescriptor[] dependencies = md.getDependencies();
            for (int j = 0; j < dependencies.length; j++) {
                for (int k = 0; k < multiRevisionDependencies.length; k++) {
                    MultiRevDependencyDescriptor multiRevision = multiRevisionDependencies[k];
                    ModuleRevisionId dependencyRevisionId = dependencies[j]
                            .getDependencyRevisionId();
                    if (dependencies[j].getDependencyId().equals(multiRevision.getModuleId())
                            && multiRevision.hasNewRevision()
                            && multiRevision.isForContainer(container)) {
                        newRevisions.put(dependencyRevisionId,
                            multiRevisionDependencies[k].getNewRevision());
                        break; // move on to the next dependency
                    }
                }
            }

            UpdateOptions updateOptions = new UpdateOptions().setResolvedRevisions(newRevisions)
                    .setReplaceInclude(false).setGenerateRevConstraint(false)
                    .setNamespace(new RevisionPreservingNamespace());

            File ivyFile;
            try {
                ivyFile = container.getState().getIvyFile();
            } catch (IvyDEException e) {
                errorStatuses.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
                        "Fail to resolve the ivy file", e));
                continue;
            }

            File ivyTempFile = new File(ivyFile.toString() + ".temp");
            try {
                XmlModuleDescriptorUpdater.update(ivyFile.toURI().toURL(), ivyTempFile,
                    updateOptions);
                saveChanges(container, ivyFile, ivyTempFile);
            } catch (MalformedURLException e) {
                errorStatuses.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
                        "Failed to write Ivy file " + ivyFile + " (malformed URL)", e));
            } catch (IOException e) {
                errorStatuses.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
                        "Failed to write Ivy file " + ivyFile, e));
            } catch (SAXException e) {
                errorStatuses.add(new Status(IStatus.ERROR, IvyPlugin.ID, IStatus.ERROR,
                        "Failed to write Ivy file " + ivyFile, e));
            } finally {
                ivyTempFile.delete();
            }
        }

        if (errorStatuses.getChildren().length > 0) {
            return errorStatuses;
        }
        return Status.OK_STATUS;
    }
View Full Code Here

    /**
     * @see IPersistablePart
     */
    public IStatus restoreState(IMemento memento) {
        MultiStatus result = new MultiStatus(
                PlatformUI.PLUGIN_ID,
                IStatus.OK,
                WorkbenchMessages.RootLayoutContainer_problemsRestoringPerspective, null);

        // Remove the default editor workbook that is
        // initialy created with the editor area.
        if (children != null) {
          StartupThreading.runWithoutExceptions(new StartupRunnable() {

        public void runWithException() throws Throwable {
          EditorStack defaultWorkbook = null;
                for (int i = 0; i < children.size(); i++) {
                    LayoutPart child = (LayoutPart) children.get(i);
                    if (child.getID() == DEFAULT_WORKBOOK_ID) {
                        defaultWorkbook = (EditorStack) child;
                        if (defaultWorkbook.getItemCount() > 0) {
                defaultWorkbook = null;
              }
                    }
                }
                if (defaultWorkbook != null) {
            remove(defaultWorkbook);
          }
        }});
           
        }

        // Restore the relationship/layout
        IMemento[] infos = memento.getChildren(IWorkbenchConstants.TAG_INFO);
        final Map mapIDtoPart = new HashMap(infos.length);

        for (int i = 0; i < infos.length; i++) {
            // Get the info details.
            IMemento childMem = infos[i];
            final String partID = childMem.getString(IWorkbenchConstants.TAG_PART);
            final String relativeID = childMem
                    .getString(IWorkbenchConstants.TAG_RELATIVE);
            int relationship = 0;
            int left = 0, right = 0;
            float ratio = 0.5f;
            if (relativeID != null) {
                relationship = childMem.getInteger(
                        IWorkbenchConstants.TAG_RELATIONSHIP).intValue();
                Float ratioFloat = childMem
                        .getFloat(IWorkbenchConstants.TAG_RATIO);
                Integer leftInt = childMem
                        .getInteger(IWorkbenchConstants.TAG_RATIO_LEFT);
                Integer rightInt = childMem
                        .getInteger(IWorkbenchConstants.TAG_RATIO_RIGHT);
                if (leftInt != null && rightInt != null) {
                    left = leftInt.intValue();
                    right = rightInt.intValue();
                } else if (ratioFloat != null) {
                    ratio = ratioFloat.floatValue();
                }
            }

            final EditorStack workbook [] = new EditorStack[1];
            StartupThreading.runWithoutExceptions(new StartupRunnable() {

        public void runWithException() throws Throwable {
          // Create the part.
                workbook[0] = EditorStack.newEditorWorkbook(EditorSashContainer.this, page);
                workbook[0].setID(partID);
                // 1FUN70C: ITPUI:WIN - Shouldn't set Container when not active
                workbook[0].setContainer(EditorSashContainer.this);
        }});
           

            IMemento workbookMemento = childMem
                    .getChild(IWorkbenchConstants.TAG_FOLDER);
            if (workbookMemento != null) {
                result.add(workbook[0].restoreState(workbookMemento));
            }

            final int myLeft = left, myRight = right, myRelationship = relationship;
            final float myRatio = ratio;
            StartupThreading.runWithoutExceptions(new StartupRunnable() {
View Full Code Here

    /**
     * @see IPersistablePart
     */
    public IStatus saveState(IMemento memento) {
        RelationshipInfo[] relationships = computeRelation();
        MultiStatus result = new MultiStatus(
                PlatformUI.PLUGIN_ID,
                IStatus.OK,
                WorkbenchMessages.RootLayoutContainer_problemsSavingPerspective, null);

        for (int i = 0; i < relationships.length; i++) {
            // Save the relationship info ..
            //    private LayoutPart part;
            //     private int relationship;
            //     private float ratio;
            //     private LayoutPart relative;
            RelationshipInfo info = relationships[i];
            IMemento childMem = memento
                    .createChild(IWorkbenchConstants.TAG_INFO);
            childMem.putString(IWorkbenchConstants.TAG_PART, info.part.getID());

            EditorStack stack = (EditorStack) info.part;
            if (stack != null) {
                IMemento folderMem = childMem
                        .createChild(IWorkbenchConstants.TAG_FOLDER);
                result.add(stack.saveState(folderMem));
            }

            if (info.relative != null) {
                childMem.putString(IWorkbenchConstants.TAG_RELATIVE,
                        info.relative.getID());
View Full Code Here

   *            The activation; must not be <code>null</code>.
   */
  final void activateHandler(final IHandlerActivation activation) {
    // First we update the handlerActivationsByCommandId map.
    final String commandId = activation.getCommandId();
    MultiStatus conflicts = new MultiStatus("org.eclipse.ui.workbench", 0//$NON-NLS-1$
        "A handler conflict occurred.  This may disable some commands.", //$NON-NLS-1$
        null);
    final Object value = handlerActivationsByCommandId.get(commandId);
    if (value instanceof SortedSet) {
      final SortedSet handlerActivations = (SortedSet) value;
      if (!handlerActivations.contains(activation)) {
        handlerActivations.add(activation);
        updateCommand(commandId, resolveConflicts(commandId,
            handlerActivations, conflicts));
      }
    } else if (value instanceof IHandlerActivation) {
      if (value != activation) {
        final SortedSet handlerActivations = new TreeSet(
            new EvaluationResultCacheComparator());
        handlerActivations.add(value);
        handlerActivations.add(activation);
        handlerActivationsByCommandId
            .put(commandId, handlerActivations);
        updateCommand(commandId, resolveConflicts(commandId,
            handlerActivations, conflicts));
      }
    } else {
      handlerActivationsByCommandId.put(commandId, activation);
      updateCommand(commandId, (evaluate(activation) ? activation : null));
    }
   
    if (conflicts.getSeverity()!=IStatus.OK) {
      WorkbenchPlugin.log(conflicts);
    }

    // Next we update the source priority bucket sort of activations.
    final int sourcePriority = activation.getSourcePriority();
View Full Code Here

   *            The activation; must not be <code>null</code>.
   */
  final void deactivateHandler(final IHandlerActivation activation) {
    // First we update the handlerActivationsByCommandId map.
    final String commandId = activation.getCommandId();
    MultiStatus conflicts = new MultiStatus("org.eclipse.ui.workbench", 0//$NON-NLS-1$
        "A handler conflict occurred.  This may disable some commands.", //$NON-NLS-1$
        null);
    final Object value = handlerActivationsByCommandId.get(commandId);
    if (value instanceof SortedSet) {
      final SortedSet handlerActivations = (SortedSet) value;
      if (handlerActivations.contains(activation)) {
        handlerActivations.remove(activation);
        if (handlerActivations.isEmpty()) {
          handlerActivationsByCommandId.remove(commandId);
          updateCommand(commandId, null);

        } else if (handlerActivations.size() == 1) {
          final IHandlerActivation remainingActivation = (IHandlerActivation) handlerActivations
              .iterator().next();
          handlerActivationsByCommandId.put(commandId,
              remainingActivation);
          updateCommand(
              commandId,
              (evaluate(remainingActivation) ? remainingActivation
                  : null));

        } else {
          updateCommand(commandId, resolveConflicts(commandId,
              handlerActivations, conflicts));
        }
      }
    } else if (value instanceof IHandlerActivation) {
      if (value == activation) {
        handlerActivationsByCommandId.remove(commandId);
        updateCommand(commandId, null);
      }
    }
    if (conflicts.getSeverity()!=IStatus.OK) {
      WorkbenchPlugin.log(conflicts);
    }

    // Next we update the source priority bucket sort of activations.
    final int sourcePriority = activation.getSourcePriority();
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.