當前位置: 首頁>>代碼示例>>Java>>正文


Java MultiStatus類代碼示例

本文整理匯總了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));
			}
		}
	}
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:18,代碼來源:ProjectStructureCreator.java

示例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();
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:27,代碼來源:ErrorDialogWithStackTraceUtil.java

示例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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:24,代碼來源:ExternalLibraryPreferencePage.java

示例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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:23,代碼來源:ExternalLibraryPreferencePage.java

示例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);

	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:31,代碼來源:ExternalLibraryPreferencePage.java

示例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();
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:33,代碼來源:ExternalLibraryPreferencePage.java

示例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()));
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:32,代碼來源:ExternalLibraryPreferencePage.java

示例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);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:26,代碼來源:NpmManager.java

示例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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:24,代碼來源:NpmManager.java

示例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 );
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:21,代碼來源:AbstractItemAction.java

示例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 );
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:21,代碼來源:PreferencePage.java

示例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 () );
        }
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:26,代碼來源:EditorHelper.java

示例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;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:23,代碼來源:AbstractServerHandler.java

示例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));
			}
		}
	}
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:19,代碼來源:ProjectStructureCreator.java

示例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$
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:27,代碼來源:TestingEnvironment.java


注:本文中的org.eclipse.core.runtime.MultiStatus類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。