Java 类org.eclipse.core.runtime.MultiStatus 实例源码

项目:n4js    文件:ErrorDialogWithStackTraceUtil.java   
/**
 * Shows JFace ErrorDialog but improved by constructing full stack trace in detail area.
 *
 * @return true if OK was pressed
 */
public static boolean showErrorDialogWithStackTrace(String msg, Throwable throwable) {

    // Temporary holder of child statuses
    List<Status> childStatuses = new ArrayList<>();

    for (StackTraceElement stackTraceElement : throwable.getStackTrace()) {
        childStatuses.add(new Status(IStatus.ERROR, "N4js-plugin-id", stackTraceElement.toString()));
    }

    MultiStatus ms = new MultiStatus("N4js-plugin-id", IStatus.ERROR,
            childStatuses.toArray(new Status[] {}), // convert to array of statuses
            throwable.getLocalizedMessage(), throwable);

    final AtomicBoolean result = new AtomicBoolean(true);
    Display.getDefault()
            .syncExec(
                    () -> result.set(
                            ErrorDialog.openError(null, "Error occurred while organizing ", msg, ms) == Window.OK));

    return result.get();
}
项目:n4js    文件:ExternalLibraryPreferencePage.java   
@Override
public boolean performOk() {
    final MultiStatus multistatus = statusHelper
            .createMultiStatus("Status of importing target platform.");
    try {
        new ProgressMonitorDialog(getShell()).run(true, false, monitor -> {
            final IStatus status = store.save(monitor);
            if (!status.isOK()) {
                setMessage(status.getMessage(), ERROR);
                multistatus.merge(status);
            } else {
                updateInput(viewer, store.getLocations());
            }
        });
    } catch (final InvocationTargetException | InterruptedException exc) {
        multistatus.merge(statusHelper.createError("Error while building external libraries.", exc));
    }

    if (multistatus.isOK())
        return super.performOk();
    else
        return false;
}
项目:n4js    文件:ExternalLibraryPreferencePage.java   
/**
 * Handler for executing maintenance action based on the provided {@link MaintenanceActionsChoice user choice}.
 */
private MultiStatus runMaintananceActions(final MaintenanceActionsChoice userChoice, IProgressMonitor monitor) {
    final MultiStatus multistatus = statusHelper
            .createMultiStatus("Status of executing maintenance actions.");

    // persist state for reinstall
    Map<String, String> oldPackages = new HashMap<>();
    if (userChoice.decisionReinstall)
        oldPackages.putAll(getInstalledNpms());

    // keep the order Cache->TypeDefs->NPMs->Reinstall->Update
    // actions have side effects that can interact with each other
    maintenanceCleanNpmCache(userChoice, multistatus, monitor);
    maintenanceResetTypeDefinitions(userChoice, multistatus);
    maintenanceDeleteNpms(userChoice, multistatus);
    maintenanceReinstallNpms(userChoice, multistatus, monitor, oldPackages);
    maintenanceUpateState(userChoice, multistatus, monitor);

    return multistatus;
}
项目:n4js    文件:ExternalLibraryPreferencePage.java   
/**
 * Actions to be taken if reinstalling npms is requested.
 *
 * @param userChoice
 *            options object used to decide if / how actions should be performed
 * @param multistatus
 *            the status used accumulate issues
 * @param monitor
 *            the monitor used to interact with npm manager
 * @param packageNames
 *            names of the packages and their versions to reinstall
 *
 */
private void maintenanceReinstallNpms(final MaintenanceActionsChoice userChoice,
        final MultiStatus multistatus, IProgressMonitor monitor, Map<String, String> packageNames) {
    if (userChoice.decisionReinstall) {

        // unless all npms were purged, uninstall known ones
        if (!userChoice.decisionPurgeNpm) {
            IStatus uninstallStatus = unintallAndUpdate(packageNames.keySet(), monitor);
            if (!uninstallStatus.isOK())
                multistatus.merge(uninstallStatus);
        }

        IStatus installStatus = intallAndUpdate(packageNames, monitor);
        if (!installStatus.isOK())
            multistatus.merge(installStatus);

    }
}
项目:n4js    文件:ExternalLibraryPreferencePage.java   
/**
 * Actions to be taken if deleting npms is requested.
 *
 * @param userChoice
 *            options object used to decide if / how actions should be performed
 * @param multistatus
 *            the status used accumulate issues
 */
private void maintenanceDeleteNpms(final MaintenanceActionsChoice userChoice, final MultiStatus multistatus) {
    if (userChoice.decisionPurgeNpm) {
        // get folder
        File npmFolder = N4_NPM_FOLDER_SUPPLIER.get();

        if (npmFolder.exists()) {
            FileDeleter.delete(npmFolder, (IOException ioe) -> multistatus.merge(
                    statusHelper.createError("Exception during deletion of the npm folder.", ioe)));
        }

        if (!npmFolder.exists()) {
            // recreate npm folder
            if (!repairNpmFolderState()) {
                multistatus.merge(statusHelper
                        .createError("The npm folder was not recreated correctly."));
            }
        } else {// should never happen
            multistatus
                    .merge(statusHelper.createError("Could not verify deletion of " + npmFolder.getAbsolutePath()));
        }
        // other actions like reinstall depends on this state
        externalLibraryWorkspace.updateState();
    }
}
项目:n4js    文件:ExternalLibraryPreferencePage.java   
/**
 * Actions to be taken if reseting type definitions is requested.
 *
 * @param userChoice
 *            options object used to decide if / how actions should be performed
 * @param multistatus
 *            the status used accumulate issues
 */
private void maintenanceResetTypeDefinitions(final MaintenanceActionsChoice userChoice,
        final MultiStatus multistatus) {
    if (userChoice.decisionResetTypeDefinitions) {
        // get folder
        File typeDefinitionsFolder = gitSupplier.get();

        if (typeDefinitionsFolder.exists()) {
            FileDeleter.delete(typeDefinitionsFolder, (IOException ioe) -> multistatus.merge(
                    statusHelper.createError("Exception during deletion of the type definitions.", ioe)));
        }

        if (!typeDefinitionsFolder.exists()) {
            // recreate npm folder
            if (!gitSupplier.repairTypeDefinitions()) {
                multistatus.merge(
                        statusHelper.createError("The type definitions folder was not recreated correctly."));
            }
        } else { // should never happen
            multistatus.merge(statusHelper
                    .createError("Could not verify deletion of " + typeDefinitionsFolder.getAbsolutePath()));
        }
    }
}
项目:n4js    文件:NpmManager.java   
private Collection<File> adaptNPMPackages(final IProgressMonitor monitor, final MultiStatus status,
        final Collection<String> addedDependencies) {

    logger.logInfo(LINE_SINGLE);
    logger.logInfo("Adapting npm package structure to N4JS project structure... [step 3 of 4]");
    monitor.setTaskName("Adapting npm package structure to N4JS project structure... [step 3 of 4]");
    final Pair<IStatus, Collection<File>> result = npmPackageToProjectAdapter.adaptPackages(addedDependencies);
    final IStatus adaptionStatus = result.getFirst();

    // log possible errors, but proceed with the process
    // assume that at least some packages were installed correctly and can be adapted
    if (!adaptionStatus.isOK()) {
        logger.logError(adaptionStatus);
        status.merge(adaptionStatus);
    }

    final Collection<File> adaptedPackages = result.getSecond();
    logger.logInfo("Packages structures has been adapted to N4JS project structure.");
    monitor.worked(2);

    logger.logInfo(LINE_SINGLE);
    return adaptedPackages;
}
项目:neoscada    文件:AbstractItemAction.java   
@Override
public void run ( final IAction action )
{
    final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, this.message, null );
    for ( final Item item : this.items )
    {
        try
        {
            processItem ( item );
        }
        catch ( final PartInitException e )
        {
            status.add ( e.getStatus () );
        }
    }
    if ( !status.isOK () )
    {
        showError ( status );
    }
}
项目:neoscada    文件:PreferencePage.java   
protected void handleRemove ()
{
    final MultiStatus ms = new MultiStatus ( Activator.PLUGIN_ID, 0, "Removing key providers", null );

    for ( final KeyProvider provider : this.selectedProviders )
    {
        try
        {
            this.factory.remove ( provider );
        }
        catch ( final Exception e )
        {
            ms.add ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) );
        }
    }
    if ( !ms.isOK () )
    {
        ErrorDialog.openError ( getShell (), "Error", null, ms );
    }
}
项目:neoscada    文件:EditorHelper.java   
public static void handleOpen ( final IWorkbenchPage page, final ISelection selection )
{
    final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, "Open editor", null );

    final IEditorInput[] inputs = EditorHelper.createInput ( selection );

    for ( final IEditorInput input : inputs )
    {
        try
        {
            if ( input instanceof ConfigurationEditorInput )
            {
                page.openEditor ( input, MultiConfigurationEditor.EDITOR_ID, true );
            }
            else if ( input instanceof FactoryEditorInput )
            {
                page.openEditor ( input, FactoryEditor.EDITOR_ID, true );
            }
        }
        catch ( final PartInitException e )
        {
            status.add ( e.getStatus () );
        }
    }
}
项目:neoscada    文件:AbstractServerHandler.java   
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final MultiStatus ms = new MultiStatus ( HivesPlugin.PLUGIN_ID, 0, getLabel (), null );

    for ( final ServerLifecycle server : SelectionHelper.iterable ( getSelection (), ServerLifecycle.class ) )
    {
        try
        {
            process ( server );
        }
        catch ( final CoreException e )
        {
            ms.add ( e.getStatus () );
        }
    }
    if ( !ms.isOK () )
    {
        StatusManager.getManager ().handle ( ms, StatusManager.SHOW );
    }
    return null;
}
项目:Hydrograph    文件:ProjectStructureCreator.java   
private void copyBuildFile(String source, IProject project) throws CoreException {
    File sourceFileLocation = new File(source);
    File[] listFiles = sourceFileLocation.listFiles();
    if(listFiles != null){
        for(File sourceFile : listFiles){
            IFile destinationFile = project.getFile(sourceFile.getName());
            try(InputStream fileInputStream = new FileInputStream(sourceFile)) {
                if(!destinationFile.exists()){ //used while importing a project
                    destinationFile.create(fileInputStream, true, null);
                }
            } catch (IOException | CoreException exception) {
                logger.debug("Copy build file operation failed");
                throw new CoreException(new MultiStatus(Activator.PLUGIN_ID, 100, "Copy build file operation failed", exception));
            }
        }
    }
}
项目:Hydrograph    文件:ProjectStructureCreator.java   
private void copyExternalLibAndAddToClassPath(String source,IFolder destinationFolder, List<IClasspathEntry> entries) throws CoreException{
    File sourceFileLocation = new File(source);
    File[] listFiles = sourceFileLocation.listFiles();
    if(listFiles != null){
        for(File sourceFile : listFiles){
            IFile destinationFile = destinationFolder.getFile(sourceFile.getName());
            try(InputStream fileInputStream = new FileInputStream(sourceFile)) {
                if(!destinationFile.exists()){ //used while importing a project
                    destinationFile.create(fileInputStream, true, null);
                }
                entries.add(JavaCore.newLibraryEntry(new Path(destinationFile.getLocation().toOSString()), null, null));
            } catch (IOException | CoreException exception) {
                logger.debug("Copy external library files operation failed", exception);
                throw new CoreException(new MultiStatus(Activator.PLUGIN_ID, 101, "Copy external library files operation failed", exception));
            }
        }
    }
}
项目:dacapobench    文件:TestingEnvironment.java   
/**
 * Handles a core exception thrown during a testing environment operation
 */
private void handleCoreException(CoreException e) {
  e.printStackTrace();
  IStatus status = e.getStatus();
  String message = e.getMessage();
  if (status.isMultiStatus()) {
    MultiStatus multiStatus = (MultiStatus) status;
    IStatus[] children = multiStatus.getChildren();
    StringBuffer buffer = new StringBuffer();
    for (int i = 0, max = children.length; i < max; i++) {
      IStatus child = children[i];
      if (child != null) {
        buffer.append(child.getMessage());
        buffer.append(System.getProperty("line.separator"));//$NON-NLS-1$
        Throwable childException = child.getException();
        if (childException != null) {
          childException.printStackTrace();
        }
      }
    }
    message = buffer.toString();
  }
  Assert.isTrue(false, "Core exception in testing environment: " + message); //$NON-NLS-1$
}
项目:codegen-ecore    文件:GenerateAction.java   
private static MultiStatus createMultiStatus(String msg, Throwable t) {
    List<Status> childStatuses = new ArrayList<>();

    for (StackTraceElement stackTrace : t.getStackTrace()) {
        childStatuses.add(new Status(IStatus.ERROR, "org.nasdanika.codegen.editor", stackTrace.toString()));
    }

    if (t.getCause() != null) {
        childStatuses.add(createMultiStatus("Caused by: " + t.getCause(), t.getCause()));
    }

    for (Throwable s : t.getSuppressed()) {
        childStatuses.add(createMultiStatus("Supressed: " + s, s.getCause()));
    }

    MultiStatus ms = new MultiStatus("org.nasdanika.codegen.editor", IStatus.ERROR, childStatuses.toArray(new Status[childStatuses.size()]), msg, t);

    return ms;
}
项目:vsDiaryWriter    文件:ExceptionDisplayer.java   
public static void errorDialogWithStackTrace(String msg, Throwable t) {

        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        t.printStackTrace(pw);

        final String trace = sw.toString(); // stack trace as a string

        // Temp holder of child statuses
        List<Status> childStatuses = new ArrayList<>();

        // Split output by OS-independend new-line
        for (String line : trace.split(System.getProperty("line.separator"))) {
            // build & add status
            childStatuses.add(new Status(IStatus.ERROR, "Journal", line));
        }

        MultiStatus ms = new MultiStatus("Journal", IStatus.ERROR, childStatuses.toArray(new Status[] {}), // convert
                                                                                                            // to
                                                                                                            // array
                                                                                                            // of
                                                                                                            // statuses
                t.getLocalizedMessage(), t);

        ErrorDialog.openError(null, "Error", msg, ms);
    }
项目:team-explorer-everywhere    文件:NonFatalCommandHelper.java   
/**
 * Gets the best status to use (might be a {@link MultiStatus} to explain
 * the accumulated non-fatal errors. The given format string is used only
 * when multiple errors are present. If only one error happened, then that
 * error's status is returned and the message format string is not used.
 *
 * @param severity
 *        the severity with which to construct the returned status
 * @param errorCount
 *        the count of errors to format the
 *        multipleStatusesDescriptionFormat format string with
 * @param multipleErrorsDescriptionFormat
 *        a format string, {0} is errorCount, to use in the status when
 *        multiple non-fatal errors were encountered (must not be
 *        <code>null</code>)
 * @return
 */
public IStatus getBestStatus(
    final int severity,
    final int errorCount,
    final String multipleErrorsDescriptionFormat) {
    final IStatus[] statuses = getStatuses(severity);

    if (statuses.length == 0) {
        /* Hopefully never happens, but vague is better than nothing. */
        return new Status(
            severity,
            TFSCommonClientPlugin.PLUGIN_ID,
            0,
            Messages.getString("NonFatalCommandHelper.UnspecifiedErrorMoreInfoInLog"), //$NON-NLS-1$
            null);
    } else if (statuses.length == 1) {
        return statuses[0];
    } else {
        return new MultiStatus(
            TFSCommonClientPlugin.PLUGIN_ID,
            0,
            statuses,
            MessageFormat.format(multipleErrorsDescriptionFormat, errorCount),
            null);
    }
}
项目:team-explorer-everywhere    文件:StatusHelper.java   
public static IStatus combine(
    final String pluginId,
    final int code,
    final String message,
    final IStatus one,
    final IStatus two) {
    if (one == null && two == null) {
        return null;
    }

    final MultiStatus newStatus = new MultiStatus(pluginId, code, message, null);

    if (one != null && one.isMultiStatus()) {
        newStatus.addAll(one);
    } else if (one != null) {
        newStatus.add(one);
    }

    if (two != null && two.isMultiStatus()) {
        newStatus.addAll(two);
    } else if (two != null) {
        newStatus.add(two);
    }

    return newStatus;
}
项目:subclipse    文件:SVNFileModificationValidator.java   
protected IStatus getStatus(IFile[] files) {
      if (files.length == 1) {
    return getDefaultStatus(files[0]);
}

IStatus[] stati = new Status[files.length];
boolean allOK = true;

for (int i = 0; i < files.length; i++) {
    stati[i] = getDefaultStatus(files[i]);  
    if(! stati[i].isOK())
        allOK = false;
}

return new MultiStatus(SVNProviderPlugin.ID,
    0, stati,
    allOK
            ? Policy.bind("ok")
            : Policy.bind("FileModificationValidator.someReadOnly"),
    null);
  }
项目:subclipse    文件:SVNOperation.java   
protected void handleErrors(IStatus[] errors) throws SVNException {
    if (errors.length == 0) return;
    if (errors.length == 1 && statusCount == 1)  {
        throw new SVNException(errors[0]);
    }
    MultiStatus result = new MultiStatus(SVNUIPlugin.ID, 0, getErrorMessage(errors, statusCount), null);
    for (int i = 0; i < errors.length; i++) {
        IStatus s = errors[i];
        if (s.isMultiStatus()) {
            result.add(new SVNStatus(s.getSeverity(), s.getMessage(), s.getException()));
            result.addAll(s);
        } else {
            result.add(s);
        }
    }
    throw new SVNException(result);
}
项目:google-cloud-eclipse    文件:StatusUtil.java   
public static IStatus merge(IStatus status, IStatus newStatus) {
  if (status == null) {
    return newStatus;
  } else {
    if (status instanceof MultiStatus) {
      ((MultiStatus) status).merge(newStatus);
      return status;
    } else {
      MultiStatus merged = new MultiStatus(status.getPlugin(), status.getCode(),
          status.getMessage(), status.getException());
      merged.merge(newStatus);
      return merged;
    }
  }

}
项目:google-cloud-eclipse    文件:StatusUtil.java   
/**
 * Return a simplified status by discarding all OK child statuses.
 */
public static IStatus filter(IStatus status) {
  if (!status.isMultiStatus()) {
    return status;
  } else if (status.isOK()) {
    // return OK_STATUS to avoids oddities like Progress View showing the MultiStatus's
    // error message
    return Status.OK_STATUS;
  }
  MultiStatus newStatus = new MultiStatus(status.getPlugin(), status.getCode(),
      status.getMessage(), status.getException());
  for (IStatus child : status.getChildren()) {
    if (!child.isOK()) {
      newStatus.add(filter(child));
    }
  }
  return newStatus;
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegate.java   
@VisibleForTesting
void checkConflictingLaunches(ILaunchConfigurationType launchConfigType, String mode,
    DefaultRunConfiguration runConfig, ILaunch[] launches) throws CoreException {

  for (ILaunch launch : launches) {
    if (launch.isTerminated()
        || launch.getLaunchConfiguration() == null
        || launch.getLaunchConfiguration().getType() != launchConfigType) {
      continue;
    }
    IServer otherServer = ServerUtil.getServer(launch.getLaunchConfiguration());
    DefaultRunConfiguration otherRunConfig =
        generateServerRunConfiguration(launch.getLaunchConfiguration(), otherServer, mode);
    IStatus conflicts = checkConflicts(runConfig, otherRunConfig,
        new MultiStatus(Activator.PLUGIN_ID, 0,
            Messages.getString("conflicts.with.running.server", otherServer.getName()), //$NON-NLS-1$
            null));
    if (!conflicts.isOK()) {
      throw new CoreException(StatusUtil.filter(conflicts));
    }
  }
}
项目:google-cloud-eclipse    文件:LocalAppEngineServerLaunchConfigurationDelegate.java   
/**
 * Check for known conflicting settings.
 */
@VisibleForTesting
static IStatus checkConflicts(RunConfiguration ours, RunConfiguration theirs,
    MultiStatus status) {
  Class<?> clazz = LocalAppEngineServerLaunchConfigurationDelegate.class;
  // use {0,number,#} to avoid localized port numbers
  if (equalPorts(ours.getPort(), theirs.getPort(),
      LocalAppEngineServerBehaviour.DEFAULT_SERVER_PORT)) {
    status.add(StatusUtil.error(clazz,
        Messages.getString("server.port", //$NON-NLS-1$
            ifNull(ours.getPort(), LocalAppEngineServerBehaviour.DEFAULT_SERVER_PORT))));
  }
  if (equalPorts(ours.getApiPort(), theirs.getApiPort(), 0)) {
    // ours.getAdminPort() will never be null with a 0 default
    Preconditions.checkNotNull(ours.getApiPort());
    status.add(StatusUtil.error(clazz, Messages.getString("api.port", ours.getAdminPort()))); //$NON-NLS-1$
  }

  return status;
}
项目:google-cloud-eclipse    文件:LibraryClasspathContainerResolverService.java   
@Override
public IStatus resolveAll(IJavaProject javaProject, IProgressMonitor monitor) {
  try {
    MultiStatus status = StatusUtil.multi(this, Messages.getString("TaskResolveLibrariesError")); //$NON-NLS-1$
    IClasspathEntry[] rawClasspath = javaProject.getRawClasspath();
    SubMonitor subMonitor = SubMonitor.convert(monitor,
        Messages.getString("TaskResolveLibraries"), //$NON-NLS-1$
        getTotalWork(rawClasspath));
    for (IClasspathEntry classpathEntry : rawClasspath) {
      if (classpathEntry.getPath().segment(0)
          .equals(LibraryClasspathContainer.CONTAINER_PATH_PREFIX)) {
        IStatus resolveContainerStatus =
            resolveContainer(javaProject, classpathEntry.getPath(), subMonitor.newChild(1));
        status.add(resolveContainerStatus);
      }
    }
    // rewrite if OK as otherwise Progress View shows the resolving error message
    return StatusUtil.filter(status);
  } catch (CoreException ex) {
    return StatusUtil.error(this, 
        Messages.getString("TaskResolveLibrariesError"), ex); //$NON-NLS-1$
  }
}
项目:google-cloud-eclipse    文件:BasePublishOperation.java   
/**
 * Utility method to throw a CoreException based on the contents of a list of error and warning
 * status.
 * 
 * @param statuses a list of error and warning IStatus
 * @throws CoreException reporting these error and warning statuses
 */
protected static void throwExceptionOnError(List<IStatus> statuses) throws CoreException {
  if (statuses == null || statuses.size() == 0) {
    return;
  }

  if (statuses.size() == 1) {
    IStatus substatus = statuses.get(0);
    throw new CoreException(substatus);
  }
  IStatus[] children = new IStatus[statuses.size()];
  statuses.toArray(children);
  String message = "Publishing failed with multiple errors"; // Messages.errorPublish;
  MultiStatus multistatus = new MultiStatus(PLUGIN_ID, 0, children, message, null);
  throw new CoreException(multistatus);
}
项目:tlaplus    文件:ModelEditor.java   
private static IStatus shortenStatusMessage(IStatus status) {
    if (status.isMultiStatus()) {
        final IStatus[] convertedChildren = new Status[status.getChildren().length];
        // convert nested status objects.
        final IStatus[] children = status.getChildren();
        for (int i = 0; i < children.length; i++) {
            final IStatus child = children[i];
            convertedChildren[i] = new Status(child.getSeverity(), child.getPlugin(), child.getCode(),
                    substring(child.getMessage()),
                    child.getException());
        }
        return new MultiStatus(status.getPlugin(), status.getCode(), convertedChildren,
                substring(status.getMessage()),
                status.getException());
    } else {
        return new Status(status.getSeverity(), status.getPlugin(), status.getCode(),
                substring(status.getMessage()),
                status.getException());
    }
}
项目:NEXCORE-UML-Modeler    文件:UMLFileTreeNode.java   
/**
 * @see nexcore.tool.uml.ui.core.project.ITreeNode#isValid()
 */
public boolean isValid() {
    IFile file = WorkspaceSynchronizer.getFile(eobject.eResource());
    try {
        file.deleteMarkers(IMarker.PROBLEM, true, 0);
        IStatus valid = ModelUpdater.isValid(file);
        if (valid.getSeverity() != IStatus.OK) {
            if (valid.isMultiStatus()) {
                MultiStatus status = (MultiStatus) valid;
                IStatus[] children = status.getChildren();
                for (IStatus s : children) {
                    IMarker createMarker = file.createMarker(IMarker.PROBLEM);
                    createMarker.setAttribute(IMarker.MESSAGE, s.getMessage());
                    createMarker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
                }
            }
        }
        return valid.getSeverity() == IStatus.OK;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
项目:che    文件:ResourceChangeValidator.java   
private IStatus combineResults(IStatus[] result) {
  List<IStatus> notOK = new ArrayList<IStatus>();
  for (int i = 0; i < result.length; i++) {
    IStatus status = result[i];
    if (!status.isOK()) {
      notOK.add(status);
    }
  }
  if (notOK.isEmpty()) {
    return Status.OK_STATUS;
  }
  if (notOK.size() == 1) {
    return notOK.get(0);
  }
  return new MultiStatus(
      ResourcesPlugin.PI_RESOURCES,
      0,
      notOK.toArray(new IStatus[notOK.size()]),
      Messages.mapping_multiProblems,
      null);
}
项目:che    文件:Resources.java   
private static IStatus addModified(IStatus status, IFile file) {
  IStatus entry =
      JavaUIStatus.createError(
          IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
          Messages.format(
              CorextMessages.Resources_fileModified,
              BasicElementLabels.getPathLabel(file.getFullPath(), false)),
          null);
  if (status == null) {
    return entry;
  } else if (status.isMultiStatus()) {
    ((MultiStatus) status).add(entry);
    return status;
  } else {
    MultiStatus result =
        new MultiStatus(
            JavaPlugin.getPluginId(),
            IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
            CorextMessages.Resources_modifiedResources,
            null);
    result.add(status);
    result.add(entry);
    return result;
  }
}
项目:che    文件:RefactoringHistoryManager.java   
/**
 * Returns the cached refactoring session descriptor.
 *
 * @param store the file store of the descriptor
 * @param projectName project name, or <code>null</code> for the workspace
 * @param input the input stream where to read the descriptor
 * @return the cached refactoring session descriptor
 * @throws CoreException if an error occurs while reading the session
 */
private RefactoringSessionDescriptor getCachedSession(
    final IFileStore store, String projectName, final InputStream input) throws CoreException {
  if (store.equals(fCachedStore) && fCachedDescriptor != null) return fCachedDescriptor;
  final RefactoringSessionDescriptor descriptor;
  try {
    descriptor =
        new RefactoringSessionReader(false, projectName).readSession(new InputSource(input));
    fCachedDescriptor = descriptor;
    fCachedStore = store;
    return descriptor;
  } catch (CoreException e) {
    throw new CoreException(
        new MultiStatus(
            RefactoringCorePlugin.getPluginId(),
            IRefactoringCoreStatusCodes.REFACTORING_HISTORY_IO_ERROR,
            new IStatus[] {e.getStatus()},
            Messages.format(
                RefactoringCoreMessages.RefactoringHistoryManager_error_reading_file,
                BasicElementLabels.getURLPart(store.toURI().toString())),
            null));
  }
}
项目:gama    文件:NavigatorResourceDropAssistant.java   
/**
 * Performs a drop using the FileTransfer transfer type.
 */
private IStatus performFileDrop(final CommonDropAdapter anAdapter, final Object data) {
    final int currentOperation = anAdapter.getCurrentOperation();
    final MultiStatus problems =
            new MultiStatus(PlatformUI.PLUGIN_ID, 0, WorkbenchNavigatorMessages.DropAdapter_problemImporting, null);
    mergeStatus(problems,
            validateTarget(anAdapter.getCurrentTarget(), anAdapter.getCurrentTransfer(), currentOperation));

    final IContainer target = getActualTarget(ResourceManager.getResource(anAdapter.getCurrentTarget()));
    final String[] names = (String[]) data;
    // Run the import operation asynchronously.
    // Otherwise the drag source (e.g., Windows Explorer) will be blocked
    // while the operation executes. Fixes bug 16478.
    Display.getCurrent().asyncExec(() -> {
        getShell().forceActive();
        new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles(names, target, currentOperation);
    });
    return problems;
}
项目:JFaceUtils    文件:EnhancedErrorDialog.java   
public static MultiStatus createMultiStatus(final int severity, final Throwable throwable) {
    final Collection<IStatus> childStatuses = new ArrayList<IStatus>();

    StringReader sr = null;
    BufferedReader br = null;
    try {
        sr = new StringReader(ExceptionUtils.getStackTrace(throwable));
        br = new BufferedReader(sr);
        String line;
        while ((line = br.readLine()) != null) {
            final IStatus status = new Status(severity, throwable.getClass().getName(), line.replace("\t", NESTING_INDENT));
            childStatuses.add(status);
        }
    }
    catch (final IOException e) {
        logger.log(Level.WARNING, e.toString(), e);
    }
    finally {
        IOUtils.closeQuietly(br, sr);
    }

    return new MultiStatus(EnhancedErrorDialog.class.getPackage().getName(), severity, childStatuses.toArray(new IStatus[childStatuses.size()]), throwable.toString(), throwable);
}
项目:synergyview    文件:ProjectsDropAdapterAssistant.java   
/**
    * Performs a drop using the FileTransfer transfer type.
    * 
    * @param anAdapter
    *            the an adapter
    * @param data
    *            the data
    * @return the i status
    */
   private IStatus performFileDrop(CommonDropAdapter anAdapter, Object data) {

MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 0, WorkbenchNavigatorMessages.DropAdapter_problemImporting, null);
mergeStatus(problems, validateTarget(anAdapter.getCurrentTarget(), anAdapter.getCurrentTransfer(), anAdapter.getCurrentOperation()));

final IContainer target = getActualTarget(((MediaRootNode) anAdapter.getCurrentTarget()).getResource());
final String[] names = (String[]) data;
// Run the import operation asynchronously.
// Otherwise the drag source (e.g., Windows Explorer) will be blocked
// while the operation executes. Fixes bug 16478.
Display.getCurrent().asyncExec(new Runnable() {
    public void run() {
    getShell().forceActive();
    CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(getShell());
    operation.copyFiles(names, target);
    }
});
return problems;
   }
项目:APICloud-Studio    文件:SVNOperation.java   
protected void handleErrors(IStatus[] errors) throws SVNException {
    if (errors.length == 0) return;
    if (errors.length == 1 && statusCount == 1)  {
        throw new SVNException(errors[0]);
    }
    MultiStatus result = new MultiStatus(SVNUIPlugin.ID, 0, getErrorMessage(errors, statusCount), null);
    for (int i = 0; i < errors.length; i++) {
        IStatus s = errors[i];
        if (s.isMultiStatus()) {
            result.add(new SVNStatus(s.getSeverity(), s.getMessage(), s.getException()));
            result.addAll(s);
        } else {
            result.add(s);
        }
    }
    throw new SVNException(result);
}
项目:APICloud-Studio    文件:MarkerUtils.java   
/**
 * Delete all Markers with the given type.
 * 
 * @param resource
 * @param type
 * @param includeSubtypes
 * @return IMarker[]
 * @throws CoreException
 *             with a multi-status problems in case some markers where not successfully deleted.
 */
public static void deleteMarkers(IUniformResource resource, String type, boolean includeSubtypes)
        throws CoreException
{
    IMarker[] toDelete = findMarkers(resource, type, includeSubtypes);
    MultiStatus status = new MultiStatus(CorePlugin.PLUGIN_ID, 0, "Errors deleting markers", null); //$NON-NLS-1$
    for (IMarker marker : toDelete)
    {
        try
        {
            marker.delete();
        }
        catch (CoreException e)
        {
            status.add(new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, e.getMessage(), e));
        }
    }
    if (status.getChildren().length > 0)
    {
        throw new CoreException(status);
    }
}
项目:APICloud-Studio    文件:SVNFileModificationValidator.java   
protected IStatus getStatus(IFile[] files) {
      if (files.length == 1) {
    return getDefaultStatus(files[0]);
}

IStatus[] stati = new Status[files.length];
boolean allOK = true;

for (int i = 0; i < files.length; i++) {
    stati[i] = getDefaultStatus(files[i]);  
    if(! stati[i].isOK())
        allOK = false;
}

return new MultiStatus(SVNProviderPlugin.ID,
    0, stati,
    allOK
            ? Policy.bind("ok")
            : Policy.bind("FileModificationValidator.someReadOnly"),
    null);
  }
项目:Eclipse-Postfix-Code-Completion    文件:Resources.java   
private static IStatus addModified(IStatus status, IFile file) {
    IStatus entry= JavaUIStatus.createError(
        IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
        Messages.format(CorextMessages.Resources_fileModified, BasicElementLabels.getPathLabel(file.getFullPath(), false)),
        null);
    if (status == null) {
        return entry;
    } else if (status.isMultiStatus()) {
        ((MultiStatus)status).add(entry);
        return status;
    } else {
        MultiStatus result= new MultiStatus(JavaPlugin.getPluginId(),
            IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
            CorextMessages.Resources_modifiedResources, null);
        result.add(status);
        result.add(entry);
        return result;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Resources.java   
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, 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,
            CorextMessages.Resources_outOfSyncResources, null);
        result.add(status);
        result.add(entry);
        return result;
    }
}