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


Java IStatus.isOK方法代碼示例

本文整理匯總了Java中org.eclipse.core.runtime.IStatus.isOK方法的典型用法代碼示例。如果您正苦於以下問題:Java IStatus.isOK方法的具體用法?Java IStatus.isOK怎麽用?Java IStatus.isOK使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.runtime.IStatus的用法示例。


在下文中一共展示了IStatus.isOK方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateBinaries

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
private void validateBinaries() throws ExitCodeException {
	IStatus status = nodeJsBinaryProvider.get().validate();
	if (!status.isOK()) {
		System.out.println(status.getMessage());
		if (null != status.getException()) {
			dumpThrowable(status.getException());
		}
		throw new ExitCodeException(EXITCODE_CONFIGURATION_ERROR, status.getMessage(), status.getException());
	}
	if (null != targetPlatformFile) {
		status = npmBinaryProvider.get().validate();
		if (!status.isOK()) {
			System.out.println(status.getMessage());
			if (null != status.getException()) {
				dumpThrowable(status.getException());
			}
			throw new ExitCodeException(EXITCODE_CONFIGURATION_ERROR, status.getMessage(), status.getException());
		}
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:21,代碼來源:N4jscBase.java

示例2: maintenanceReinstallNpms

import org.eclipse.core.runtime.IStatus; //導入方法依賴的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: installIU

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
/**
 * Installs an {@link IInstallableUnit} from a p2 repository.
 * 
 * @param installableUnitID the ID of the IU to be installed
 * @param repositoryURI the repository ID
 * @return true if successful
 */
public boolean installIU(String installableUnitID, URI repositoryURI) {

	// --- Make sure the repository is known and enabled ---------
	this.addRepository(repositoryURI);

	// --- Query the repository for the IU of interest -----------
	IQueryResult<IInstallableUnit> queryResult = this.queryRepositoryForInstallableUnit(repositoryURI, installableUnitID);

	if (queryResult.isEmpty() == false) {

		// --- If found, trigger an InstallOperation ---------------
		InstallOperation installOperation = new InstallOperation(this.getProvisioningSession(), queryResult.toSet());
		IStatus result = this.performOperation(installOperation);
		return result.isOK();

	} else {

		// --- If not, print an error message -----------------------
		String errorMessage = "Installable unit " + installableUnitID + " could not be found in the repositoty " + repositoryURI;
		System.err.println(errorMessage);
		return false;

	}

}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:33,代碼來源:P2OperationsHandler.java

示例4: saveState

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
@Override
public IStatus saveState(final IProgressMonitor monitor) {
	final IStatus superSaveResult = super.saveState(monitor);

	if (superSaveResult.isOK()) {

		final Preferences node = getPreferences();
		node.put(ORDERED_FILTERS_KEY, Joiner.on(SEPARATOR).join(orderedWorkingSetFilters));

		try {
			node.flush();
		} catch (final BackingStoreException e) {
			final String message = "Error occurred while saving state to preference store.";
			LOGGER.error(message, e);
			return statusHelper.createError(message, e);
		}

		return statusHelper.OK();
	}

	return superSaveResult;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:23,代碼來源:ProjectNameFilterAwareWorkingSetManager.java

示例5: restoreState

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
@Override
public IStatus restoreState(final IProgressMonitor monitor) {
	final IStatus superRestoreResult = super.restoreState(monitor);

	if (superRestoreResult.isOK()) {

		final Preferences node = getPreferences();
		final String orderedFilters = node.get(ORDERED_FILTERS_KEY, EMPTY_STRING);
		if (!Strings.isNullOrEmpty(orderedFilters)) {
			orderedWorkingSetFilters.clear();
			orderedWorkingSetFilters.addAll(Arrays.asList(orderedFilters.split(SEPARATOR)));
		}

		discardWorkingSetCaches();
		return statusHelper.OK();

	}

	return superRestoreResult;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:21,代碼來源:ProjectNameFilterAwareWorkingSetManager.java

示例6: installUninstallNPMs

import org.eclipse.core.runtime.IStatus; //導入方法依賴的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

示例7: reloadLibrariesInternal

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
private void reloadLibrariesInternal(final boolean refreshNpmDefinitions, final IProgressMonitor monitor)
		throws InvocationTargetException {

	final SubMonitor subMonitor = SubMonitor.convert(monitor, refreshNpmDefinitions ? 2 : 1);

	if (monitor instanceof Cancelable) {
		((Cancelable) monitor).setCancelable(false); // No cancel is allowed from now on.
	}

	if (monitor.isCanceled()) {
		return;
	}

	// Refresh the type definitions for the npm packages if required.
	if (refreshNpmDefinitions) {
		final IStatus refreshStatus = npmManager.refreshInstalledNpmPackages(subMonitor.newChild(1));
		if (!refreshStatus.isOK()) {
			throw new InvocationTargetException(new CoreException(refreshStatus));
		}
	}

	// Make sure to rebuild only those external ones that are not in the workspace.
	// Get all accessible workspace projects...
	final Collection<String> workspaceProjectNames = from(asList(getWorkspace().getRoot().getProjects()))
			.filter(p -> p.isAccessible())
			.transform(p -> p.getName())
			.toSet();

	// And build all those externals that has no corresponding workspace project.
	final Iterable<IProject> toBuild = from(collector.collectExternalProjects())
			.filter(p -> !workspaceProjectNames.contains(p.getName()))
			.filter(IProject.class);

	final Iterable<IProject> workspaceProjectsToRebuild = collector
			.collectProjectsWithDirectExternalDependencies(toBuild);

	builderHelper.build(toBuild, subMonitor.newChild(1));

	scheduler.scheduleBuildIfNecessary(workspaceProjectsToRebuild);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:41,代碼來源:ExternalLibrariesReloadHelper.java

示例8: validateFullResourcePath

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
/**
 * @param resourcePath
 * @return
 */
protected boolean validateFullResourcePath(IPath resourcePath,Problem pb) {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();

	IStatus result = workspace.validatePath(resourcePath.toString(),
			IResource.FOLDER);
	if (!result.isOK()) {
		pb.raiseProblem(result.getMessage(), Problem.PROBLEM_PATH_INVALID);
		return false;
	}


	return true;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:18,代碼來源:FolderSelectionGroup.java

示例9: restoreState

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
@Override
public IStatus restoreState(final IProgressMonitor monitor) {
	final IStatus superRestoreResult = super.restoreState(monitor);

	if (superRestoreResult.isOK()) {

		final Preferences node = getPreferences();
		final String orderedFilters = node.get(ORDERED_ASSOCIATIONS_KEY, EMPTY_STRING);
		if (!Strings.isNullOrEmpty(orderedFilters)) {
			try {
				final ProjectAssociation association = mapper.readValue(orderedFilters, ProjectAssociation.class);
				projectAssociations.clear();
				projectAssociations.putAll(association);
			} catch (final IOException e) {
				final String message = "Error occurred while deserializing project associations.";
				LOGGER.error(message, e);
				return statusHelper.createError(message, e);
			}
		}

		discardWorkingSetCaches();

		return statusHelper.OK();

	}

	return superRestoreResult;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:29,代碼來源:ManualAssociationAwareWorkingSetManager.java

示例10: refreshInstalledNpmPackagesInternal

import org.eclipse.core.runtime.IStatus; //導入方法依賴的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

示例11: checkNPM

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
/**
 * Checks the npm binary.
 */
private IStatus checkNPM() {
	final NpmBinary npmBinary = npmBinaryProvider.get();
	final IStatus npmBinaryStatus = npmBinary.validate();
	if (!npmBinaryStatus.isOK()) {
		return statusHelper.createError("npm binary invalid",
				new IllegalBinaryStateException(npmBinary, npmBinaryStatus));
	}
	return statusHelper.OK();
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:13,代碼來源:NpmManager.java

示例12: validate

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
@Override
public IStatus validate() {
	final Binary parent = getParent();
	if (null != parent) {
		final IStatus parentStatus = parent.validate();
		if (!parentStatus.isOK()) {
			return parentStatus;
		}
	}
	return validator.validate(this);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:12,代碼來源:NpmBinary.java

示例13: validate

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
private void validate() {
	if (projectData.packageName.trim().isEmpty()) {
		setErrorMessage("Package name must not be empty");
		setPageComplete(false);
		return;
	}

	IStatus validPackageName = JavaConventions.validatePackageName(projectData.packageName, "1.5", "1.5");
	if (!validPackageName.isOK()) {
		setErrorMessage("Package name is invalid");
		setPageComplete(false);
		return;
	}

	
	if (projectData.mainClassName.trim().isEmpty()) {
		setErrorMessage("Main class name must not be empty");
		setPageComplete(false);
		return;
	}

	IStatus validClassName = JavaConventions.validateJavaTypeName(projectData.mainClassName, "1.5", "1.5");
	if (!validClassName.isOK()) {
		setErrorMessage("Main class name is invalid");
		setPageComplete(false);
		return;
	}

	setErrorMessage(null);
	setPageComplete(true);
}
 
開發者ID:gluonhq,項目名稱:ide-plugins,代碼行數:32,代碼來源:ConfigureDesktopClassPage.java

示例14: run

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
@Override
public Process run(RunConfiguration runConfig, IExecutor executor) {

	final NodeJsBinary nodeJsBinary = nodeJsBinaryProvider.get();
	final IStatus status = nodeJsBinary.validate();
	if (!status.isOK()) {
		Exceptions.sneakyThrow(new IllegalBinaryStateException(nodeJsBinary, status));
	}

	Process process = null;
	String[] cmds = new String[0];
	try {
		NodeRunOptions runOptions = new NodeRunOptions();

		runOptions.setExecModule(runConfig.getExecModule());
		runOptions.addInitModules(runConfig.getInitModules());
		runOptions.setCoreProjectPaths(on(NODE_PATH_SEP).join(runConfig.getCoreProjectPaths()));
		runOptions.setEngineOptions(runConfig.getEngineOptions());
		runOptions.setCustomEnginePath(runConfig.getCustomEnginePath());
		runOptions.setExecutionData(runConfig.getExecutionDataAsJSON());
		runOptions.setSystemLoader(SystemLoaderInfo.fromString(runConfig.getSystemLoader()));

		final Collection<String> paths = newLinkedHashSet();
		// Add custom node paths
		paths.addAll(newArrayList(Splitter.on(NODE_PATH_SEP).omitEmptyStrings().trimResults()
				.split(runConfig.getCustomEnginePath())));

		NodeEngineCommandBuilder cb = commandBuilderProvider.get();
		cmds = cb.createCmds(runOptions);

		File workingDirectory = Files.createTempDirectory(null).toFile();

		paths.addAll(runConfig.getCoreProjectPaths());
		if (runConfig.getAdditionalPath() != null && !runConfig.getAdditionalPath().isEmpty())
			paths.add(runConfig.getAdditionalPath());

		String nodePaths = on(NODE_PATH_SEP).join(paths);

		Map<String, String> env = new LinkedHashMap<>();
		env.put(NODE_PATH, nodePaths);

		env = nodeJsBinary.updateEnvironment(env);

		process = executor.exec(cmds, workingDirectory, env);

	} catch (IOException | RuntimeException | ExecutionException e) {
		LOGGER.error(e);
	}
	return process;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:51,代碼來源:NodeRunner.java

示例15: validate

import org.eclipse.core.runtime.IStatus; //導入方法依賴的package包/類
private void validate() {
	IWorkspace workspace = ResourcesPlugin.getWorkspace();

	// check whether the project name is empty
	String projectName = projectData.projectName;
	if (projectName == null || projectName.trim().isEmpty()) {
		setErrorMessage("Project name must not be empty");
		setPageComplete(false);
		return;
	}

	// check whether the project name is valid
	final IStatus projectNameStatus = workspace.validateName(projectName, IResource.PROJECT);
	if (!projectNameStatus.isOK()) {
		setErrorMessage(projectNameStatus.getMessage());
		setPageComplete(false);
		return;
	}

	// check whether the project with the name already exists
	IProject handle = workspace.getRoot().getProject(projectData.projectName);
	if (handle.exists()) {
		setErrorMessage("A project with name '" + projectData.projectName + "' already exists in the workspace");
		setPageComplete(false);
		return;
	}

	// check whether the location is empty
	String location = projectData.projectLocation;
	if (location == null || location.isEmpty()) {
		setErrorMessage("Enter a location for the project.");
		setPageComplete(false);
		return;
	}

	// check whether the location is a syntactically correct path
	if (!Path.EMPTY.isValidPath(location)) {
		setErrorMessage("Invalid project contents directory");
		setPageComplete(false);
		return;
	}

	IPath projectPath = null;
	if (!useDefaultsButton.getSelection()) {
		projectPath = Path.fromOSString(location);
		if (!projectPath.toFile().exists()) {
			if (!canCreate(projectPath.toFile())) {
				setErrorMessage("Cannot create project content at the given external location.");
				setPageComplete(false);
				return;
			}
		}
	}

	// check whether the location is valid
	final IStatus locationStatus = workspace.validateProjectLocation(handle, projectPath);
	if (!locationStatus.isOK()) {
		setErrorMessage(locationStatus.getMessage());
		setPageComplete(false);
		return;
	}

	setErrorMessage(null);
	setPageComplete(true);
}
 
開發者ID:gluonhq,項目名稱:ide-plugins,代碼行數:66,代碼來源:ConfigureGluonProjectPage.java


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