|
Lines 14-31
Link Here
|
| 14 |
import java.net.URL; |
14 |
import java.net.URL; |
| 15 |
import java.util.ArrayList; |
15 |
import java.util.ArrayList; |
| 16 |
import java.util.Arrays; |
16 |
import java.util.Arrays; |
|
|
17 |
import java.util.HashMap; |
| 17 |
import java.util.List; |
18 |
import java.util.List; |
|
|
19 |
import java.util.Map; |
| 18 |
import java.util.Properties; |
20 |
import java.util.Properties; |
| 19 |
|
21 |
|
| 20 |
import org.eclipse.core.resources.IContainer; |
22 |
import org.eclipse.core.resources.IContainer; |
| 21 |
import org.eclipse.core.resources.IFile; |
23 |
import org.eclipse.core.resources.IFile; |
| 22 |
import org.eclipse.core.resources.IProject; |
24 |
import org.eclipse.core.resources.IProject; |
|
|
25 |
import org.eclipse.core.resources.IResource; |
| 23 |
import org.eclipse.core.resources.ResourcesPlugin; |
26 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 24 |
import org.eclipse.core.runtime.CoreException; |
27 |
import org.eclipse.core.runtime.CoreException; |
| 25 |
import org.eclipse.core.runtime.IPath; |
28 |
import org.eclipse.core.runtime.IPath; |
| 26 |
import org.eclipse.core.runtime.Path; |
29 |
import org.eclipse.core.runtime.Path; |
|
|
30 |
import org.eclipse.jdt.core.IClasspathEntry; |
| 27 |
import org.eclipse.jdt.core.IJavaProject; |
31 |
import org.eclipse.jdt.core.IJavaProject; |
| 28 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
32 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
|
|
33 |
import org.eclipse.jdt.core.JavaCore; |
| 34 |
import org.eclipse.jdt.core.JavaModelException; |
| 29 |
import org.eclipse.jem.workbench.utility.JemProjectUtilities; |
35 |
import org.eclipse.jem.workbench.utility.JemProjectUtilities; |
| 30 |
import org.eclipse.jst.j2ee.application.Application; |
36 |
import org.eclipse.jst.j2ee.application.Application; |
| 31 |
import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualArchiveComponent; |
37 |
import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualArchiveComponent; |
|
Lines 49-54
Link Here
|
| 49 |
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; |
55 |
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; |
| 50 |
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; |
56 |
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; |
| 51 |
import org.eclipse.wst.common.componentcore.resources.IVirtualReference; |
57 |
import org.eclipse.wst.common.componentcore.resources.IVirtualReference; |
|
|
58 |
import org.eclipse.wst.common.componentcore.resources.VirtualTreeNode; |
| 59 |
import org.eclipse.wst.common.componentcore.resources.VirtualTreeNode.Entry; |
| 52 |
import org.eclipse.wst.server.core.IModule; |
60 |
import org.eclipse.wst.server.core.IModule; |
| 53 |
import org.eclipse.wst.server.core.ServerUtil; |
61 |
import org.eclipse.wst.server.core.ServerUtil; |
| 54 |
import org.eclipse.wst.server.core.internal.ModuleFile; |
62 |
import org.eclipse.wst.server.core.internal.ModuleFile; |
|
Lines 471-478
Link Here
|
| 471 |
} |
479 |
} |
| 472 |
return module; |
480 |
return module; |
| 473 |
} |
481 |
} |
| 474 |
|
482 |
|
| 475 |
/** |
483 |
@Override |
|
|
484 |
protected VirtualTreeNode getVirtualTreeRoot() throws CoreException { |
| 485 |
VirtualTreeNode root = getComponentVirtualTreeRoot(); |
| 486 |
if (root == null) return null; |
| 487 |
IProject project = getProject(); |
| 488 |
final List<Entry> replaced = new ArrayList<Entry>(); |
| 489 |
if (project.hasNature(JavaCore.NATURE_ID)) { |
| 490 |
final Map<IResource, IResource> map = getJavaOutputLocationMap(project); |
| 491 |
root = root.filter(new VirtualTreeNode.IEntryFilter() { |
| 492 |
public boolean accept(Entry entry) { |
| 493 |
IResource resource = entry.getResource(); |
| 494 |
if (resource != null) { |
| 495 |
resource = map.get(resource); |
| 496 |
if (resource != null) { |
| 497 |
replaced.add(new Entry(entry.getRuntimePath(), resource)); |
| 498 |
return false; |
| 499 |
} |
| 500 |
} |
| 501 |
return true; |
| 502 |
} |
| 503 |
}); |
| 504 |
} |
| 505 |
ArrayList<Entry> entries = new ArrayList<Entry>(); |
| 506 |
entries.add(new VirtualTreeNode.Entry(null, root)); |
| 507 |
entries.addAll(replaced); |
| 508 |
addLocalVirtualTreeEntries(entries); |
| 509 |
return newVirtualTreeNode(entries); |
| 510 |
} |
| 511 |
|
| 512 |
@Override |
| 513 |
protected void addLocalVirtualTreeEntries(ArrayList<Entry> entries) throws CoreException { |
| 514 |
super.addLocalVirtualTreeEntries(entries); |
| 515 |
addConsumableReferencedEntries(entries); |
| 516 |
} |
| 517 |
|
| 518 |
private Map<IResource, IResource> getJavaOutputLocationMap(IProject project) throws JavaModelException { |
| 519 |
Map<IResource, IResource> map = new HashMap<IResource, IResource>(); |
| 520 |
IContainer workspace = project.getParent(); |
| 521 |
IJavaProject jproject = JavaCore.create(project); |
| 522 |
for (IClasspathEntry cpe : jproject.getRawClasspath()) { |
| 523 |
if (IClasspathEntry.CPE_SOURCE == cpe.getEntryKind()) { |
| 524 |
IPath path = cpe.getPath(); |
| 525 |
IPath output = cpe.getOutputLocation(); |
| 526 |
if (output == null) output = jproject.getOutputLocation(); |
| 527 |
map.put(workspace.findMember(path), workspace.findMember(output)); |
| 528 |
} |
| 529 |
} |
| 530 |
return map; |
| 531 |
} |
| 532 |
|
| 533 |
protected void addConsumableReferencedEntries(List<Entry> entries) throws CoreException { |
| 534 |
IVirtualComponent vc = ComponentCore.createComponent(getProject()); |
| 535 |
if (vc == null) return; |
| 536 |
|
| 537 |
IVirtualReference[] refComponents = vc.getReferences(); |
| 538 |
for (int i = 0; i < refComponents.length; i++) { |
| 539 |
final IVirtualReference reference = refComponents[i]; |
| 540 |
if (reference != null && reference.getDependencyType()==IVirtualReference.DEPENDENCY_TYPE_CONSUMES) { |
| 541 |
IVirtualComponent consumedComponent = reference.getReferencedComponent(); |
| 542 |
IProject project = consumedComponent.getProject(); |
| 543 |
if (consumedComponent!=null && isProjectOfType(project,IModuleConstants.JST_UTILITY_MODULE)) { |
| 544 |
if (consumedComponent != null && consumedComponent.getRootFolder()!=null) { |
| 545 |
VirtualTreeNode root = consumedComponent.getVirtualTreeRoot(); |
| 546 |
if (project.hasNature(JavaCore.NATURE_ID)) { |
| 547 |
final Map<IResource, IResource> map = getJavaOutputLocationMap(project); |
| 548 |
final List<Entry> replaced = new ArrayList<Entry>(); |
| 549 |
root = root.filter(new VirtualTreeNode.IEntryFilter() { |
| 550 |
public boolean accept(Entry entry) { |
| 551 |
IResource resource = entry.getResource(); |
| 552 |
if (resource != null) { |
| 553 |
resource = map.get(resource); |
| 554 |
if (resource != null) { |
| 555 |
replaced.add(new Entry(reference.getRuntimePath().append(entry.getRuntimePath()), resource)); |
| 556 |
return false; |
| 557 |
} |
| 558 |
} |
| 559 |
return true; |
| 560 |
} |
| 561 |
}); |
| 562 |
entries.add(new Entry(null, root)); |
| 563 |
entries.addAll(replaced); |
| 564 |
} else { |
| 565 |
entries.add(new Entry(null, root)); |
| 566 |
} |
| 567 |
} |
| 568 |
} |
| 569 |
} |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
/** |
| 476 |
* Determine if the component is nested J2EE module on the application.xml of this EAR |
574 |
* Determine if the component is nested J2EE module on the application.xml of this EAR |
| 477 |
* @param aComponent |
575 |
* @param aComponent |
| 478 |
* @return boolean is passed in component a nested J2EE module on this EAR |
576 |
* @return boolean is passed in component a nested J2EE module on this EAR |