當前位置: 首頁>>代碼示例>>Java>>正文


Java IWorkspaceRoot.findContainersForLocationURI方法代碼示例

本文整理匯總了Java中org.eclipse.core.resources.IWorkspaceRoot.findContainersForLocationURI方法的典型用法代碼示例。如果您正苦於以下問題:Java IWorkspaceRoot.findContainersForLocationURI方法的具體用法?Java IWorkspaceRoot.findContainersForLocationURI怎麽用?Java IWorkspaceRoot.findContainersForLocationURI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.resources.IWorkspaceRoot的用法示例。


在下文中一共展示了IWorkspaceRoot.findContainersForLocationURI方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: determineContainersToCheck

import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
/**
 * Given a base URI, figure out which {@link IFolder}, if any, it refers to.
 *
 * @param baseURI
 *          to find the folder(s) for; must not be {@code null}
 * @return an array of all folders mapping to that URI, or an empty array if none do.
 */
private static IContainer[] determineContainersToCheck(final URI baseURI) {
  Preconditions.checkNotNull(baseURI);
  IContainer[] result = {};
  if (baseURI.isPlatformResource() || baseURI.isFile()) {
    IWorkspaceRoot workspace = EcorePlugin.getWorkspaceRoot();
    if (workspace != null) {
      if (baseURI.isFile()) {
        result = workspace.findContainersForLocationURI(java.net.URI.create(baseURI.toString()));
      } else {
        // Must be a platform/resource URI
        IPath platformPath = new Path(baseURI.toPlatformString(true));
        IFolder folder = workspace.getFolder(platformPath);
        if (folder != null) {
          result = new IContainer[] {folder};
        }
      }
    }
  }
  return result;
}
 
開發者ID:dsldevkit,項目名稱:dsl-devkit,代碼行數:28,代碼來源:CheckGenModelUtil.java

示例2: getOverlappingProjectName

import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
/**
 * Returns the name of a {@link IProject} with a location that includes targetDirectory. Returns null if there is no
 * such {@link IProject}.
 *
 * @param targetDirectory
 *            the path of the directory to check.
 * @return the overlapping project name or <code>null</code>
 */
private String getOverlappingProjectName(String targetDirectory) {
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IPath testPath = new Path(targetDirectory);
	IContainer[] containers = root.findContainersForLocationURI(testPath.makeAbsolute().toFile().toURI());
	if (containers.length > 0) {
		return containers[0].getProject().getName();
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:18,代碼來源:AbstractExportToSingleFileWizardPage.java


注:本文中的org.eclipse.core.resources.IWorkspaceRoot.findContainersForLocationURI方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。