當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。