Search in sources :

Example 21 with IOutline

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

the class PageWithTableAndPageBeanTest method prepareTest.

private PageWithTable prepareTest() {
    IDesktop desktop = TestEnvironmentClientSession.get().getDesktop();
    assertNotNull(desktop);
    desktop.setAvailableOutlines(Collections.singletonList(new PageWithTableOutline()));
    desktop.setOutline(PageWithTableOutline.class);
    desktop.activateFirstPage();
    IOutline outline = desktop.getOutline();
    assertNotNull(outline);
    assertSame(PageWithTableOutline.class, outline.getClass());
    IPage<?> page = outline.getActivePage();
    assertNotNull(page);
    assertSame(PageWithTable.class, page.getClass());
    return (PageWithTable) page;
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop)

Example 22 with IOutline

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

the class BookmarkUtility method createBookmark.

@SuppressWarnings("squid:S1643")
public static Bookmark createBookmark(IPage<?> page) {
    if (page == null || page.getOutline() == null) {
        return null;
    }
    IBookmarkAdapter bookmarkAdapter = getBookmarkAdapter(page);
    IOutline outline = page.getOutline();
    Bookmark b = new Bookmark();
    b.setIconId(bookmarkAdapter.getIconId());
    // outline
    b.setOutlineClassName(bookmarkAdapter.getOutlineClassName());
    ArrayList<IPage<?>> path = new ArrayList<IPage<?>>();
    ArrayList<String> titleSegments = new ArrayList<String>();
    while (page != null) {
        IBookmarkAdapter currentBookmarkAdapter = getBookmarkAdapter(page);
        path.add(0, page);
        String s = currentBookmarkAdapter.getTitle();
        if (s != null) {
            titleSegments.add(0, s);
        }
        // next
        page = (IPage) page.getParentNode();
    }
    if (bookmarkAdapter.getOutlineTitle() != null) {
        titleSegments.add(0, bookmarkAdapter.getOutlineTitle());
    }
    // title
    int len = 0;
    if (titleSegments.size() > 0) {
        len += titleSegments.get(0).length();
    }
    if (titleSegments.size() > 1) {
        len += titleSegments.get(titleSegments.size() - 1).length();
    }
    for (int i = titleSegments.size() - 1; i > 0; i--) {
        if (len > 200) {
            titleSegments.remove(i);
        } else if (len + titleSegments.get(i).length() <= 200) {
            len += titleSegments.get(i).length();
        } else {
            titleSegments.set(i, "...");
            len = 201;
        }
    }
    StringBuilder buf = new StringBuilder();
    for (String s : titleSegments) {
        if (buf.length() > 0) {
            buf.append(" - ");
        }
        buf.append(s);
    }
    b.setTitle(buf.toString());
    // text
    StringBuilder text = new StringBuilder();
    // add constraints texts
    String prefix = "";
    for (int i = 0; i < path.size(); i++) {
        page = path.get(i);
        IBookmarkAdapter currentBookmarkAdapter = getBookmarkAdapter(page);
        if (i > 0 || outline.isRootNodeVisible()) {
            text.append(prefix + currentBookmarkAdapter.getText());
            text.append("\n");
            if (page instanceof IPageWithTable) {
                IPageWithTable tablePage = (IPageWithTable) page;
                SearchFilter search = tablePage.getSearchFilter();
                if (search != null) {
                    for (String s : search.getDisplayTexts()) {
                        if (s != null) {
                            String indent = prefix + "  ";
                            s = s.trim().replaceAll("[\\n]", "\n" + indent);
                            if (s.length() > 0) {
                                text.append(indent + s);
                                text.append("\n");
                            }
                        }
                    }
                }
            }
            prefix += "  ";
        }
    }
    b.setText(text.toString().trim());
    // path
    for (int i = 0; i < path.size(); i++) {
        page = path.get(i);
        if (page instanceof IPageWithTable) {
            IPageWithTable tablePage = (IPageWithTable) page;
            IPage<?> childPage = null;
            if (i + 1 < path.size()) {
                childPage = path.get(i + 1);
            }
            b.addPathElement(bmStoreTablePage(tablePage, childPage));
        } else if (page instanceof IPageWithNodes) {
            IPageWithNodes nodePage = (IPageWithNodes) page;
            b.addPathElement(bmStoreNodePage(nodePage));
        }
    }
    return b;
}
Also used : IPageWithTable(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithTable) IBookmarkAdapter(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkAdapter) IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) SearchFilter(org.eclipse.scout.rt.shared.services.common.jdbc.SearchFilter) IPage(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPage) Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) IPageWithNodes(org.eclipse.scout.rt.client.ui.desktop.outline.pages.IPageWithNodes)

Example 23 with IOutline

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

the class OutlineDeepLinkHandler method handleImpl.

@Override
public void handleImpl(Matcher matcher) throws DeepLinkException {
    String outlineId = matcher.group(1);
    IOutline selectedOutline = null;
    IDesktop desktop = ClientSessionProvider.currentSession().getDesktop();
    for (IOutline outline : desktop.getAvailableOutlines()) {
        String tmpOutlineId = outlineId(outline);
        if (tmpOutlineId.equals(outlineId)) {
            selectedOutline = outline;
            break;
        }
    }
    if (selectedOutline == null) {
        throw new DeepLinkException("No outline with ID " + outlineId + " found");
    }
    if (!selectedOutline.isVisible() || !selectedOutline.isEnabled()) {
        throw new DeepLinkException("Outline ID " + outlineId + " is not enabled or visible");
    }
    desktop.activateOutline(selectedOutline);
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) IDesktop(org.eclipse.scout.rt.client.ui.desktop.IDesktop)

Example 24 with IOutline

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

the class AbstractDesktop method activateOutline.

@Override
public void activateOutline(IOutline outline) {
    final IOutline newOutline = resolveOutline(outline);
    if (m_outline == newOutline || m_outlineChanging) {
        return;
    }
    try {
        m_outlineChanging = true;
        setOutlineInternal(newOutline);
    } finally {
        m_outlineChanging = false;
    }
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)

Example 25 with IOutline

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

the class AbstractDesktop method initConfig.

protected void initConfig() {
    m_eventHistory = createEventHistory();
    // add convenience observer for event history
    addDesktopListener(new DesktopListener() {

        @Override
        public void desktopChanged(DesktopEvent e) {
            IEventHistory<DesktopEvent> h = getEventHistory();
            if (h != null) {
                h.notifyEvent(e);
            }
        }
    });
    ClientSessionProvider.currentSession().getMemoryPolicy().registerDesktop(this);
    BEANS.get(IDeviceTransformationService.class).install(this);
    initDesktopExtensions();
    setTitle(getConfiguredTitle());
    setCssClass(getConfiguredCssClass());
    setSelectViewTabsKeyStrokesEnabled(getConfiguredSelectViewTabsKeyStrokesEnabled());
    setSelectViewTabsKeyStrokeModifier(getConfiguredSelectViewTabsKeyStrokeModifier());
    setLogoId(getConfiguredLogoId());
    setDisplayStyle(getConfiguredDisplayStyle());
    initDisplayStyle(getDisplayStyle());
    setCacheSplitterPosition(getConfiguredCacheSplitterPosition());
    List<IDesktopExtension> extensions = getDesktopExtensions();
    m_contributionHolder = new ContributionComposite(this);
    // outlines
    OrderedCollection<IOutline> outlines = new OrderedCollection<IOutline>();
    for (IDesktopExtension ext : extensions) {
        try {
            ext.contributeOutlines(outlines);
        } catch (Exception t) {
            LOG.error("contributing outlines by {}", ext, t);
        }
    }
    List<IOutline> contributedOutlines = m_contributionHolder.getContributionsByClass(IOutline.class);
    outlines.addAllOrdered(contributedOutlines);
    // move outlines
    ExtensionUtility.moveModelObjects(outlines);
    setAvailableOutlines(outlines.getOrderedList());
    // actions (keyStroke, menu, viewButton, toolButton)
    List<IAction> actionList = new ArrayList<IAction>();
    for (IDesktopExtension ext : extensions) {
        try {
            ext.contributeActions(actionList);
        } catch (Exception t) {
            LOG.error("contributing actions by {}", ext, t);
        }
    }
    List<IAction> contributedActions = m_contributionHolder.getContributionsByClass(IAction.class);
    actionList.addAll(contributedActions);
    // build complete menu and viewButton lists
    // only top level menus
    OrderedComparator orderedComparator = new OrderedComparator();
    List<IMenu> menuList = new ActionFinder().findActions(actionList, IMenu.class, false);
    ExtensionUtility.moveModelObjects(menuList);
    Collections.sort(menuList, orderedComparator);
    m_menus = menuList;
    List<IViewButton> viewButtonList = new ActionFinder().findActions(actionList, IViewButton.class, false);
    ExtensionUtility.moveModelObjects(viewButtonList);
    Collections.sort(viewButtonList, orderedComparator);
    m_viewButtons = viewButtonList;
    // add dynamic keyStrokes
    List<IKeyStroke> ksList = new ActionFinder().findActions(actionList, IKeyStroke.class, true);
    for (IKeyStroke ks : ksList) {
        try {
            ks.initAction();
        } catch (RuntimeException | PlatformError e) {
            LOG.error("could not initialize key stroke '{}'.", ks, e);
        }
    }
    addKeyStrokes(ksList.toArray(new IKeyStroke[ksList.size()]));
    // init outlines
    for (IOutline o : m_availableOutlines) {
        try {
            o.initTree();
        } catch (Exception e) {
            LOG.error("Could not init outline {}", o, e);
        }
    }
    addPropertyChangeListener(new P_LocalPropertyChangeListener());
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ArrayList(java.util.ArrayList) IEventHistory(org.eclipse.scout.rt.client.ui.IEventHistory) IKeyStroke(org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke) OrderedComparator(org.eclipse.scout.rt.platform.OrderedComparator) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ContributionComposite(org.eclipse.scout.rt.shared.extension.ContributionComposite) OrderedCollection(org.eclipse.scout.rt.platform.util.collection.OrderedCollection) DeepLinkException(org.eclipse.scout.rt.client.deeplink.DeepLinkException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) VetoException(org.eclipse.scout.rt.platform.exception.VetoException) PlatformError(org.eclipse.scout.rt.platform.exception.PlatformError) IViewButton(org.eclipse.scout.rt.client.ui.action.view.IViewButton) IDeviceTransformationService(org.eclipse.scout.rt.client.transformation.IDeviceTransformationService) ActionFinder(org.eclipse.scout.rt.client.ui.action.ActionFinder)

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