本文整理汇总了Java中org.eclipse.wst.common.componentcore.resources.IVirtualComponent类的典型用法代码示例。如果您正苦于以下问题:Java IVirtualComponent类的具体用法?Java IVirtualComponent怎么用?Java IVirtualComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IVirtualComponent类属于org.eclipse.wst.common.componentcore.resources包,在下文中一共展示了IVirtualComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateJsp
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的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: findFile
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的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;
}
示例3: traverse
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的package包/类
/**
* Scans the module using the specified visitor.
*
* @param module
* module to traverse
* @param visitor
* visitor to handle resources
* @param monitor
* a progress monitor
* @throws CoreException
*/
public static void traverse(IModule module, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException
{
if (module == null || module.getModuleType() == null)
return;
String typeId = module.getModuleType().getId();
IVirtualComponent component = ComponentCore.createComponent(module.getProject());
if (component == null)
{
// can happen if project has been closed
Trace.trace(Trace.WARNING,"Unable to create component for module " + module.getName());
return;
}
if (EAR_MODULE.equals(typeId))
{
traverseEarComponent(component,visitor,monitor);
}
else if (WEB_MODULE.equals(typeId))
{
traverseWebComponent(component,visitor,monitor);
}
}
示例4: getWebContentPath
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的package包/类
/**
* Returns the web contents folder of the specified project
*
* @param project
* the project which web contents path is needed
* @return IPath of the web contents folder
*/
public static IPath getWebContentPath( IProject project )
{
IPath path = null;
if ( project != null
&& JavaEEProjectUtilities.isDynamicWebProject( project )
)
{
IVirtualComponent component = ComponentCore
.createComponent( project );
path = component.getRootFolder( ).getWorkspaceRelativePath( );
}
return path;
}
示例5: findWebInfForNewResource
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的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);
}
示例6: findInWebInf
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的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;
}
示例7: getWebContentFolder
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的package包/类
/**
* Returns the WebContent folder for a Dynamic Web Project, or null if the
* project does not have a WebContent folder.
*
* @return A project-relative path to the WebContent folder
*/
public static IPath getWebContentFolder(IProject project) {
IPath path = null;
IVirtualComponent component = ComponentCore.createComponent(project);
if (component != null && component.exists()) {
path = component.getRootFolder().getWorkspaceRelativePath();
if (project.getFullPath().isPrefixOf(path)) {
return path.removeFirstSegments(project.getFullPath().segmentCount());
}
}
return null;
}
示例8: traverseEarComponent
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的package包/类
private static void traverseEarComponent(IVirtualComponent component, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException
{
// Currently the JST Server portion of WTP may not depend on the JST Enterprise portion of WTP
/*
* EARArtifactEdit earEdit = EARArtifactEdit .getEARArtifactEditForRead(component); if (earEdit != null) { IVirtualReference[] j2eeComponents =
* earEdit.getJ2EEModuleReferences(); for (int i = 0; i < j2eeComponents.length; i++) { traverseWebComponent(
* j2eeComponents[i].getReferencedComponent(), visitor, monitor); } IVirtualReference[] jarComponents = earEdit.getUtilityModuleReferences(); for (int i
* = 0; i < jarComponents.length; i++) { IVirtualReference jarReference = jarComponents[i]; IVirtualComponent jarComponent = jarReference
* .getReferencedComponent(); IProject dependentProject = jarComponent.getProject(); if (!dependentProject.hasNature(JavaCore.NATURE_ID)) continue;
* IJavaProject project = JavaCore.create(dependentProject); IClasspathEntry cpe = getClasspathEntry(project, jarComponent
* .getRootFolder().getProjectRelativePath()); visitor.visitEarResource(null, getOSPath(dependentProject, project, cpe.getOutputLocation())); } }
*/
visitor.endVisitEarComponent(component);
}
示例9: visitWebComponent
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void visitWebComponent(IVirtualComponent component) throws CoreException
{
IProject project = component.getProject();
if (project.hasNature(JavaCore.NATURE_ID))
{
IJavaProject javaProject = JavaCore.create(project);
runtimeClasspath.add(JavaRuntime.newDefaultProjectClasspathEntry(javaProject));
}
}
示例10: getWebContentPath
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的package包/类
/**
* Returns the web contents folder of the specified project
*
* @param project
* the project which web contents path is needed
* @return IPath of the web contents folder
*/
public static IPath getWebContentPath( IProject project )
{
IPath path = null;
if ( project != null
&& JavaEEProjectUtilities.isDynamicWebProject( project ) )
{
IVirtualComponent component = ComponentCore.createComponent( project );
path = component.getRootFolder( ).getWorkspaceRelativePath( );
}
return path;
}
示例11: findTemplateFoldersNames
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的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;
}
示例12: endVisitWebComponent
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void endVisitWebComponent(IVirtualComponent component) throws CoreException
{
// do nothing
}
示例13: endVisitEarComponent
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void endVisitEarComponent(IVirtualComponent component) throws CoreException
{
// do nothing
}
示例14: handleClassButtonSelected
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的package包/类
@Override
protected void handleClassButtonSelected()
{
getControl().setCursor(new Cursor(getShell().getDisplay(),SWT.CURSOR_WAIT));
try
{
IProject project = (IProject)model.getProperty(PROJECT);
if (project == null)
{
// show info message
return;
}
IVirtualComponent component = ComponentCore.createComponent(project);
MultiSelectFilteredFileSelectionDialog ms = new MultiSelectFilteredFileSelectionDialog(getShell(),NEW_SERVLET_WIZARD_WINDOW_TITLE,
CHOOSE_SERVLET_CLASS,JSPEXTENSIONS,false,project);
IContainer root = component.getRootFolder().getUnderlyingFolder();
ms.setInput(root);
ms.open();
if (ms.getReturnCode() == Window.OK)
{
String qualifiedClassName = ""; //$NON-NLS-1$
if (ms.getSelectedItem() == MultiSelectFilteredFileSelectionDialog.JSP)
{
Object obj = ms.getFirstResult();
if (obj != null)
{
if (obj instanceof IFile)
{
IFile file = (IFile)obj;
IPath pFull = file.getFullPath();
IPath pBase = root.getFullPath();
IPath path = pFull.removeFirstSegments(pBase.segmentCount());
qualifiedClassName = path.makeAbsolute().toString();
model.setProperty(IS_SERVLET_TYPE, Boolean.valueOf(false));
}
}
}
else
{
IType type = (IType)ms.getFirstResult();
if (type != null)
{
qualifiedClassName = type.getFullyQualifiedName();
model.setProperty(IS_SERVLET_TYPE,new Boolean(true));
}
}
existingClassText.setText(qualifiedClassName);
}
}
finally
{
getControl().setCursor(null);
}
}
示例15: getAcceptableRootPathsP
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; //导入依赖的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()]);
}