Author: rob.stryker(a)jboss.com
Date: 2009-09-16 16:28:24 -0400 (Wed, 16 Sep 2009)
New Revision: 17626
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/OutputFolderReferenceWizardFragment.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFolderReferenceResolver.java
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/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/AddModuleDependenciesPropertiesPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java
Log:
Adding output folder mappings
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFolderReferenceResolver.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFolderReferenceResolver.java 2009-09-16
18:48:12 UTC (rev 17625)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFolderReferenceResolver.java 2009-09-16
20:28:24 UTC (rev 17626)
@@ -14,7 +14,7 @@
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
public class OutputFolderReferenceResolver implements IReferenceResolver {
- public static final String OUTPUT_FOLDER_SEGMENT =
"org.jboss.ide.eclipse.as.wtp.core.vcf.outputFolder";
+ public static final String OUTPUT_FOLDER_SEGMENT =
"org.jboss.ide.eclipse.as.wtp.core.vcf.outputFolders";
public static final String OUTPUT_FOLDER_PROTOCOL =
PlatformURLModuleConnection.MODULE_PROTOCOL
+IPath.SEPARATOR+ OUTPUT_FOLDER_SEGMENT + IPath.SEPARATOR;
public OutputFolderReferenceResolver() {
@@ -38,7 +38,11 @@
public IVirtualReference resolve(IVirtualComponent context,
ReferencedComponent referencedComponent) {
String project = referencedComponent.getHandle().segment(1);
- IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(project);
+ IProject p = null;
+ if( !project.equals(""))
+ p = ResourcesPlugin.getWorkspace().getRoot().getProject(project);
+ else
+ p = context.getProject();
IVirtualComponent comp = new OutputFoldersVirtualComponent(p, context);
IVirtualReference ref = ComponentCore.createReference(context, comp);
ref.setArchiveName(referencedComponent.getArchiveName());
@@ -49,11 +53,12 @@
public ReferencedComponent resolve(IVirtualReference reference) {
if( reference.getReferencedComponent() instanceof OutputFoldersVirtualComponent ) {
+ OutputFoldersVirtualComponent comp =
(OutputFoldersVirtualComponent)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(OUTPUT_FOLDER_PROTOCOL + p.getName()));
+ rc.setHandle(URI.createURI(comp.getId()));
rc.setDependencyType(DependencyType.CONSUMES_LITERAL);
return rc;
}
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-16
18:48:12 UTC (rev 17625)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.core/src/org/jboss/ide/eclipse/as/wtp/core/vcf/OutputFoldersVirtualComponent.java 2009-09-16
20:28:24 UTC (rev 17626)
@@ -1,5 +1,7 @@
package org.jboss.ide.eclipse.as.wtp.core.vcf;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
import org.eclipse.core.resources.IContainer;
@@ -8,6 +10,10 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
+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;
@@ -18,6 +24,7 @@
private IProject project;
private IVirtualComponent referencingComp;
+
public OutputFoldersVirtualComponent(IProject p, IVirtualComponent referencingComponent)
{
this.project = p;
this.referencingComp = referencingComponent;
@@ -45,7 +52,9 @@
}
protected String getId() {
- return OutputFolderReferenceResolver.OUTPUT_FOLDER_SEGMENT + Path.SEPARATOR +
project.getName();
+ if( project.equals(referencingComp.getProject()))
+ return OutputFolderReferenceResolver.OUTPUT_FOLDER_PROTOCOL;
+ return OutputFolderReferenceResolver.OUTPUT_FOLDER_PROTOCOL + Path.SEPARATOR +
project.getName();
}
public IProject getProject() {
@@ -56,10 +65,45 @@
}
public IVirtualFolder getRootFolder() {
- IContainer[] containers = J2EEProjectUtilities.getOutputContainers(project);
+ IContainer[] containers = getOutputContainers(project);
return new LimitedContainerVirtualFolder(project, new Path("/"),
containers);
}
+
+ private static IContainer[] getOutputContainers(IProject project) {
+ List<IContainer> result = new ArrayList<IContainer>();
+ try {
+ if (!project.hasNature(JavaCore.NATURE_ID))
+ return new IContainer[] {};
+ } catch (Exception e) {
+ }
+ IPackageFragmentRoot[] sourceContainers = getSourceContainers(project);
+ for (int i = 0; i < sourceContainers.length; i++) {
+ IContainer outputFolder = J2EEProjectUtilities.getOutputContainer(project,
sourceContainers[i]);
+ if (outputFolder != null && !result.contains(outputFolder))
+ result.add(outputFolder);
+ }
+ return result.toArray(new IContainer[result.size()]);
+ }
+ public static IPackageFragmentRoot[] getSourceContainers(IProject project) {
+ IJavaProject jProject = JavaCore.create(project);
+ if (jProject == null)
+ return new IPackageFragmentRoot[0];
+ List<IPackageFragmentRoot> list = new ArrayList<IPackageFragmentRoot>();
+ IPackageFragmentRoot[] roots;
+ try {
+ roots = jProject.getPackageFragmentRoots();
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].getKind() != IPackageFragmentRoot.K_SOURCE)
+ continue;
+ list.add(roots[i]);
+ }
+ } catch( JavaModelException jme ) {
+ }
+ return list.toArray(new IPackageFragmentRoot[list.size()]);
+ }
+
+
public Properties getMetaProperties() {
// TODO Auto-generated method stub
return null;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/META-INF/MANIFEST.MF 2009-09-16
18:48:12 UTC (rev 17625)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/META-INF/MANIFEST.MF 2009-09-16
20:28:24 UTC (rev 17626)
@@ -24,7 +24,8 @@
org.eclipse.wst.server.ui;bundle-version="1.1.102",
org.eclipse.wst.server.core;bundle-version="1.1.101",
org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.1.300",
- org.eclipse.emf.ecore;bundle-version="2.5.0"
+ org.eclipse.emf.ecore;bundle-version="2.5.0",
+ org.jboss.ide.eclipse.as.wtp.core;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss by Red Hat
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-16 18:48:12 UTC
(rev 17625)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/plugin.xml 2009-09-16 20:28:24 UTC
(rev 17626)
@@ -55,5 +55,11 @@
id="org.jboss.ide.eclipse.as.wtp.ui.variableReference"
name="Variable">
</referenceFragment>
+ <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"
+ name="Mapped Output Folders">
+ </referenceFragment>
</extension>
</plugin>
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/AddModuleDependenciesPropertiesPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-09-16
18:48:12 UTC (rev 17625)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-09-16
20:28:24 UTC (rev 17626)
@@ -453,7 +453,7 @@
Object p1 = wizard.getTaskModel().getObject(NewReferenceWizard.COMPONENT_PATH);
IVirtualComponent[] compArr = c1 instanceof IVirtualComponent ?
new IVirtualComponent[] { (IVirtualComponent)c1 } :
- (IVirtualComponent[])c1;
+ (IVirtualComponent[])c1;
String[] pathArr = p1 instanceof String ?
new String[] { (String)p1 } :
(String[])p1;
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java 2009-09-16
18:48:12 UTC (rev 17625)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/ComponentDependencyContentProvider.java 2009-09-16
20:28:24 UTC (rev 17626)
@@ -90,7 +90,7 @@
p = new
Path(((VirtualArchiveComponent)comp).getUnderlyingDiskFile().getAbsolutePath());
return p.toString();
}
- return comp.getProject().getName();
+ return comp.getName();
}
} else if (element instanceof IProject){
if (columnIndex == 0) {
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/OutputFolderReferenceWizardFragment.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/OutputFolderReferenceWizardFragment.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.ui/src/org/jboss/ide/eclipse/as/wtp/ui/propertypage/OutputFolderReferenceWizardFragment.java 2009-09-16
20:28:24 UTC (rev 17626)
@@ -0,0 +1,109 @@
+package org.jboss.ide.eclipse.as.wtp.ui.propertypage;
+
+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.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.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+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.server.ui.wizard.IWizardHandle;
+import org.eclipse.wst.server.ui.wizard.WizardFragment;
+import org.jboss.ide.eclipse.as.wtp.core.vcf.OutputFoldersVirtualComponent;
+
+public class OutputFolderReferenceWizardFragment extends WizardFragment {
+
+ protected TreeViewer viewer;
+ protected IPath[] paths;
+ protected IWizardHandle handle;
+ protected IProject selected = null;
+ public OutputFolderReferenceWizardFragment() {
+ super();
+ }
+
+ public boolean hasComposite() {
+ return true;
+ }
+
+ public Composite createComposite(Composite parent, IWizardHandle handle) {
+ this.handle = handle;
+ handle.setTitle("Add output folders");
+ handle.setDescription("This reference will add in all source folder outputs from
the selected project.");
+
+ Composite c = new Composite(parent, SWT.NONE);
+ c.setLayout(new FormLayout());
+ viewer = new TreeViewer(c, SWT.SINGLE | 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) {
+ IVirtualComponent parentComp =
(IVirtualComponent)getTaskModel().getObject(NewReferenceWizard.ROOT_COMPONENT);
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ selected = (IProject)sel.getFirstElement();
+ }
+ });
+ return c;
+ }
+
+ private ITreeContentProvider getContentProvider() {
+ return new ITreeContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ }
+ 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);
+ selected = selected == null ? parentComp.getProject() : selected;
+ OutputFoldersVirtualComponent vc = new OutputFoldersVirtualComponent(selected,
parentComp);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT, vc);
+ getTaskModel().putObject(NewReferenceWizard.COMPONENT_PATH, "/");
+ }
+}