当前位置: 首页>>代码示例>>Java>>正文


Java IStatus.getCode方法代码示例

本文整理汇总了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;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:27,代码来源:GW4ENature.java

示例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"); 
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:28,代码来源:ProjectStructureCreator.java

示例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;
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:72,代码来源:N4JSResource.java

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

		}
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:81,代码来源:AgentGuiUpdater.java

示例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;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:7,代码来源:JDTManager.java


注:本文中的org.eclipse.core.runtime.IStatus.getCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。