本文整理匯總了Java中org.eclipse.core.resources.IWorkspaceRoot.getFolder方法的典型用法代碼示例。如果您正苦於以下問題:Java IWorkspaceRoot.getFolder方法的具體用法?Java IWorkspaceRoot.getFolder怎麽用?Java IWorkspaceRoot.getFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IWorkspaceRoot
的用法示例。
在下文中一共展示了IWorkspaceRoot.getFolder方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例2: createFolder
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
public static IFolder createFolder(IPath parentPath, IPath folder) throws CoreException {
IWorkspaceRoot wroot = ResourcesPlugin.getWorkspace().getRoot();
IFolder pf = wroot.getFolder(parentPath);
int max = folder.segmentCount();
IFolder childFolder = pf;
for (int i = 0; i < max; i++) {
childFolder = childFolder.getFolder(folder.segment(i));
childFolder.create(IResource.NONE, true, new NullProgressMonitor());
}
return childFolder;
}
示例3: getOutputLocation
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private String getOutputLocation(IJavaProject project) {
String outputLocation = "";
IPath path;
try {
path = project.getOutputLocation();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFolder folder = root.getFolder(path);
outputLocation = folder.getLocation().toOSString();
} catch (JavaModelException e) {
e.printStackTrace();
}
return outputLocation;
}
示例4: loadResourceFromString
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
@Override
protected IFolder loadResourceFromString(String resourceString, IWorkspaceRoot workspaceRoot) {
if (resourceString == null || resourceString.isEmpty()) {
return null;
}
IPath folderPath = new Path(resourceString);
return workspaceRoot.getFolder(folderPath);
}
示例5: getResourceFor
import org.eclipse.core.resources.IWorkspaceRoot; //導入方法依賴的package包/類
/**
* Returns workspace resource for the given local file system <code>location</code>
* and which is a child of the given <code>parent</code> resource. Returns
* <code>parent</code> if parent's file system location equals to the given
* <code>location</code>. Returns <code>null</code> if <code>parent</code> is the
* workspace root.
*
* Resource does not have to exist in the workspace in which case resource
* type will be determined by the type of the local filesystem object.
*/
public static IResource getResourceFor(IResource parent, IPath location) {
if (parent == null || location == null) {
return null;
}
if (parent instanceof IWorkspaceRoot) {
return null;
}
if (!isManagedBySubclipse(parent.getProject())) {
return null;
}
if (!parent.getLocation().isPrefixOf(location)) {
return null;
}
int segmentsToRemove = parent.getLocation().segmentCount();
IPath fullPath = parent.getFullPath().append(location.removeFirstSegments(segmentsToRemove));
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(fullPath,true);
if (resource != null) {
return resource;
}
if (parent instanceof IFile) {
return null;
}
if (fullPath.isRoot()) {
return root;
} else if (fullPath.segmentCount() == 1) {
return root.getProject(fullPath.segment(0));
}
if (!location.toFile().exists()) {
if (location.toFile().getName().indexOf(".") == -1) {
return root.getFolder(fullPath);
}
}
if (location.toFile().isDirectory()) {
return root.getFolder(fullPath);
}
return root.getFile(fullPath);
}