Search in sources :

Example 11 with IOutline

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

the class OutlineDeepLinkHandlerTest method addOutlineToDesktop.

/**
 * Adds an outline to the desktop by reflection.
 */
private void addOutlineToDesktop(IDesktop desktop, IOutline outline) throws ReflectiveOperationException {
    AbstractDesktop ad = (AbstractDesktop) desktop;
    Field field = AbstractDesktop.class.getDeclaredField("m_availableOutlines");
    field.setAccessible(true);
    @SuppressWarnings("unchecked") List<IOutline> outlines = (List<IOutline>) field.get(ad);
    outlines.add(outline);
}
Also used : AbstractDesktop(org.eclipse.scout.rt.client.ui.desktop.AbstractDesktop) Field(java.lang.reflect.Field) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) List(java.util.List)

Example 12 with IOutline

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

the class OutlineDeepLinkHandlerTest method testCreateBrowserHistory.

@Test
public void testCreateBrowserHistory() {
    OutlineDeepLinkHandler handler = new OutlineDeepLinkHandler();
    IOutline outline = new P_OutlineFoo();
    BrowserHistoryEntry entry = handler.createBrowserHistoryEntry(outline);
    assertEquals("outline-04446", entry.getDeepLinkPath());
    // title of outline is added to title of desktop (this string is used for the title in the browser-window)
    assertEquals("Test Environment Application - Foo", entry.getTitle());
    // title of outline is used to create the (i)nfo URL parameter
    assertEquals("./?dl=outline-04446&i=foo", entry.getPath());
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) BrowserHistoryEntry(org.eclipse.scout.rt.client.ui.desktop.BrowserHistoryEntry) Test(org.junit.Test)

Example 13 with IOutline

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

the class BookmarkUtility method createBookmark.

public static Bookmark createBookmark(IDesktop desktop) {
    IOutline outline = desktop.getOutline();
    if (outline == null) {
        return null;
    }
    IPage<?> activePage = outline.getActivePage();
    return createBookmark(activePage);
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)

Example 14 with IOutline

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

the class BookmarkUtility method activateBookmark.

/**
 * Load a {@link Bookmark} on the specified {@link IDesktop} model.
 * <p>
 * First the specific {@link Bookmark#getOutlineClassName()} is evaluated and, if activateOutline is true, activated.
 * Afterwards every page from the {@link Bookmark#getPath()} will be selected (respecting the
 * {@link AbstractPageState}).
 * </p>
 * Finally the path will be expanded. Possible exceptions might occur if no outline is set in the {@link Bookmark} or
 * the outline is not available.
 */
public static void activateBookmark(IDesktop desktop, Bookmark bm, boolean activateOutline) {
    if (bm.getOutlineClassName() == null) {
        return;
    }
    IOutline outline = BookmarkUtility.resolveOutline(desktop.getAvailableOutlines(), bm.getOutlineClassName());
    if (outline == null) {
        throw new ProcessingException("outline '" + bm.getOutlineClassName() + "' was not found");
    }
    if (!(outline.isVisible() && outline.isEnabled())) {
        throw new VetoException(TEXTS.get("BookmarkActivationFailedOutlineNotAvailable", outline.getTitle()));
    }
    if (activateOutline) {
        desktop.activateOutline(outline);
    }
    try {
        outline.setTreeChanging(true);
        // 
        IPage<?> parentPage = outline.getRootPage();
        boolean pathFullyRestored = true;
        List<AbstractPageState> path = bm.getPath();
        AbstractPageState parentPageState = path.get(0);
        boolean resetViewAndWarnOnFail = bm.getId() != 0;
        for (int i = 1; i < path.size(); i++) {
            // try to find correct child page (next parentPage)
            IPage<?> childPage = null;
            AbstractPageState childState = path.get(i);
            if (parentPageState instanceof TablePageState) {
                TablePageState tablePageState = (TablePageState) parentPageState;
                if (parentPage instanceof IPageWithTable) {
                    IPageWithTable tablePage = (IPageWithTable) parentPage;
                    childPage = bmLoadTablePage(tablePage, tablePageState, false, resetViewAndWarnOnFail);
                }
            } else if (parentPageState instanceof NodePageState) {
                NodePageState nodePageState = (NodePageState) parentPageState;
                if (parentPage instanceof IPageWithNodes) {
                    IPageWithNodes nodePage = (IPageWithNodes) parentPage;
                    childPage = bmLoadNodePage(nodePage, nodePageState, childState, resetViewAndWarnOnFail);
                }
            }
            // next
            if (childPage != null) {
                parentPage = childPage;
                parentPageState = childState;
            } else if (i < path.size()) {
                pathFullyRestored = false;
                break;
            }
        }
        if (pathFullyRestored) {
            if (parentPageState instanceof TablePageState && parentPage instanceof IPageWithTable) {
                bmLoadTablePage((IPageWithTable) parentPage, (TablePageState) parentPageState, true, resetViewAndWarnOnFail);
            } else if (parentPage instanceof IPageWithNodes) {
                bmLoadNodePage((IPageWithNodes) parentPage, (NodePageState) parentPageState, null, resetViewAndWarnOnFail);
            }
        }
        /*
       * Expansions of the restored tree path
       */
        IPage<?> p = parentPage;
        // last element
        if (pathFullyRestored && parentPageState.isExpanded() != null) {
            p.setExpanded(parentPageState.isExpanded());
        } else {
            if (!(p instanceof IPageWithTable)) {
                p.setExpanded(true);
            }
        }
        // ancestor elements
        p = p.getParentPage();
        while (p != null) {
            p.setExpanded(true);
            p = p.getParentPage();
        }
        outline.selectNode(parentPage, false);
    } finally {
        outline.setTreeChanging(false);
    }
}
Also used : VetoException(org.eclipse.scout.rt.platform.exception.VetoException) AbstractPageState(org.eclipse.scout.rt.shared.services.common.bookmark.AbstractPageState) IPageWithTable(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithTable) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IPageWithNodes(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithNodes) NodePageState(org.eclipse.scout.rt.shared.services.common.bookmark.NodePageState) TablePageState(org.eclipse.scout.rt.shared.services.common.bookmark.TablePageState) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 15 with IOutline

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

the class SmallMemoryPolicy method beforeTablePageLoadData.

/**
 * clear table before loading new data, thus disabling "replaceRow" mechanism but saving memory
 */
@Override
public void beforeTablePageLoadData(IPageWithTable<?> page) {
    // make sure inactive outlines have no selection that "keeps" the pages
    IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    for (IOutline o : desktop.getAvailableOutlines()) {
        if (o != desktop.getOutline()) {
            o.selectNode(null);
        }
    }
    desktop.releaseUnusedPages();
    if (page.getTable() != null) {
        page.getTable().discardAllRows();
    }
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop)

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