当前位置: 首页>>代码示例>>Java>>正文


Java MultiStatus.merge方法代码示例

本文整理汇总了Java中org.eclipse.core.runtime.MultiStatus.merge方法的典型用法代码示例。如果您正苦于以下问题:Java MultiStatus.merge方法的具体用法?Java MultiStatus.merge怎么用?Java MultiStatus.merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.runtime.MultiStatus的用法示例。


在下文中一共展示了MultiStatus.merge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performOk

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
@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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:ExternalLibraryPreferencePage.java

示例2: maintenanceReinstallNpms

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
/**
 * 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);

	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:31,代码来源:ExternalLibraryPreferencePage.java

示例3: maintenanceDeleteNpms

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
/**
 * 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();
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:33,代码来源:ExternalLibraryPreferencePage.java

示例4: maintenanceResetTypeDefinitions

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
/**
 * 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()));
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:32,代码来源:ExternalLibraryPreferencePage.java

示例5: installUninstallNPMs

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
private void installUninstallNPMs(final Map<String, String> versionedNPMs, final IProgressMonitor monitor,
		final MultiStatus status, final Set<String> requestedNPMs, final Set<String> oldNPMs) {

	logger.logInfo(LINE_SINGLE);
	logger.logInfo("Installing packages... [step 1 of 4]");
	monitor.setTaskName("Installing packages... [step 1 of 4]");
	// calculate already installed to skip
	final Set<String> npmNamesToInstall = difference(requestedNPMs, oldNPMs);
	final Set<String> npmsToInstall = versionedNPMs.entrySet().stream()
			// skip already installed
			.filter(e -> npmNamesToInstall.contains(e.getKey()))
			// [name, @">=1.0.0 <2.0.0"] to [[email protected]">=1.0.0 <2.0.0"]
			.map(e -> e.getKey() + Strings.emptyIfNull(e.getValue()))
			.collect(Collectors.toSet());

	IStatus installStatus = batchInstallUninstall(monitor, npmsToInstall, true);

	// log possible errors, but proceed with the process
	// assume that at least some packages were installed correctly and can be adapted
	if (!installStatus.isOK()) {
		logger.logInfo("Some packages could not be installed due to errors, see log for details.");
		status.merge(installStatus);
	}
	monitor.worked(2);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:NpmManager.java

示例6: adaptNPMPackages

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:NpmManager.java

示例7: merge

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
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;
    }
  }
  
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:17,代码来源:StatusUtil.java

示例8: maintenanceUpateState

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
/**
 * Updates all affected state after maintenance actions have been performed. In particular updates state of the
 * workspace, persisted preferences state, and displayed preferences.
 *
 * @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
 */
private void maintenanceUpateState(final MaintenanceActionsChoice userChoice,
		final MultiStatus multistatus, IProgressMonitor monitor) {
	if (userChoice.decisionReload || userChoice.decisionReinstall || userChoice.decisionPurgeNpm
			|| userChoice.decisionResetTypeDefinitions) {
		externalLibraryWorkspace.updateState();
		try {
			externalLibrariesReloadHelper.reloadLibraries(true, monitor);
		} catch (InvocationTargetException e) {
			multistatus.merge(
					statusHelper.createError("Error when reloading libraries after maintenance actions.", e));
		}
		updateInput(viewer, store.getLocations());
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:ExternalLibraryPreferencePage.java

示例9: widgetSelected

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
@Override
public void widgetSelected(final SelectionEvent e) {
	final MultiStatus multistatus = statusHelper.createMultiStatus("Status of installing npm dependencies.");

	InstallNpmDependencyDialog dialog = new InstallNpmDependencyDialog(getShell(),
			packageNameValidator.get(), packageVersionValidator.get());
	dialog.open();
	final String packageName = dialog.getPackageName();
	if (!StringExtensions.isNullOrEmpty(packageName) && dialog.getReturnCode() == Window.OK) {
		try {
			final String packageVersion = dialog.getVersionConstraint();
			new ProgressMonitorDialog(getShell()).run(true, false, monitor -> {
				multistatus
						.merge(installAction.apply(Collections.singletonMap(packageName, packageVersion), monitor));
			});
		} catch (final InvocationTargetException | InterruptedException exc) {
			multistatus.merge(
					statusHelper.createError("Error while installing npm dependency: '" + packageName + "'.",
							exc));
		} finally {
			if (!multistatus.isOK()) {
				N4JSActivator.getInstance().getLog().log(multistatus);
				getDisplay().asyncExec(() -> openError(
						UIUtils.getShell(),
						"npm Install Failed",
						"Error while installing '" + packageName
								+ "' npm package.\nPlease check your Error Log view for the detailed npm log about the failure."));
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:32,代码来源:InstallNpmDependencyButtonListener.java

示例10: widgetSelected

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
@Override
public void widgetSelected(final SelectionEvent e) {
	final MultiStatus multistatus = statusHelper.createMultiStatus("Status of uninstalling npm dependencies.");

	final InputDialog dialog = new InputDialog(UIUtils.getShell(), "npm Uninstall",
			"Specify an npm package name to uninstall:", initalValue.get(), validator.get());

	dialog.open();
	final String packageName = dialog.getValue();
	if (!StringExtensions.isNullOrEmpty(packageName) && dialog.getReturnCode() == Window.OK) {
		try {
			new ProgressMonitorDialog(UIUtils.getShell()).run(true, false, monitor -> {
				multistatus.merge(uninstallAction.apply(Arrays.asList(packageName), monitor));
			});
		} catch (final InvocationTargetException | InterruptedException exc) {
			multistatus.merge(
					statusHelper.createError("Error while uninstalling npm dependency: '" + packageName + "'.",
							exc));
		} finally {
			if (!multistatus.isOK()) {
				N4JSActivator.getInstance().getLog().log(multistatus);
				getDisplay().asyncExec(() -> openError(
						UIUtils.getShell(),
						"npm Uninstall Failed",
						"Error while uninstalling '" + packageName
								+ "' npm package.\nPlease check your Error Log view for the detailed npm log about the failure."));
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:31,代码来源:UninstallNpmDependencyButtonListener.java

示例11: refreshInstalledNpmPackagesInternal

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
private IStatus refreshInstalledNpmPackagesInternal(final IProgressMonitor monitor) {
	checkNotNull(monitor, "monitor");

	final Collection<String> packageNames = getAllNpmProjectsMapping().keySet();

	if (packageNames.isEmpty()) {
		return statusHelper.OK();
	}

	final SubMonitor subMonitor = SubMonitor.convert(monitor, packageNames.size() + 1);
	try {

		logger.logInfo(LINE_DOUBLE);
		logger.logInfo("Refreshing installed npm packages.");
		subMonitor.setTaskName("Refreshing cache for type definitions files...");

		performGitPull(subMonitor.newChild(1, SubMonitor.SUPPRESS_ALL_LABELS));

		final MultiStatus refreshStatus = statusHelper
				.createMultiStatus("Status of refreshing definitions for npm packages.");
		for (final String packageName : packageNames) {
			final IStatus status = refreshInstalledNpmPackage(packageName, false, subMonitor.newChild(1));
			if (!status.isOK()) {
				logger.logError(status);
				refreshStatus.merge(status);
			}
		}
		logger.logInfo("Installed npm packages have been refreshed.");
		logger.logInfo(LINE_DOUBLE);
		return refreshStatus;

	} finally {
		subMonitor.done();
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:36,代码来源:NpmManager.java

示例12: queryHistory

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
/**
 * Queries history in item mode for the class's configured resource and
 * returns the changesets found.
 *
 * Consumes one unit of work from the given {@link IProgressMonitor}.
 *
 * @param progressMonitor
 *        a progress monitor used for running {@link QueryHistoryCommand}; 1
 *        unit of work will be used by this method (must not be
 *        <code>null</code> )
 * @param multiStatus
 *        a {@link MultiStatus} into which the status of the history query
 *        will be merged (must not be <code>null</code>)
 * @return the changesets returned by the server, <code>null</code> if no
 *         changesets were returned by the server or the user cancelled
 */
private Changeset[] queryHistory(final IProgressMonitor progressMonitor, final MultiStatus multiStatus)
    throws Exception {
    Check.notNull(progressMonitor, "progressMonitor"); //$NON-NLS-1$
    Check.notNull(multiStatus, "multiStatus"); //$NON-NLS-1$

    try {
        final String messageFormat = Messages.getString("AnnotateCommand.ProgressQueryingHistoryFormat"); //$NON-NLS-1$
        final String message = MessageFormat.format(messageFormat, resource.getLocation().toOSString());
        progressMonitor.setTaskName(message);

        final QueryHistoryCommand queryHistoryCommand = new QueryHistoryCommand(
            repository,
            resource.getLocation().toOSString(),
            new WorkspaceVersionSpec(repository.getWorkspace()),
            RecursionType.NONE,
            BEGINNING_OF_TIME,
            new WorkspaceVersionSpec(repository.getWorkspace()));

        final IStatus status = queryHistoryCommand.run(new NullProgressMonitor());
        multiStatus.merge(status);

        return queryHistoryCommand.getChangesets();
    } finally {
        progressMonitor.worked(1);
    }
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:43,代码来源:AnnotateCommand.java

示例13: fromString

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
public static SVNRepositoryLocation fromString(String location)
	throws SVNException {
	try {
		return fromString(location, false);
	} catch (SVNException e) {
		// Parsing failed. Include a status that
		// shows the passed location and the proper form
		MultiStatus error = new MultiStatus(SVNProviderPlugin.ID, SVNStatus.ERROR, Policy.bind("SVNRepositoryLocation.invalidFormat", new Object[] { location }), null); //$NON-NLS-1$ 
		error.merge(new SVNStatus(SVNStatus.ERROR, Policy.bind("SVNRepositoryLocation.locationForm"))); //$NON-NLS-1$ 
		error.merge(e.getStatus());
		throw new SVNException(error);
	}
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:14,代码来源:SVNRepositoryLocation.java

示例14: getStatusToDisplay

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
/**
 * Return the status to be displayed in an error dialog for the given list
 * of non-OK status.
 * 
 * This method can be overridden by subclasses. Returning an OK status will 
 * prevent the error dialog from being shown.
 */
protected IStatus getStatusToDisplay(IStatus[] problems) {
	if (problems.length == 1) {
		return problems[0];
	}
	MultiStatus combinedStatus = new MultiStatus(SVNUIPlugin.ID, 0, getMultiStatusMessage(), null); //$NON-NLS-1$
	for (int i = 0; i < problems.length; i++) {
		combinedStatus.merge(problems[i]);
	}
	return combinedStatus;
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:18,代码来源:SVNAction.java

示例15: upgradeProjects

import org.eclipse.core.runtime.MultiStatus; //导入方法依赖的package包/类
/**
 * Perform the upgrade.
 */
private IStatus upgradeProjects(Collection<IProject> projects, SubMonitor progress) {
  progress.setWorkRemaining(projects.size());
  MultiStatus status = StatusUtil.multi(this, Messages.getString("updating.projects.jobname")); //$NON-NLS-1$
  for (IProject project : projects) {
    progress.subTask(Messages.getString("updating.project", project.getName())); //$NON-NLS-1$
    IStatus result = CloudToolsEclipseProjectUpdater.updateProject(project, progress.newChild(1));
    status.merge(result);
  }
  // rewrite if OK as otherwise Progress View shows the "Updating projects for..." message
  return StatusUtil.filter(status);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:15,代码来源:CloudToolsEclipseProjectNotifier.java


注:本文中的org.eclipse.core.runtime.MultiStatus.merge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。