本文整理汇总了Java中org.eclipse.core.runtime.IStatus.getCode方法的典型用法代码示例。如果您正苦于以下问题:Java IStatus.getCode方法的具体用法?Java IStatus.getCode怎么用?Java IStatus.getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.runtime.IStatus
的用法示例。
在下文中一共展示了IStatus.getCode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setGW4ENature
import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
/**
* Set the GW4E Nature to the passed project
*
* @param project
* @return
* @throws CoreException
*/
public static IStatus setGW4ENature(IProject project) throws CoreException {
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
// add our id
newNatures[natures.length] = GW4ENature.NATURE_ID;
// validate the natures
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IStatus status = workspace.validateNatureSet(newNatures);
if (status.getCode() == IStatus.OK) {
description.setNatureIds(newNatures);
project.setDescription(description, null);
}
return status;
}
示例2: addNature
import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
private void addNature(IProject project) throws CoreException{
if(!project.hasNature(ProjectNature.NATURE_ID)){
IProjectDescription description = project.getDescription();
String[] prevNatures = description.getNatureIds();
String[] newNatures = new String[prevNatures.length + 3];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length] = ProjectNature.NATURE_ID;
newNatures[prevNatures.length + 1] = JavaCore.NATURE_ID;
newNatures[prevNatures.length + 2] = ORG_ECLIPSE_M2E_CORE_MAVEN2_NATURE;
// validate the natures
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IStatus status = workspace.validateNatureSet(newNatures);
ICommand javaBuildCommand= description.newCommand();
javaBuildCommand.setBuilderName("org.eclipse.jdt.core.javabuilder");
ICommand mavenBuildCommand= description.newCommand();
mavenBuildCommand.setBuilderName("org.eclipse.m2e.core.maven2Builder");
ICommand[] iCommand = {javaBuildCommand, mavenBuildCommand};
description.setBuildSpec(iCommand);
// only apply new nature, if the status is ok
if (status.getCode() == IStatus.OK) {
description.setNatureIds(newNatures);
project.setDescription(description, null);
}
logger.debug("Project nature added");
}
}
示例3: demandLoadResource
import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
/**
*
* Discards the current content of the resource, sets the parser result as first slot, installs derived state (this
* will build up the second slot again) and sends notifications that proxies have been resolved. The resource will
* be even loaded if its already marked as loaded.
*
* If the second slot, that is the TModule, was already loaded and we just resolved the AST, then the existing
* TModule is kept in the resource and rewired to the resolved AST.
*
* @param object
* the object which resource should be loaded
* @return the loaded/resolved object
*/
private EObject demandLoadResource(EObject object) {
TModule oldModule = null;
EObject oldScript = null;
ModuleAwareContentsList myContents = ((ModuleAwareContentsList) contents);
try {
oldModule = discardStateFromDescription(false);
if (!myContents.isEmpty()) {
oldScript = myContents.basicGet(0);
myContents.sneakyClear();
}
// now everything is removed from the resource and contents is empty
// stop sending notifications
eSetDeliver(false);
if (isLoaded) {
// Loads the resource even its marked as being already loaded
isLoaded = false;
}
superLoad(null);
// manually send the notification
eSetDeliver(true);
EObject result = getParseResult().getRootASTElement();
if (myContents.isEmpty()) {
myContents.sneakyAdd(0, result);
if (oldModule != null) {
myContents.sneakyAdd(oldModule);
}
forceInstallDerivedState(false);
} else {
if (myContents.size() == 1) {
if (oldModule != null) {
myContents.sneakyAdd(oldModule);
}
}
installDerivedState(false);
}
if (oldScript != null) {
notifyProxyResolved(0, oldScript);
}
fullyPostProcessed = false;
return result;
} catch (IOException | IllegalStateException ioe) {
if (myContents.isEmpty()) {
myContents.sneakyAdd(oldScript);
myContents.sneakyAdd(oldModule);
}
Throwable cause = ioe.getCause();
if (cause instanceof CoreException) {
IStatus status = ((CoreException) cause).getStatus();
if (IResourceStatus.RESOURCE_NOT_FOUND == status.getCode()) {
return object;
}
}
logger.error("Error in demandLoadResource for " + getURI(), ioe);
return object;
}
}
示例4: startP2Updates
import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
/**
* Starts a p2-based update procedure
*/
public void startP2Updates() {
// --- Check for available updates -------
System.out.println("P2 Update: Check for updates ...");
if (Application.isOperatingHeadless() == false) {
this.getProgressMonitor().setVisible(true);
this.getProgressMonitor().setProgress(0);
}
IStatus status = P2OperationsHandler.getInstance().checkForUpdates();
if (status.getSeverity()!=IStatus.ERROR) {
if (status.getCode()==UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
// --- No updates found --------------
System.out.println("P2 Update: No updates found!");
if (Application.isOperatingHeadless() == false) {
this.getProgressMonitor().setProgress(100);
this.getProgressMonitor().setVisible(false);
this.getProgressMonitor().dispose();
}
if (Application.isOperatingHeadless()==false && this.manualyExecutedByUser==true) {
JOptionPane.showMessageDialog(null, Language.translate("Keine Updates gefunden") + "!", Language.translate("Keine Updates gefunden"), JOptionPane.INFORMATION_MESSAGE);
}
} else {
// --- Ask for user confirmation if specified in the settings -------
boolean installUpdates = true;
if (this.askBeforeDownload==true) {
// --- Temporary hide the progress dialog, otherwise the confirmation dialog would not be shown--------
if(this.executionMode == ExecutionMode.APPLICATION) {
this.getProgressMonitor().setVisible(false);
}
// --- Show confirmation dialog ----------
int userAnswer = JOptionPane.showConfirmDialog(null, Language.translate("Updates verfügbar, installieren?"), "Agent.GUI Update", JOptionPane.YES_NO_OPTION);
if (userAnswer == JOptionPane.NO_OPTION) {
installUpdates = false;
System.out.println("P2 Update: Update canceled by user.");
if(Application.isOperatingHeadless() == false) {
this.getProgressMonitor().setVisible(false);
this.getProgressMonitor().dispose();
}
}
}
if (installUpdates==true) {
// --- Change progress dialog texts ----------------
if (Application.isOperatingHeadless() == false) {
this.getProgressMonitor().setHeaderText(Language.translate("Installiere Updates"));
this.getProgressMonitor().setProgressText(Language.translate("Installiere") + "...");
this.getProgressMonitor().setVisible(true);
this.getProgressMonitor().setProgress(30);
}
status = P2OperationsHandler.getInstance().installAvailableUpdates();
if (status.isOK()) {
System.out.println("P2 Update: Updates sucessfully installed, restarting...");
Application.restart();
} else {
System.err.println("P2 Update: Error installing updates.");
}
}
if (Application.isOperatingHeadless() == false) {
this.getProgressMonitor().setProgress(100);
this.getProgressMonitor().setVisible(false);
this.getProgressMonitor().dispose();
}
}
}
}
示例5: validateClassName
import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
public static boolean validateClassName(String name) {
String temp = name + ".java";
IStatus status = JavaConventions.validateCompilationUnitName(temp, JavaCore.VERSION_1_8, JavaCore.VERSION_1_8);
boolean b = (status.getCode() == IStatus.OK);
return b;
}