org.eclipse.ui.internal.ide.IDEInternalPreferences#org.eclipse.core.runtime.MultiStatus源码实例Demo

下面列出了org.eclipse.ui.internal.ide.IDEInternalPreferences#org.eclipse.core.runtime.MultiStatus 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MergeProcessor   文件: MergeTask.java
/**
 * Executes the merge in a separate minimal working copy.
 * 
 * @throws InterruptedException
 * @throws InvocationTargetException
 * @throws SvnClientException
 */
private void mergeInMinimalWorkingCopy() throws InvocationTargetException, InterruptedException {
	LogUtil.entering();
	final ProgressMonitorDialog pmd = new ProgressMonitorDialog(shellProvider.getShell());
	Dashboard.setShellProgressMonitorDialog(pmd);
	pmd.run(true, true, monitor -> {
		try {
			boolean cancelled = MergeProcessorUtil.merge(pmd, monitor, configuration, mergeUnit);
			if (cancelled) {
				mergeUnit.setStatus(MergeUnitStatus.CANCELLED);
				MergeProcessorUtil.canceled(mergeUnit);
			} else {
				mergeUnit.setStatus(MergeUnitStatus.DONE);
			}
		} catch (Throwable e) {
			pmd.getShell().getDisplay().syncExec(() -> {
				MultiStatus status = createMultiStatus(e);
				ErrorDialog.openError(pmd.getShell(), "Error dusrching merge process",
						"An Exception occured during the merge process. The merge didn't run successfully.",
						status);
			});
		}

	});
	LogUtil.exiting();
}
 
源代码2 项目: 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();
}
 
@Override
public IStatus validate(final Object value) {
    checkArgument(value instanceof ContractConstraint);
    final ContractConstraint constraint = (ContractConstraint) value;
    final List<String> constraintInputNames = constraint.getInputNames();
    if (constraintInputNames.isEmpty()) {
        return ValidationStatus.error(Messages.bind(Messages.noInputReferencedInConstraintExpression, constraint.getName()));
    }
    final Set<String> existingInputNames = allContractInputNames(ModelHelper.getFirstContainerOfType(constraint, Contract.class));
    final MultiStatus status = new MultiStatus(ContractPlugin.PLUGIN_ID, IStatus.OK, "", null);
    for (final String name : constraintInputNames) {
        if (!existingInputNames.contains(name)) {
            status.add(ValidationStatus.error(Messages.bind(Messages.unknownInputReferencedInConstraintExpression, name, constraint.getName())));
        }
    }
    return status;
}
 
源代码4 项目: 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);
}
 
源代码5 项目: 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;
}
 
源代码6 项目: 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 );
    }
}
 
源代码7 项目: 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;
}
 
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;
	}
}
 
源代码9 项目: 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$
}
 
源代码10 项目: textuml   文件: CompilationDirectorCLI.java
private void compile(IRepository repository, final String inputPathAsString, final String outputPathAsString)
		throws CoreException {
	IFileSystem localFS = EFS.getLocalFileSystem();
	final IFileStore outputPath = localFS.getStore(new Path(outputPathAsString));
	LocationContext context = new LocationContext(outputPath);
	final IFileStore sourcePath = localFS.getStore(new Path(inputPathAsString));
	if (!sourcePath.fetchInfo().exists()) {
		System.err.println(sourcePath + " does not exist");
		System.exit(1);
	}
	context.addSourcePath(sourcePath, outputPath);
	int mode = ICompilationDirector.CLEAN | ICompilationDirector.FULL_BUILD;
	if (Boolean.getBoolean("args.debug"))
		mode |= ICompilationDirector.DEBUG;
	IProblem[] problems = CompilationDirector.getInstance().compile(null, repository, context, mode, null);
	if (problems.length > 0) {
		MultiStatus parent = new MultiStatus(FrontEnd.PLUGIN_ID, IStatus.OK, "Problems occurred", null);
		for (int i = 0; i < problems.length; i++) {
			String message = problems[i].toString();
			parent.add(buildStatus(message, null));
		}
		LogUtils.log(parent);
	} else
		LogUtils.logInfo(FrontEnd.PLUGIN_ID, "Done", null);
}
 
源代码11 项目: bonita-studio   文件: DeployArtifactsHandler.java
protected IStatus deployArtifacts(RepositoryAccessor repositoryAccessor,
        Collection<Artifact> artifactsToDeploy,
        Map<String, Object> deployOptions,
        IWizardContainer container) {
    MultiStatus status = new MultiStatus(ApplicationPlugin.PLUGIN_ID, 0, null, null);
    if (!checkDirtyState(container)) {
        return null;
    }
    try {
        container.run(true, true,
                performFinish(repositoryAccessor, artifactsToDeploy, deployOptions, status));
    } catch (InvocationTargetException | InterruptedException e) {
        BonitaStudioLog.error(e);
        return new Status(IStatus.ERROR, ApplicationPlugin.PLUGIN_ID, "Deploy failed",
                e.getCause() != null ? e.getCause() : e);
    }
    if (status.getSeverity() == IStatus.CANCEL) {
        openAbortDialog(Display.getDefault().getActiveShell());
    }
    return status.getSeverity() == IStatus.CANCEL ? null : status;
}
 
@VisibleForTesting
void checkConflictingLaunches(ILaunchConfigurationType launchConfigType, String mode,
    RunConfiguration 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());
    List<Path> paths = new ArrayList<>();
    RunConfiguration otherRunConfig =
        generateServerRunConfiguration(launch.getLaunchConfiguration(), otherServer, mode, paths);
    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));
    }
  }
}
 
@Override
protected IStatus performBatchValidation(final IValidationContext context) {
    final BusinessObjectModelFileStore modelFileStore = getCurrentBDM();
    final MultiStatus multiStatus = new MultiStatus(ValidationPlugin.PLUGIN_ID, 0, null, null);
    if (modelFileStore != null) {
        for (final BusinessObject bo : modelFileStore.getBusinessObjects()) {
            for (final Query q : BDMQueryUtil.createProvidedQueriesForBusinessObject(bo)) {
                for (final Query customQuery : bo.getQueries()) {
                    if (Objects.equal(customQuery.getName().toLowerCase(), q.getName().toLowerCase())) {
                        multiStatus.add(
                                context.createFailureStatus(NLS.bind(Messages.conflictingQueryNamesInBusinessObject,
                                        bo.getSimpleName(), q.getName())));
                    }
                }
            }
        }
        return multiStatus;
    }
    return context.createSuccessStatus();
}
 
public static Object[] getSelectedElementsWithoutContainedChildren(ILaunchConfiguration launchconfig, JarPackageData data, IRunnableContext context, MultiStatus status) throws CoreException {
	if (launchconfig == null)
		return new Object[0];

	String projectName= launchconfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$

	IPath[] classpath= getClasspath(launchconfig);
	IPackageFragmentRoot[] classpathResources= getRequiredPackageFragmentRoots(classpath, projectName, status);

	String mainClass= getMainClass(launchconfig, status);
	IType mainType= findMainMethodByName(mainClass, classpathResources, context);
	if (mainType == null) {
		status.add(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, FatJarPackagerMessages.FatJarPackageWizardPage_error_noMainMethod));
	}
	data.setManifestMainClass(mainType);

	return classpathResources;
}
 
源代码15 项目: bonita-studio   文件: LabelProviderBuilder.java
private Function<T, Optional<String>> tooltipProvider() {
    return element -> {
        if (statusProvider.isPresent()) {
            final IStatus status = statusProvider.get().apply(element);
            if (!status.isOK()) {
                if (status.isMultiStatus()) {
                    return Optional.ofNullable(Arrays.asList(((MultiStatus) status).getChildren()).stream()
                            .filter(s -> !s.isOK())
                            .map(IStatus::getMessage)
                            .reduce((message1, message2) -> String.format("%s\n%s", message1, message2)).orElse(""));
                }
                return Optional.ofNullable(status.getMessage());
            }
        }
        if (tooltipFunction.isPresent()) {
            return Optional.ofNullable(tooltipFunction.get().apply(element));
        }
        return Optional.empty();
    };
}
 
源代码16 项目: translationstudio8   文件: OpenMessageUtils.java
/**
 * 将<code>Throwable<code>转化成<code>MultiStatus<code>对象,
 * 让<code>MultiStatus<code>对象包含详细的<code>Throwable<code>详细的堆栈信息。
 * @param message
 *            <code>MultiStatus<code>对象的消息
 * @param throwable
 *            异常对象
 * @return 包含有详细的堆栈信息的<code>MultiStatus<code>对象;
 */
public static MultiStatus throwable2MultiStatus(String message, Throwable throwable) {
	StringWriter sw = new StringWriter();
	PrintWriter pw = new PrintWriter(sw);
	throwable.printStackTrace(pw);

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

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

	// Split output by OS-independend new-line
	String[] lines = trace.split(System.getProperty("line.separator")); //$NON-NLS-N$
	int j = lines.length == 1 ? 0 : 1;
	for (int i = j; i < lines.length; i++) {
		String line = lines[i];
		// build & add status
		childStatuses.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, line));
	}

	// convert to array of statuses
	MultiStatus ms = new MultiStatus(Activator.PLUGIN_ID, IStatus.ERROR, childStatuses.toArray(new Status[] {}),
			message, throwable);
	return ms;
}
 
源代码17 项目: Pydev   文件: PyResourceDropAdapterAssistant.java
/**
 * Performs a resource copy
 */
private IStatus performResourceCopy(CommonDropAdapter dropAdapter, Shell shell, IResource[] sources) {
    MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1,
            WorkbenchNavigatorMessages.DropAdapter_problemsMoving, null);
    mergeStatus(
            problems,
            validateTarget(getCurrentTarget(dropAdapter), dropAdapter.getCurrentTransfer(),
                    dropAdapter.getCurrentOperation()));

    IContainer target = getActualTarget((IResource) getCurrentTarget(dropAdapter));
    CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
    IResource[] copiedResources = operation.copyResources(sources, target);
    if (copiedResources.length > 0) {
        PythonPathHelper.updatePyPath(copiedResources, target, PythonPathHelper.OPERATION_COPY);
    }

    return problems;
}
 
源代码18 项目: bonita-studio   文件: MultiStatusDialog.java
public MultiStatusDialog(Shell parentShell, String dialogTitle,
        String dialogMessage,
        int dialogImageType,
        String[] dialogButtonLabels,
        MultiStatus status,
        int finishId,
        Predicate<IStatus> canFinish) {
    super(parentShell, dialogTitle, dialogMessage, dialogImageType, dialogButtonLabels);
    this.status = status;
    this.canFinish = canFinish;
    this.finishId = finishId;
}
 
public static void logErrorStatus(String message, IStatus status) {
	if (status == null) {
		logErrorMessage(message);
		return;
	}
	MultiStatus multi = new MultiStatus(PLUGIN_ID, IEditorConfigStatusConstants.INTERNAL_ERROR, message, null);
	multi.add(status);
	log(multi);
}
 
源代码20 项目: n4js   文件: ExternalLibraryPreferencePage.java
/** Actions to be taken if deleting npms is requested. */
private MultiStatus cleanNpms(final IProgressMonitor monitor, final MultiStatus multistatus) {
	try {
		multistatus.merge(externalLibrariesActionsHelper.maintenanceDeleteNpms(monitor));
	} catch (Exception e) {
		String msg = "Error when cleaning external libraries.";
		multistatus.merge(statusHelper.createError(msg, e));
	} finally {
		updateInput(viewer, store.getLocations());
	}
	return multistatus;
}
 
/**
 * Tells whether one of the active post save listeners needs to be informed about the changed
 * region in this save cycle.
 * 
 * @param unit the unit which is about to be saved
 * @return true if the change regions need do be determined
 * @throws CoreException if something went wrong
 * @since 3.4
 */
public static boolean isChangedRegionsRequired(final ICompilationUnit unit) throws CoreException {
	String message= SaveParticipantMessages.SaveParticipantRegistry_needsChangedRegionFailed;
	final MultiStatus errorStatus= new MultiStatus(JavaUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_CHANGED_REGION_CALCULATION, message, null);

	IPostSaveListener[] listeners= JavaPlugin.getDefault().getSaveParticipantRegistry().getEnabledPostSaveListeners(unit.getJavaProject().getProject());
	try {
		final boolean result[]= new boolean[] {false};
		for (int i= 0; i < listeners.length; i++) {
			final IPostSaveListener listener= listeners[i];
			SafeRunner.run(new ISafeRunnable() {

				public void run() throws Exception {
					if (listener.needsChangedRegions(unit))
						result[0]= true;
				}

				public void handleException(Throwable ex) {
					String msg= Messages.format("The save participant ''{0}'' caused an exception.", new String[] { listener.getId() }); //$NON-NLS-1$
					JavaPlugin.log(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_POST_SAVE_NOTIFICATION, msg, ex));

					final String participantName= listener.getName();
					msg= Messages.format(SaveParticipantMessages.SaveParticipantRegistry_needsChangedRegionCausedException, new String[] { participantName, ex.toString() });
					errorStatus.add(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_CHANGED_REGION_CALCULATION, msg, null));
				}

			});
			if (result[0])
				return true;
		}
	} finally {
		if (!errorStatus.isOK())
			throw new CoreException(errorStatus);
	}

	return false;
}
 
/**
 * Returns the status of the operation. If there were any errors, the result is a status object containing
 * individual status objects for each error. If there were no errors, the result is a status object with error code
 * <code>OK</code>.
 * @return the status
 */
public IStatus getStatus() {
	IStatus[] errors = new IStatus[errorTable.size()];
	errorTable.toArray(errors);
	return new MultiStatus(IDEWorkbenchPlugin.IDE_WORKBENCH, IStatus.OK, errors,
			DataTransferMessages.FileSystemExportOperation_problemsExporting, null);
}
 
源代码23 项目: bonita-studio   文件: BuildProjectOperation.java
private void addToStatus(IStatus validationStatus) {
    if (validationStatus instanceof MultiStatus) {
        status.addAll(validationStatus);
    } else {
        status.add(validationStatus);
    }
}
 
源代码24 项目: bonita-studio   文件: DeployArtifactsHandler.java
private void addToMultiStatus(IStatus status, MultiStatus multiStatus) {
    if (status instanceof MultiStatus) {
        multiStatus.addAll(status);
    } else {
        multiStatus.add(status);
    }
}
 
源代码25 项目: Pydev   文件: PyConditionalBreakPointManager.java
/**
 * Display an error dialog and traceback raised while evaluating the
 * conditional breakpoint.
 *
 * @param payload
 *      would contain exception_type + "\t" + stacktrace_xml
 */
public void handleBreakpointException(final AbstractDebugTarget target,
        final String payload) {
    if (payload.indexOf(DELIMETER) > 0) {
        // exceptionDetailList = ["exceptionType", "<frame>traceback</frame>"]
        final String[] exceptionDetailList = payload.split(DELIMETER);

        RunInUiThread.async(new Runnable() {
            @Override
            public void run() {
                // adding exception detail with error message
                String errorMessage = ERROR_MESSAGE + "\n" + exceptionDetailList[0];
                List<ExceptionStackTrace> exceptionStackTraceList = new ArrayList<ExceptionStackTrace>();
                Shell shell = new Shell(Display.getCurrent());
                shell.setText(SHELL_TEXT);
                MultiStatus multiStatusInfo = new MultiStatus(PID, ERROR_CODE, errorMessage, null);

                multiStatusInfo.add(new Status(IStatus.ERROR, PID, ERROR_CODE, PYTHON_TRACEBACK, null));
                try {
                    // Parse traceback xml
                    exceptionStackTraceList = XMLUtils.getExceptionStackTrace(target, exceptionDetailList[1]);
                } catch (Exception e) {
                    Log.log(e);
                }
                if (exceptionStackTraceList != null) {
                    // Adding traceback details to multiStatusInfo
                    for (ExceptionStackTrace exceptionStackTrace : exceptionStackTraceList) {
                        multiStatusInfo.add(new Status(IStatus.ERROR, PID, ERROR_CODE, exceptionStackTrace
                                .toString(),
                                null));
                    }
                }
                ErrorDialog.openError(shell, TITLE, null, multiStatusInfo);
            }
        });
    }
}
 
源代码26 项目: bonita-studio   文件: DeployApplicationAction.java
protected int openStatusDialog(Shell shell, final DeployApplicationDescriptorOperation deployOperation,
        String[] onFinishButtons) {
    MultiStatus status = deployOperation.getStatus() instanceof MultiStatus ? (MultiStatus) deployOperation.getStatus()
            : new MultiStatus(LivingApplicationPlugin.PLUGIN_ID, 0, new IStatus[] { deployOperation.getStatus() }, "",
                    null);
    return new MultiStatusDialog(shell, Messages.deployDoneTitle, Messages.deployDoneMessage, MessageDialog.INFORMATION,
            onFinishButtons, status).open();
}
 
源代码27 项目: bonita-studio   文件: BatchValidationOperation.java
private boolean statusExists(final MultiStatus multi, final String message) {
    for (final IStatus s : multi.getChildren()) {
        if (s.getMessage().equals(message)) {
            return true;
        }
    }
    return false;
}
 
源代码28 项目: n4js   文件: NpmCLI.java
private Collection<LibraryChange> batchInstallInternal(IProgressMonitor monitor, MultiStatus status,
		Collection<LibraryChange> requestedChanges, FileURI target) {

	SubMonitor subMonitor = SubMonitor.convert(monitor, 1);
	subMonitor.setTaskName("Installing npm packages.");

	// Convert platform URI to local (e.g. file) URI
	File installPath = target.toJavaIoFile();

	// for installation, we invoke npm only once for all packages
	final List<Pair<N4JSProjectName, String>> packageNamesAndVersions = Lists.newArrayList();
	for (LibraryChange reqChg : requestedChanges) {
		if (reqChg.type == LibraryChangeType.Install) {
			packageNamesAndVersions.add(Tuples.pair(reqChg.name, "@" + reqChg.version));
		}
	}

	IStatus installStatus = install(packageNamesAndVersions, installPath);
	subMonitor.worked(1);

	Set<LibraryChange> actualChanges;
	MultiStatus batchStatus = statusHelper.createMultiStatus("Installing npm packages.");
	if (installStatus == null || !installStatus.isOK()) {
		actualChanges = Collections.emptySet();
		batchStatus.merge(installStatus);
	} else {
		actualChanges = computeActualChanges(installPath.toPath(), requestedChanges, batchStatus);
	}

	if (!batchStatus.isOK()) {
		logger.logInfo("Some packages could not be installed due to errors, see log for details.");
		status.merge(batchStatus);
	}

	return actualChanges;
}
 
源代码29 项目: n4js   文件: NpmCLI.java
private Set<LibraryChange> computeActualChanges(Path installPath, Collection<LibraryChange> requestedChanges,
		MultiStatus mergeStatusHere) {
	Set<LibraryChange> result = new LinkedHashSet<>();
	Path nodeModulesFolder = installPath.resolve(N4JSGlobals.NODE_MODULES);
	for (LibraryChange reqChg : requestedChanges) {
		if (reqChg.type == LibraryChangeType.Install) {
			Path completePath = nodeModulesFolder.resolve(reqChg.name.getRawName());
			String actualVersion = getActualVersion(completePath);
			if (actualVersion.isEmpty()) {
				// unable to load version from package.json:
				// -> retry loading from node_modules folder located in yarn workspace root folder
				NodeModulesFolder nmf = nodeModulesDiscoveryHelper.getNodeModulesFolder(installPath);
				if (nmf.isYarnWorkspace()) {
					Path nodeModulesFolderInYarnWorkspaceRoot = nmf.workspaceNodeModulesFolder.toPath();
					completePath = nodeModulesFolderInYarnWorkspaceRoot.resolve(reqChg.name.getRawName());
					actualVersion = getActualVersion(completePath);
				}
			}
			if (actualVersion.isEmpty()) {
				String msg = "Error reading package json when " + reqChg.toString();
				IStatus packJsonError = statusHelper.createError(msg);
				mergeStatusHere.merge(packJsonError);
			} else {
				FileURI actualLocation = new FileURI(URIUtils.toFileUri(completePath));
				LibraryChange actualChange = new LibraryChange(LibraryChangeType.Added, actualLocation,
						reqChg.name, actualVersion);
				result.add(actualChange);
			}
		}
	}
	return result;
}
 
源代码30 项目: uima-uimaj   文件: PearException.java
/**
 * opens an ErrorDialog with details about this exception.
 *
 * @param shell the shell
 */
public void openErrorDialog(Shell shell) {
  try {
    getCause().printStackTrace();
    String msg = getCause().getMessage();
    msg = msg == null ? "" : msg; //$NON-NLS-1$
    MultiStatus status = new MultiStatus(PLUGIN_ID, IStatus.ERROR, getCustomStackTrace(), msg,
            getCause());
    ErrorDialog.openError(shell, "Operation Error", getMessage()
            + " \nPlease see the details (below).", status, 0xFFFF);
  } catch (Throwable th) {
    th.printStackTrace();
  }
}