本文整理汇总了Java中org.eclipse.core.runtime.MultiStatus类的典型用法代码示例。如果您正苦于以下问题:Java MultiStatus类的具体用法?Java MultiStatus怎么用?Java MultiStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultiStatus类属于org.eclipse.core.runtime包,在下文中一共展示了MultiStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyBuildFile
import org.eclipse.core.runtime.MultiStatus; //导入依赖的package包/类
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));
}
}
}
}
示例2: showErrorDialogWithStackTrace
import org.eclipse.core.runtime.MultiStatus; //导入依赖的package包/类
/**
* 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();
}
示例3: 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;
}
示例4: runMaintananceActions
import org.eclipse.core.runtime.MultiStatus; //导入依赖的package包/类
/**
* 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;
}
示例5: 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);
}
}
示例6: 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();
}
}
示例7: 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()));
}
}
}
示例8: 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);
}
示例9: 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;
}
示例10: run
import org.eclipse.core.runtime.MultiStatus; //导入依赖的package包/类
@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 );
}
}
示例11: handleRemove
import org.eclipse.core.runtime.MultiStatus; //导入依赖的package包/类
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 );
}
}
示例12: handleOpen
import org.eclipse.core.runtime.MultiStatus; //导入依赖的package包/类
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 () );
}
}
}
示例13: execute
import org.eclipse.core.runtime.MultiStatus; //导入依赖的package包/类
@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;
}
示例14: copyExternalLibAndAddToClassPath
import org.eclipse.core.runtime.MultiStatus; //导入依赖的package包/类
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));
}
}
}
}
示例15: handleCoreException
import org.eclipse.core.runtime.MultiStatus; //导入依赖的package包/类
/**
* 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$
}