Search in sources :

Example 41 with IOutline

use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.

the class JsonTableFieldTest method createTablePageAndSelectNode.

private IPageWithTable<?> createTablePageAndSelectNode() {
    TablePage tablePage = new TablePage(1, new TablePage.NodePageWithFormFactory());
    List<IPage<?>> pages = new ArrayList<IPage<?>>();
    pages.add(tablePage);
    IOutline outline = new Outline(pages);
    outline.selectNode(tablePage);
    return tablePage;
}
Also used : IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) TablePage(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.TablePage) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) Outline(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline) JsonOutline(org.eclipse.scout.rt.ui.html.json.desktop.JsonOutline) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)

Example 42 with IOutline

use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.

the class AbstractPageField method setPageInternal.

private void setPageInternal(PAGE page) {
    if (m_page == page) {
        return;
    }
    // remove old
    getDetailFormField().setInnerForm(null);
    getTableField().setTable(null, true);
    getSearchFormField().setInnerForm(null);
    if (m_page != null) {
        m_outline.disposeTree();
        m_outline = null;
        m_page = null;
    }
    // add new
    PAGE oldPage = m_page;
    m_page = page;
    if (m_page != null) {
        m_outline = new SimpleOutline();
        m_outline.setRootNode(m_page);
        m_outline.selectNode(m_page);
        m_outline.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent e) {
                try {
                    if (e.getPropertyName().equals(IOutline.PROP_DETAIL_FORM)) {
                        getDetailFormField().setInnerForm(((IOutline) e.getSource()).getDetailForm());
                    } else if (e.getPropertyName().equals(IOutline.PROP_DETAIL_TABLE)) {
                        getTableField().setTable(detachSearchFormTableControl(((IOutline) e.getSource()).getDetailTable()), true);
                    } else if (e.getPropertyName().equals(IOutline.PROP_SEARCH_FORM)) {
                        getSearchFormField().setInnerForm(((IOutline) e.getSource()).getSearchForm());
                    }
                } catch (RuntimeException | PlatformError ex) {
                    BEANS.get(ExceptionHandler.class).handle(ex);
                }
            }
        });
        // Detail Form
        getDetailFormField().setInnerForm(m_outline.getDetailForm());
        getTableField().setTable(detachSearchFormTableControl(m_outline.getDetailTable()), true);
        // Search Form
        getSearchFormField().setInnerForm(m_outline.getSearchForm());
    }
    interceptPageChanged(oldPage, m_page);
}
Also used : ExceptionHandler(org.eclipse.scout.rt.platform.exception.ExceptionHandler) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)

Example 43 with IOutline

use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.

the class JsonDesktop method toJson.

@Override
public JSONObject toJson() {
    JSONObject json = super.toJson();
    json.put(IDesktop.PROP_DISPLAY_STYLE, getModel().getDisplayStyle());
    putAdapterIdProperty(json, IDesktop.PROP_ACTIVE_FORM, getModel().getActiveForm());
    putAdapterIdsProperty(json, "views", getModel().getViews(getModel()));
    putAdapterIdsProperty(json, "dialogs", getModel().getDialogs(getModel(), false));
    putAdapterIdsProperty(json, "messageBoxes", getModel().getMessageBoxes(getModel()));
    putAdapterIdsProperty(json, "notifications", getModel().getNotifications());
    putAdapterIdsProperty(json, "fileChoosers", getModel().getFileChoosers(getModel()));
    putAdapterIdsProperty(json, "menus", getModel().getMenus(), new DisplayableActionFilter<IMenu>());
    putAdapterIdsProperty(json, "addOns", getModel().getAddOns());
    putAdapterIdsProperty(json, "keyStrokes", getModel().getKeyStrokes(), new DisplayableActionFilter<IKeyStroke>());
    putAdapterIdsProperty(json, "viewButtons", getModel().getViewButtons(), new DisplayableActionFilter<IViewButton>());
    putAdapterIdProperty(json, "outline", getModel().getOutline(), new DisplayableOutlineFilter<IOutline>());
    if (getModel().getSelectedViews(getModel()).size() > 0) {
        putAdapterIdsProperty(json, "selectedViewTabs", getModel().getSelectedViews(getModel()));
    }
    return json;
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) JSONObject(org.json.JSONObject) IViewButton(org.eclipse.scout.rt.client.ui.action.view.IViewButton) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)

Example 44 with IOutline

use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.

the class JsonDesktopTest method testDontSendNonDisplayableOutline.

/**
 * Tests whether non displayable outline is 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 testDontSendNonDisplayableOutline() throws Exception {
    IDesktop desktop = new DesktopWithNonDisplayableOutline();
    desktop.initDesktop();
    desktop.setOutline(NonDisplayableOutlineWithOneNode.class);
    JsonDesktop<IDesktop> jsonDesktop = createJsonDesktop(desktop);
    JsonOutline<IOutline> jsonNonDisplayableOutline = jsonDesktop.getAdapter(desktop.findOutline(NonDisplayableOutlineWithOneNode.class));
    // Adapter for NonDisplayableMenu must not exist
    assertNull(jsonNonDisplayableOutline);
    // Json response must not contain outline
    JSONObject json = jsonDesktop.toJson();
    String outlineId = json.optString("outline", null);
    assertNull(outlineId);
}
Also used : NonDisplayableOutlineWithOneNode(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.NonDisplayableOutlineWithOneNode) JSONObject(org.json.JSONObject) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) DesktopWithNonDisplayableOutline(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.DesktopWithNonDisplayableOutline) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop) Test(org.junit.Test) JsonAdapterRegistryTest(org.eclipse.scout.rt.ui.html.json.JsonAdapterRegistryTest)

Example 45 with IOutline

use of org.eclipse.scout.rt.client.ui.desktop.outline.IOutline in project scout.rt by eclipse.

the class JsonOutlineTest method testDontSendNonDisplayableMenus.

/**
 * Tests whether only header menus are sent.
 * <p>
 * Other menus are never displayed, no need to send them.
 */
@Test
public void testDontSendNonDisplayableMenus() throws Exception {
    List<IPage<?>> pages = new ArrayList<IPage<?>>();
    IOutline outline = new Outline(pages);
    IMenu headerMenu = new HeaderMenu();
    headerMenu.initAction();
    IMenu nonHeaderMenu = new NonHeaderMenu();
    nonHeaderMenu.initAction();
    outline.getContextMenu().addChildAction(headerMenu);
    outline.getContextMenu().addChildAction(nonHeaderMenu);
    JsonOutline<IOutline> jsonOutline = UiSessionTestUtility.newJsonAdapter(m_uiSession, outline, null);
    // ----------
    JsonMenu<IMenu> jsonHeaderMenu = jsonOutline.getAdapter(headerMenu);
    JsonMenu<IMenu> jsonNonHeaderMenu = jsonOutline.getAdapter(nonHeaderMenu);
    // Adapter for NonHeaderMenu must not exist
    assertNull(jsonNonHeaderMenu);
    // Json response must not contain NonHeaderMenu
    JSONObject json = jsonOutline.toJson();
    JSONArray jsonMenus = json.getJSONArray("menus");
    assertEquals(1, jsonMenus.length());
    assertEquals(jsonHeaderMenu.getId(), jsonMenus.get(0));
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) JSONObject(org.json.JSONObject) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) Outline(org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) JsonTreeTest(org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest) Test(org.junit.Test)

Aggregations

IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)49 Test (org.junit.Test)24 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)18 IPage (org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage)12 ArrayList (java.util.ArrayList)11 Outline (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.Outline)9 JsonTreeTest (org.eclipse.scout.rt.ui.html.json.tree.JsonTreeTest)7 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)5 IForm (org.eclipse.scout.rt.client.ui.form.IForm)5 JSONObject (org.json.JSONObject)5 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)4 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)4 TablePage (org.eclipse.scout.rt.ui.html.json.desktop.fixtures.TablePage)4 List (java.util.List)3 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)3 IViewButton (org.eclipse.scout.rt.client.ui.action.view.IViewButton)3 ITableField (org.eclipse.scout.rt.client.ui.form.fields.tablefield.ITableField)3 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)3 VetoException (org.eclipse.scout.rt.platform.exception.VetoException)3 JsonOutline (org.eclipse.scout.rt.ui.html.json.desktop.JsonOutline)3