本文整理汇总了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());
}
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}