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


Java IPackageFragmentRoot.getCorrespondingResource方法代码示例

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


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

示例1: getSourceFolders

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
/**
 * Returns the list of source folders of the given project as a list of
 * absolute workspace paths.
 * 
 * @param project
 *            a project
 * @return a list of absolute workspace paths
 */
public static List<IFolder> getSourceFolders(IProject project) {
	List<IFolder> srcFolders = new ArrayList<IFolder>();

	try {
		IJavaProject javaProject = JavaCore.create(project);
		if (!javaProject.exists()) {
			return srcFolders;
		}

		// iterate over package roots
		for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) {
			IResource resource = root.getCorrespondingResource();
			if (resource != null && resource.getType() == IResource.FOLDER) {
				srcFolders.add((IFolder) resource);
			}
		}
	} catch (CoreException e) {
		Logger.debug("Get source folder exception: %s", e);
	}

	return srcFolders;
}
 
开发者ID:turnus,项目名称:turnus,代码行数:31,代码来源:EcoreUtils.java

示例2: execute

import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
	boolean autoBuilding = ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
	IWorkbenchWindow aww = HandlerUtil.getActiveWorkbenchWindow(event);
	ISelection sel = HandlerUtil.getCurrentSelection(event);
	if (sel.isEmpty())
		return null;
	if (sel instanceof IStructuredSelection) {

		IStructuredSelection selection = (IStructuredSelection) sel;
		if (selection != null) {
			Object obj = selection.getFirstElement();
			if (obj != null) {
				try {
					IResource selectedResource = null;
					if (obj instanceof IJavaProject) {
						IJavaProject jp = (IJavaProject) obj;
						selectedResource = jp.getProject();
					}
					if (obj instanceof IPackageFragmentRoot) {
						IPackageFragmentRoot pfr = (IPackageFragmentRoot) obj;
						selectedResource = pfr.getCorrespondingResource();
					}
					if (obj instanceof IPackageFragment) {
						IPackageFragment pf = (IPackageFragment) obj;
						selectedResource = pf.getCorrespondingResource();
					}
					if (selectedResource != null && !selectedResource.exists())
						return null;
					// This is where the synchronization is done ...
					ResourceManager.setAutoBuilding(false);
					GraphWalkerContextManager.synchronizeBuildPolicies(selectedResource, aww);
				} catch (Exception e) {
					ResourceManager.logException(e);
				} finally {
					ResourceManager.setAutoBuilding(autoBuilding);
				}
			}
		}
	}
	return null;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:42,代码来源:SynchronizeBuildPoliciesHandler.java


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