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