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


Java IJavaProject.getAllPackageFragmentRoots方法代码示例

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


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

示例1: getSrcPackageFragment

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
@SuppressWarnings("restriction")
public PackageFragmentRoot getSrcPackageFragment(IJavaProject iJavaProject) throws JavaModelException {
	for(IPackageFragmentRoot iPackageFragmentRoot:iJavaProject.getAllPackageFragmentRoots()){
		if(iPackageFragmentRoot instanceof PackageFragmentRoot && iPackageFragmentRoot.getKind()==iPackageFragmentRoot.K_SOURCE){
			if(StringUtils.startsWith(iPackageFragmentRoot.toString(),hydrograph.ui.common.util.Constants.ProjectSupport_SRC)){
				return (PackageFragmentRoot) iPackageFragmentRoot;
			}
		}
	}
	return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:12,代码来源:BuildExpressionEditorDataSturcture.java

示例2: getIPackageFragment

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Returns packages of given jar file
 * 
 * @param jarFileName
 * @return IPackageFragmentRoot
 * 			packages of given jar file
 */
public IPackageFragmentRoot getIPackageFragment(String jarFileName) {
	IProject iProject = getCurrentProject();
	IJavaProject javaProject = JavaCore.create(iProject);
	try {
		if(StringUtils.equals(jarFileName, hydrograph.ui.common.util.Constants.ProjectSupport_SRC)){
			return getSrcPackageFragment(javaProject);
		}
		
		IPackageFragmentRoot[] fragmentRoot = javaProject.getAllPackageFragmentRoots();
		for (IPackageFragmentRoot iPackageFragmentRoot : fragmentRoot) {
			if (StringUtils.contains(iPackageFragmentRoot.getElementName(), jarFileName))
				return iPackageFragmentRoot;
		}
	} catch (JavaModelException javaModelException) {
		LOGGER.error("Error occurred while loading engines-transform jar", javaModelException);
	}
	finally{
		if(javaProject!=null){
			try {
				javaProject.close();
			} catch (JavaModelException modelException) {
				LOGGER.warn("JavaModelException occurred while closing java-project"+modelException);
			}
		}
	}
	if(StringUtils.equals(jarFileName, ConfigFileReader.INSTANCE.getConfigurationValueFromCommon(Constants.KEY_TRANSFORMATION_JAR)))
		new CustomMessageBox(SWT.ERROR, "Error occurred while loading " + jarFileName + " file", "ERROR").open();
	return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:37,代码来源:BuildExpressionEditorDataSturcture.java

示例3: loadComboJarListFromBuildPath

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
@SuppressWarnings("restriction")
private void loadComboJarListFromBuildPath(Combo comboJarList, String newJarName) {
	comboJarList.removeAll();
	IProject iProject = BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject();
	IJavaProject iJavaProject=null;
	try {
		iJavaProject = JavaCore.create(iProject);
		PackageFragmentRoot srcfragmentRoot= BuildExpressionEditorDataSturcture.INSTANCE.getSrcPackageFragment(iJavaProject);
		comboJarList.add(hydrograph.ui.common.util.Constants.ProjectSupport_SRC);
		comboJarList.setData(String.valueOf(comboJarList.getItemCount() - 1), srcfragmentRoot);
		
		for (IPackageFragmentRoot iPackageFragmentRoot : iJavaProject.getAllPackageFragmentRoots()) {
			if (isJarPresentInLibFolder(iPackageFragmentRoot.getPath())
					&& iPackageFragmentRoot.getKind() != IPackageFragmentRoot.K_SOURCE) {
				comboJarList.add(iPackageFragmentRoot.getElementName());
				comboJarList.setData(String.valueOf(comboJarList.getItemCount() - 1), iPackageFragmentRoot);
			}
		}
		selectAndLoadJarData(newJarName);
	} catch (JavaModelException javaModelException) {
		LOGGER.error("Error occurred while loading engines-transform jar", javaModelException);
	}
	finally{
		if(iJavaProject!=null){
			try {
				iJavaProject.close();
			} catch (JavaModelException e) {
				LOGGER.warn("JavaModelException occurred while closing java-project"+e);
			}
		}
	}

}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:34,代码来源:CategoriesDialogSourceComposite.java

示例4: getBuildPathForMethodInvocation

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static Object[] getBuildPathForMethodInvocation() throws JavaModelException, MalformedURLException {
	String transfromJarPath = null;
	Object[] returnObj=new Object[3];
	IJavaProject iJavaProject = JavaCore.create(BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject());
	List<URL> urlList = new ArrayList<>();
	Properties properties = ConfigFileReader.INSTANCE.getCommonConfigurations();
	for (IPackageFragmentRoot iPackageFragmentRoot : iJavaProject.getAllPackageFragmentRoots()) {
		if (!iPackageFragmentRoot.isExternal()
				|| StringUtils.contains(iPackageFragmentRoot.getElementName(), properties.getProperty(Constants.KEY_TRANSFORMATION_JAR))
				|| StringUtils.contains(iPackageFragmentRoot.getElementName(), Constants.ANTLR_JAR_FILE_NAME)
				|| StringUtils.contains(iPackageFragmentRoot.getElementName(), Constants.BEAN_SHELLJAR_FILE_NAME)
				|| StringUtils.contains(iPackageFragmentRoot.getElementName(), Constants.SL4JLOG)
				|| StringUtils.contains(iPackageFragmentRoot.getElementName(), properties.getProperty(Constants.KEY_EXPRESSION_JAR))) {
			URL url = null;
			if (!iPackageFragmentRoot.isExternal()) {
				url = BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject()
						.getFile(iPackageFragmentRoot.getPath().removeFirstSegments(1)).getLocation().toFile()
						.toURI().toURL();
				urlList.add(url);
			} else {
				url = iPackageFragmentRoot.getPath().toFile().toURI().toURL();
				urlList.add(url);
			}

			if (!iPackageFragmentRoot.isExternal()
					|| StringUtils.contains(iPackageFragmentRoot.getElementName(), properties.getProperty(Constants.KEY_TRANSFORMATION_JAR))) {
				if (transfromJarPath == null) {
					if (OSValidator.isMac() || OSValidator.isUnix())
						transfromJarPath = url.getPath() + Constants.COLON;
					else
						transfromJarPath = url.getPath() + Constants.SEMICOLON;
				} else {
					if (OSValidator.isMac() || OSValidator.isUnix())
						transfromJarPath = transfromJarPath + url.getPath() + Constants.COLON;
					else
						transfromJarPath = transfromJarPath + url.getPath() + Constants.SEMICOLON;
				}
			}
		}
	}
	
	returnObj[0]=urlList;
	returnObj[1]=transfromJarPath;
	returnObj[2]=getPropertyFilePath(iJavaProject);
	iJavaProject.close();
	return returnObj;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:48,代码来源:ValidateExpressionToolButton.java


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