Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: f967f76065d2d194de70d4c529f7eab86535e487 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
/***************************************************************************************************
 * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
 * accompanying materials are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: IBM Corporation - initial API and implementation
 **************************************************************************************************/
package org.eclipse.jst.j2ee.internal.earcreation;


import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.common.util.WrappedException;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.jst.j2ee.application.Application;
import org.eclipse.jst.j2ee.application.ApplicationResource;
import org.eclipse.jst.j2ee.application.Module;
import org.eclipse.jst.j2ee.internal.J2EEConstants;
import org.eclipse.jst.j2ee.internal.application.ApplicationPackage;
import org.eclipse.jst.j2ee.internal.common.XMLResource;
import org.eclipse.jst.j2ee.internal.earcreation.modulemap.EARProjectMap;
import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModuleMapping;
import org.eclipse.jst.j2ee.internal.earcreation.modulemap.ModulemapPackage;
import org.eclipse.jst.j2ee.internal.earcreation.modulemap.UtilityJARMapping;
import org.eclipse.jst.j2ee.internal.moduleextension.EarModuleManager;
import org.eclipse.wst.common.frameworks.internal.SaveFailedException;
import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext;
import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelEvent;

/**
 * 
 * @deprecated
 * Use
 * <p>
 * 	EARArtifactEdit
 * </p>
 *
 */
public class EAREditModel extends org.eclipse.jst.j2ee.internal.J2EEEditModel {
	private boolean stopListenerNotifications = false;
	//TODO this is a hack until the DOM adaptors are working
	public static final String MODULE_MAP_URI = "META-INF/.modulemaps"; //$NON-NLS-1$
	public static final URI MODULE_MAP_URI_OBJ = URI.createURI(MODULE_MAP_URI);

	/**
	 * EJBSaveModel constructor comment.
	 * 
	 * @param Object
	 *            editModelID - An editModelID to identify the EditModel
	 */
	public EAREditModel(String editModelID, EMFWorkbenchContext context, boolean readOnly) {
		super(editModelID, context, readOnly);
	}// EAREditModel

	/**
	 * EJBSaveModel constructor comment.
	 * 
	 * @param Object
	 *            editModelID - An editModelID to identify the EditModel
	 */
	public EAREditModel(String editModelID, EMFWorkbenchContext context, boolean readOnly, boolean accessUnkownResourcesAsReadOnly) {
		super(editModelID, context, readOnly, accessUnkownResourcesAsReadOnly);
	}// EAREditModel

	/**
	 * Adds the module mapping to a project.
	 * 
	 * @param Module
	 *            module - The module to add
	 * @param IProject
	 *            project - The current project.
	 * @return ModuleMapping
	 */
	public ModuleMapping addModuleMapping(Module module, IProject aProject) {

		ModuleMapping map = ((ModulemapPackage) EPackage.Registry.INSTANCE.getEPackage(ModulemapPackage.eNS_URI)).getModulemapFactory().createModuleMapping();
		map.setModule(module);
		map.setProjectName(aProject.getName());
		getEARProjectMap().getMappings().add(map);

		return map;
	}// ModuleMapping

	/**
	 * Adds a utility jar mapping to a project.
	 * 
	 * @param String
	 *            uri - Utility jar uri.
	 * @param IProject
	 *            project - The current project.
	 * @return UtilityJARMapping
	 */
	public UtilityJARMapping addUtilityJARMapping(String uri, IProject aProject) {

		UtilityJARMapping map = ((ModulemapPackage) EPackage.Registry.INSTANCE.getEPackage(ModulemapPackage.eNS_URI)).getModulemapFactory().createUtilityJARMapping();
		map.setUri(uri);
		map.setProjectName(aProject.getName());
		getEARProjectMap().getUtilityJARMappings().add(map);

		return map;
	}// addUtilityJARMapping

	/**
	 * Return the root object, application, from the application.xml DD.
	 * 
	 * @return Application
	 */
	public Application getApplication() {
		ApplicationResource dd = getApplicationXmiResource();
		return dd == null ? null : dd.getApplication();
	}

	/**
	 * Gets the application resource.
	 * 
	 * @return ApplicationResource
	 */
	public ApplicationResource getApplicationXmiResource() {
		return (ApplicationResource) getResource(J2EEConstants.APPLICATION_DD_URI_OBJ);
	}// getApplicationXmiResource

	/**
	 * Answer all the projects referenced by the .modulemaps file
	 * 
	 * @return Set
	 */
	public Set getModuleMappedProjects() {
		Set aSet = getModuleMappedModuleProjects();
		aSet.addAll(getModuleMappedUtilityJarProjects());
		return aSet;
	}

	public Map getModuleMappedProjectsAsMap() {
		Map aMap = getModuleMappedModuleProjectsAsMap();
		aMap.putAll(getModuleMappedUtilityJarProjectsAsMap());
		return aMap;
	}


	public Set getModuleMappedUtilityJarProjects() {
		Set aSet = new HashSet();
		aSet.addAll(getModuleMappedUtilityJarProjectsAsMap().values());
		return aSet;
	}

	public Map getModuleMappedUtilityJarProjectsAsMap() {
		Map aMap = new HashMap();
		IProject aProject = null;
		List utilityJARMappings = getUtilityJARMappings();
		for (int i = 0; i < utilityJARMappings.size(); i++) {
			aProject = null;
			UtilityJARMapping map = (UtilityJARMapping) utilityJARMappings.get(i);
			if (map.getProjectName() != null && map.getProjectName().length() > 0)
				aProject = getProject(map.getProjectName());
			if (aProject != null && map.getUri() != null && map.getUri().length() > 0)
				aMap.put(map.getUri(), aProject);
		}
		return aMap;
	}

	public Set getModuleMappedModuleProjects() {
		Set aSet = new HashSet();
		aSet.addAll(getModuleMappedModuleProjectsAsMap().values());
		return aSet;
	}

	public Map getModuleMappedModuleProjectsAsMap() {
		Map aMap = new HashMap();
		List moduleMappings = getModuleMappings();
		IProject aProject = null;
		for (int i = 0; i < moduleMappings.size(); i++) {
			aProject = null;
			ModuleMapping map = (ModuleMapping) moduleMappings.get(i);
			if (map.getProjectName() != null && map.getProjectName().length() > 0)
				aProject = getProject(map.getProjectName());
			Module module = map.getModule();
			if (aProject != null && module != null && module.getUri() != null && module.getUri().length() > 0)
				aMap.put(module.getUri(), aProject);
		}
		return aMap;
	}


	/**
	 * Get a project
	 * 
	 * @param String
	 *            name - The project name.
	 * @return IProject
	 */
	protected IProject getProject(String name) {
		if (name == null || name.length() == 0)
			return null;
		return ResourcesPlugin.getWorkspace().getRoot().getProject(name);
	}

	protected IProject getProject(ModuleMapping mapping) {
		if (mapping != null && mapping.getProjectName() != null && mapping.getProjectName().length() > 0)
			return getProject(mapping.getProjectName());
		return null;
	}

	/**
	 * Finds an existing UtilityJARMapping for the project and uri, if one exists
	 *  
	 */
	public UtilityJARMapping getUtilityJARMapping(String uri, IProject aProject) {
		if (aProject == null || uri == null)
			return null;
		List maps = getUtilityJARMappings();
		for (int i = 0; i < maps.size(); i++) {
			UtilityJARMapping map = (UtilityJARMapping) maps.get(i);
			if (aProject.getName().equals(map.getProjectName()) && uri.equals(map.getUri()))
				return map;
		}
		return null;
	}

	/**
	 * Insert the method's description here. Creation date: (4/11/2001 4:14:26 PM)
	 * 
	 * @return EJBNatureRuntime
	 */
	public EARNatureRuntime getEARNature() {
		return EARNatureRuntime.getRuntime(getProject());
	}

	/**
	 * The root object which contains the list of mappings from application modules to workbench
	 * projects
	 */
	public EARProjectMap getEARProjectMap() {
		return getEARProjectMap(true);
	}

	/**
	 * The root object which contains the list of mappings from application modules to workbench
	 * projects
	 */
	protected EARProjectMap getEARProjectMap(boolean createIfEmpty) {
		Resource res = null;
		try {
			res = getOrCreateResource(MODULE_MAP_URI_OBJ);
		} catch (WrappedException e) {
			//Ignore
		}
		if (res == null)
			return null;
		if (res.getContents().isEmpty() && createIfEmpty) {
			boolean dirtyFlag = res.isModified();
			res.getContents().add(ModulemapPackage.eINSTANCE.getModulemapFactory().createEARProjectMap());
			res.setModified(dirtyFlag);
		}// if
		if (res.getContents().isEmpty())
			return null;
		return (EARProjectMap) res.getContents().get(0);
	}// getEARProjectMap

	/**
	 * Get the module mappings from module
	 * 
	 * @param Module
	 *            module - The current module.
	 * @return ModuleMapping
	 */
	public ModuleMapping getModuleMapping(Module module) {
		if (module == null)
			return null;
		List maps = getModuleMappings();
		for (int i = 0; i < maps.size(); i++) {
			ModuleMapping map = (ModuleMapping) maps.get(i);
			Module iModule = map.getModule();
			if (module.equals(iModule))
				return map;
		}// for
		return null;
	}// getModuleMapping

	/**
	 * Get the utility jar mapping from an uri
	 * 
	 * @param String
	 *            uri - The current uri
	 * @return UtilityJARMapping
	 */
	public UtilityJARMapping getUtilityJARMapping(String uri) {
		if (uri == null)
			return null;
		List maps = getUtilityJARMappings();
		for (int i = 0; i < maps.size(); i++) {
			UtilityJARMapping map = (UtilityJARMapping) maps.get(i);
			if (uri.equals(map.getUri()))
				return map;
		}// for
		return null;
	}// getUtilityJARMapping

	/**
	 * Return a Project for the given <code>uri</code>. This will return a Project for a utility
	 * JAR mapping or a module mapping. A project will be returned if the mapping has a project name
	 * even if the project does not exist or is not accessible.
	 * 
	 * @param uri
	 * @return
	 */
	public IProject getMappedProject(String uri) {
		UtilityJARMapping utilMapping = getUtilityJARMapping(uri);
		if (utilMapping != null) {
			return getProject(utilMapping.getProjectName());
		}
		List moduleMappings = getModuleMappings();
		for (int i = 0; i < moduleMappings.size(); i++) {
			ModuleMapping map = (ModuleMapping) moduleMappings.get(i);
			Module mod = map.getModule();
			if (mod != null && uri.equals(mod.getUri()))
				return getProject(map.getProjectName());
		}
		return null;
	}

	/**
	 * Get the module mapping based on a project.
	 * 
	 * @param IProject
	 *            project - The current project.
	 * @return ModuleMapping
	 */
	public ModuleMapping getModuleMapping(IProject aProject) {
		if (aProject == null)
			return null;
		List maps = getModuleMappings();
		for (int i = 0; i < maps.size(); i++) {
			ModuleMapping map = (ModuleMapping) maps.get(i);
			if (aProject.getName().equals(map.getProjectName()))
				return map;
		}// for
		return null;
	}// getModuleMapping

	/**
	 * Checks if the uri mapping already exists.
	 * 
	 * @param String
	 *            currentName - The current uri of the module.
	 * @return boolean
	 */
	public boolean uriExists(String currentName) {

		if (currentName != null) {
			return (this.moduleMappingExists(currentName) || this.utilJarMappingExists(currentName));
		} // if
		return false;
	} // uriExists

	/**
	 * Checks if the current uri conflicts with any of the existing module mappings.
	 * 
	 * @param String
	 *            currentUri - The uri to check to see if it exists.
	 * @return boolean
	 */
	public boolean moduleMappingExists(String currentUri) {
		if (currentUri == null)
			return false;
		List maps = getModuleMappings();
		if (maps != null || !maps.isEmpty()) {
			for (int i = 0; i < maps.size(); i++) {
				ModuleMapping map = (ModuleMapping) maps.get(i);
				if (currentUri.equals(map.getModule().getUri())) {
					return true;
				}
			}
		}
		return false;
	}

	/**
	 * Checks if the current uri conflicts with any of the existing utility jar mappings.
	 * 
	 * @param String
	 *            currentUri - The uri to check to see if it exists.
	 * @return boolean
	 */
	public boolean utilJarMappingExists(String currentUri) {
		if (currentUri == null)
			return false;
		List utilMaps = this.getUtilityJARMappings();
		if (utilMaps != null || !utilMaps.isEmpty()) {
			for (int i = 0; i < utilMaps.size(); i++) {
				UtilityJARMapping utilMap = (UtilityJARMapping) utilMaps.get(i);
				if (currentUri.equals(utilMap.getUri())) {
					return true;
				} // if
			} // for
		} // if
		return false;
	} // utilJarMappingExists

	/**
	 * Gets the utilityJARMapping bases on project.
	 * 
	 * @param IProject
	 *            project - The current project.
	 * @return UtilityJARMapping
	 */
	public UtilityJARMapping getUtilityJARMapping(IProject aProject) {
		if (aProject == null)
			return null;
		List maps = getUtilityJARMappings();
		for (int i = 0; i < maps.size(); i++) {
			UtilityJARMapping map = (UtilityJARMapping) maps.get(i);
			if (aProject.getName().equals(map.getProjectName()))
				return map;
		}// for
		return null;
	}// getUtilityJARMapping

	/**
	 * Get a collection of module mappings.
	 * 
	 * @return List
	 */
	public List getModuleMappings() {
		EARProjectMap map = getEARProjectMap();
		if (map == null)
			return java.util.Collections.EMPTY_LIST;
		return map.getMappings();
	}//getModuleMappings

	/**
	 * Get a collection of utility mappings.
	 * 
	 * @return List
	 */
	public List getUtilityJARMappings() {
		EARProjectMap map = getEARProjectMap();
		if (map == null)
			return java.util.Collections.EMPTY_LIST;
		return map.getUtilityJARMappings();
	}// getUtilityJARMappings

	/**
	 * The resource which contains the mappings from application modules to workbench projects
	 * 
	 * @return Resource
	 */
	protected Resource getModuleMapsXmiResource() {
		return getResource(MODULE_MAP_URI_OBJ);
	}// getModuleMapsXmiResource

	//	TODO Removed to make way for the generic getRootObject()
	//	/**
	//	 * Gets the root object.
	//	 *
	//	 * @return Application
	//	 * @deprecated Please use getApplication() for consistency
	//	 */
	//	public org.eclipse.jst.j2ee.internal.internal.application.Application getRootObject() {
	//		return getApplication();
	//	}// getRootObject


	/**
	 * discription goes here
	 * 
	 * @return Resource
	 */
	public Resource makeDeploymentDescriptorWithRoot() {
		XMLResource res = (XMLResource) makeEarXmiResource();
		Application app = ApplicationPackage.eINSTANCE.getApplicationFactory().createApplication();
		res.getContents().add(app);
		res.setID(app, J2EEConstants.APPL_ID);
		res.setJ2EEVersionID(getEARNature().getJ2EEVersion());
		app.setDisplayName(getProject().getName());
		return res;
	}// Resource

	/**
	 * discription goes here
	 * 
	 * @return Resource
	 */
	public Resource makeEarXmiResource() {
		return createResource(J2EEConstants.APPLICATION_DD_URI_OBJ);
	}// makeEarXmiResource

	/**
	 * The resource which contains the mappings from application modules to workbench projects
	 * 
	 * @return Resource
	 */
	protected Resource makeModuleMapsXmiResource() {

		if (isReadOnly())
			return null;

		Resource res = createResource(MODULE_MAP_URI_OBJ);
		EARProjectMap root = ModulemapPackage.eINSTANCE.getModulemapFactory().createEARProjectMap();
		res.getContents().add(root);
		res.setModified(false);
		return res;
	}// makeModuleMapsXmiResource

	/**
	 * makeRoot
	 * 
	 * @param Resource
	 *            deploymentDescriptor - The current deployment descriptor
	 */
	public Resource makeRoot(Resource deploymentDescriptor) {

		Application app = ((ApplicationPackage) EPackage.Registry.INSTANCE.getEPackage(ApplicationPackage.eNS_URI)).getApplicationFactory().createApplication();
		app.setDisplayName(getProject().getName());
		((XMIResource) app.eResource()).setID(app, J2EEConstants.APPL_ID);
		deploymentDescriptor.getContents().add(app);
		return deploymentDescriptor;
	}// makeRoot

	//HACK TO BE REMOVED
	protected void notifyListeners(EditModelEvent anEvent) {
		if (!stopListenerNotifications)
			super.notifyListeners(anEvent);
	}

	//HACK TO BE REMOVED
	public void resumeNotifications() {
		stopListenerNotifications = false;
	}

	//HACK TO BE REMOVED
	public void stopNotifications() {
		stopListenerNotifications = true;
	}

	/**
	 * primSave
	 * 
	 * @param IProgressMonitor
	 *            monitor - Current progress monitor.
	 * @see EditModel#primSave(IProgressMonitor)
	 */
	public void primSave(IProgressMonitor monitor) {
		removeInvalidModuleMaps(true);
		super.primSave(monitor);
		try {
			updateProjectReferences(monitor);
		} catch (CoreException ex) {
			throw new SaveFailedException(EARCreationResourceHandler.getString("PROJ_DESC_UPDATE_ERROR_UI_"), ex); //$NON-NLS-1$
		}// try
	} // primSave

	public void removeInvalidModuleMaps(boolean preserveModifiedFlag) {
		if (!this.isReadOnly()) {
			List moduleMaps = this.getExistingModuleMappings();
			if (!moduleMaps.isEmpty()) {
				Resource mmResource = getModuleMapsXmiResource();
				boolean isDirty = mmResource.isModified();
				try {
					Iterator mapIterator = moduleMaps.iterator();
					ModuleMapping mm = null;
					Module m = null;
					while (mapIterator.hasNext()) {
						mm = (ModuleMapping) mapIterator.next();
						m = mm.getModule();
						if (m == null || m.eIsProxy())
							mapIterator.remove();
					}
				} finally {
					if (preserveModifiedFlag)
						mmResource.setModified(isDirty);
				}
			}
		}
	}

	/**
	 * @return
	 */
	private List getExistingModuleMappings() {
		EARProjectMap map = getEARProjectMap(false);
		if (map == null)
			return java.util.Collections.EMPTY_LIST;
		return map.getMappings();
	}



	/**
	 * Updates the project references
	 * 
	 * @param IProgressMonitor
	 *            monitor - Current progress monitor.
	 */
	protected void updateProjectReferences(IProgressMonitor monitor) throws CoreException {
		IProjectDescription description = getProject().getDescription();
		Set newProjects = new HashSet();
		newProjects.addAll(getModuleMappedProjects());
		if (!hasProjectReferenceChanges(description, newProjects))
			return;
		IProject[] newArray = (IProject[]) newProjects.toArray(new IProject[newProjects.size()]);
		description.setReferencedProjects(newArray);
		int flags = IResource.FORCE | IResource.KEEP_HISTORY;
		getProject().setDescription(description, flags, monitor);
	}// updateProjectReferences

	/**
	 * Checks if there are reference changes.
	 * 
	 * @return boolean
	 */
	public boolean hasProjectReferenceChanges() {
		IProjectDescription description;
		try {
			description = getProject().getDescription();
		} catch (CoreException ex) {
			return false;
		}// try

		Set newProjects = new HashSet();
		newProjects.addAll(getModuleMappedProjects());
		return hasProjectReferenceChanges(description, newProjects);
	}// hasProjectReferenceChanges

	/**
	 * Checks if any of the project references have changed.
	 * 
	 * @param IProjectDescription
	 *            description - Current project discription.
	 * @param Set
	 *            newProjects - A set of new projects.
	 * @return boolean
	 */
	protected boolean hasProjectReferenceChanges(IProjectDescription description, Set newProjects) {
		IProject[] projects = description.getReferencedProjects();
		Set oldProjects = new HashSet();
		oldProjects.addAll(Arrays.asList(projects));
		return !oldProjects.equals(newProjects);
	}// hasProjectReferenceChanges

	/**
	 * Gets a list of non resource files.
	 * 
	 * @return List
	 * @see org.eclipse.wst.common.internal.emfworkbench.validateedit.ResourceStateInputProvider#getNonResourceFiles()
	 */
	public List getNonResourceFiles() {
		IFile aFile = getProject().getFile(ProjectUtilities.DOT_PROJECT);
		return Collections.singletonList(aFile);
	}// getNonResourceFiles

	/**
	 * Get the deployment descripto resource
	 * 
	 * @return XMLResource
	 */
	public XMLResource getDeploymentDescriptorResource() {
		return getApplicationXmiResource();
	}// getDeploymentDescriptorResource

	/**
	 * Answer whether there is either a module mapping or a utility JAR mapping to the project.
	 * 
	 * @param IProject
	 *            p - The current project.
	 * @return boolean
	 */
	public boolean hasMappingToProject(IProject p) {
		return getModuleMapping(p) != null || getUtilityJARMapping(p) != null;
	}//  hasMappingToProject

	/**
	 * Returns a project based on a util jar mapping.
	 * 
	 * @param UtilityJARMapping
	 *            utilJarMapping - The current utilJarMapping
	 * @return IProject
	 */
	public IProject getProjectFromUtilJarMapping(UtilityJARMapping utilJarMapping) {
		if (utilJarMapping != null) {
			String projectName = utilJarMapping.getProjectName();
			return getProject(projectName);
		} // if
		return null;
	} // getProjectFromUtilJarMapping

	public boolean isEjbClientJarMapping(UtilityJARMapping utilJarMapping) {
		IProject aProject = getProjectFromUtilJarMapping(utilJarMapping);
		if (aProject != null)
			return isEjbClientJarProject(aProject);
		return false;
	}

	/**
	 * @param project
	 * @return
	 */
	public boolean isEjbClientJarProject(IProject utilProject) {
		if (utilProject != null) {
			List mappings = getModuleMappings();
			ModuleMapping mapping;
			IProject ejbProject;
			for (int i = 0; i < mappings.size(); i++) {
				mapping = (ModuleMapping) mappings.get(i);
				if (mapping.getModule() != null && mapping.getModule().isEjbModule()) {
					ejbProject = getProject(mapping);
					if (utilProject.equals(EarModuleManager.getEJBModuleExtension().getDefinedEJBClientJARProject(ejbProject)))
						return true;
				}
			}
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jst.j2ee.internal.internal.workbench.J2EEEditModel#getRootObject()
	 */
	public Object getRootObject() {
		return getApplication();
	}

	public String getDevelopmentAcivityID() {
		return ENTERPRISE_JAVA;
	}
}

Back to the top