|
Lines 16-21
Link Here
|
| 16 |
import java.util.List; |
16 |
import java.util.List; |
| 17 |
import java.util.Map; |
17 |
import java.util.Map; |
| 18 |
import java.util.Properties; |
18 |
import java.util.Properties; |
|
|
19 |
import java.util.Set; |
| 19 |
|
20 |
|
| 20 |
import org.eclipse.core.resources.IProject; |
21 |
import org.eclipse.core.resources.IProject; |
| 21 |
import org.eclipse.core.runtime.CoreException; |
22 |
import org.eclipse.core.runtime.CoreException; |
|
Lines 24-41
Link Here
|
| 24 |
import org.eclipse.core.runtime.IStatus; |
25 |
import org.eclipse.core.runtime.IStatus; |
| 25 |
import org.eclipse.core.runtime.Path; |
26 |
import org.eclipse.core.runtime.Path; |
| 26 |
import org.eclipse.core.runtime.Platform; |
27 |
import org.eclipse.core.runtime.Platform; |
|
|
28 |
import org.eclipse.emf.common.util.URI; |
| 27 |
import org.eclipse.wst.common.componentcore.ComponentCore; |
29 |
import org.eclipse.wst.common.componentcore.ComponentCore; |
| 28 |
import org.eclipse.wst.common.componentcore.ModuleCoreNature; |
30 |
import org.eclipse.wst.common.componentcore.ModuleCoreNature; |
| 29 |
import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; |
31 |
import org.eclipse.wst.common.componentcore.internal.ComponentcoreFactory; |
| 30 |
import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; |
32 |
import org.eclipse.wst.common.componentcore.internal.ComponentcorePackage; |
| 31 |
import org.eclipse.wst.common.componentcore.internal.DependencyType; |
|
|
| 32 |
import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin; |
33 |
import org.eclipse.wst.common.componentcore.internal.ModulecorePlugin; |
| 33 |
import org.eclipse.wst.common.componentcore.internal.Property; |
34 |
import org.eclipse.wst.common.componentcore.internal.Property; |
| 34 |
import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; |
35 |
import org.eclipse.wst.common.componentcore.internal.ReferencedComponent; |
| 35 |
import org.eclipse.wst.common.componentcore.internal.StructureEdit; |
36 |
import org.eclipse.wst.common.componentcore.internal.StructureEdit; |
| 36 |
import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; |
37 |
import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; |
| 37 |
import org.eclipse.wst.common.componentcore.internal.builder.DependencyGraphManager; |
38 |
import org.eclipse.wst.common.componentcore.internal.builder.IDependencyGraph; |
| 38 |
import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil; |
39 |
import org.eclipse.wst.common.componentcore.resolvers.IReferenceResolver; |
|
|
40 |
import org.eclipse.wst.common.componentcore.resolvers.ReferenceResolverUtil; |
| 39 |
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; |
41 |
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; |
| 40 |
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; |
42 |
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; |
| 41 |
import org.eclipse.wst.common.componentcore.resources.IVirtualReference; |
43 |
import org.eclipse.wst.common.componentcore.resources.IVirtualReference; |
|
Lines 286-294
Link Here
|
| 286 |
if (referencedComponent==null) |
288 |
if (referencedComponent==null) |
| 287 |
continue; |
289 |
continue; |
| 288 |
IVirtualReference vReference = StructureEdit.createVirtualReference(this, referencedComponent); |
290 |
IVirtualReference vReference = StructureEdit.createVirtualReference(this, referencedComponent); |
| 289 |
if( vReference != null ){ |
|
|
| 290 |
vReference.setArchiveName( referencedComponent.getArchiveName() ); |
| 291 |
} |
| 292 |
if (vReference != null && vReference.getReferencedComponent() != null && vReference.getReferencedComponent().exists()) |
291 |
if (vReference != null && vReference.getReferencedComponent() != null && vReference.getReferencedComponent().exists()) |
| 293 |
references.add(vReference); |
292 |
references.add(vReference); |
| 294 |
} |
293 |
} |
|
Lines 312-332
Link Here
|
| 312 |
WorkbenchComponent component = core.getComponent(); |
311 |
WorkbenchComponent component = core.getComponent(); |
| 313 |
ReferencedComponent referencedComponent = null; |
312 |
ReferencedComponent referencedComponent = null; |
| 314 |
ComponentcoreFactory factory = ComponentcorePackage.eINSTANCE.getComponentcoreFactory(); |
313 |
ComponentcoreFactory factory = ComponentcorePackage.eINSTANCE.getComponentcoreFactory(); |
|
|
314 |
IReferenceResolver resolver = null; |
| 315 |
for (int i=0; i<references.length; i++) { |
315 |
for (int i=0; i<references.length; i++) { |
| 316 |
if (references[i] == null) |
316 |
if (references[i] == null) |
| 317 |
continue; |
317 |
continue; |
| 318 |
referencedComponent = factory.createReferencedComponent(); |
318 |
resolver = ReferenceResolverUtil.getDefault().getResolver(references[i]); |
| 319 |
referencedComponent.setDependencyType(DependencyType.get(references[i].getDependencyType())); |
319 |
referencedComponent = resolver.resolve(references[i]); |
| 320 |
referencedComponent.setRuntimePath(references[i].getRuntimePath()); |
|
|
| 321 |
|
| 322 |
IVirtualComponent comp = references[i].getReferencedComponent(); |
| 323 |
if(comp!=null && !comp.isBinary()) |
| 324 |
referencedComponent.setHandle(ModuleURIUtil.fullyQualifyURI(comp.getProject())); |
| 325 |
else if (comp!=null) |
| 326 |
referencedComponent.setHandle(ModuleURIUtil.archiveComponentfullyQualifyURI(comp.getName())); |
| 327 |
if (component != null) |
320 |
if (component != null) |
| 328 |
component.getReferencedComponents().add(referencedComponent); |
321 |
component.getReferencedComponents().add(referencedComponent); |
| 329 |
referencedComponent.setArchiveName(references[i].getArchiveName()); |
|
|
| 330 |
} |
322 |
} |
| 331 |
//clean up any old obsolete references |
323 |
//clean up any old obsolete references |
| 332 |
if (component != null){ |
324 |
if (component != null){ |
|
Lines 362-380
Link Here
|
| 362 |
|
354 |
|
| 363 |
component.getReferencedComponents().clear(); |
355 |
component.getReferencedComponents().clear(); |
| 364 |
ComponentcoreFactory factory = ComponentcorePackage.eINSTANCE.getComponentcoreFactory(); |
356 |
ComponentcoreFactory factory = ComponentcorePackage.eINSTANCE.getComponentcoreFactory(); |
|
|
357 |
IReferenceResolver resolver = null; |
| 365 |
for (int i=0; i<references.length; i++) { |
358 |
for (int i=0; i<references.length; i++) { |
| 366 |
referencedComponent = factory.createReferencedComponent(); |
359 |
resolver = ReferenceResolverUtil.getDefault().getResolver(references[i]); |
| 367 |
referencedComponent.setDependencyType(DependencyType.get(references[i].getDependencyType())); |
360 |
referencedComponent = resolver.resolve(references[i]); |
| 368 |
referencedComponent.setRuntimePath(references[i].getRuntimePath()); |
361 |
if( referencedComponent != null) |
| 369 |
|
362 |
component.getReferencedComponents().add(referencedComponent); |
| 370 |
IVirtualComponent comp = references[i].getReferencedComponent(); |
|
|
| 371 |
if( !comp.isBinary()) |
| 372 |
referencedComponent.setHandle(ModuleURIUtil.fullyQualifyURI(references[i].getReferencedComponent().getProject())); |
| 373 |
else |
| 374 |
referencedComponent.setHandle(ModuleURIUtil.archiveComponentfullyQualifyURI(references[i].getReferencedComponent().getName())); |
| 375 |
|
| 376 |
referencedComponent.setArchiveName(references[i].getArchiveName()); |
| 377 |
component.getReferencedComponents().add(referencedComponent); |
| 378 |
} |
363 |
} |
| 379 |
|
364 |
|
| 380 |
} finally { |
365 |
} finally { |
|
Lines 434-443
Link Here
|
| 434 |
* @return array of components |
419 |
* @return array of components |
| 435 |
*/ |
420 |
*/ |
| 436 |
public IVirtualComponent[] getReferencingComponents() { |
421 |
public IVirtualComponent[] getReferencingComponents() { |
| 437 |
IProject[] handles = DependencyGraphManager.getInstance().getDependencyGraph().getReferencingComponents(getProject()); |
422 |
Set<IProject> projects = IDependencyGraph.INSTANCE.getReferencingComponents(getProject()); |
| 438 |
IVirtualComponent[] result = new IVirtualComponent[handles.length]; |
423 |
IVirtualComponent[] result = new IVirtualComponent[projects.size()]; |
| 439 |
for (int i=0; i<handles.length; i++) |
424 |
Iterator<IProject> i = projects.iterator(); |
| 440 |
result[i] = ComponentCore.createComponent(handles[i]); |
425 |
for (int j=0; j<projects.size(); j++) |
|
|
426 |
result[j] = ComponentCore.createComponent(i.next()); |
| 441 |
return result; |
427 |
return result; |
| 442 |
} |
428 |
} |
| 443 |
|
429 |
|
|
Lines 477-492
Link Here
|
| 477 |
if (aReference == null || aReference.getReferencedComponent() == null || component == null) |
463 |
if (aReference == null || aReference.getReferencedComponent() == null || component == null) |
| 478 |
return null; |
464 |
return null; |
| 479 |
List referencedComponents = component.getReferencedComponents(); |
465 |
List referencedComponents = component.getReferencedComponents(); |
|
|
466 |
URI uri = ReferenceResolverUtil.getDefault().getResolver(aReference).resolve(aReference).getHandle(); |
| 480 |
for (int i=0; i<referencedComponents.size(); i++) { |
467 |
for (int i=0; i<referencedComponents.size(); i++) { |
| 481 |
ReferencedComponent ref = (ReferencedComponent) referencedComponents.get(i); |
468 |
ReferencedComponent ref = (ReferencedComponent) referencedComponents.get(i); |
| 482 |
if (!aReference.getReferencedComponent().isBinary()) { |
469 |
if( ref.getHandle().equals(uri)) |
| 483 |
if (ref.getHandle().equals(ModuleURIUtil.fullyQualifyURI(aReference.getReferencedComponent().getProject()))) |
470 |
return ref; |
| 484 |
return ref; |
|
|
| 485 |
} |
| 486 |
else { |
| 487 |
if (ref.getHandle().equals(ModuleURIUtil.archiveComponentfullyQualifyURI(aReference.getReferencedComponent().getName()))) |
| 488 |
return ref; |
| 489 |
} |
| 490 |
} |
471 |
} |
| 491 |
return null; |
472 |
return null; |
| 492 |
} |
473 |
} |