本文整理匯總了Java中org.eclipse.wst.common.componentcore.resources.IVirtualFolder類的典型用法代碼示例。如果您正苦於以下問題:Java IVirtualFolder類的具體用法?Java IVirtualFolder怎麽用?Java IVirtualFolder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IVirtualFolder類屬於org.eclipse.wst.common.componentcore.resources包,在下文中一共展示了IVirtualFolder類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validateJsp
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; //導入依賴的package包/類
/**
* Verifies that every <jsp-file> element exists in the project.
*/
private void validateJsp() {
if (isVersion25()) {
IProject project = resource.getProject();
IVirtualComponent component = ComponentCore.createComponent(project);
if (component != null && component.exists()) {
IVirtualFolder root = component.getRootFolder();
if (root.exists()) {
NodeList jspList = document.getElementsByTagName("jsp-file");
for (int i = 0; i < jspList.getLength(); i++) {
Node jspNode = jspList.item(i);
String jspName = jspNode.getTextContent();
if (!resolveJsp(root, jspName)) {
DocumentLocation location = (DocumentLocation) jspNode.getUserData("location");
BannedElement element = new JspFileElement(jspName, location, jspName.length());
blacklist.add(element);
}
}
}
}
}
}
示例2: resolveJsp
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; //導入依賴的package包/類
private static boolean resolveJsp(IVirtualFolder root, String fileName) {
// For a typical Maven project:
// WEB-INF -> src/main/webapp/WEB-INF
// / -> src/main/webapp
// WEB-INF/classes -> src/main/java
// WEB-INF/lib -> src/main/webapp/WEB-INF/lib
IVirtualFile file = root.getFile(fileName);
if (file.exists()) {
return true;
}
file = root.getFile("WEB-INF/" + fileName);
if (file.exists()) {
return true;
}
file = root.getFile("WEB-INF/classes/" + fileName);
if (file.exists()) {
return true;
}
// TODO: Search for JSP files in jars if web.xml is version 3.0+.
// JSP file META-INF/resources/test.jsp in a jar should be able to be referenced
// as test.jsp in web.xml.
return false;
}
示例3: findFile
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; //導入依賴的package包/類
public static IFile findFile(final IDocument document, String name,
final boolean inClassesFolder) {
IFile result = null;
IProject project = getCurrentProject(document);
if (project != null && project.exists()) {
IVirtualComponent rootComponent = ComponentCore
.createComponent(project);
if (rootComponent != null) {
IVirtualFolder folder = rootComponent.getRootFolder();
if (folder != null && folder.exists()) {
if (inClassesFolder) {
name = WEB_INF_CLASSES_FOLDER_PATH + "/" + name;
}
result = folder.getFile(name).getUnderlyingFile();
}
}
}
return result;
}
示例4: findWebInfForNewResource
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; //導入依賴的package包/類
/**
* Find the directory within the project where new resources for the {@code WEB-INF} should be
* placed, respecting the order and tags on the WTP virtual component model. Specifically, we use
* the directory in the {@code <wb-resource>} with the {@code defaultRootSource} tag when present.
*/
private static IFolder findWebInfForNewResource(IProject project) {
// Check if the project is a faceted project, and use the deployment assembly information
IVirtualComponent component = ComponentCore.createComponent(project);
if (component != null && component.exists()) {
IVirtualFolder root = component.getRootFolder();
// first see if there is a resource tagged as the defaultSourceRoot
IPath defaultPath = J2EEModuleVirtualComponent.getDefaultDeploymentDescriptorFolder(root);
if (defaultPath != null) {
return project.getFolder(defaultPath).getFolder(WEB_INF);
}
// otherwise use the first
return (IFolder) root.getFolder(WEB_INF).getUnderlyingFolder();
}
// Otherwise it's seemingly fair game
for (String possibleWebInfContainer : DEFAULT_WEB_PATHS) {
// simplify mocking: get the location as two parts and check for null despite that getFolder()
// should be @NonNull
IFolder defaultLocation = project.getFolder(possibleWebInfContainer);
if (defaultLocation != null && defaultLocation.exists()) {
defaultLocation = defaultLocation.getFolder(WEB_INF);
if (defaultLocation != null && defaultLocation.exists()) {
return defaultLocation;
}
}
}
return project.getFolder(DEFAULT_WEB_PATH).getFolder(WEB_INF);
}
示例5: findInWebInf
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; //導入依賴的package包/類
/**
* Attempt to resolve the given file within the project's {@code WEB-INF}. Note that this method
* may return a file that is in a build location (e.g.,
* {@code target/m2e-wtp/web-resources/WEB-INF}) which may be frequently removed or regenerated.
*
* @return the file location or {@code null} if not found
*/
public static IFile findInWebInf(IProject project, IPath filePath) {
// Try to obtain the directory as if it was a Dynamic Web Project
IVirtualComponent component = ComponentCore.createComponent(project);
if (component != null && component.exists()) {
IVirtualFolder root = component.getRootFolder();
// the root should exist, but the WEB-INF may not yet exist
IVirtualFile file = root.getFolder(WEB_INF).getFile(filePath);
if (file != null && file.exists()) {
return file.getUnderlyingFile();
}
return null;
}
// Otherwise check the standard places
for (String possibleWebInfContainer : DEFAULT_WEB_PATHS) {
// check each directory component to simplify mocking in tests
// so we can just say WEB-INF doesn't exist
IFolder defaultLocation = project.getFolder(possibleWebInfContainer);
if (defaultLocation != null && defaultLocation.exists()) {
defaultLocation = defaultLocation.getFolder(WEB_INF);
if (defaultLocation != null && defaultLocation.exists()) {
IFile resourceFile = defaultLocation.getFile(filePath);
if (resourceFile.exists()) {
return resourceFile;
}
}
}
}
return null;
}
示例6: getRootContainerForPath
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; //導入依賴的package包/類
static IPath getRootContainerForPath(IProject project, IPath path) {
if (ModuleCoreNature.isFlexibleProject(project)) {
IVirtualFolder componentFolder = ComponentCore.createFolder(project, Path.ROOT);
if (componentFolder != null && componentFolder.exists()) {
IContainer[] workspaceFolders = componentFolder.getUnderlyingFolders();
for (int i = 0; i < workspaceFolders.length; i++) {
if (workspaceFolders[i].getFullPath().isPrefixOf(path)) {
return workspaceFolders[i].getFullPath();
}
}
}
}
return null;
}
示例7: getDefaultRoot
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; //導入依賴的package包/類
static IPath getDefaultRoot(IProject project) {
if (ModuleCoreNature.isFlexibleProject(project)) {
IVirtualFolder componentFolder = ComponentCore.createFolder(project, Path.ROOT);
if (componentFolder != null && componentFolder.exists()) {
return componentFolder.getWorkspaceRelativePath();
}
}
return null;
}
示例8: findTemplateFoldersNames
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; //導入依賴的package包/類
public static Set<String> findTemplateFoldersNames(
final IDocument currentDocument) {
final Set<String> result = new HashSet<String>();
try {
final IProject project = getCurrentProject(currentDocument);
if (project != null && project.exists()) {
IVirtualComponent rootComponent = ComponentCore
.createComponent(project);
if (rootComponent != null) {
IVirtualFolder folder = rootComponent.getRootFolder();
folder = folder.getFolder(WEB_INF_CLASSES_FOLDER_PATH + "/"
+ TEMPLATE_FOLDER_NAME);
if (folder != null && folder.exists()) {
IResource[] resources = folder.getUnderlyingResources();
if (resources != null) {
for (final IResource res : resources) {
res.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource)
throws CoreException {
if (resource.isAccessible()
&& resource.getType() == IResource.FOLDER
&& !TEMPLATE_FOLDER_NAME
.equals(resource
.getName())) {
result.add(resource.getName());
}
return true;
}
}, IResource.DEPTH_ONE, IResource.NONE);
}
}
}
}
}
} catch (CoreException e) {
e.printStackTrace();
}
return result;
}
示例9: getAcceptableRootPathsP
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; //導入依賴的package包/類
static IPath[] getAcceptableRootPathsP(IProject project) {
if (!ModuleCoreNature.isFlexibleProject(project)) {
return new IPath[] { project.getFullPath() };
}
List paths = new ArrayList();
IVirtualFolder componentFolder = ComponentCore.createFolder(project, Path.ROOT);
if (componentFolder != null && componentFolder.exists()) {
IContainer[] workspaceFolders = componentFolder.getUnderlyingFolders();
for (int i = 0; i < workspaceFolders.length; i++) {
if (workspaceFolders[i].getFolder(META_INF_RESOURCES_PATH).isAccessible())
paths.add(workspaceFolders[i].getFullPath().append(META_INF_RESOURCES_PATH));
else
paths.add(workspaceFolders[i].getFullPath());
}
IVirtualReference[] references = ComponentCore.createComponent(project).getReferences();
if (references != null) {
for (int i = 0; i < references.length; i++) {
IVirtualComponent referencedComponent = references[i].getReferencedComponent();
if (referencedComponent == null)
continue;
IVirtualComponent component = referencedComponent.getComponent();
if (component == null)
continue;
IVirtualFolder rootFolder = component.getRootFolder();
if (rootFolder == null)
continue;
IPath referencedPathRoot = rootFolder.getWorkspaceRelativePath();
/* http://bugs.eclipse.org/410161 */
if (referencedPathRoot != null) {
/*
* See Servlet 3.0, section 4.6 ; this is the only
* referenced module/component type we support
*/
IPath resources = referencedPathRoot.append(META_INF_RESOURCES);
if (resources != null && component.getProject().findMember(resources.removeFirstSegments(1)) != null) {
paths.add(resources);
}
}
}
}
} else {
paths.add(new IPath[] { project.getFullPath() });
}
return (IPath[]) paths.toArray(new IPath[paths.size()]);
}