Example usage for org.eclipse.jface.bindings.keys IKeyLookup ESC_NAME

List of usage examples for org.eclipse.jface.bindings.keys IKeyLookup ESC_NAME

Introduction

In this page you can find the example usage for org.eclipse.jface.bindings.keys IKeyLookup ESC_NAME.

Prototype

String ESC_NAME

To view the source code for org.eclipse.jface.bindings.keys IKeyLookup ESC_NAME.

Click Source Link

Document

The formal name of the escape (U+001B) key.

Usage

From source file:org.eclipse.sirius.tests.swtbot.SessionSaveableTest.java

License:Open Source License

private void escapeOnSaveDialog() throws WidgetNotFoundException {
    bot.waitUntil(Conditions.shellIsActive("Save"));
    SWTBotShell saveShell = bot.shell("Save");
    try {//from w  w w .jav  a 2  s  . c  o m
        saveShell.pressShortcut(KeyStroke.getInstance(IKeyLookup.ESC_NAME));
    } catch (ParseException e) {
        fail("Problem to press escape key");
    }
    bot.waitUntil(Conditions.shellCloses(saveShell));
}

From source file:org.eclipse.sirius.tests.swtbot.tabbar.ResetToDefaultFiltersActionTests.java

License:Open Source License

/**
 * Test the non visibility of "Reset to default filters" action as there is
 * not default concern./* www.  j av a  2 s  . c  o m*/
 */
public void testResetToDefaultFiltersActionUnavailability() {
    UIDiagramRepresentation newDiagramRepresentation = localSession
            .newDiagramRepresentation("new " + DIAGRAM_DESCRIPTION_WITHOUT_CONCERN,
                    DIAGRAM_DESCRIPTION_WITHOUT_CONCERN)
            .on(modelElementItem).withDefaultName().ok();
    ;
    editor = newDiagramRepresentation.getEditor();
    DRepresentation dRepresentation = editor.getDRepresentation();
    assertTrue(dRepresentation instanceof DDiagram);
    DDiagram dDiagram = (DDiagram) dRepresentation;
    List<FilterDescription> filters = dDiagram.getDescription().getFilters();
    SWTBotToolbarDropDownButton button = editor.bot().toolbarDropDownButtonWithTooltip("Filters");
    List<? extends SWTBotMenu> menuItems = button.menuItems(WidgetMatcherFactory.widgetOfType(MenuItem.class));
    assertEquals(filters.size(), menuItems.size());
    for (int i = 0; i < menuItems.size(); i++) {
        SWTBotMenu menuItem = menuItems.get(i);
        assertEquals(new IdentifiedElementQuery(filters.get(i)).getLabel(), menuItem.getText());
    }
    assertEquals("Any filter is activated, all classes must be visible.", 5,
            getNbOfVisibleDiagramElements(dDiagram));
    try {
        // The drop down menu is not closed, so use the Escape key as
        // workaround.
        button.pressShortcut(KeyStroke.getInstance(IKeyLookup.ESC_NAME));
        SWTBotUtils.waitAllUiEvents();
    } catch (ParseException e) {
    }
}

From source file:org.eclipse.sirius.tests.swtbot.tabbar.ResetToDefaultFiltersActionTests.java

License:Open Source License

/**
 * Test the visibility of "Reset to default filters" action as there is a
 * default concern./*from  ww  w  . ja v a2  s. c o  m*/
 */
public void testResetToDefaultFiltersActionAvailability() {
    UIDiagramRepresentation newDiagramRepresentation = localSession
            .newDiagramRepresentation("new " + DIAGRAM_DESCRIPTION_WITH_CONCERN,
                    DIAGRAM_DESCRIPTION_WITH_CONCERN)
            .on(modelElementItem).withDefaultName().ok();
    ;
    editor = newDiagramRepresentation.getEditor();
    DRepresentation dRepresentation = editor.getDRepresentation();
    assertTrue(dRepresentation instanceof DDiagram);
    DDiagram dDiagram = (DDiagram) dRepresentation;
    List<FilterDescription> filters = dDiagram.getDescription().getFilters();
    final SWTBotToolbarDropDownButton filtersButton = editor.bot().toolbarDropDownButtonWithTooltip("Filters");
    List<? extends SWTBotMenu> menuItems = filtersButton
            .menuItems(WidgetMatcherFactory.widgetOfType(MenuItem.class));
    assertEquals(filters.size() + 1, menuItems.size());
    for (int i = 0; i < menuItems.size() - 1; i++) {
        SWTBotMenu menuItem = menuItems.get(i);
        assertEquals(new IdentifiedElementQuery(filters.get(i)).getLabel(), menuItem.getText());
    }
    SWTBotMenu menuItem = menuItems.get(menuItems.size() - 1);
    assertEquals(Messages.ResetToDefaultFiltersAction_text, menuItem.getText());
    assertFalse(menuItem.isEnabled());
    assertEquals("By default A filter is activated, only B classes must be visible.", 2,
            getNbOfVisibleDiagramElements(dDiagram));

    // Change default filters selection
    menuItems.get(0).click();
    try {
        // The drop down menu is not closed, so use the Escape key as
        // workaround.
        filtersButton.pressShortcut(KeyStroke.getInstance(IKeyLookup.ESC_NAME));
        SWTBotUtils.waitAllUiEvents();
    } catch (ParseException e) {
    }
    assertEquals(0, dDiagram.getActivatedFilters().size());
    assertEquals("Any filter is activated, all classes must be visible.", 5,
            getNbOfVisibleDiagramElements(dDiagram));

    // Test that "Reset to default filters" action is enabled
    menuItems = filtersButton.menuItems(WidgetMatcherFactory.widgetOfType(MenuItem.class));
    menuItem = menuItems.get(menuItems.size() - 1);
    assertEquals(Messages.ResetToDefaultFiltersAction_text, menuItem.getText());
    assertTrue(menuItem.isEnabled());

    // Test result of a reset
    menuItem.click();
    try {
        // The drop down menu is not closed, so use the Escape key as
        // workaround.
        filtersButton.pressShortcut(KeyStroke.getInstance(IKeyLookup.ESC_NAME));
        SWTBotUtils.waitAllUiEvents();
    } catch (ParseException e) {
    }
    assertEquals(dDiagram.getDescription().getDefaultConcern().getFilters(), dDiagram.getActivatedFilters());
    assertEquals(dDiagram.getDescription().getDefaultConcern(), dDiagram.getCurrentConcern());
    assertEquals("By default A filter is activated, only B classes must be visible.", 2,
            getNbOfVisibleDiagramElements(dDiagram));

    // Test that "Reset to default filters" action is disabled now
    menuItems = filtersButton.menuItems(WidgetMatcherFactory.widgetOfType(MenuItem.class));
    menuItem = menuItems.get(menuItems.size() - 1);
    assertEquals(Messages.ResetToDefaultFiltersAction_text, menuItem.getText());
    assertFalse(menuItem.isEnabled());
    assertEquals("By default A filter is activated, only B classes must be visible.", 2,
            getNbOfVisibleDiagramElements(dDiagram));
    try {
        // The drop down menu is not closed, so use the Escape key as
        // workaround.
        filtersButton.pressShortcut(KeyStroke.getInstance(IKeyLookup.ESC_NAME));
        SWTBotUtils.waitAllUiEvents();
    } catch (ParseException e) {
    }

    // Test "Reset to default filters" action on concern change
    Session session = localSession.getOpenedSession();
    TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
    domain.getCommandStack().execute(new SetCurrentConcernCommand(domain, dDiagram,
            dDiagram.getDescription().getConcerns().getOwnedConcernDescriptions().get(1)));
    menuItems = filtersButton.menuItems(WidgetMatcherFactory.widgetOfType(MenuItem.class));
    menuItem = menuItems.get(menuItems.size() - 1);
    assertEquals(Messages.ResetToDefaultFiltersAction_text, menuItem.getText());
    assertTrue(menuItem.isEnabled());
    assertEquals("With second concern, B filter is activated, only A classes must be visible.", 3,
            getNbOfVisibleDiagramElements(dDiagram));

    // Test result of a reset
    menuItem.click();
    try {
        // The drop down menu is not closed, so use the Escape key as
        // workaround.
        filtersButton.pressShortcut(KeyStroke.getInstance(IKeyLookup.ESC_NAME));
        SWTBotUtils.waitAllUiEvents();
    } catch (ParseException e) {
    }
    assertEquals(dDiagram.getDescription().getDefaultConcern().getFilters(), dDiagram.getActivatedFilters());
    assertEquals(dDiagram.getDescription().getDefaultConcern(), dDiagram.getCurrentConcern());

}