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


Java IStatus.getSeverity方法代码示例

本文整理汇总了Java中org.eclipse.core.runtime.IStatus.getSeverity方法的典型用法代码示例。如果您正苦于以下问题:Java IStatus.getSeverity方法的具体用法?Java IStatus.getSeverity怎么用?Java IStatus.getSeverity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.runtime.IStatus的用法示例。


在下文中一共展示了IStatus.getSeverity方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyToStatusLine

import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
/** copied from PropertyAndPreferencePage */
private static void applyToStatusLine(DialogPage page, IStatus status) {
	String message = status.getMessage();
	if (message != null && message.length() == 0) {
		message = null;
	}
	switch (status.getSeverity()) {
	case IStatus.OK:
		page.setMessage(message, IMessageProvider.NONE);
		page.setErrorMessage(null);
		break;
	case IStatus.WARNING:
		page.setMessage(message, IMessageProvider.WARNING);
		page.setErrorMessage(null);
		break;
	case IStatus.INFO:
		page.setMessage(message, IMessageProvider.INFORMATION);
		page.setErrorMessage(null);
		break;
	default:
		page.setMessage(null);
		page.setErrorMessage(message);
		break;
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:AbstractN4JSPreferencePage.java

示例2: testLogExceptionThrowable

import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
@Test
public void testLogExceptionThrowable() throws Exception {
	ILog log = Activator.getDefault().getLog();
	String [] msg = new String [] {"",""};
	ILogListener listener = new ILogListener() {
		@Override
		public void logging(IStatus status, String plugin) {
			msg [0] = status.getMessage();
			if (status.getSeverity()==IStatus.ERROR) {
				msg [1] =  "error";
			}
		}
	};
	log.addLogListener(listener);
	try {
		ResourceManager.logException(new Exception("test"));
		assertEquals("test",msg [0]);
		assertEquals("error",msg [1]);
	} finally {
		log.removeLogListener(listener);
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:23,代码来源:ResourceManagerTest.java

示例3: testLogExceptionThrowableString

import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
@Test
public void testLogExceptionThrowableString() throws Exception {
	ILog log = Activator.getDefault().getLog();
	String [] msg = new String [] {"",""};
	ILogListener listener = new ILogListener() {
		@Override
		public void logging(IStatus status, String plugin) {
			msg [0] = status.getMessage();
			if (status.getSeverity()==IStatus.ERROR) {
				msg [1] =  "error";
			}
		}
	};
	log.addLogListener(listener);
	try {
		ResourceManager.logException(new Exception("message"));
		assertEquals("message",msg [0]);
		assertEquals("error",msg [1]);
	} finally {
		log.removeLogListener(listener);
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:23,代码来源:ResourceManagerTest.java

示例4: validatePage

import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
protected boolean validatePage() {
	if (getSourceFolderText().getText().length() == 0) {
		setErrorMessage("Source Folder 不能为空!");
		setPageComplete(false);
		return false;
	}
	IStatus sta = containerChanged();
	if (sta.getSeverity() == IStatus.ERROR) {
		setErrorMessage(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, sta.getMessage()));
		setPageComplete(false);
		return false;
	}

	sta = packageChanged();
	if (sta.getSeverity() == IStatus.ERROR) {
		setErrorMessage(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, sta.getMessage()));
		setPageComplete(false);
		return false;
	}

	setErrorMessage(null);
	setPageComplete(true);
	return true;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:25,代码来源:ExportToJavaBeanWizardPage.java

示例5: validateLinkedResource

import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
/**
 * Checks whether the linked resource target is valid. Sets the error
 * message accordingly and returns the status.
 * 
 * @return IStatus validation result from the CreateLinkedResourceGroup
 */
protected IStatus validateLinkedResource() {
	IPath containerPath = resourceGroup.getContainerFullPath();
	IPath newFilePath = containerPath.append(resourceGroup.getResource());
	IFile newFileHandle = createFileHandle(newFilePath);
	IStatus status = linkedResourceGroup
			.validateLinkLocation(newFileHandle);

	if (status.getSeverity() == IStatus.ERROR) {
		if (firstLinkCheck) {
			setMessage(status.getMessage());
			setErrorMessage(null);
		} else {
			setErrorMessage(status.getMessage());
		}
	} else if (status.getSeverity() == IStatus.WARNING) {
		setMessage(status.getMessage(), WARNING);
		setErrorMessage(null);
	}
	return status;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:27,代码来源:WizardNewFileCreationPage.java

示例6: testLogInfo

import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
@Test
public void testLogInfo() throws Exception {
	ILog log = Activator.getDefault().getLog();
	String [] msg = new String [] {"",""};
	ILogListener listener = new ILogListener() {
		@Override
		public void logging(IStatus status, String plugin) {
			msg [0] = status.getMessage();
			if (status.getSeverity()==IStatus.INFO) {
				msg [1] =  "info";
			}
		}
	};
	log.addLogListener(listener);
	IJavaProject jp = null;
	try {
		jp = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, false, false);
		PreferenceManager.setLogInfoEnabled (jp.getProject().getName(),true);
		ResourceManager.logInfo(jp.getProject().getName(), "infomessage");
		assertEquals("infomessage",msg [0]);
		assertEquals("info",msg [1]);
	} finally {
		PreferenceManager.setLogInfoEnabled (jp.getProject().getName(),false);
		log.removeLogListener(listener);
	}
	
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:28,代码来源:ResourceManagerTest.java

示例7: 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

示例8: packageChanged

import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
protected IStatus packageChanged() {
	StatusInfo status = new StatusInfo();
	IPackageFragmentRoot root = getPackageFragmentRoot();
	IJavaProject project = root != null ? root.getJavaProject() : null;

	String packName = getPackageText().getText();
	if (packName.length() > 0) {
		IStatus val = validatePackageName(packName, project);
		if (val.getSeverity() == IStatus.ERROR) {
			status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, val.getMessage()));
			return status;
		} else if (val.getSeverity() == IStatus.WARNING) {
			status.setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_DiscouragedPackageName, val.getMessage()));
			// continue
		}
	} else {
		status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
	}

	if (project != null) {
		if (project.exists() && packName.length() > 0) {
			try {
				IPath rootPath = root.getPath();
				IPath outputPath = project.getOutputLocation();
				if (rootPath.isPrefixOf(outputPath) && !rootPath.equals(outputPath)) {
					// if the bin folder is inside of our root, don't allow
					// to name a package
					// like the bin folder
					IPath packagePath = rootPath.append(packName.replace('.', '/'));
					if (outputPath.isPrefixOf(packagePath)) {
						status.setError(NewWizardMessages.NewTypeWizardPage_error_ClashOutputLocation);
						return status;
					}
				}
			} catch (JavaModelException e) {
				JavaPlugin.log(e);
				// let pass
			}
		}

		fCurrPackage = root.getPackageFragment(packName);
		IResource resource = fCurrPackage.getResource();
		if (resource != null) {
			if (resource.isVirtual()) {
				status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageIsVirtual);
				return status;
			}
			if (!ResourcesPlugin.getWorkspace().validateFiltered(resource).isOK()) {
				status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageNameFiltered);
				return status;
			}
		}
	} else {
		status.setError("");
	}
	return status;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:58,代码来源:ExportToJavaBeanWizardPage.java

示例9: validatePage

import org.eclipse.core.runtime.IStatus; //导入方法依赖的package包/类
/**
 * Returns whether this page's controls currently all contain valid values.
 * 
 * @return <code>true</code> if all controls are valid, and
 *         <code>false</code> if at least one is invalid
 */
protected boolean validatePage() {
	boolean valid = true;

	if (!resourceGroup.areAllValuesValid()) {
		// if blank name then fail silently
		if (resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_RESOURCE_EMPTY
				|| resourceGroup.getProblemType() == ResourceAndContainerGroup.PROBLEM_CONTAINER_EMPTY) {
			setMessage(resourceGroup.getProblemMessage());
			setErrorMessage(null);
		} else {
			setErrorMessage(resourceGroup.getProblemMessage());
		}
		valid = false;
	}

	String resourceName = resourceGroup.getResource();
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	IStatus result = workspace.validateName(resourceName, IResource.FILE);
	if (!result.isOK()) {
		setErrorMessage(result.getMessage());
		return false;
	}

	IStatus linkedResourceStatus = null;
	if (valid) {
		linkedResourceStatus = validateLinkedResource();
		if (linkedResourceStatus.getSeverity() == IStatus.ERROR) {
			valid = false;
		}
	}
	// validateLinkedResource sets messages itself
	if (valid
			&& (linkedResourceStatus == null || linkedResourceStatus.isOK())) {
		setMessage(null);
		setErrorMessage(null);

		// perform "resource exists" check if it was skipped in
		// ResourceAndContainerGroup
		if (resourceGroup.getAllowExistingResources()) {
			String problemMessage = NLS.bind(
					IDEWorkbenchMessages.ResourceGroup_nameExists,
					getFileName());
			IPath resourcePath = getContainerFullPath().append(
					getFileName());
			if (workspace.getRoot().getFolder(resourcePath).exists()) {
				setErrorMessage(problemMessage);
				valid = false;
			}
			if (workspace.getRoot().getFile(resourcePath).exists()) {
				setMessage(problemMessage, IMessageProvider.WARNING);
			}
		}
	}
	if (isFilteredByParent()) {
		setMessage(
				IDEWorkbenchMessages.WizardNewFileCreationPage_resourceWillBeFilteredWarning,
				IMessageProvider.ERROR);
		setupLinkedResourceTarget();
		valid = false;
	}
	return valid;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:69,代码来源:WizardNewFileCreationPage.java


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