Search in sources :

Example 1 with TableWithNonDisplayableMenu

use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu in project scout.rt by eclipse.

the class JsonTableTest method testMenuDisposalOnPropertyChangeWithNonDisplayableMenu.

/**
 * Tests whether it is possible to dispose (or replace) menus if at least one menu is not displayable.<br>
 */
@Test
public void testMenuDisposalOnPropertyChangeWithNonDisplayableMenu() throws JSONException {
    ITable table = new TableWithNonDisplayableMenu();
    table.initTable();
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    // ----------
    DisplayableMenu displayableMenu = table.getMenuByClass(TableWithNonDisplayableMenu.DisplayableMenu.class);
    NonDisplayableMenu NonDisplayableMenu = table.getMenuByClass(TableWithNonDisplayableMenu.NonDisplayableMenu.class);
    assertNull(jsonTable.getAdapter(NonDisplayableMenu));
    assertNotNull(jsonTable.getAdapter(displayableMenu));
    assertTrue(jsonTable.getAdapter(displayableMenu).isInitialized());
    table.getContextMenu().removeChildAction(NonDisplayableMenu);
    table.getContextMenu().removeChildAction(displayableMenu);
    assertNull(jsonTable.getAdapter(NonDisplayableMenu));
    assertNull(jsonTable.getAdapter(displayableMenu));
}
Also used : TableWithNonDisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu) NonDisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu.NonDisplayableMenu) DisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu.DisplayableMenu) TableWithNonDisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu) NonDisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu.NonDisplayableMenu) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) TableWithNonDisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu) Test(org.junit.Test)

Example 2 with TableWithNonDisplayableMenu

use of org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu in project scout.rt by eclipse.

the class JsonTableTest method testDontSendNonDisplayableMenus.

/**
 * Tests whether non displayable menus are sent.
 * <p>
 * This reduces response size and also leverages security because the menus are never visible to the user, not even
 * with the dev tools of the browser
 */
@Test
public void testDontSendNonDisplayableMenus() throws Exception {
    TableWithNonDisplayableMenu table = new TableWithNonDisplayableMenu();
    table.initTable();
    JsonTable<ITable> jsonTable = UiSessionTestUtility.newJsonAdapter(m_uiSession, table, null);
    jsonTable.toJson();
    // ----------
    JsonMenu<IMenu> jsonDisplayableMenu = jsonTable.getAdapter(table.getMenuByClass(TableWithNonDisplayableMenu.DisplayableMenu.class));
    JsonMenu<IMenu> jsonNonDisplayableMenu = jsonTable.getAdapter(table.getMenuByClass(TableWithNonDisplayableMenu.NonDisplayableMenu.class));
    // Adapter for NonDisplayableMenu must not exist
    assertNull(jsonNonDisplayableMenu);
    // Json response must not contain NonDisplayableMenu
    JSONObject json = jsonTable.toJson();
    JSONArray jsonMenus = json.getJSONArray("menus");
    assertEquals(1, jsonMenus.length());
    assertEquals(jsonDisplayableMenu.getId(), jsonMenus.get(0));
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) TableWithNonDisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu) NonDisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu.NonDisplayableMenu) DisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu.DisplayableMenu) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) TableWithNonDisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu) NonDisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu.NonDisplayableMenu) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) TableWithNonDisplayableMenu(org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu) Test(org.junit.Test)

Aggregations

ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 TableWithNonDisplayableMenu (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu)2 DisplayableMenu (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu.DisplayableMenu)2 NonDisplayableMenu (org.eclipse.scout.rt.ui.html.json.table.fixtures.TableWithNonDisplayableMenu.NonDisplayableMenu)2 Test (org.junit.Test)2 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1