001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.ui.tests.browsing;
011:
012: import java.io.File;
013:
014: import junit.framework.Test;
015: import junit.framework.TestCase;
016: import junit.framework.TestSuite;
017:
018: import org.eclipse.jdt.testplugin.JavaProjectHelper;
019: import org.eclipse.jdt.testplugin.JavaTestPlugin;
020:
021: import org.eclipse.core.resources.IResource;
022: import org.eclipse.core.resources.IWorkspace;
023: import org.eclipse.core.resources.IWorkspaceDescription;
024: import org.eclipse.core.resources.ResourcesPlugin;
025: import org.eclipse.core.runtime.Path;
026:
027: import org.eclipse.jface.viewers.IStructuredContentProvider;
028:
029: import org.eclipse.ui.IViewPart;
030: import org.eclipse.ui.IWorkbench;
031: import org.eclipse.ui.IWorkbenchPage;
032: import org.eclipse.ui.PlatformUI;
033:
034: import org.eclipse.jdt.core.ElementChangedEvent;
035: import org.eclipse.jdt.core.ICompilationUnit;
036: import org.eclipse.jdt.core.IElementChangedListener;
037: import org.eclipse.jdt.core.IJavaElement;
038: import org.eclipse.jdt.core.IJavaElementDelta;
039: import org.eclipse.jdt.core.IJavaProject;
040: import org.eclipse.jdt.core.IPackageFragment;
041: import org.eclipse.jdt.core.IPackageFragmentRoot;
042: import org.eclipse.jdt.core.JavaCore;
043:
044: import org.eclipse.jdt.internal.ui.browsing.LogicalPackage;
045:
046: public class PackagesViewContentProviderTests2 extends TestCase {
047:
048: public static Test suite() {
049: TestSuite suite = new TestSuite(
050: "org.eclipse.jdt.ui.tests.PackagesViewContentProviderTests2"); //$NON-NLS-1$
051: //$JUnit-BEGIN$
052: suite.addTestSuite(PackagesViewContentProviderTests2.class);
053: //$JUnit-END$
054: return suite;
055: }
056:
057: private IJavaProject fJProject1;
058: private IJavaProject fJProject2;
059:
060: private IPackageFragmentRoot fRoot1;
061: private IWorkspace fWorkspace;
062: private IWorkbench fWorkbench;
063: private MockPluginView fMyPart;
064:
065: private IStructuredContentProvider fProvider;
066: private IPackageFragmentRoot fArchiveFragmentRoot;
067: private IPackageFragment fPackJunit;
068: private IPackageFragment fPackJunitSamples;
069: private IPackageFragment fPackJunitSamplesMoney;
070:
071: private IWorkbenchPage fPage;
072: private IPackageFragmentRoot fRoot2;
073: private IPackageFragment fPack12;
074: private IPackageFragment fPack32;
075: private IPackageFragment fPack42;
076: private IPackageFragment fPack52;
077: private IPackageFragment fPack62;
078: private IPackageFragment fPack21;
079: private IPackageFragment fPack61;
080: private IPackageFragment fPack51;
081: private IPackageFragment fPack41;
082: private IPackageFragment fPack31;
083: private IPackageFragment fPackDefault1;
084: private IPackageFragment fPackDefault2;
085: private IPackageFragment fPack17;
086: private IPackageFragment fPack81;
087: private IPackageFragment fPack91;
088: private IPackageFragmentRoot fInternalJarRoot;
089: private IPackageFragment fInternalPackDefault;
090: private IPackageFragment fInternalPack3;
091: private IPackageFragment fInternalPack4;
092: private IPackageFragment fInternalPack5;
093: private IPackageFragment fInternalPack10;
094: private IPackageFragment fInternalPack6;
095: private boolean fEnableAutoBuildAfterTesting;
096: private IPackageFragment fPack102;
097:
098: public PackagesViewContentProviderTests2(String name) {
099: super (name);
100: }
101:
102: //----------- getElement in flat view ------------------------------
103:
104: public void testGetElementsPackageFragmentRoot() throws Exception {
105: Object[] children = fProvider.getElements(fRoot1);
106: Object[] expectedChildren = new Object[] { fPack21, fPack31,
107: fPack41, fPack51, fPack61, fPack81, fPack91,
108: fPackDefault1 };
109: assertTrue(
110: "Wrong children found for PackageFragment", compareArrays(children, expectedChildren)); //$NON-NLS-1$
111: }
112:
113: public void testGetElementsProject() throws Exception {
114:
115: LogicalPackage cp3 = new LogicalPackage(fPack31);
116: cp3.add(fPack32);
117: cp3.add(fInternalPack3);
118:
119: LogicalPackage defaultCp = new LogicalPackage(fPackDefault1);
120: defaultCp.add(fPackDefault2);
121: defaultCp.add(fInternalPackDefault);
122:
123: LogicalPackage cp4 = new LogicalPackage(fPack41);
124: cp4.add(fPack42);
125: cp4.add(fInternalPack4);
126:
127: LogicalPackage cp5 = new LogicalPackage(fPack51);
128: cp5.add(fPack52);
129: cp5.add(fInternalPack5);
130:
131: LogicalPackage cp6 = new LogicalPackage(fPack61);
132: cp6.add(fPack62);
133: cp6.add(fInternalPack6);
134:
135: LogicalPackage cp10 = new LogicalPackage(fPack102);
136: cp10.add(fInternalPack10);
137:
138: Object[] children = fProvider.getElements(fJProject2);
139: Object[] expectedChildren = new Object[] { defaultCp, cp3, cp4,
140: cp5, cp6, cp10, fPack21, fPack12, fPack91, fPack81,
141: fPack17 };
142: assertTrue(
143: "Wrong children founf for PackageFragment", compareArrays(children, expectedChildren)); //$NON-NLS-1$
144: }
145:
146: //---------------Delta Tests-----------------------------
147: public void testRemovePackageNotLogicalPackage() throws Exception {
148: //initialise Map
149: fProvider.getElements(fJProject2);
150:
151: fMyPart.clear();
152:
153: IElementChangedListener listener = (IElementChangedListener) fProvider;
154: IJavaElementDelta delta = new TestDelta(
155: IJavaElementDelta.REMOVED, fPack12);
156: listener.elementChanged(new ElementChangedEvent(delta,
157: ElementChangedEvent.POST_CHANGE));
158:
159: //force events from display
160: fMyPart.pushDisplay();
161:
162: assertTrue("Remove happened", fMyPart.hasRemoveHappened()); //$NON-NLS-1$
163: assertTrue(
164: "Correct package removed", fMyPart.getRemovedObject().contains(fPack12)); //$NON-NLS-1$
165: }
166:
167: public void testRemovePackageInTwoPackageLogicalPackage()
168: throws Exception {
169:
170: //initialise map
171: fProvider.getElements(fJProject2);
172:
173: //create CompoundElement containning
174: LogicalPackage cp10 = new LogicalPackage(fInternalPack10);
175:
176: fMyPart.clear();
177:
178: //send a delta indicating fragment deleted
179: IElementChangedListener listener = (IElementChangedListener) fProvider;
180: IJavaElementDelta delta = new TestDelta(
181: IJavaElementDelta.REMOVED, fPack102);
182: listener.elementChanged(new ElementChangedEvent(delta,
183: ElementChangedEvent.POST_CHANGE));
184:
185: //force events from display
186: fMyPart.pushDisplay();
187:
188: //assert remove happened (delta worked)
189: assertTrue(
190: "Refresh happened", fMyPart.hasRemoveHappened() && fMyPart.hasAddHappened()); //$NON-NLS-1$
191: Object addedObject = fMyPart.getAddedObject().get(0);
192: Object removedObject = fMyPart.getRemovedObject().get(0);
193: assertTrue(
194: "Correct guy removed", canFindEqualCompoundElement(cp10, new Object[] { removedObject })); //$NON-NLS-1$
195: assertTrue(
196: "Correct guy added", fInternalPack10.equals(addedObject)); //$NON-NLS-1$
197: }
198:
199: public void testRemovePackageFromLogicalPackage() throws Exception {
200:
201: //initialise map
202: fProvider.getElements(fJProject2);
203:
204: fMyPart.clear();
205:
206: //send a delta indicating fragment deleted
207: IElementChangedListener listener = (IElementChangedListener) fProvider;
208: IJavaElementDelta delta = new TestDelta(
209: IJavaElementDelta.REMOVED, fPack62);
210: listener.elementChanged(new ElementChangedEvent(delta,
211: ElementChangedEvent.POST_CHANGE));
212:
213: //force events from display
214: fMyPart.pushDisplay();
215:
216: //assert remove happened (delta worked)
217: assertTrue(
218: "Refresh did not happened", !fMyPart.hasRefreshHappened()); //$NON-NLS-1$
219: }
220:
221: public void testRemoveCUFromPackageNotLogicalPackage()
222: throws Exception {
223:
224: //initialise Map
225: ICompilationUnit cu = fPack81.createCompilationUnit(
226: "Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
227:
228: //make sure parent is visible
229: fMyPart.fViewer.setInput(fJProject2);
230:
231: fMyPart.clear();
232:
233: IElementChangedListener listener = (IElementChangedListener) fProvider;
234: IJavaElementDelta delta = TestDelta.createCUDelta(
235: new ICompilationUnit[] { cu }, fPack81,
236: IJavaElementDelta.REMOVED);
237: listener.elementChanged(new ElementChangedEvent(delta,
238: ElementChangedEvent.POST_CHANGE));
239:
240: //force events from display
241: fMyPart.pushDisplay();
242:
243: assertPack81RefreshedOnce();
244: }
245:
246: private void assertPack81RefreshedOnce() {
247: assertTrue("Refresh happened", fMyPart.hasRefreshHappened()); //$NON-NLS-1$
248: if (!fMyPart.getRefreshedObject().contains(fPack81))
249: fail("fPack81 not refreshed:\n"
250: + fMyPart.getRefreshedObject());
251: if (fMyPart.getRefreshedObject().size() != 1)
252: fail("Too many refreshes ("
253: + fMyPart.getRefreshedObject().size() + "):\n"
254: + fMyPart.getRefreshedObject());
255: }
256:
257: public void testAddCUFromPackageNotLogicalPackage()
258: throws Exception {
259:
260: ICompilationUnit cu = fPack81.createCompilationUnit(
261: "Object.java", "", true, null); //$NON-NLS-1$//$NON-NLS-2$
262:
263: //initialise Map
264: fMyPart.fViewer.setInput(fJProject2);
265:
266: fMyPart.clear();
267:
268: IElementChangedListener listener = (IElementChangedListener) fProvider;
269: IJavaElementDelta delta = TestDelta.createCUDelta(
270: new ICompilationUnit[] { cu }, fPack81,
271: IJavaElementDelta.ADDED);
272: listener.elementChanged(new ElementChangedEvent(delta,
273: ElementChangedEvent.POST_CHANGE));
274:
275: //force events from display
276: fMyPart.pushDisplay();
277:
278: assertPack81RefreshedOnce();
279: }
280:
281: public void testAddFragmentToLogicalPackage() throws Exception {
282:
283: //create package fragment to be added
284: IPackageFragment pack101 = fRoot1.createPackageFragment(
285: "pack3.pack4.pack10", true, null);//$NON-NLS-1$
286:
287: //initialise map
288: fProvider.getElements(fJProject2);
289:
290: fMyPart.clear();
291:
292: //send delta
293: IElementChangedListener listener = (IElementChangedListener) fProvider;
294: IJavaElementDelta delta = new TestDelta(
295: IJavaElementDelta.ADDED, pack101);
296: listener.elementChanged(new ElementChangedEvent(delta,
297: ElementChangedEvent.POST_CHANGE));
298:
299: //force events from display
300: fMyPart.pushDisplay();
301:
302: //make sure no refresh happened
303: assertTrue(
304: "Refresh did not happened", !fMyPart.hasRefreshHappened()); //$NON-NLS-1$
305: }
306:
307: public void testAddPackageNotLogicalPackage() throws Exception {
308:
309: //initialise Map
310: fProvider.getElements(fJProject2);
311:
312: fMyPart.clear();
313:
314: IPackageFragment test = fRoot1.createPackageFragment(
315: "pack3.test", true, null); //$NON-NLS-1$
316: IElementChangedListener listener = (IElementChangedListener) fProvider;
317: IJavaElementDelta delta = new TestDelta(
318: IJavaElementDelta.ADDED, test);
319: listener.elementChanged(new ElementChangedEvent(delta,
320: ElementChangedEvent.POST_CHANGE));
321:
322: //force events from display
323: fMyPart.pushDisplay();
324:
325: assertTrue("Add happened", fMyPart.hasAddHappened()); //$NON-NLS-1$
326: assertTrue(
327: "Correct package added", fMyPart.getAddedObject().contains(test)); //$NON-NLS-1$
328: }
329:
330: public void testAddPackageToCreateLogicalPackage() throws Exception {
331: //initialise map
332: fProvider.getElements(fJProject2);
333:
334: //create new package
335: IPackageFragment pack11 = fRoot1.createPackageFragment(
336: "pack1", true, null);//$NON-NLS-1$
337:
338: //create a logical package for testing
339: LogicalPackage lp1 = new LogicalPackage(fPack12);
340: lp1.add(pack11);
341:
342: fMyPart.clear();
343:
344: //send a delta indicating fragment deleted
345: IElementChangedListener listener = (IElementChangedListener) fProvider;
346: IJavaElementDelta delta = new TestDelta(
347: IJavaElementDelta.ADDED, pack11);
348: listener.elementChanged(new ElementChangedEvent(delta,
349: ElementChangedEvent.POST_CHANGE));
350:
351: //force events from display
352: fMyPart.pushDisplay();
353:
354: //assert remove and add happened (delta worked)
355: assertTrue(
356: "Remove and add happened", fMyPart.hasRemoveHappened() && fMyPart.hasAddHappened()); //$NON-NLS-1$
357: Object addedObject = fMyPart.getAddedObject().get(0);
358: Object removedObject = fMyPart.getRemovedObject().get(0);
359: assertTrue("Correct guy removed", fPack12.equals(removedObject)); //$NON-NLS-1$
360: assertTrue("Correct guy added", lp1.equals(addedObject)); //$NON-NLS-1$
361: }
362:
363: /*
364: * @see TestCase#setUp()
365: */
366: protected void setUp() throws Exception {
367: super .setUp();
368:
369: fWorkspace = ResourcesPlugin.getWorkspace();
370: assertNotNull(fWorkspace);
371:
372: IWorkspaceDescription workspaceDesc = fWorkspace
373: .getDescription();
374: fEnableAutoBuildAfterTesting = workspaceDesc.isAutoBuilding();
375: if (fEnableAutoBuildAfterTesting)
376: JavaProjectHelper.setAutoBuilding(false);
377:
378: fJProject1 = JavaProjectHelper.createJavaProject(
379: "TestProject1", "bin");//$NON-NLS-1$//$NON-NLS-2$
380: fJProject2 = JavaProjectHelper.createJavaProject(
381: "TestProject2", "bin");//$NON-NLS-1$//$NON-NLS-2$
382:
383: assertNotNull("project1 null", fJProject1);//$NON-NLS-1$
384: assertNotNull("project2 null", fJProject2);//$NON-NLS-1$
385:
386: //------------set up project #1 : External Jar and zip file-------
387:
388: IPackageFragmentRoot jdk = JavaProjectHelper.addVariableRTJar(
389: fJProject1, "JRE_LIB_TEST", null, null);//$NON-NLS-1$
390: assertTrue("jdk not found", jdk != null);//$NON-NLS-1$
391:
392: //---Create zip file-------------------
393:
394: java.io.File junitSrcArchive = JavaTestPlugin.getDefault()
395: .getFileInPlugin(JavaProjectHelper.JUNIT_SRC_381);
396:
397: assertTrue(
398: "junit src not found", junitSrcArchive != null && junitSrcArchive.exists());//$NON-NLS-1$
399:
400: fArchiveFragmentRoot = JavaProjectHelper
401: .addSourceContainerWithImport(
402: fJProject1,
403: "src", junitSrcArchive, JavaProjectHelper.JUNIT_SRC_ENCODING);//$NON-NLS-1$
404:
405: fPackJunit = fArchiveFragmentRoot.getPackageFragment("junit");//$NON-NLS-1$
406: fPackJunitSamples = fArchiveFragmentRoot
407: .getPackageFragment("junit.samples");//$NON-NLS-1$
408: fPackJunitSamplesMoney = fArchiveFragmentRoot
409: .getPackageFragment("junit.samples.money");//$NON-NLS-1$
410:
411: assertNotNull("creating fPackJunit", fPackJunit);//$NON-NLS-1$
412: assertNotNull("creating fPackJunitSamples", fPackJunitSamples);//$NON-NLS-1$
413: assertNotNull(
414: "creating fPackJunitSamplesMoney", fPackJunitSamplesMoney);//$NON-NLS-1$
415:
416: fPackJunitSamplesMoney.getCompilationUnit("IMoney.java");//$NON-NLS-1$
417: fPackJunitSamplesMoney.getCompilationUnit("Money.java");//$NON-NLS-1$
418: fPackJunitSamplesMoney.getCompilationUnit("MoneyBag.java");//$NON-NLS-1$
419: fPackJunitSamplesMoney.getCompilationUnit("MoneyTest.java");//$NON-NLS-1$
420:
421: //java.io.File mylibJar= JavaTestPlugin.getDefault().getFileInPlugin(JavaProjectHelper.MYLIB);
422: //assertTrue("lib not found", mylibJar != null && mylibJar.exists());//$NON-NLS-1$
423: //JavaProjectHelper.addLibraryWithImport(fJProject1, new Path(mylibJar.getPath()), null, null);
424:
425: //----------------Set up internal jar----------------------------
426: File myInternalJar = JavaTestPlugin.getDefault()
427: .getFileInPlugin(
428: new Path("testresources/compoundtest.jar"));//$NON-NLS-1$
429: assertTrue(
430: "lib not found", myInternalJar != null && myInternalJar.exists());//$NON-NLS-1$
431:
432: fInternalJarRoot = JavaProjectHelper.addLibraryWithImport(
433: fJProject2, Path.fromOSString(myInternalJar.getPath()),
434: null, null); //$NON-NLS-1$
435:
436: fInternalPackDefault = fInternalJarRoot.getPackageFragment("");//$NON-NLS-1$
437: fInternalPack3 = fInternalJarRoot.getPackageFragment("pack3");//$NON-NLS-1$
438: fInternalPack4 = fInternalJarRoot
439: .getPackageFragment("pack3.pack4");//$NON-NLS-1$
440: fInternalPack5 = fInternalJarRoot
441: .getPackageFragment("pack3.pack5");//$NON-NLS-1$
442: fInternalPack6 = fInternalJarRoot
443: .getPackageFragment("pack3.pack5.pack6");//$NON-NLS-1$
444: fInternalPack10 = fInternalJarRoot
445: .getPackageFragment("pack3.pack4.pack10");//$NON-NLS-1$
446:
447: //-----------------Set up source folder--------------------------
448:
449: fRoot2 = JavaProjectHelper.addSourceContainer(fJProject2,
450: "src2");//$NON-NLS-1$
451: fPackDefault2 = fRoot2.createPackageFragment("", true, null);//$NON-NLS-1$
452: fPack12 = fRoot2.createPackageFragment("pack1", true, null);//$NON-NLS-1$
453: fPack17 = fRoot2.createPackageFragment(
454: "pack1.pack7", true, null);//$NON-NLS-1$
455: fPack32 = fRoot2.createPackageFragment("pack3", true, null);//$NON-NLS-1$
456: fPack42 = fRoot2.createPackageFragment(
457: "pack3.pack4", true, null);//$NON-NLS-1$
458: fPack52 = fRoot2.createPackageFragment(
459: "pack3.pack5", true, null);//$NON-NLS-1$
460: fPack62 = fRoot2.createPackageFragment(
461: "pack3.pack5.pack6", true, null);//$NON-NLS-1$
462: fPack102 = fRoot2.createPackageFragment(
463: "pack3.pack4.pack10", true, null);//$NON-NLS-1$
464:
465: fPack12.createCompilationUnit("Object.java", "", true, null);//$NON-NLS-1$//$NON-NLS-2$
466: fPack62.createCompilationUnit("Object.java", "", true, null);//$NON-NLS-1$//$NON-NLS-2$
467:
468: //set up project #2: file system structure with in a source folder
469:
470: // JavaProjectHelper.addVariableEntry(fJProject2, new Path("JRE_LIB_TEST"), null, null);
471:
472: //----------------Set up source folder--------------------------
473:
474: fRoot1 = JavaProjectHelper.addSourceContainer(fJProject2,
475: "src1"); //$NON-NLS-1$
476: fPackDefault1 = fRoot1.createPackageFragment("", true, null); //$NON-NLS-1$
477: fPack21 = fRoot1.createPackageFragment("pack2", true, null);//$NON-NLS-1$
478: fPack31 = fRoot1.createPackageFragment("pack3", true, null);//$NON-NLS-1$
479: fPack41 = fRoot1.createPackageFragment(
480: "pack3.pack4", true, null);//$NON-NLS-1$
481: fPack91 = fRoot1.createPackageFragment(
482: "pack3.pack4.pack9", true, null);//$NON-NLS-1$
483: fPack51 = fRoot1.createPackageFragment(
484: "pack3.pack5", true, null);//$NON-NLS-1$
485: fPack61 = fRoot1.createPackageFragment(
486: "pack3.pack5.pack6", true, null);//$NON-NLS-1$
487: fPack81 = fRoot1.createPackageFragment(
488: "pack3.pack8", true, null);//$NON-NLS-1$
489:
490: fPack21.createCompilationUnit("Object.java", "", true, null);//$NON-NLS-1$//$NON-NLS-2$
491: fPack61.createCompilationUnit("Object.java", "", true, null);//$NON-NLS-1$//$NON-NLS-2$
492:
493: //set up the mock view
494: setUpMockView();
495: }
496:
497: public void setUpMockView() throws Exception {
498:
499: fWorkbench = PlatformUI.getWorkbench();
500: assertNotNull(fWorkbench);
501:
502: fPage = fWorkbench.getActiveWorkbenchWindow().getActivePage();
503: assertNotNull(fPage);
504:
505: MockPluginView.setListState(true);
506: IViewPart myPart = fPage
507: .showView("org.eclipse.jdt.ui.tests.browsing.MockPluginView");//$NON-NLS-1$
508: if (myPart instanceof MockPluginView) {
509: fMyPart = (MockPluginView) myPart;
510:
511: fProvider = (IStructuredContentProvider) fMyPart
512: .getTreeViewer().getContentProvider();
513: //create map and set listener
514: fProvider.inputChanged(null, null, fJProject2);
515: JavaCore
516: .removeElementChangedListener((IElementChangedListener) fProvider);
517: } else {
518: assertTrue("Unable to get view", false);//$NON-NLS-1$
519: }
520:
521: assertNotNull(fProvider);
522: }
523:
524: /*
525: * @see TestCase#tearDown()
526: */
527: protected void tearDown() throws Exception {
528:
529: JavaProjectHelper.delete(fJProject1);
530: JavaProjectHelper.delete(fJProject2);
531: fProvider.inputChanged(null, null, null);
532: fPage.hideView(fMyPart);
533:
534: if (fEnableAutoBuildAfterTesting)
535: JavaProjectHelper.setAutoBuilding(true);
536:
537: super .tearDown();
538: }
539:
540: private boolean compareArrays(Object[] children,
541: Object[] expectedChildren) {
542: if (children.length != expectedChildren.length)
543: return false;
544: for (int i = 0; i < children.length; i++) {
545: Object child = children[i];
546: if (child instanceof IJavaElement) {
547: IJavaElement el = (IJavaElement) child;
548: if (!contains(el, expectedChildren))
549: return false;
550: } else if (child instanceof IResource) {
551: IResource res = (IResource) child;
552: if (!contains(res, expectedChildren)) {
553: return false;
554: }
555: } else if (child instanceof LogicalPackage) {
556: if (!canFindEqualCompoundElement(
557: (LogicalPackage) child, expectedChildren))
558: return false;
559: }
560: }
561: return true;
562: }
563:
564: private boolean canFindEqualCompoundElement(
565: LogicalPackage compoundElement, Object[] expectedChildren) {
566: for (int i = 0; i < expectedChildren.length; i++) {
567: Object object = expectedChildren[i];
568: if (object instanceof LogicalPackage) {
569: LogicalPackage el = (LogicalPackage) object;
570: if (el.getElementName().equals(
571: compoundElement.getElementName())
572: && (el.getJavaProject().equals(compoundElement
573: .getJavaProject()))) {
574: if (compareArrays(el.getFragments(),
575: compoundElement.getFragments()))
576: return true;
577: }
578: }
579: }
580: return false;
581: }
582:
583: private boolean contains(IResource res, Object[] expectedChildren) {
584: for (int i = 0; i < expectedChildren.length; i++) {
585: Object object = expectedChildren[i];
586: if (object instanceof IResource) {
587: IResource expres = (IResource) object;
588: if (expres.equals(res))
589: return true;
590: }
591: }
592: return false;
593: }
594:
595: private boolean contains(IJavaElement fragment,
596: Object[] expectedChildren) {
597: for (int i = 0; i < expectedChildren.length; i++) {
598: Object object = expectedChildren[i];
599: if (object instanceof IJavaElement) {
600: IJavaElement expfrag = (IJavaElement) object;
601: if (expfrag.equals(fragment))
602: return true;
603: }
604: }
605: return false;
606: }
607: }
|