use of org.eclipse.e4.ui.internal.workbench.E4Workbench in project eclipse.platform.ui by eclipse-platform.
the class TextField method setUp.
@Before
public void setUp() throws Exception {
appContext = E4Application.createDefaultContext();
appContext.set(IWorkbench.PRESENTATION_URI_ARG, PartRenderingEngine.engineURI);
ems = appContext.get(EModelService.class);
window = ems.createModelElement(MWindow.class);
window.setWidth(500);
window.setHeight(500);
MPartSashContainer sash = ems.createModelElement(MPartSashContainer.class);
window.getChildren().add(sash);
window.setSelectedElement(sash);
MPartStack stack = ems.createModelElement(MPartStack.class);
sash.getChildren().add(stack);
sash.setSelectedElement(stack);
part = ems.createModelElement(MPart.class);
part.setElementId("Part");
part.setLabel("Part");
part.setToolbar(ems.createModelElement(MToolBar.class));
part.setContributionURI(asURI(PartBackend.class));
stack.getChildren().add(part);
toolControl = ems.createModelElement(MToolControl.class);
toolControl.setElementId("ToolControl");
toolControl.setContributionURI(asURI(TextField.class));
part.getToolbar().getChildren().add(toolControl);
stack = ems.createModelElement(MPartStack.class);
sash.getChildren().add(stack);
sash.setSelectedElement(stack);
otherPart = ems.createModelElement(MPart.class);
otherPart.setElementId("OtherPart");
otherPart.setLabel("OtherPart");
otherPart.setContributionURI(asURI(PartBackend.class));
stack.getChildren().add(otherPart);
MApplication application = ems.createModelElement(MApplication.class);
application.getChildren().add(window);
application.setContext(appContext);
appContext.set(MApplication.class, application);
wb = new E4Workbench(application, appContext);
wb.createAndRunUI(window);
eps = window.getContext().get(EPartService.class);
// ensure the parts are populated and the contributions instantiated
eps.activate(part);
eps.activate(otherPart);
processEvents();
// ensure our model backend objects are created
assertNotNull(part.getObject());
assertNotNull(toolControl.getObject());
assertNotNull(otherPart.getObject());
assertNotNull(part.getWidget());
assertNotNull(toolControl.getWidget());
assertNotNull(otherPart.getWidget());
// ensure focus is set to otherPart.text1
eps.activate(otherPart);
processEvents();
assertTrue(((PartBackend) otherPart.getObject()).text1.isFocusControl());
}
use of org.eclipse.e4.ui.internal.workbench.E4Workbench in project eclipse.platform.ui by eclipse-platform.
the class MPartSashContainerTest method testPartSashContainer_Horizontal.
@Test
public void testPartSashContainer_Horizontal() {
MWindow window = ems.createModelElement(MWindow.class);
MPartSashContainer partSashContainer = ems.createModelElement(MPartSashContainer.class);
MPart partA = ems.createModelElement(MPart.class);
MPart partB = ems.createModelElement(MPart.class);
partSashContainer.setHorizontal(true);
partA.setContributionURI("bundleclass://org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.workbench.SampleView");
partB.setContributionURI("bundleclass://org.eclipse.e4.ui.tests/org.eclipse.e4.ui.tests.workbench.SampleView");
window.getChildren().add(partSashContainer);
partSashContainer.getChildren().add(partA);
partSashContainer.getChildren().add(partB);
MApplication application = ems.createModelElement(MApplication.class);
application.getChildren().add(window);
application.setContext(appContext);
appContext.set(MApplication.class, application);
wb = new E4Workbench(application, appContext);
wb.createAndRunUI(window);
Object widget = partSashContainer.getWidget();
assertNotNull(widget);
}
use of org.eclipse.e4.ui.internal.workbench.E4Workbench in project eclipse.platform.ui by eclipse-platform.
the class MSashTest method testSashWeights.
@Test
public void testSashWeights() {
MWindow window = createSashWithNViews(2);
MApplication application = ems.createModelElement(MApplication.class);
application.getChildren().add(window);
application.setContext(appContext);
appContext.set(MApplication.class, application);
wb = new E4Workbench(application, appContext);
wb.createAndRunUI(window);
Widget topWidget = (Widget) window.getWidget();
((Shell) topWidget).layout(true);
MPartSashContainer sash = (MPartSashContainer) window.getChildren().get(0);
MPart part0 = (MPart) sash.getChildren().get(0);
MPart part1 = (MPart) sash.getChildren().get(1);
int cdVal0 = -1;
try {
cdVal0 = Integer.parseInt(part0.getContainerData());
} catch (NumberFormatException e) {
}
assertTrue("Part0 data is not an integer", cdVal0 != -1);
int cdVal1 = -1;
try {
cdVal1 = Integer.parseInt(part1.getContainerData());
} catch (NumberFormatException e) {
}
assertTrue("Part1 data is not an integer", cdVal1 != -1);
assertTrue("Values should be equal", cdVal0 == cdVal1);
}
use of org.eclipse.e4.ui.internal.workbench.E4Workbench in project eclipse.platform.ui by eclipse-platform.
the class AreaRendererTest method testMultipleStacksUnderTheAreaCreateACTabFolder.
@Test
public void testMultipleStacksUnderTheAreaCreateACTabFolder() {
MWindow window = ems.createModelElement(MWindow.class);
MArea area = ems.createModelElement(MArea.class);
// Create two PartStacks with MParts inside
MPartStack stack1 = ems.createModelElement(MPartStack.class);
stack1.getChildren().add(ems.createModelElement(MPart.class));
stack1.getChildren().add(ems.createModelElement(MPart.class));
MPartStack stack2 = ems.createModelElement(MPartStack.class);
stack2.getChildren().add(ems.createModelElement(MPart.class));
stack2.getChildren().add(ems.createModelElement(MPart.class));
// Place the containers in the area
area.getChildren().add(stack1);
area.getChildren().add(stack2);
// Add area to the window
window.getChildren().add(area);
MApplication application = ems.createModelElement(MApplication.class);
application.getChildren().add(window);
application.setContext(appContext);
appContext.set(MApplication.class, application);
wb = new E4Workbench(application, appContext);
wb.createAndRunUI(window);
// Make sure the widget is now a CTabFolder
Assert.assertTrue(area.getWidget() instanceof CTabFolder);
}
use of org.eclipse.e4.ui.internal.workbench.E4Workbench in project eclipse.platform.ui by eclipse-platform.
the class HandlerActivationTest method createLayoutWithThreeContextLayers.
/**
* Creates an example application model with one window and two perspectives
*/
public void createLayoutWithThreeContextLayers() {
window = ems.createModelElement(MWindow.class);
MPerspectiveStack perspectiveStack = ems.createModelElement(MPerspectiveStack.class);
window.getChildren().add(perspectiveStack);
perspectiveA = ems.createModelElement(MPerspective.class);
perspectiveB = ems.createModelElement(MPerspective.class);
MPartStack stackA = ems.createModelElement(MPartStack.class);
partA1 = ems.createModelElement(MPart.class);
partA2 = ems.createModelElement(MPart.class);
stackA.getChildren().add(partA1);
stackA.getChildren().add(partA2);
perspectiveA.getChildren().add(stackA);
perspectiveStack.getChildren().add(perspectiveA);
MPartStack stackB = ems.createModelElement(MPartStack.class);
partB1 = ems.createModelElement(MPart.class);
stackB.getChildren().add(partB1);
stackB.setSelectedElement(partB1);
perspectiveB.getChildren().add(stackB);
perspectiveStack.getChildren().add(perspectiveB);
perspectiveStack.setSelectedElement(perspectiveA);
stackA.setSelectedElement(partA1);
command = ems.createModelElement(MCommand.class);
command.setElementId(COMMANDID);
command.setCommandName("Test Handler Activation");
MApplication application = ems.createModelElement(MApplication.class);
application.getCommands().add(command);
application.getChildren().add(window);
application.setContext(appContext);
appContext.set(MApplication.class, application);
appContext.set(CommandProcessingAddon.class, ContextInjectionFactory.make(CommandProcessingAddon.class, appContext));
appContext.set(HandlerProcessingAddon.class, ContextInjectionFactory.make(HandlerProcessingAddon.class, appContext));
wb = new E4Workbench(window, appContext);
wb.createAndRunUI(window);
ECommandService commandService = appContext.get(ECommandService.class);
handlerService = appContext.get(EHandlerService.class);
parameterizedCommand = commandService.createCommand(COMMANDID, null);
partService = appContext.get(EPartService.class);
}
Aggregations