Author: rob.stryker(a)jboss.com
Date: 2009-09-17 20:00:41 -0400 (Thu, 17 Sep 2009)
New Revision: 17645
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ResourceListVirtualFolder.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClassFolderReferenceResolver.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClasspathFoldersVirtualComponent.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/FilesetVirtualComponent.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ExportedClasspathFoldersReferenceWizardFragment.java
Removed:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/LimitedContainerVirtualFolder.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFoldersVirtualComponent.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml
Log:
Pushing even more forward with extensions for ESB project structure
Deleted:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/LimitedContainerVirtualFolder.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/LimitedContainerVirtualFolder.java 2009-09-17
22:59:17 UTC (rev 17644)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/LimitedContainerVirtualFolder.java 2009-09-18
00:00:41 UTC (rev 17645)
@@ -1,69 +0,0 @@
-package org.jboss.ide.eclipse.as.wtp.core.util;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualFile;
-import org.eclipse.wst.common.componentcore.internal.resources.VirtualFolder;
-import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
-
-public class LimitedContainerVirtualFolder extends VirtualFolder {
-
- private IContainer[] containers;
- public LimitedContainerVirtualFolder(
- IProject aComponentProject,
- IPath aRuntimePath,
- IContainer[] containers) {
- super(aComponentProject, aRuntimePath);
- this.containers = containers;
- }
-
- public IContainer getUnderlyingFolder() {
- if( containers != null && containers.length > 0
- && containers[0] != null )
- return containers[0];
- return null;
- }
-
- public IContainer[] getUnderlyingFolders() {
- return containers == null ? new IContainer[]{} : containers;
- }
-
- public IVirtualResource[] members(int memberFlags) throws CoreException {
- List<IVirtualResource> virtualResources = new
ArrayList<IVirtualResource>(); // result
- Set allNames = new HashSet();
-
- for( int i = 0; i < containers.length; i++ ) {
- IResource realResource = containers[i];
- if ((realResource != null) && (realResource.getType() == IResource.FOLDER ||
realResource.getType() == IResource.PROJECT)) {
- IContainer realContainer = (IContainer) realResource;
- IResource[] realChildResources = realContainer.members(memberFlags);
- for (int realResourceIndex = 0; realResourceIndex < realChildResources.length;
realResourceIndex++) {
- IResource child = realChildResources[realResourceIndex];
- String localName = child.getName();
- if (allNames.add(localName)) {
- IPath newRuntimePath = getRuntimePath().append(localName);
- if (child instanceof IFile) {
- virtualResources.add(new VirtualFile(getProject(), newRuntimePath, (IFile)
child));
- } else {
- virtualResources.add(ComponentCore.createFolder(getProject(), newRuntimePath));
- }
- }
- }
- }
- // An IResource.FILE would be an error condition (as this is a container)
- }
- return virtualResources.toArray(new IVirtualResource[virtualResources.size()]);
- }
-
-
-}
Copied:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ResourceListVirtualFolder.java
(from rev 17524,
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/LimitedContainerVirtualFolder.java)
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ResourceListVirtualFolder.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/util/ResourceListVirtualFolder.java 2009-09-18
00:00:41 UTC (rev 17645)
@@ -0,0 +1,96 @@
+package org.jboss.ide.eclipse.as.wtp.core.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualFile;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualFolder;
+import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
+
+public class ResourceListVirtualFolder extends VirtualFolder {
+
+ private ArrayList<IResource> resources;
+ public ResourceListVirtualFolder(
+ IProject aComponentProject,
+ IPath aRuntimePath,
+ IResource[] containers) {
+ super(aComponentProject, aRuntimePath);
+ this.resources = new ArrayList<IResource>();
+ this.resources.addAll(Arrays.asList(containers));
+ }
+
+ protected void addResource(IResource c) {
+ //this.resources.add(c);
+ }
+
+ public IResource getUnderlyingResource() {
+ // Since I'm a container, pretend I'm a container I guess
+ return getUnderlyingFolder();
+ }
+
+ public IResource[] getUnderlyingResources() {
+ return getUnderlyingFolders();
+ }
+
+ public IContainer getUnderlyingFolder() {
+ IResource[] r = (IResource[]) resources.toArray(new IResource[resources.size()]);
+ for( int i = 0; i < r.length; i++ )
+ if( r[i] instanceof IContainer )
+ return (IContainer)r[i];
+ return null;
+ }
+
+ public IContainer[] getUnderlyingFolders() {
+ IResource[] r = (IResource[]) resources.toArray(new IResource[resources.size()]);
+ ArrayList<IContainer> c = new ArrayList<IContainer>();
+ for( int i = 0; i < r.length; i++ )
+ if( r[i] instanceof IContainer )
+ c.add((IContainer)r[i]);
+ return (IContainer[]) c.toArray(new IContainer[c.size()]);
+ }
+
+ public IVirtualResource[] members(int memberFlags) throws CoreException {
+ List<IVirtualResource> virtualResources = new
ArrayList<IVirtualResource>(); // result
+ Set allNames = new HashSet();
+ IResource[] containers2 = (IResource[]) this.resources.toArray(new
IResource[this.resources.size()]);
+ for( int i = 0; i < containers2.length; i++ ) {
+ IResource realResource = containers2[i];
+ if ((realResource != null) && (realResource.getType() == IResource.FOLDER ||
realResource.getType() == IResource.PROJECT)) {
+ IContainer realContainer = (IContainer) realResource;
+ IResource[] realChildResources = realContainer.members(memberFlags);
+ for (int realResourceIndex = 0; realResourceIndex < realChildResources.length;
realResourceIndex++) {
+ IResource child = realChildResources[realResourceIndex];
+ String localName = child.getName();
+ if (allNames.add(localName)) {
+ IPath newRuntimePath = getRuntimePath().append(localName);
+ if (child instanceof IFile) {
+ virtualResources.add(new VirtualFile(getProject(), newRuntimePath, (IFile)
child));
+ } else if( child instanceof IContainer ){
+ IContainer childContainer = (IContainer)child;
+ IResource[] members = childContainer.members();
+ ResourceListVirtualFolder childFolder =
+ new ResourceListVirtualFolder(getProject(), newRuntimePath, members);
+ virtualResources.add(childFolder);
+ }
+ }
+ }
+ } else if(realResource != null && realResource instanceof IFile) {
+ // An IResource.FILE would be an error condition (as this is a container)
+ virtualResources.add(new VirtualFile(getProject(),
+ getRuntimePath().append(((IFile)realResource).getName()),
(IFile)realResource));
+ }
+ }
+ return virtualResources.toArray(new IVirtualResource[virtualResources.size()]);
+ }
+
+
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClassFolderReferenceResolver.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClassFolderReferenceResolver.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClassFolderReferenceResolver.java 2009-09-18
00:00:41 UTC (rev 17645)
@@ -0,0 +1,68 @@
+package org.jboss.ide.eclipse.as.wtp.core.vcf;
+
+import org.eclipse.core.internal.resources.Workspace;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage;
+import org.eclipse.wst.common.componentcore.internal.DependencyType;
+import org.eclipse.wst.common.componentcore.internal.ReferencedComponent;
+import org.eclipse.wst.common.componentcore.internal.impl.PlatformURLModuleConnection;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+
+public class ExportedClassFolderReferenceResolver implements IReferenceResolver {
+ public static final String OUTPUT_FOLDER_SEGMENT =
"org.jboss.ide.eclipse.as.wtp.core.vcf.exportedClassFolders";
+ public static final String OUTPUT_FOLDER_PROTOCOL =
PlatformURLModuleConnection.MODULE_PROTOCOL
+ +IPath.SEPARATOR+ OUTPUT_FOLDER_SEGMENT + IPath.SEPARATOR;
+ public ExportedClassFolderReferenceResolver() {
+ }
+
+ public boolean canResolve(IVirtualComponent context,
+ ReferencedComponent referencedComponent) {
+ URI handle = referencedComponent.getHandle();
+ String s = handle.toString();
+ if(s.startsWith(OUTPUT_FOLDER_PROTOCOL))
+ return true;
+ return false;
+ }
+
+ public boolean canResolve(IVirtualReference reference) {
+ if( reference.getReferencedComponent() instanceof
ExportedClasspathFoldersVirtualComponent )
+ return true;
+ return false;
+ }
+
+ public IVirtualReference resolve(IVirtualComponent context,
+ ReferencedComponent referencedComponent) {
+ String project = referencedComponent.getHandle().segment(1);
+ IProject p = null;
+ if( !project.equals(""))
+ p = ResourcesPlugin.getWorkspace().getRoot().getProject(project);
+ else
+ p = context.getProject();
+ IVirtualComponent comp = new ExportedClasspathFoldersVirtualComponent(p, context);
+ IVirtualReference ref = ComponentCore.createReference(context, comp);
+ ref.setArchiveName(referencedComponent.getArchiveName());
+ ref.setRuntimePath(referencedComponent.getRuntimePath());
+ ref.setDependencyType(referencedComponent.getDependencyType().getValue());
+ return ref;
+ }
+
+ public ReferencedComponent resolve(IVirtualReference reference) {
+ if( reference.getReferencedComponent() instanceof
ExportedClasspathFoldersVirtualComponent ) {
+ ExportedClasspathFoldersVirtualComponent comp =
(ExportedClasspathFoldersVirtualComponent)reference.getReferencedComponent();
+ IProject p = reference.getReferencedComponent().getProject();
+ ReferencedComponent rc =
ComponentcorePackage.eINSTANCE.getComponentcoreFactory().createReferencedComponent();
+ rc.setArchiveName(reference.getArchiveName());
+ rc.setRuntimePath(reference.getRuntimePath());
+ rc.setHandle(URI.createURI(comp.getId()));
+ rc.setDependencyType(DependencyType.CONSUMES_LITERAL);
+ return rc;
+ }
+ return null;
+ }
+
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClasspathFoldersVirtualComponent.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClasspathFoldersVirtualComponent.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/ExportedClasspathFoldersVirtualComponent.java 2009-09-18
00:00:41 UTC (rev 17645)
@@ -0,0 +1,59 @@
+package org.jboss.ide.eclipse.as.wtp.core.vcf;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+
+public class ExportedClasspathFoldersVirtualComponent extends FilesetVirtualComponent {
+ public ExportedClasspathFoldersVirtualComponent(IProject p, IVirtualComponent
referencingComponent) {
+ super(p,referencingComponent);
+ }
+
+ protected String getFirstIdSegment() {
+ return ExportedClassFolderReferenceResolver.OUTPUT_FOLDER_PROTOCOL;
+ }
+
+ protected IResource[] getExposableResources() {
+ IJavaProject jp = JavaCore.create(project);
+ IClasspathEntry[] entries = findAllClassFolderEntries(jp);
+ ArrayList<IResource> results = new ArrayList<IResource>();
+ for( int i = 0; i < entries.length; i++ ) {
+ IClasspathAttribute attribute =
ClasspathDependencyUtil.checkForComponentDependencyAttribute(
+ entries[i],
+ ClasspathDependencyUtil.DependencyAttributeType.CLASSPATH_COMPONENT_DEPENDENCY);
+
+ if( attribute != null ) {
+ final IResource resource =
ResourcesPlugin.getWorkspace().getRoot().findMember(entries[i].getPath());
+ if (resource != null && resource instanceof IContainer ) {
+ results.add(resource);
+ }
+ }
+ }
+ return (IResource[]) results.toArray(new IResource[results.size()]);
+ }
+
+ protected IClasspathEntry[] findAllClassFolderEntries(IJavaProject javaProject) {
+ List<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
+ try {
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ for( int i = 0; i < entries.length; i++ ) {
+ if( ClasspathDependencyUtil.isClassFolderEntry(entries[i]))
+ list.add(entries[i]);
+ }
+ } catch( CoreException ce) {
+ }
+ return list.toArray(new IClasspathEntry[list.size()]);
+ }
+
+}
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/FilesetVirtualComponent.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/FilesetVirtualComponent.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/FilesetVirtualComponent.java 2009-09-18
00:00:41 UTC (rev 17645)
@@ -0,0 +1,120 @@
+package org.jboss.ide.eclipse.as.wtp.core.vcf;
+
+import java.util.Properties;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
+import org.jboss.ide.eclipse.as.wtp.core.util.ResourceListVirtualFolder;
+
+public abstract class FilesetVirtualComponent implements IVirtualComponent {
+ protected IProject project;
+ protected IVirtualComponent referencingComp;
+
+ public FilesetVirtualComponent(IProject p, IVirtualComponent referencingComponent) {
+ this.project = p;
+ this.referencingComp = referencingComponent;
+ }
+
+ public void create(int updateFlags, IProgressMonitor aMonitor)
+ throws CoreException {
+ // Ignore
+ }
+
+ public boolean exists() {
+ return true;
+ }
+
+ public IVirtualComponent getComponent() {
+ return this;
+ }
+
+ public String getName() {
+ return getId();
+ }
+
+ public String getDeployedName() {
+ return getName();
+ }
+
+ protected String getId() {
+ String firstSegment = getFirstIdSegment();
+ if (project.equals(referencingComp.getProject()))
+ return firstSegment;
+
+ return firstSegment + Path.SEPARATOR + project.getName();
+ }
+
+ protected abstract String getFirstIdSegment();
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public IVirtualComponent[] getReferencingComponents() {
+ return referencingComp == null ? new IVirtualComponent[] {}
+ : new IVirtualComponent[] { referencingComp };
+ }
+
+ public IVirtualFolder getRootFolder() {
+ IResource[] resources = getExposableResources();
+ return new ResourceListVirtualFolder(
+ project, new Path("/"), resources);
+ }
+
+ protected abstract IResource[] getExposableResources();
+
+ public Properties getMetaProperties() {
+ return null;
+ }
+
+ public IPath[] getMetaResources() {
+ return null;
+ }
+
+ public IVirtualReference getReference(String aComponentName) {
+ // Ignore
+ return null;
+ }
+
+ public IVirtualReference[] getReferences() {
+ // Ignore; no children
+ return new IVirtualReference[] {};
+ }
+
+ public boolean isBinary() {
+ return false;
+ }
+
+ public void setMetaProperties(Properties properties) {
+ // Ignore
+ }
+
+ public void setMetaProperty(String name, String value) {
+ // Ignore
+ }
+
+ public void setMetaResources(IPath[] theMetaResourcePaths) {
+ // Ignore
+ }
+
+ public void setReferences(IVirtualReference[] theReferences) {
+ // Ignore
+ }
+
+ public Object getAdapter(Class adapter) {
+ // Ignore
+ return null;
+ }
+
+ public void addReferences(IVirtualReference[] references) {
+ // Ignore
+ }
+
+}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFoldersVirtualComponent.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFoldersVirtualComponent.java 2009-09-17
22:59:17 UTC (rev 17644)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFoldersVirtualComponent.java 2009-09-18
00:00:41 UTC (rev 17645)
@@ -2,74 +2,28 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
+import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
-import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
-import org.jboss.ide.eclipse.as.wtp.core.util.LimitedContainerVirtualFolder;
-public class OutputFoldersVirtualComponent implements IVirtualComponent {
+public class OutputFoldersVirtualComponent extends FilesetVirtualComponent {
- private IProject project;
- private IVirtualComponent referencingComp;
-
public OutputFoldersVirtualComponent(IProject p, IVirtualComponent referencingComponent)
{
- this.project = p;
- this.referencingComp = referencingComponent;
+ super(p, referencingComponent);
}
- public void create(int updateFlags, IProgressMonitor aMonitor)
- throws CoreException {
- // Ignore
+ protected String getFirstIdSegment() {
+ return OutputFolderReferenceResolver.OUTPUT_FOLDER_PROTOCOL;
}
- public boolean exists() {
- return true;
- }
-
- public IVirtualComponent getComponent() {
- return this;
- }
-
- public String getName() {
- return getId();
- }
-
- public String getDeployedName() {
- return getName();
- }
-
- protected String getId() {
- if( project.equals(referencingComp.getProject()))
- return OutputFolderReferenceResolver.OUTPUT_FOLDER_PROTOCOL;
- return OutputFolderReferenceResolver.OUTPUT_FOLDER_PROTOCOL + Path.SEPARATOR +
project.getName();
- }
-
- public IProject getProject() {
- return project;
- }
- public IVirtualComponent[] getReferencingComponents() {
- return referencingComp == null ? new IVirtualComponent[]{} : new
IVirtualComponent[]{referencingComp};
- }
-
- public IVirtualFolder getRootFolder() {
- IContainer[] containers = getOutputContainers(project);
- return new LimitedContainerVirtualFolder(project, new Path("/"),
containers);
- }
-
- private static IContainer[] getOutputContainers(IProject project) {
+ protected IResource[] getExposableResources() {
List<IContainer> result = new ArrayList<IContainer>();
try {
if (!project.hasNature(JavaCore.NATURE_ID))
@@ -102,55 +56,4 @@
}
return list.toArray(new IPackageFragmentRoot[list.size()]);
}
-
-
- public Properties getMetaProperties() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public IPath[] getMetaResources() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public IVirtualReference getReference(String aComponentName) {
- // Ignore
- return null;
- }
-
- public IVirtualReference[] getReferences() {
- // Ignore; no children
- return new IVirtualReference[]{};
- }
-
- public boolean isBinary() {
- return false;
- }
-
- public void setMetaProperties(Properties properties) {
- // Ignore
- }
-
- public void setMetaProperty(String name, String value) {
- // Ignore
- }
-
- public void setMetaResources(IPath[] theMetaResourcePaths) {
- // Ignore
- }
-
- public void setReferences(IVirtualReference[] theReferences) {
- // Ignore
- }
-
- public Object getAdapter(Class adapter) {
- // Ignore
- return null;
- }
-
- public void addReferences(IVirtualReference[] references) {
- // Ignore
- }
-
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml 2009-09-17 22:59:17 UTC
(rev 17644)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml 2009-09-18 00:00:41 UTC
(rev 17645)
@@ -58,8 +58,14 @@
<referenceFragment
class="org.jboss.ide.eclipse.as.wtp.ui.propertypage.OutputFolderReferenceWizardFragment"
icon="icons/jar_obj.gif"
- id="org.jboss.ide.eclipse.as.wtp.ui.mappedOutputFolders"
+ id="org.jboss.ide.eclipse.as.wtp.ui.mappedOutputFoldersReference"
name="Mapped Output Folders">
</referenceFragment>
+ <referenceFragment
+
class="org.jboss.ide.eclipse.as.wtp.ui.propertypage.ExportedClasspathFoldersReferenceWizardFragment"
+ icon="icons/jar_obj.gif"
+
id="org.jboss.ide.eclipse.as.wtp.ui.ExportedClasspathFoldersReference"
+ name="Build Path Class Folders">
+ </referenceFragment>
</extension>
</plugin>
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ExportedClasspathFoldersReferenceWizardFragment.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ExportedClasspathFoldersReferenceWizardFragment.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ExportedClasspathFoldersReferenceWizardFragment.java 2009-09-18
00:00:41 UTC (rev 17645)
@@ -0,0 +1,212 @@
+package org.jboss.ide.eclipse.as.wtp.ui.propertypage;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil;
+import
org.eclipse.jst.j2ee.internal.classpathdep.UpdateClasspathAttributesDataModelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.SharedImages;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.jboss.ide.eclipse.as.wtp.core.vcf.ExportedClasspathFoldersVirtualComponent;
+
+public class ExportedClasspathFoldersReferenceWizardFragment extends
+ WizardFragment {
+
+ protected TreeViewer viewer;
+ protected IPath[] paths;
+ protected IWizardHandle handle;
+ protected IStructuredSelection selected = null;
+ protected IStructuredSelection initialSelection = null;
+ protected Object[] allElements;
+ public ExportedClasspathFoldersReferenceWizardFragment() {
+ super();
+ }
+
+ public boolean hasComposite() {
+ return true;
+ }
+
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
+ this.handle = handle;
+ int x = 1;
+ handle.setTitle("Add exported folders from the build pathx");
+ handle.setDescription("This reference will allow you to add references to exported
classpaths from this project's build page. Please select all entries you wish to be
published.");
+ IVirtualComponent parentComp =
(IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
+ IProject project = parentComp.getProject();
+ IJavaProject javaProject = JavaCore.create(project);
+ allElements = findAllClassFolderEntries(javaProject);
+
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setLayout(new FormLayout());
+ viewer = new TreeViewer(c, SWT.MULTI | SWT.BORDER);
+ viewer.setContentProvider(getContentProvider());
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.setInput(ResourcesPlugin.getWorkspace());
+
+ FormData fd = new FormData();
+ fd.left = new FormAttachment(0, 5);
+ fd.top = new FormAttachment(0, 5);
+ fd.right = new FormAttachment(100, -5);
+ fd.bottom = new FormAttachment(100, -5);
+ viewer.getTree().setLayoutData(fd);
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ selected = (IStructuredSelection)viewer.getSelection();
+ }
+ });
+
+ ArrayList<IClasspathEntry> withTag = new ArrayList<IClasspathEntry>();
+ for( int i = 0; i < allElements.length; i++ ) {
+ IClasspathAttribute attribute =
ClasspathDependencyUtil.checkForComponentDependencyAttribute(
+ ((IClasspathEntry)allElements[i]),
+ ClasspathDependencyUtil.DependencyAttributeType.CLASSPATH_COMPONENT_DEPENDENCY);
+
+ if( attribute != null )
+ withTag.add((IClasspathEntry)allElements[i]);
+ }
+
+ StructuredSelection newSel = new StructuredSelection(withTag);
+ viewer.setSelection(newSel);
+ initialSelection = newSel;
+ return c;
+ }
+
+ protected IClasspathEntry[] findAllClassFolderEntries(IJavaProject javaProject) {
+ List<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
+ try {
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ for( int i = 0; i < entries.length; i++ ) {
+ if( ClasspathDependencyUtil.isClassFolderEntry(entries[i]))
+ list.add(entries[i]);
+ }
+ } catch( CoreException ce) {
+ }
+ return list.toArray(new IClasspathEntry[list.size()]);
+ }
+
+ private ITreeContentProvider getContentProvider() {
+ return new ITreeContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ IVirtualComponent parentComp =
(IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
+ IProject project = parentComp.getProject();
+ IJavaProject jp = JavaCore.create(project);
+ if( jp != null ) {
+ return findAllClassFolderEntries(jp);
+ }
+ return new Object[]{};
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ public void dispose() {
+ }
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+ public Object getParent(Object element) {
+ return null;
+ }
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+ };
+ }
+
+ private LabelProvider getLabelProvider() {
+ return new LabelProvider() {
+ public Image getImage(Object element) {
+ return
PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OBJ_PROJECT);
+ }
+ public String getText(Object element) {
+ return element instanceof IProject ? ((IProject)element).getName() :
element.toString();
+ }
+ };
+ }
+
+ public void performFinish(IProgressMonitor monitor) throws CoreException {
+ IVirtualComponent parentComp =
(IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
+ try {
+ Map<IClasspathEntry, IPath> toAdd = new HashMap<IClasspathEntry,
IPath>();
+ Map<IClasspathEntry, IPath> toRemove = new HashMap<IClasspathEntry,
IPath>();
+
+ List pre = Arrays.asList(initialSelection.toArray());
+ List post = Arrays.asList(selected.toArray());
+ for( int i = 0; i < allElements.length; i++ ) {
+ if( pre.contains(allElements[i]) && !post.contains(allElements[i])) {
+ toRemove.put((IClasspathEntry)allElements[i],
getOriginalPath((IClasspathEntry)allElements[i]));
+ }
+ else if( !pre.contains(allElements[i]) && post.contains(allElements[i])) {
+ toAdd.put((IClasspathEntry)allElements[i],
getNewPath((IClasspathEntry)allElements[i]));
+ }
+ }
+
+ UpdateClasspathAttributesDataModelProvider provider = new
UpdateClasspathAttributesDataModelProvider();
+ IDataModel model = DataModelFactory.createDataModel(provider);
+ model.setProperty(UpdateClasspathAttributesDataModelProvider.PROJECT_NAME,
parentComp.getProject().getName());
+ model.setProperty(UpdateClasspathAttributesDataModelProvider.ENTRIES_TO_ADD_ATTRIBUTE,
toAdd);
+ model.getDefaultOperation().execute(new NullProgressMonitor(), null);
+
+ provider = new UpdateClasspathAttributesDataModelProvider();
+ model = DataModelFactory.createDataModel(provider);
+ model.setProperty(UpdateClasspathAttributesDataModelProvider.PROJECT_NAME,
parentComp.getProject().getName());
+ model.setProperty(UpdateClasspathAttributesDataModelProvider.ENTRIES_TO_REMOVE_ATTRIBUTE,
toRemove);
+ model.getDefaultOperation().execute(new NullProgressMonitor(), null);
+
+ } catch( ExecutionException ee) {
+
+ }
+
+ ExportedClasspathFoldersVirtualComponent vc = new
ExportedClasspathFoldersVirtualComponent(parentComp.getProject(), parentComp);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT, vc);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, "/");
+ }
+
+ protected IPath getOriginalPath(IClasspathEntry entry) {
+ final IClasspathAttribute[] attributes = entry.getExtraAttributes();
+ for (int i = 0; i < attributes.length; i++) {
+ final IClasspathAttribute attribute = attributes[i];
+ final String name = attribute.getName();
+ if (name.equals(ClasspathDependencyUtil.CLASSPATH_COMPONENT_DEPENDENCY)) {
+ return new Path(attribute.getValue());
+ }
+ }
+ return new Path("/");
+ }
+
+ protected IPath getNewPath(IClasspathEntry cpe) {
+ return new Path("/");
+ }
+}