Search in sources :

Example 6 with E4Workbench

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());
}
Also used : MToolBar(org.eclipse.e4.ui.model.application.ui.menu.MToolBar) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) MToolControl(org.eclipse.e4.ui.model.application.ui.menu.MToolControl) E4Workbench(org.eclipse.e4.ui.internal.workbench.E4Workbench) EModelService(org.eclipse.e4.ui.workbench.modeling.EModelService) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow) MPartSashContainer(org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer) MApplication(org.eclipse.e4.ui.model.application.MApplication) Before(org.junit.Before)

Example 7 with E4Workbench

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);
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) E4Workbench(org.eclipse.e4.ui.internal.workbench.E4Workbench) MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow) MPartSashContainer(org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer) MApplication(org.eclipse.e4.ui.model.application.MApplication) Test(org.junit.Test)

Example 8 with E4Workbench

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);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) E4Workbench(org.eclipse.e4.ui.internal.workbench.E4Workbench) Widget(org.eclipse.swt.widgets.Widget) MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow) MPartSashContainer(org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer) MApplication(org.eclipse.e4.ui.model.application.MApplication) Test(org.junit.Test)

Example 9 with E4Workbench

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);
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) CTabFolder(org.eclipse.swt.custom.CTabFolder) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) E4Workbench(org.eclipse.e4.ui.internal.workbench.E4Workbench) MArea(org.eclipse.e4.ui.model.application.ui.advanced.MArea) MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow) MApplication(org.eclipse.e4.ui.model.application.MApplication) Test(org.junit.Test)

Example 10 with E4Workbench

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);
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) EHandlerService(org.eclipse.e4.core.commands.EHandlerService) CommandProcessingAddon(org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon) MPartStack(org.eclipse.e4.ui.model.application.ui.basic.MPartStack) MCommand(org.eclipse.e4.ui.model.application.commands.MCommand) HandlerProcessingAddon(org.eclipse.e4.ui.internal.workbench.addons.HandlerProcessingAddon) MPerspectiveStack(org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack) MWindow(org.eclipse.e4.ui.model.application.ui.basic.MWindow) MPerspective(org.eclipse.e4.ui.model.application.ui.advanced.MPerspective) E4Workbench(org.eclipse.e4.ui.internal.workbench.E4Workbench) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) MApplication(org.eclipse.e4.ui.model.application.MApplication) ECommandService(org.eclipse.e4.core.commands.ECommandService)

Aggregations

E4Workbench (org.eclipse.e4.ui.internal.workbench.E4Workbench)15 MWindow (org.eclipse.e4.ui.model.application.ui.basic.MWindow)12 MApplication (org.eclipse.e4.ui.model.application.MApplication)10 MPart (org.eclipse.e4.ui.model.application.ui.basic.MPart)9 Test (org.junit.Test)9 Shell (org.eclipse.swt.widgets.Shell)8 MPartStack (org.eclipse.e4.ui.model.application.ui.basic.MPartStack)5 Widget (org.eclipse.swt.widgets.Widget)5 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)3 MPartSashContainer (org.eclipse.e4.ui.model.application.ui.basic.MPartSashContainer)3 CTabFolder (org.eclipse.swt.custom.CTabFolder)3 ULocale (com.ibm.icu.util.ULocale)2 Hashtable (java.util.Hashtable)2 EPartService (org.eclipse.e4.ui.workbench.modeling.EPartService)2 EObject (org.eclipse.emf.ecore.EObject)2 Category (com.ibm.icu.util.ULocale.Category)1 BufferedInputStream (java.io.BufferedInputStream)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1