|
Lines 21-28
Link Here
|
| 21 |
import org.eclipse.e4.ui.model.application.MPartSashContainer; |
21 |
import org.eclipse.e4.ui.model.application.MPartSashContainer; |
| 22 |
import org.eclipse.e4.ui.model.application.MPartStack; |
22 |
import org.eclipse.e4.ui.model.application.MPartStack; |
| 23 |
import org.eclipse.e4.ui.model.application.MWindow; |
23 |
import org.eclipse.e4.ui.model.application.MWindow; |
|
|
24 |
import org.eclipse.e4.ui.services.IServiceConstants; |
| 24 |
import org.eclipse.e4.ui.workbench.swt.internal.E4Application; |
25 |
import org.eclipse.e4.ui.workbench.swt.internal.E4Application; |
| 25 |
import org.eclipse.e4.ui.workbench.swt.internal.PartRenderingEngine; |
26 |
import org.eclipse.e4.ui.workbench.swt.internal.PartRenderingEngine; |
|
|
27 |
import org.eclipse.e4.workbench.modeling.EPartService; |
| 26 |
import org.eclipse.e4.workbench.ui.IPresentationEngine; |
28 |
import org.eclipse.e4.workbench.ui.IPresentationEngine; |
| 27 |
import org.eclipse.e4.workbench.ui.internal.E4Workbench; |
29 |
import org.eclipse.e4.workbench.ui.internal.E4Workbench; |
| 28 |
import org.eclipse.swt.widgets.Display; |
30 |
import org.eclipse.swt.widgets.Display; |
|
Lines 96-101
Link Here
|
| 96 |
assertNotNull(window2.getWidget()); |
98 |
assertNotNull(window2.getWidget()); |
| 97 |
} |
99 |
} |
| 98 |
|
100 |
|
|
|
101 |
public void testEPartService_Activate() throws Exception { |
| 102 |
// create a window with two parts |
| 103 |
MWindow window = MApplicationFactory.eINSTANCE.createWindow(); |
| 104 |
|
| 105 |
MPart part = MApplicationFactory.eINSTANCE.createPart(); |
| 106 |
window.getChildren().add(part); |
| 107 |
part.setLabel(""); |
| 108 |
part.setURI("platform:/plugin/org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.workbench.SampleView"); |
| 109 |
|
| 110 |
MPart part2 = MApplicationFactory.eINSTANCE.createPart(); |
| 111 |
part2.setLabel(""); |
| 112 |
part2.setURI("platform:/plugin/org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.workbench.SampleView"); |
| 113 |
|
| 114 |
window.getChildren().add(part2); |
| 115 |
window.setActiveChild(part2); |
| 116 |
|
| 117 |
// add the window to the app |
| 118 |
MApplication application = MApplicationFactory.eINSTANCE |
| 119 |
.createApplication(); |
| 120 |
application.getChildren().add(window); |
| 121 |
application.setContext(appContext); |
| 122 |
appContext.set(MApplication.class.getName(), application); |
| 123 |
|
| 124 |
wb = new E4Workbench(application, appContext); |
| 125 |
// render |
| 126 |
wb.createAndRunUI(window); |
| 127 |
|
| 128 |
IEclipseContext windowContext = window.getContext(); |
| 129 |
|
| 130 |
EPartService service = (EPartService) windowContext |
| 131 |
.get(EPartService.class.getName()); |
| 132 |
|
| 133 |
// active part should be the second one |
| 134 |
assertEquals(part2, windowContext.get(IServiceConstants.ACTIVE_PART)); |
| 135 |
assertEquals(part2, service.getActivePart()); |
| 136 |
|
| 137 |
// activate the first one |
| 138 |
service.activate(part); |
| 139 |
|
| 140 |
// active part should be the first one |
| 141 |
assertEquals(part, windowContext.get(IServiceConstants.ACTIVE_PART)); |
| 142 |
assertEquals(part, service.getActivePart()); |
| 143 |
} |
| 144 |
|
| 99 |
private MWindow createWindowWithOneView(String partName) { |
145 |
private MWindow createWindowWithOneView(String partName) { |
| 100 |
final MWindow window = MApplicationFactory.eINSTANCE.createWindow(); |
146 |
final MWindow window = MApplicationFactory.eINSTANCE.createWindow(); |
| 101 |
window.setHeight(300); |
147 |
window.setHeight(300); |