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;
}
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);
}
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;
}
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);
}
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));
}
Aggregations