Search in sources :

Example 1 with BookmarkFolder

use of org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder in project scout.rt by eclipse.

the class AbstractBookmarkMenu method addBookmarkTreeInternal.

protected void addBookmarkTreeInternal(BookmarkFolder folder, List<IMenu> actionList) {
    for (BookmarkFolder f : folder.getFolders()) {
        IMenu group = new MenuSeparator();
        group.setSeparator(false);
        group.setText(f.getTitle());
        group.setIconId(f.getIconId());
        List<IMenu> childActionList = new ArrayList<IMenu>();
        addBookmarkTreeInternal(f, childActionList);
        group.setChildActions(childActionList);
        actionList.add(group);
    }
    List<IMenu> newActions = new ArrayList<>();
    for (Bookmark b : folder.getBookmarks()) {
        newActions.add(new ActivateBookmarkMenu(b));
    }
    ActionUtility.initActions(newActions);
    actionList.addAll(newActions);
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) BookmarkFolder(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder) ArrayList(java.util.ArrayList) AbstractMenuSeparator(org.eclipse.scout.rt.client.ui.action.menu.AbstractMenuSeparator) MenuSeparator(org.eclipse.scout.rt.client.ui.action.menu.MenuSeparator)

Example 2 with BookmarkFolder

use of org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder in project scout.rt by eclipse.

the class AbstractBookmarkTreeField method refreshBookmarkModel.

/**
 * Only some values have changed, just save the model
 */
private void refreshBookmarkModel() {
    getTree().visitTree(new ITreeVisitor() {

        @Override
        public boolean visit(ITreeNode node) {
            BookmarkFolder bmFolder = null;
            if (node == getTree().getRootNode()) {
                bmFolder = getBookmarkRootFolder();
            } else if (isFolderNode(node)) {
                bmFolder = (BookmarkFolder) node.getCell().getValue();
            }
            if (bmFolder != null) {
                bmFolder.getFolders().clear();
                bmFolder.getBookmarks().clear();
                for (ITreeNode n : node.getChildNodes()) {
                    if (isFolderNode(n)) {
                        bmFolder.getFolders().add((BookmarkFolder) n.getCell().getValue());
                    } else if (isBookmarkNode(n)) {
                        bmFolder.getBookmarks().add((Bookmark) n.getCell().getValue());
                    }
                }
            }
            return true;
        }
    });
    // save
    BEANS.get(IBookmarkService.class).storeBookmarks();
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) BookmarkFolder(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder) IBookmarkService(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)

Example 3 with BookmarkFolder

use of org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder in project scout.rt by eclipse.

the class AbstractBookmarkTreeField method rebuildBookmarkModel.

/**
 * The structure of the folders has changed, completely rebuild the model
 */
private void rebuildBookmarkModel() {
    getTree().visitTree(new ITreeVisitor() {

        @Override
        public boolean visit(ITreeNode node) {
            BookmarkFolder bmFolder = null;
            if (node == getTree().getRootNode()) {
                bmFolder = getBookmarkRootFolder();
            } else if (isFolderNode(node)) {
                bmFolder = (BookmarkFolder) node.getCell().getValue();
            }
            if (bmFolder != null) {
                bmFolder.getFolders().clear();
                bmFolder.getBookmarks().clear();
                // sort folders
                ArrayList<BookmarkFolder> folderList = new ArrayList<BookmarkFolder>();
                for (ITreeNode n : node.getChildNodes()) {
                    if (isFolderNode(n)) {
                        BookmarkFolder f = (BookmarkFolder) n.getCell().getValue();
                        folderList.add(f);
                    }
                }
                Collections.sort(folderList, new Comparator<BookmarkFolder>() {

                    @Override
                    public int compare(BookmarkFolder f1, BookmarkFolder f2) {
                        return StringUtility.compareIgnoreCase(f1.getTitle(), f2.getTitle());
                    }
                });
                bmFolder.getFolders().addAll(folderList);
                for (ITreeNode n : node.getChildNodes()) {
                    if (isBookmarkNode(n)) {
                        bmFolder.getBookmarks().add((Bookmark) n.getCell().getValue());
                    }
                }
            }
            return true;
        }
    });
    // save
    BEANS.get(IBookmarkService.class).storeBookmarks();
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) BookmarkFolder(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder) ArrayList(java.util.ArrayList) IBookmarkService(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService) ITreeVisitor(org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor) Comparator(java.util.Comparator)

Example 4 with BookmarkFolder

use of org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder in project scout.rt by eclipse.

the class AbstractBookmarkStorageService method readBookmarks.

protected BookmarkData readBookmarks(Object userId) {
    BookmarkData model = new BookmarkData();
    // user
    BookmarkFolder folder = readUserFolder(userId);
    if (folder != null) {
        model.setUserBookmarks(folder);
    }
    // global
    if (ACCESS.check(new ReadGlobalBookmarkPermission())) {
        folder = readGlobalFolder();
        if (folder != null) {
            model.setGlobalBookmarks(folder);
        }
    }
    return model;
}
Also used : BookmarkData(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkData) BookmarkFolder(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder) ReadGlobalBookmarkPermission(org.eclipse.scout.rt.shared.security.ReadGlobalBookmarkPermission)

Example 5 with BookmarkFolder

use of org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder in project scout.rt by eclipse.

the class AbstractSqlBookmarkStorageService method readGlobalFolder.

@Override
protected BookmarkFolder readGlobalFolder() {
    Object[][] data = execSelectGlobalBookmarkFolder();
    for (int r = 0; r < data.length; r++) {
        Object[] row = data[r];
        long id = ((Number) row[0]).longValue();
        try {
            BookmarkFolder folder = execResolveBookmarkFolder(id, row[1]);
            if (folder != null) {
                folder.setId(id);
                return folder;
            }
        } catch (RuntimeException p) {
            LOG.warn("invalid bookmark folder binary data for id={}: {}", id, p);
        }
    }
    return null;
}
Also used : BookmarkFolder(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder)

Aggregations

BookmarkFolder (org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder)12 Bookmark (org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark)4 IBookmarkService (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)3 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)3 ArrayList (java.util.ArrayList)2 ITreeVisitor (org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)2 Comparator (java.util.Comparator)1 AbstractMenuSeparator (org.eclipse.scout.rt.client.ui.action.menu.AbstractMenuSeparator)1 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)1 MenuSeparator (org.eclipse.scout.rt.client.ui.action.menu.MenuSeparator)1 BookmarkForm (org.eclipse.scout.rt.client.ui.desktop.bookmark.BookmarkForm)1 IBookmarkForm (org.eclipse.scout.rt.client.ui.desktop.bookmark.IBookmarkForm)1 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)1 ReadGlobalBookmarkPermission (org.eclipse.scout.rt.shared.security.ReadGlobalBookmarkPermission)1 BookmarkData (org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkData)1