|
Lines 43-57
Link Here
|
| 43 |
protected void setUp() throws Exception { |
43 |
protected void setUp() throws Exception { |
| 44 |
applicationContext = E4Application.createDefaultContext(); |
44 |
applicationContext = E4Application.createDefaultContext(); |
| 45 |
|
45 |
|
| 46 |
IContributionFactory contributionFactory = (IContributionFactory) applicationContext |
|
|
| 47 |
.get(IContributionFactory.class.getName()); |
| 48 |
Object newEngine = contributionFactory.create(getEngineURI(), |
| 49 |
applicationContext); |
| 50 |
assertTrue(newEngine instanceof IPresentationEngine); |
| 51 |
applicationContext.set(IPresentationEngine.class.getName(), newEngine); |
| 52 |
|
| 53 |
engine = (IPresentationEngine) newEngine; |
| 54 |
|
| 55 |
super.setUp(); |
46 |
super.setUp(); |
| 56 |
} |
47 |
} |
| 57 |
|
48 |
|
|
Lines 67-77
Link Here
|
| 67 |
} |
58 |
} |
| 68 |
} |
59 |
} |
| 69 |
|
60 |
|
|
|
61 |
private IPresentationEngine getEngine() { |
| 62 |
if (engine == null) { |
| 63 |
IContributionFactory contributionFactory = (IContributionFactory) applicationContext |
| 64 |
.get(IContributionFactory.class.getName()); |
| 65 |
Object newEngine = contributionFactory.create(getEngineURI(), |
| 66 |
applicationContext); |
| 67 |
assertTrue(newEngine instanceof IPresentationEngine); |
| 68 |
applicationContext.set(IPresentationEngine.class.getName(), |
| 69 |
newEngine); |
| 70 |
|
| 71 |
engine = (IPresentationEngine) newEngine; |
| 72 |
} |
| 73 |
|
| 74 |
return engine; |
| 75 |
} |
| 76 |
|
| 70 |
public void testFindPart_PartInWindow() { |
77 |
public void testFindPart_PartInWindow() { |
| 71 |
MApplication application = createApplication("partId"); |
78 |
MApplication application = createApplication("partId"); |
| 72 |
|
79 |
|
| 73 |
MWindow window = application.getChildren().get(0); |
80 |
MWindow window = application.getChildren().get(0); |
| 74 |
engine.createGui(window); |
81 |
getEngine().createGui(window); |
| 75 |
|
82 |
|
| 76 |
EPartService partService = (EPartService) window.getContext().get( |
83 |
EPartService partService = (EPartService) window.getContext().get( |
| 77 |
EPartService.class.getName()); |
84 |
EPartService.class.getName()); |
|
Lines 89-95
Link Here
|
| 89 |
MApplication application = createApplication("partId"); |
96 |
MApplication application = createApplication("partId"); |
| 90 |
|
97 |
|
| 91 |
MWindow window = application.getChildren().get(0); |
98 |
MWindow window = application.getChildren().get(0); |
| 92 |
engine.createGui(window); |
99 |
getEngine().createGui(window); |
| 93 |
|
100 |
|
| 94 |
EPartService partService = (EPartService) window.getContext().get( |
101 |
EPartService partService = (EPartService) window.getContext().get( |
| 95 |
EPartService.class.getName()); |
102 |
EPartService.class.getName()); |
|
Lines 105-112
Link Here
|
| 105 |
MWindow window1 = application.getChildren().get(0); |
112 |
MWindow window1 = application.getChildren().get(0); |
| 106 |
MWindow window2 = application.getChildren().get(1); |
113 |
MWindow window2 = application.getChildren().get(1); |
| 107 |
|
114 |
|
| 108 |
engine.createGui(window1); |
115 |
getEngine().createGui(window1); |
| 109 |
engine.createGui(window2); |
116 |
getEngine().createGui(window2); |
| 110 |
|
117 |
|
| 111 |
EPartService partService = (EPartService) window1.getContext().get( |
118 |
EPartService partService = (EPartService) window1.getContext().get( |
| 112 |
EPartService.class.getName()); |
119 |
EPartService.class.getName()); |
|
Lines 137-143
Link Here
|
| 137 |
MPart partFront = partStack.getChildren().get(0); |
144 |
MPart partFront = partStack.getChildren().get(0); |
| 138 |
partStack.setActiveChild(partFront); |
145 |
partStack.setActiveChild(partFront); |
| 139 |
|
146 |
|
| 140 |
engine.createGui(window); |
147 |
getEngine().createGui(window); |
| 141 |
|
148 |
|
| 142 |
EPartService partService = (EPartService) window.getContext().get( |
149 |
EPartService partService = (EPartService) window.getContext().get( |
| 143 |
EPartService.class.getName()); |
150 |
EPartService.class.getName()); |
|
Lines 154-160
Link Here
|
| 154 |
MPart partFront = partStack.getChildren().get(0); |
161 |
MPart partFront = partStack.getChildren().get(0); |
| 155 |
partStack.setActiveChild(partFront); |
162 |
partStack.setActiveChild(partFront); |
| 156 |
|
163 |
|
| 157 |
engine.createGui(window); |
164 |
getEngine().createGui(window); |
| 158 |
|
165 |
|
| 159 |
EPartService partService = (EPartService) partFront.getContext().get( |
166 |
EPartService partService = (EPartService) partFront.getContext().get( |
| 160 |
EPartService.class.getName()); |
167 |
EPartService.class.getName()); |
|
Lines 172-178
Link Here
|
| 172 |
MPart partBack = partStack.getChildren().get(1); |
179 |
MPart partBack = partStack.getChildren().get(1); |
| 173 |
partStack.setActiveChild(partFront); |
180 |
partStack.setActiveChild(partFront); |
| 174 |
|
181 |
|
| 175 |
engine.createGui(window); |
182 |
getEngine().createGui(window); |
| 176 |
|
183 |
|
| 177 |
EPartService partService = (EPartService) window.getContext().get( |
184 |
EPartService partService = (EPartService) window.getContext().get( |
| 178 |
EPartService.class.getName()); |
185 |
EPartService.class.getName()); |
|
Lines 190-196
Link Here
|
| 190 |
MPart partBack = partStack.getChildren().get(1); |
197 |
MPart partBack = partStack.getChildren().get(1); |
| 191 |
partStack.setActiveChild(partFront); |
198 |
partStack.setActiveChild(partFront); |
| 192 |
|
199 |
|
| 193 |
engine.createGui(window); |
200 |
getEngine().createGui(window); |
| 194 |
|
201 |
|
| 195 |
EPartService partService = (EPartService) partFront.getContext().get( |
202 |
EPartService partService = (EPartService) partFront.getContext().get( |
| 196 |
EPartService.class.getName()); |
203 |
EPartService.class.getName()); |
|
Lines 216-223
Link Here
|
| 216 |
MPart partBackB = partStackB.getChildren().get(1); |
223 |
MPart partBackB = partStackB.getChildren().get(1); |
| 217 |
partStackB.setActiveChild(partFrontB); |
224 |
partStackB.setActiveChild(partFrontB); |
| 218 |
|
225 |
|
| 219 |
engine.createGui(windowA); |
226 |
getEngine().createGui(windowA); |
| 220 |
engine.createGui(windowB); |
227 |
getEngine().createGui(windowB); |
| 221 |
|
228 |
|
| 222 |
EPartService partServiceA = (EPartService) windowA.getContext().get( |
229 |
EPartService partServiceA = (EPartService) windowA.getContext().get( |
| 223 |
EPartService.class.getName()); |
230 |
EPartService.class.getName()); |
|
Lines 258-269
Link Here
|
| 258 |
MPart partBackB = partStackB.getChildren().get(1); |
265 |
MPart partBackB = partStackB.getChildren().get(1); |
| 259 |
partStackB.setActiveChild(partFrontB); |
266 |
partStackB.setActiveChild(partFrontB); |
| 260 |
|
267 |
|
| 261 |
engine.createGui(windowA); |
268 |
getEngine().createGui(windowA); |
| 262 |
engine.createGui(windowB); |
269 |
getEngine().createGui(windowB); |
| 263 |
|
270 |
|
| 264 |
EPartService partServiceA = (EPartService) partFrontA.getContext().get( |
271 |
EPartService partServiceA = (EPartService) partFrontA.getContext().get( |
| 265 |
EPartService.class.getName()); |
272 |
EPartService.class.getName()); |
| 266 |
EPartService partServiceB = (EPartService) partBackB.getContext().get( |
273 |
EPartService partServiceB = (EPartService) partFrontB.getContext().get( |
| 267 |
EPartService.class.getName()); |
274 |
EPartService.class.getName()); |
| 268 |
|
275 |
|
| 269 |
partServiceA.bringToTop(partBackB); |
276 |
partServiceA.bringToTop(partBackB); |
|
Lines 287-293
Link Here
|
| 287 |
MApplication application = createApplication(1, new String[1][0]); |
294 |
MApplication application = createApplication(1, new String[1][0]); |
| 288 |
MWindow window = application.getChildren().get(0); |
295 |
MWindow window = application.getChildren().get(0); |
| 289 |
|
296 |
|
| 290 |
engine.createGui(window); |
297 |
getEngine().createGui(window); |
| 291 |
|
298 |
|
| 292 |
EPartService partService = (EPartService) window.getContext().get( |
299 |
EPartService partService = (EPartService) window.getContext().get( |
| 293 |
EPartService.class.getName()); |
300 |
EPartService.class.getName()); |
|
Lines 301-307
Link Here
|
| 301 |
MWindow window = application.getChildren().get(0); |
308 |
MWindow window = application.getChildren().get(0); |
| 302 |
MPartStack partStack = (MPartStack) window.getChildren().get(0); |
309 |
MPartStack partStack = (MPartStack) window.getChildren().get(0); |
| 303 |
|
310 |
|
| 304 |
engine.createGui(window); |
311 |
getEngine().createGui(window); |
| 305 |
|
312 |
|
| 306 |
EPartService partService = (EPartService) window.getContext().get( |
313 |
EPartService partService = (EPartService) window.getContext().get( |
| 307 |
EPartService.class.getName()); |
314 |
EPartService.class.getName()); |
|
Lines 318-325
Link Here
|
| 318 |
MWindow windowA = application.getChildren().get(0); |
325 |
MWindow windowA = application.getChildren().get(0); |
| 319 |
MWindow windowB = application.getChildren().get(1); |
326 |
MWindow windowB = application.getChildren().get(1); |
| 320 |
|
327 |
|
| 321 |
engine.createGui(windowA); |
328 |
getEngine().createGui(windowA); |
| 322 |
engine.createGui(windowB); |
329 |
getEngine().createGui(windowB); |
| 323 |
|
330 |
|
| 324 |
EPartService partServiceA = (EPartService) windowA.getContext().get( |
331 |
EPartService partServiceA = (EPartService) windowA.getContext().get( |
| 325 |
EPartService.class.getName()); |
332 |
EPartService.class.getName()); |
|
Lines 353-359
Link Here
|
| 353 |
MPart part = partStack.getChildren().get(0); |
360 |
MPart part = partStack.getChildren().get(0); |
| 354 |
partStack.setActiveChild(part); |
361 |
partStack.setActiveChild(part); |
| 355 |
|
362 |
|
| 356 |
engine.createGui(window); |
363 |
getEngine().createGui(window); |
| 357 |
|
364 |
|
| 358 |
EPartService partService = (EPartService) window.getContext().get( |
365 |
EPartService partService = (EPartService) window.getContext().get( |
| 359 |
EPartService.class.getName()); |
366 |
EPartService.class.getName()); |
|
Lines 368-374
Link Here
|
| 368 |
MPart part = partStack.getChildren().get(0); |
375 |
MPart part = partStack.getChildren().get(0); |
| 369 |
partStack.setActiveChild(part); |
376 |
partStack.setActiveChild(part); |
| 370 |
|
377 |
|
| 371 |
engine.createGui(window); |
378 |
getEngine().createGui(window); |
| 372 |
|
379 |
|
| 373 |
EPartService partService = (EPartService) part.getContext().get( |
380 |
EPartService partService = (EPartService) part.getContext().get( |
| 374 |
EPartService.class.getName()); |
381 |
EPartService.class.getName()); |
|
Lines 382-388
Link Here
|
| 382 |
MPartStack partStack = (MPartStack) window.getChildren().get(0); |
389 |
MPartStack partStack = (MPartStack) window.getChildren().get(0); |
| 383 |
partStack.setActiveChild(partStack.getChildren().get(0)); |
390 |
partStack.setActiveChild(partStack.getChildren().get(0)); |
| 384 |
|
391 |
|
| 385 |
engine.createGui(window); |
392 |
getEngine().createGui(window); |
| 386 |
|
393 |
|
| 387 |
MPart part = partStack.getChildren().get(1); |
394 |
MPart part = partStack.getChildren().get(1); |
| 388 |
|
395 |
|
|
Lines 398-410
Link Here
|
| 398 |
MPartStack partStack = (MPartStack) window.getChildren().get(0); |
405 |
MPartStack partStack = (MPartStack) window.getChildren().get(0); |
| 399 |
partStack.setActiveChild(partStack.getChildren().get(0)); |
406 |
partStack.setActiveChild(partStack.getChildren().get(0)); |
| 400 |
|
407 |
|
| 401 |
engine.createGui(window); |
408 |
getEngine().createGui(window); |
| 402 |
|
409 |
|
| 403 |
MPart part = partStack.getChildren().get(1); |
410 |
MPart part1 = partStack.getChildren().get(0); |
|
|
411 |
MPart part2 = partStack.getChildren().get(1); |
| 404 |
|
412 |
|
| 405 |
EPartService partService = (EPartService) part.getContext().get( |
413 |
EPartService partService1 = (EPartService) part1.getContext().get( |
| 406 |
EPartService.class.getName()); |
414 |
EPartService.class.getName()); |
| 407 |
assertFalse(partService.isPartVisible(part)); |
415 |
assertTrue(partService1.isPartVisible(part1)); |
|
|
416 |
assertFalse(partService1.isPartVisible(part2)); |
| 417 |
|
| 418 |
partService1.activate(part2); |
| 419 |
|
| 420 |
EPartService partService2 = (EPartService) part2.getContext().get( |
| 421 |
EPartService.class.getName()); |
| 422 |
assertFalse(partService1.isPartVisible(part1)); |
| 423 |
assertTrue(partService1.isPartVisible(part2)); |
| 424 |
assertFalse(partService2.isPartVisible(part1)); |
| 425 |
assertTrue(partService2.isPartVisible(part2)); |
| 408 |
} |
426 |
} |
| 409 |
|
427 |
|
| 410 |
public void testIsVisible_ViewInAnotherWindow() { |
428 |
public void testIsVisible_ViewInAnotherWindow() { |
|
Lines 424-431
Link Here
|
| 424 |
MPart partBackB = partStackB.getChildren().get(1); |
442 |
MPart partBackB = partStackB.getChildren().get(1); |
| 425 |
partStackB.setActiveChild(partFrontB); |
443 |
partStackB.setActiveChild(partFrontB); |
| 426 |
|
444 |
|
| 427 |
engine.createGui(windowA); |
445 |
getEngine().createGui(windowA); |
| 428 |
engine.createGui(windowB); |
446 |
getEngine().createGui(windowB); |
| 429 |
|
447 |
|
| 430 |
EPartService partServiceA = (EPartService) windowA.getContext().get( |
448 |
EPartService partServiceA = (EPartService) windowA.getContext().get( |
| 431 |
EPartService.class.getName()); |
449 |
EPartService.class.getName()); |
|
Lines 460-467
Link Here
|
| 460 |
MPart partBackB = partStackB.getChildren().get(1); |
478 |
MPart partBackB = partStackB.getChildren().get(1); |
| 461 |
partStackB.setActiveChild(partFrontB); |
479 |
partStackB.setActiveChild(partFrontB); |
| 462 |
|
480 |
|
| 463 |
engine.createGui(windowA); |
481 |
getEngine().createGui(windowA); |
| 464 |
engine.createGui(windowB); |
482 |
getEngine().createGui(windowB); |
| 465 |
|
483 |
|
| 466 |
EPartService partServiceA = (EPartService) partFrontA.getContext().get( |
484 |
EPartService partServiceA = (EPartService) partFrontA.getContext().get( |
| 467 |
EPartService.class.getName()); |
485 |
EPartService.class.getName()); |
|
Lines 486-502
Link Here
|
| 486 |
MPartStack partStack = (MPartStack) window.getChildren().get(0); |
504 |
MPartStack partStack = (MPartStack) window.getChildren().get(0); |
| 487 |
partStack.setActiveChild(partStack.getChildren().get(0)); |
505 |
partStack.setActiveChild(partStack.getChildren().get(0)); |
| 488 |
|
506 |
|
| 489 |
engine.createGui(window); |
507 |
getEngine().createGui(window); |
| 490 |
|
508 |
|
| 491 |
MPart part = partStack.getChildren().get(1); |
509 |
MPart part1 = partStack.getChildren().get(0); |
|
|
510 |
MPart part2 = partStack.getChildren().get(1); |
| 492 |
|
511 |
|
| 493 |
EPartService partService = (EPartService) part.getContext().get( |
512 |
EPartService partService1 = (EPartService) part1.getContext().get( |
| 494 |
EPartService.class.getName()); |
513 |
EPartService.class.getName()); |
| 495 |
assertFalse(partService.isPartVisible(part)); |
514 |
assertTrue(partService1.isPartVisible(part1)); |
|
|
515 |
assertFalse(partService1.isPartVisible(part2)); |
| 496 |
|
516 |
|
| 497 |
partService.activate(part); |
517 |
partService1.activate(part2); |
| 498 |
assertTrue(partService.isPartVisible(part)); |
518 |
|
| 499 |
assertEquals(part, partService.getActivePart()); |
519 |
EPartService partService2 = (EPartService) part2.getContext().get( |
|
|
520 |
EPartService.class.getName()); |
| 521 |
assertFalse(partService1.isPartVisible(part1)); |
| 522 |
assertTrue(partService1.isPartVisible(part2)); |
| 523 |
assertFalse(partService2.isPartVisible(part1)); |
| 524 |
assertTrue(partService2.isPartVisible(part2)); |
| 500 |
} |
525 |
} |
| 501 |
|
526 |
|
| 502 |
public void testActivate_partService_twoWindows() { |
527 |
public void testActivate_partService_twoWindows() { |
|
Lines 509-523
Link Here
|
| 509 |
MPart partFrontA = partStackA.getChildren().get(0); |
534 |
MPart partFrontA = partStackA.getChildren().get(0); |
| 510 |
MPart partBackA = partStackA.getChildren().get(1); |
535 |
MPart partBackA = partStackA.getChildren().get(1); |
| 511 |
partStackA.setActiveChild(partFrontA); |
536 |
partStackA.setActiveChild(partFrontA); |
|
|
537 |
windowA.setActiveChild(partStackA); |
| 512 |
|
538 |
|
| 513 |
MWindow windowB = application.getChildren().get(1); |
539 |
MWindow windowB = application.getChildren().get(1); |
| 514 |
MPartStack partStackB = (MPartStack) windowB.getChildren().get(0); |
540 |
MPartStack partStackB = (MPartStack) windowB.getChildren().get(0); |
| 515 |
MPart partFrontB = partStackB.getChildren().get(0); |
541 |
MPart partFrontB = partStackB.getChildren().get(0); |
| 516 |
MPart partBackB = partStackB.getChildren().get(1); |
542 |
MPart partBackB = partStackB.getChildren().get(1); |
| 517 |
partStackB.setActiveChild(partFrontB); |
543 |
partStackB.setActiveChild(partFrontB); |
|
|
544 |
windowB.setActiveChild(partStackB); |
| 545 |
|
| 546 |
application.setActiveChild(windowA); |
| 518 |
|
547 |
|
| 519 |
engine.createGui(windowA); |
548 |
getEngine().createGui(windowA); |
| 520 |
engine.createGui(windowB); |
549 |
getEngine().createGui(windowB); |
| 521 |
|
550 |
|
| 522 |
EPartService partServiceA = (EPartService) partFrontA.getContext().get( |
551 |
EPartService partServiceA = (EPartService) partFrontA.getContext().get( |
| 523 |
EPartService.class.getName()); |
552 |
EPartService.class.getName()); |
|
Lines 570-577
Link Here
|
| 570 |
MPart partBackB = partStackB.getChildren().get(1); |
599 |
MPart partBackB = partStackB.getChildren().get(1); |
| 571 |
partStackB.setActiveChild(partFrontB); |
600 |
partStackB.setActiveChild(partFrontB); |
| 572 |
|
601 |
|
| 573 |
engine.createGui(windowA); |
602 |
getEngine().createGui(windowA); |
| 574 |
engine.createGui(windowB); |
603 |
getEngine().createGui(windowB); |
| 575 |
|
604 |
|
| 576 |
EPartService partServiceA = (EPartService) partFrontA.getContext().get( |
605 |
EPartService partServiceA = (EPartService) partFrontA.getContext().get( |
| 577 |
EPartService.class.getName()); |
606 |
EPartService.class.getName()); |
|
Lines 618-625
Link Here
|
| 618 |
MPart partFrontB = partStackB.getChildren().get(0); |
647 |
MPart partFrontB = partStackB.getChildren().get(0); |
| 619 |
MPart partBackB = partStackB.getChildren().get(1); |
648 |
MPart partBackB = partStackB.getChildren().get(1); |
| 620 |
|
649 |
|
| 621 |
engine.createGui(windowA); |
650 |
getEngine().createGui(windowA); |
| 622 |
engine.createGui(windowB); |
651 |
getEngine().createGui(windowB); |
| 623 |
|
652 |
|
| 624 |
EPartService partServiceA = (EPartService) partFrontA.getContext().get( |
653 |
EPartService partServiceA = (EPartService) partFrontA.getContext().get( |
| 625 |
EPartService.class.getName()); |
654 |
EPartService.class.getName()); |
|
Lines 650-656
Link Here
|
| 650 |
partDescriptor.setId("partId"); |
679 |
partDescriptor.setId("partId"); |
| 651 |
application.getDescriptors().add(partDescriptor); |
680 |
application.getDescriptors().add(partDescriptor); |
| 652 |
|
681 |
|
| 653 |
engine.createGui(window); |
682 |
getEngine().createGui(window); |
| 654 |
|
683 |
|
| 655 |
EPartService partService = (EPartService) window.getContext().get( |
684 |
EPartService partService = (EPartService) window.getContext().get( |
| 656 |
EPartService.class.getName()); |
685 |
EPartService.class.getName()); |
|
Lines 669-675
Link Here
|
| 669 |
partDescriptor.setId("partId"); |
698 |
partDescriptor.setId("partId"); |
| 670 |
application.getDescriptors().add(partDescriptor); |
699 |
application.getDescriptors().add(partDescriptor); |
| 671 |
|
700 |
|
| 672 |
engine.createGui(window); |
701 |
getEngine().createGui(window); |
| 673 |
|
702 |
|
| 674 |
EPartService partService = (EPartService) window.getContext().get( |
703 |
EPartService partService = (EPartService) window.getContext().get( |
| 675 |
EPartService.class.getName()); |
704 |
EPartService.class.getName()); |
|
Lines 706-712
Link Here
|
| 706 |
((Notifier) application).eAdapters().add( |
735 |
((Notifier) application).eAdapters().add( |
| 707 |
new UIEventPublisher(applicationContext)); |
736 |
new UIEventPublisher(applicationContext)); |
| 708 |
|
737 |
|
| 709 |
engine.createGui(window); |
738 |
getEngine().createGui(window); |
| 710 |
|
739 |
|
| 711 |
EPartService partService = (EPartService) window.getContext().get( |
740 |
EPartService partService = (EPartService) window.getContext().get( |
| 712 |
EPartService.class.getName()); |
741 |
EPartService.class.getName()); |
|
Lines 756-762
Link Here
|
| 756 |
((Notifier) application).eAdapters().add( |
785 |
((Notifier) application).eAdapters().add( |
| 757 |
new UIEventPublisher(applicationContext)); |
786 |
new UIEventPublisher(applicationContext)); |
| 758 |
|
787 |
|
| 759 |
engine.createGui(window); |
788 |
getEngine().createGui(window); |
| 760 |
|
789 |
|
| 761 |
EPartService partService = (EPartService) window.getContext().get( |
790 |
EPartService partService = (EPartService) window.getContext().get( |
| 762 |
EPartService.class.getName()); |
791 |
EPartService.class.getName()); |
|
Lines 772-782
Link Here
|
| 772 |
assertEquals(part2, stack.getActiveChild()); |
801 |
assertEquals(part2, stack.getActiveChild()); |
| 773 |
} |
802 |
} |
| 774 |
|
803 |
|
|
|
804 |
public void testShowPart_CREATE() { |
| 805 |
MApplication application = MApplicationFactory.eINSTANCE |
| 806 |
.createApplication(); |
| 807 |
MWindow window = MApplicationFactory.eINSTANCE.createWindow(); |
| 808 |
application.getChildren().add(window); |
| 809 |
|
| 810 |
MPartStack partStackA = MApplicationFactory.eINSTANCE.createPartStack(); |
| 811 |
MPartStack partStackB = MApplicationFactory.eINSTANCE.createPartStack(); |
| 812 |
window.getChildren().add(partStackA); |
| 813 |
window.getChildren().add(partStackB); |
| 814 |
|
| 815 |
MPart partA1 = MApplicationFactory.eINSTANCE.createPart(); |
| 816 |
MPart partA2 = MApplicationFactory.eINSTANCE.createPart(); |
| 817 |
partA1.setId("partA1"); |
| 818 |
partA2.setId("partA2"); |
| 819 |
partStackA.getChildren().add(partA1); |
| 820 |
partStackA.getChildren().add(partA2); |
| 821 |
|
| 822 |
MPart partB1 = MApplicationFactory.eINSTANCE.createPart(); |
| 823 |
MPart partB2 = MApplicationFactory.eINSTANCE.createPart(); |
| 824 |
partB1.setId("partB1"); |
| 825 |
partB2.setId("partB2"); |
| 826 |
partStackB.getChildren().add(partB1); |
| 827 |
partStackB.getChildren().add(partB2); |
| 828 |
|
| 829 |
partStackA.setActiveChild(partA1); |
| 830 |
partStackB.setActiveChild(partB1); |
| 831 |
window.setActiveChild(partStackA); |
| 832 |
|
| 833 |
applicationContext.set(MApplication.class.getName(), application); |
| 834 |
application.setContext(applicationContext); |
| 835 |
Workbench.processHierarchy(application); |
| 836 |
((Notifier) application).eAdapters().add( |
| 837 |
new UIEventPublisher(applicationContext)); |
| 838 |
|
| 839 |
getEngine().createGui(window); |
| 840 |
|
| 841 |
EPartService partService = (EPartService) window.getContext().get( |
| 842 |
EPartService.class.getName()); |
| 843 |
partService.activate(partA1); |
| 844 |
assertEquals(partA1, partService.getActivePart()); |
| 845 |
|
| 846 |
assertEquals(null, partA2.getContext()); |
| 847 |
assertEquals(null, partB2.getContext()); |
| 848 |
|
| 849 |
MPart shownPart = partService.showPart("partA2", |
| 850 |
EPartService.PartState.CREATE); |
| 851 |
assertTrue(partService.isPartVisible(partA1)); |
| 852 |
assertTrue(partService.isPartVisible(partB1)); |
| 853 |
assertEquals(partA1, partService.getActivePart()); |
| 854 |
assertEquals(shownPart, partA2); |
| 855 |
assertNotNull( |
| 856 |
"The part should have been created so it should have a context", |
| 857 |
partA2.getContext()); |
| 858 |
assertEquals( |
| 859 |
"This part has not been instantiated yet, it should have no context", |
| 860 |
null, partB2.getContext()); |
| 861 |
|
| 862 |
shownPart = partService.showPart("partB2", |
| 863 |
EPartService.PartState.CREATE); |
| 864 |
assertTrue(partService.isPartVisible(partA1)); |
| 865 |
assertTrue(partService.isPartVisible(partB1)); |
| 866 |
assertEquals(partA1, partService.getActivePart()); |
| 867 |
assertEquals(shownPart, partB2); |
| 868 |
assertNotNull( |
| 869 |
"The part should have been created so it should have a context", |
| 870 |
partA2.getContext()); |
| 871 |
assertNotNull( |
| 872 |
"The part should have been created so it should have a context", |
| 873 |
partB2.getContext()); |
| 874 |
} |
| 875 |
|
| 876 |
public void testShowPart_CREATE2() { |
| 877 |
MApplication application = MApplicationFactory.eINSTANCE |
| 878 |
.createApplication(); |
| 879 |
MWindow window = MApplicationFactory.eINSTANCE.createWindow(); |
| 880 |
application.getChildren().add(window); |
| 881 |
|
| 882 |
MPartDescriptor partDescriptor = MApplicationFactory.eINSTANCE |
| 883 |
.createPartDescriptor(); |
| 884 |
partDescriptor.setId("partB"); |
| 885 |
partDescriptor.setCategory("aCategory"); |
| 886 |
application.getDescriptors().add(partDescriptor); |
| 887 |
|
| 888 |
MPartStack partStack = MApplicationFactory.eINSTANCE.createPartStack(); |
| 889 |
partStack.setId("aCategory"); |
| 890 |
window.getChildren().add(partStack); |
| 891 |
|
| 892 |
MPart partA = MApplicationFactory.eINSTANCE.createPart(); |
| 893 |
partA.setId("partA"); |
| 894 |
partStack.getChildren().add(partA); |
| 895 |
|
| 896 |
partStack.setActiveChild(partA); |
| 897 |
window.setActiveChild(partStack); |
| 898 |
application.setActiveChild(window); |
| 899 |
|
| 900 |
applicationContext.set(MApplication.class.getName(), application); |
| 901 |
application.setContext(applicationContext); |
| 902 |
Workbench.processHierarchy(application); |
| 903 |
((Notifier) application).eAdapters().add( |
| 904 |
new UIEventPublisher(applicationContext)); |
| 905 |
|
| 906 |
getEngine().createGui(window); |
| 907 |
|
| 908 |
EPartService partService = (EPartService) window.getContext().get( |
| 909 |
EPartService.class.getName()); |
| 910 |
partService.activate(partA); |
| 911 |
assertEquals(partA, partService.getActivePart()); |
| 912 |
|
| 913 |
MPart partB = partService.showPart("partB", |
| 914 |
EPartService.PartState.CREATE); |
| 915 |
|
| 916 |
assertEquals(2, partStack.getChildren().size()); |
| 917 |
assertEquals( |
| 918 |
"Only creating the part, the active part should not have changed", |
| 919 |
partA, partService.getActivePart()); |
| 920 |
assertNotNull("The shown part should have a context", partB |
| 921 |
.getContext()); |
| 922 |
assertFalse(partService.isPartVisible(partB)); |
| 923 |
} |
| 924 |
|
| 925 |
public void testShowPart_CREATE3() { |
| 926 |
MApplication application = MApplicationFactory.eINSTANCE |
| 927 |
.createApplication(); |
| 928 |
MWindow window = MApplicationFactory.eINSTANCE.createWindow(); |
| 929 |
application.getChildren().add(window); |
| 930 |
|
| 931 |
MPartDescriptor partDescriptor = MApplicationFactory.eINSTANCE |
| 932 |
.createPartDescriptor(); |
| 933 |
partDescriptor.setId("partB"); |
| 934 |
partDescriptor.setCategory("aCategory"); |
| 935 |
application.getDescriptors().add(partDescriptor); |
| 936 |
|
| 937 |
MPartStack partStackA = MApplicationFactory.eINSTANCE.createPartStack(); |
| 938 |
window.getChildren().add(partStackA); |
| 939 |
MPartStack partStackB = MApplicationFactory.eINSTANCE.createPartStack(); |
| 940 |
partStackB.setId("aCategory"); |
| 941 |
window.getChildren().add(partStackB); |
| 942 |
|
| 943 |
MPart partA = MApplicationFactory.eINSTANCE.createPart(); |
| 944 |
partA.setId("partA"); |
| 945 |
partStackA.getChildren().add(partA); |
| 946 |
|
| 947 |
partStackA.setActiveChild(partA); |
| 948 |
window.setActiveChild(partStackA); |
| 949 |
application.setActiveChild(window); |
| 950 |
|
| 951 |
applicationContext.set(MApplication.class.getName(), application); |
| 952 |
application.setContext(applicationContext); |
| 953 |
Workbench.processHierarchy(application); |
| 954 |
((Notifier) application).eAdapters().add( |
| 955 |
new UIEventPublisher(applicationContext)); |
| 956 |
|
| 957 |
getEngine().createGui(window); |
| 958 |
|
| 959 |
EPartService partService = (EPartService) window.getContext().get( |
| 960 |
EPartService.class.getName()); |
| 961 |
partService.activate(partA); |
| 962 |
assertEquals(partA, partService.getActivePart()); |
| 963 |
|
| 964 |
MPart partB = partService.showPart("partB", |
| 965 |
EPartService.PartState.CREATE); |
| 966 |
|
| 967 |
assertEquals(1, partStackA.getChildren().size()); |
| 968 |
assertEquals( |
| 969 |
"Only creating the part, the active part should not have changed", |
| 970 |
partA, partService.getActivePart()); |
| 971 |
assertNotNull("The shown part should have a context", partB |
| 972 |
.getContext()); |
| 973 |
assertTrue( |
| 974 |
"The part is the only one in the stack, it should be visible", |
| 975 |
partService.isPartVisible(partB)); |
| 976 |
} |
| 977 |
|
| 978 |
public void testShowPart_VISIBLE() { |
| 979 |
MApplication application = MApplicationFactory.eINSTANCE |
| 980 |
.createApplication(); |
| 981 |
MWindow window = MApplicationFactory.eINSTANCE.createWindow(); |
| 982 |
application.getChildren().add(window); |
| 983 |
|
| 984 |
MPartStack partStackA = MApplicationFactory.eINSTANCE.createPartStack(); |
| 985 |
MPartStack partStackB = MApplicationFactory.eINSTANCE.createPartStack(); |
| 986 |
window.getChildren().add(partStackA); |
| 987 |
window.getChildren().add(partStackB); |
| 988 |
|
| 989 |
MPart partA1 = MApplicationFactory.eINSTANCE.createPart(); |
| 990 |
MPart partA2 = MApplicationFactory.eINSTANCE.createPart(); |
| 991 |
partA1.setId("partA1"); |
| 992 |
partA2.setId("partA2"); |
| 993 |
partStackA.getChildren().add(partA1); |
| 994 |
partStackA.getChildren().add(partA2); |
| 995 |
|
| 996 |
MPart partB1 = MApplicationFactory.eINSTANCE.createPart(); |
| 997 |
MPart partB2 = MApplicationFactory.eINSTANCE.createPart(); |
| 998 |
partB1.setId("partB1"); |
| 999 |
partB2.setId("partB2"); |
| 1000 |
partStackB.getChildren().add(partB1); |
| 1001 |
partStackB.getChildren().add(partB2); |
| 1002 |
|
| 1003 |
partStackA.setActiveChild(partA1); |
| 1004 |
partStackB.setActiveChild(partB1); |
| 1005 |
window.setActiveChild(partStackA); |
| 1006 |
|
| 1007 |
applicationContext.set(MApplication.class.getName(), application); |
| 1008 |
application.setContext(applicationContext); |
| 1009 |
Workbench.processHierarchy(application); |
| 1010 |
((Notifier) application).eAdapters().add( |
| 1011 |
new UIEventPublisher(applicationContext)); |
| 1012 |
|
| 1013 |
getEngine().createGui(window); |
| 1014 |
|
| 1015 |
EPartService partService = (EPartService) window.getContext().get( |
| 1016 |
EPartService.class.getName()); |
| 1017 |
partService.activate(partA1); |
| 1018 |
assertEquals(partA1, partService.getActivePart()); |
| 1019 |
|
| 1020 |
MPart shownPart = partService.showPart("partB1", |
| 1021 |
EPartService.PartState.VISIBLE); |
| 1022 |
assertTrue(partService.isPartVisible(partA1)); |
| 1023 |
assertTrue(partService.isPartVisible(partB1)); |
| 1024 |
assertEquals(partA1, partService.getActivePart()); |
| 1025 |
assertEquals(partB1, shownPart); |
| 1026 |
|
| 1027 |
shownPart = partService.showPart("partB2", |
| 1028 |
EPartService.PartState.VISIBLE); |
| 1029 |
assertTrue(partService.isPartVisible(partA1)); |
| 1030 |
assertTrue(partService.isPartVisible(partB2)); |
| 1031 |
assertEquals(partA1, partService.getActivePart()); |
| 1032 |
assertEquals(partB2, shownPart); |
| 1033 |
} |
| 1034 |
|
| 1035 |
public void testShowPart_VISIBLE2() { |
| 1036 |
MApplication application = MApplicationFactory.eINSTANCE |
| 1037 |
.createApplication(); |
| 1038 |
MWindow window = MApplicationFactory.eINSTANCE.createWindow(); |
| 1039 |
application.getChildren().add(window); |
| 1040 |
|
| 1041 |
MPartDescriptor partDescriptor = MApplicationFactory.eINSTANCE |
| 1042 |
.createPartDescriptor(); |
| 1043 |
partDescriptor.setId("partB"); |
| 1044 |
partDescriptor.setCategory("aCategory"); |
| 1045 |
application.getDescriptors().add(partDescriptor); |
| 1046 |
|
| 1047 |
MPartStack partStack = MApplicationFactory.eINSTANCE.createPartStack(); |
| 1048 |
partStack.setId("aCategory"); |
| 1049 |
window.getChildren().add(partStack); |
| 1050 |
|
| 1051 |
MPart partA = MApplicationFactory.eINSTANCE.createPart(); |
| 1052 |
partA.setId("partA"); |
| 1053 |
partStack.getChildren().add(partA); |
| 1054 |
|
| 1055 |
partStack.setActiveChild(partA); |
| 1056 |
window.setActiveChild(partStack); |
| 1057 |
application.setActiveChild(window); |
| 1058 |
|
| 1059 |
applicationContext.set(MApplication.class.getName(), application); |
| 1060 |
application.setContext(applicationContext); |
| 1061 |
Workbench.processHierarchy(application); |
| 1062 |
((Notifier) application).eAdapters().add( |
| 1063 |
new UIEventPublisher(applicationContext)); |
| 1064 |
|
| 1065 |
getEngine().createGui(window); |
| 1066 |
|
| 1067 |
EPartService partService = (EPartService) window.getContext().get( |
| 1068 |
EPartService.class.getName()); |
| 1069 |
partService.activate(partA); |
| 1070 |
assertEquals(partA, partService.getActivePart()); |
| 1071 |
|
| 1072 |
MPart partB = partService.showPart("partB", |
| 1073 |
EPartService.PartState.VISIBLE); |
| 1074 |
|
| 1075 |
assertEquals(2, partStack.getChildren().size()); |
| 1076 |
assertEquals( |
| 1077 |
"The part is in the same stack as the active part, so the active part should change", |
| 1078 |
partB, partService.getActivePart()); |
| 1079 |
assertNotNull("The shown part should have a context", partB |
| 1080 |
.getContext()); |
| 1081 |
assertTrue(partService.isPartVisible(partB)); |
| 1082 |
} |
| 1083 |
|
| 1084 |
public void testShowPart_VISIBLE3() { |
| 1085 |
MApplication application = MApplicationFactory.eINSTANCE |
| 1086 |
.createApplication(); |
| 1087 |
MWindow window = MApplicationFactory.eINSTANCE.createWindow(); |
| 1088 |
application.getChildren().add(window); |
| 1089 |
|
| 1090 |
MPartDescriptor partDescriptor = MApplicationFactory.eINSTANCE |
| 1091 |
.createPartDescriptor(); |
| 1092 |
partDescriptor.setId("partB"); |
| 1093 |
partDescriptor.setCategory("aCategory"); |
| 1094 |
application.getDescriptors().add(partDescriptor); |
| 1095 |
|
| 1096 |
MPartStack partStackA = MApplicationFactory.eINSTANCE.createPartStack(); |
| 1097 |
window.getChildren().add(partStackA); |
| 1098 |
MPartStack partStackB = MApplicationFactory.eINSTANCE.createPartStack(); |
| 1099 |
partStackB.setId("aCategory"); |
| 1100 |
window.getChildren().add(partStackB); |
| 1101 |
|
| 1102 |
MPart partA = MApplicationFactory.eINSTANCE.createPart(); |
| 1103 |
partA.setId("partA"); |
| 1104 |
partStackA.getChildren().add(partA); |
| 1105 |
|
| 1106 |
partStackA.setActiveChild(partA); |
| 1107 |
window.setActiveChild(partStackA); |
| 1108 |
application.setActiveChild(window); |
| 1109 |
|
| 1110 |
applicationContext.set(MApplication.class.getName(), application); |
| 1111 |
application.setContext(applicationContext); |
| 1112 |
Workbench.processHierarchy(application); |
| 1113 |
((Notifier) application).eAdapters().add( |
| 1114 |
new UIEventPublisher(applicationContext)); |
| 1115 |
|
| 1116 |
getEngine().createGui(window); |
| 1117 |
|
| 1118 |
EPartService partService = (EPartService) window.getContext().get( |
| 1119 |
EPartService.class.getName()); |
| 1120 |
partService.activate(partA); |
| 1121 |
assertEquals(partA, partService.getActivePart()); |
| 1122 |
|
| 1123 |
MPart partB = partService.showPart("partB", |
| 1124 |
EPartService.PartState.VISIBLE); |
| 1125 |
|
| 1126 |
assertEquals(1, partStackA.getChildren().size()); |
| 1127 |
assertEquals( |
| 1128 |
"Only creating the part, the active part should not have changed", |
| 1129 |
partA, partService.getActivePart()); |
| 1130 |
assertNotNull("The shown part should have a context", partB |
| 1131 |
.getContext()); |
| 1132 |
assertTrue( |
| 1133 |
"The part is the only one in the stack, it should be visible", |
| 1134 |
partService.isPartVisible(partB)); |
| 1135 |
} |
| 1136 |
|
| 775 |
public void testGetSaveableParts() { |
1137 |
public void testGetSaveableParts() { |
| 776 |
MApplication application = createApplication(1, new String[1][0]); |
1138 |
MApplication application = createApplication(1, new String[1][0]); |
| 777 |
MWindow window = application.getChildren().get(0); |
1139 |
MWindow window = application.getChildren().get(0); |
| 778 |
|
1140 |
|
| 779 |
engine.createGui(window); |
1141 |
getEngine().createGui(window); |
| 780 |
|
1142 |
|
| 781 |
EPartService partService = (EPartService) window.getContext().get( |
1143 |
EPartService partService = (EPartService) window.getContext().get( |
| 782 |
EPartService.class.getName()); |
1144 |
EPartService.class.getName()); |
|
Lines 790-796
Link Here
|
| 790 |
MApplication application = createApplication("partId"); |
1152 |
MApplication application = createApplication("partId"); |
| 791 |
MWindow window = application.getChildren().get(0); |
1153 |
MWindow window = application.getChildren().get(0); |
| 792 |
|
1154 |
|
| 793 |
engine.createGui(window); |
1155 |
getEngine().createGui(window); |
| 794 |
|
1156 |
|
| 795 |
EPartService partService = (EPartService) window.getContext().get( |
1157 |
EPartService partService = (EPartService) window.getContext().get( |
| 796 |
EPartService.class.getName()); |
1158 |
EPartService.class.getName()); |
|
Lines 817-823
Link Here
|
| 817 |
((Notifier) application).eAdapters().add( |
1179 |
((Notifier) application).eAdapters().add( |
| 818 |
new UIEventPublisher(applicationContext)); |
1180 |
new UIEventPublisher(applicationContext)); |
| 819 |
|
1181 |
|
| 820 |
engine.createGui(window); |
1182 |
getEngine().createGui(window); |
| 821 |
|
1183 |
|
| 822 |
EPartService partService = (EPartService) window.getContext().get( |
1184 |
EPartService partService = (EPartService) window.getContext().get( |
| 823 |
EPartService.class.getName()); |
1185 |
EPartService.class.getName()); |
|
Lines 831-837
Link Here
|
| 831 |
MApplication application = createApplication(1, new String[1][0]); |
1193 |
MApplication application = createApplication(1, new String[1][0]); |
| 832 |
MWindow window = application.getChildren().get(0); |
1194 |
MWindow window = application.getChildren().get(0); |
| 833 |
|
1195 |
|
| 834 |
engine.createGui(window); |
1196 |
getEngine().createGui(window); |
| 835 |
|
1197 |
|
| 836 |
EPartService partService = (EPartService) window.getContext().get( |
1198 |
EPartService partService = (EPartService) window.getContext().get( |
| 837 |
EPartService.class.getName()); |
1199 |
EPartService.class.getName()); |
|
Lines 844-850
Link Here
|
| 844 |
MApplication application = createApplication("partId"); |
1206 |
MApplication application = createApplication("partId"); |
| 845 |
MWindow window = application.getChildren().get(0); |
1207 |
MWindow window = application.getChildren().get(0); |
| 846 |
|
1208 |
|
| 847 |
engine.createGui(window); |
1209 |
getEngine().createGui(window); |
| 848 |
|
1210 |
|
| 849 |
EPartService partService = (EPartService) window.getContext().get( |
1211 |
EPartService partService = (EPartService) window.getContext().get( |
| 850 |
EPartService.class.getName()); |
1212 |
EPartService.class.getName()); |
|
Lines 871-877
Link Here
|
| 871 |
((Notifier) application).eAdapters().add( |
1233 |
((Notifier) application).eAdapters().add( |
| 872 |
new UIEventPublisher(applicationContext)); |
1234 |
new UIEventPublisher(applicationContext)); |
| 873 |
|
1235 |
|
| 874 |
engine.createGui(window); |
1236 |
getEngine().createGui(window); |
| 875 |
|
1237 |
|
| 876 |
EPartService partService = (EPartService) window.getContext().get( |
1238 |
EPartService partService = (EPartService) window.getContext().get( |
| 877 |
EPartService.class.getName()); |
1239 |
EPartService.class.getName()); |
|
Lines 920-929
Link Here
|
| 920 |
MWindow window2 = MApplicationFactory.eINSTANCE.createWindow(); |
1282 |
MWindow window2 = MApplicationFactory.eINSTANCE.createWindow(); |
| 921 |
application.getChildren().add(window1); |
1283 |
application.getChildren().add(window1); |
| 922 |
application.getChildren().add(window2); |
1284 |
application.getChildren().add(window2); |
|
|
1285 |
application.setActiveChild(window1); |
| 923 |
|
1286 |
|
| 924 |
// place a part in the first window |
1287 |
// place a part in the first window |
| 925 |
MPart part = MApplicationFactory.eINSTANCE.createPart(); |
1288 |
MPart part = MApplicationFactory.eINSTANCE.createPart(); |
| 926 |
window1.getChildren().add(part); |
1289 |
window1.getChildren().add(part); |
|
|
1290 |
window1.setActiveChild(part); |
| 927 |
|
1291 |
|
| 928 |
// setup the context |
1292 |
// setup the context |
| 929 |
applicationContext.set(MApplication.class.getName(), application); |
1293 |
applicationContext.set(MApplication.class.getName(), application); |
|
Lines 933-940
Link Here
|
| 933 |
new UIEventPublisher(applicationContext)); |
1297 |
new UIEventPublisher(applicationContext)); |
| 934 |
|
1298 |
|
| 935 |
// render the windows |
1299 |
// render the windows |
| 936 |
engine.createGui(window1); |
1300 |
getEngine().createGui(window1); |
| 937 |
engine.createGui(window2); |
1301 |
getEngine().createGui(window2); |
| 938 |
|
1302 |
|
| 939 |
EPartService windowService1 = (EPartService) window1.getContext().get( |
1303 |
EPartService windowService1 = (EPartService) window1.getContext().get( |
| 940 |
EPartService.class.getName()); |
1304 |
EPartService.class.getName()); |
|
Lines 964-970
Link Here
|
| 964 |
// activate the part |
1328 |
// activate the part |
| 965 |
windowService2.activate(part); |
1329 |
windowService2.activate(part); |
| 966 |
|
1330 |
|
| 967 |
assertNull("No parts in this window, this should be null", |
1331 |
assertEquals("No parts in this window, this should be null", null, |
| 968 |
windowService1.getActivePart()); |
1332 |
windowService1.getActivePart()); |
| 969 |
assertEquals("We activated it just now, this should be active", part, |
1333 |
assertEquals("We activated it just now, this should be active", part, |
| 970 |
windowService2.getActivePart()); |
1334 |
windowService2.getActivePart()); |