Search in sources :

Example 6 with BookmarkFolder

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

the class AbstractSqlBookmarkStorageService method readUserFolder.

@Override
protected BookmarkFolder readUserFolder(Object userId) {
    Object[][] data = execSelectUserBookmarkFolder(userId);
    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)

Example 7 with BookmarkFolder

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

the class AbstractBookmarkMenu method createNewBookmark.

protected void createNewBookmark(int kind) {
    Bookmark b = ClientSessionProvider.currentSession().getDesktop().createBookmark();
    if (b != null) {
        IBookmarkService service = BEANS.get(IBookmarkService.class);
        b.setKind(kind);
        IBookmarkForm form = null;
        if (getConfiguredBookmarkForm() != null) {
            try {
                form = getConfiguredBookmarkForm().newInstance();
            } catch (Exception e) {
                BEANS.get(ExceptionHandler.class).handle(new ProcessingException("error creating instance of class '" + getConfiguredBookmarkForm().getName() + "'.", e));
            }
        }
        if (form == null) {
            form = new BookmarkForm();
        }
        if (kind == Bookmark.GLOBAL_BOOKMARK) {
            form.setBookmarkRootFolder(service.getBookmarkData().getGlobalBookmarks());
        } else if (kind == Bookmark.USER_BOOKMARK) {
            form.setBookmarkRootFolder(service.getBookmarkData().getUserBookmarks());
        }
        form.setBookmark(b);
        form.startNew();
        form.waitFor();
        if (form.isFormStored()) {
            b.setTitle(form.getBookmark().getTitle());
            b.setKeyStroke(form.getBookmark().getKeyStroke());
            b.setOrder(form.getBookmark().getOrder());
            BookmarkFolder folder = form.getFolder();
            if (folder == null) {
                folder = form.getBookmarkRootFolder();
            }
            folder.getBookmarks().add(b);
            service.storeBookmarks();
        }
    }
}
Also used : Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) BookmarkFolder(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder) BookmarkForm(org.eclipse.scout.rt.client.ui.desktop.bookmark.BookmarkForm) IBookmarkForm(org.eclipse.scout.rt.client.ui.desktop.bookmark.IBookmarkForm) IBookmarkForm(org.eclipse.scout.rt.client.ui.desktop.bookmark.IBookmarkForm) IBookmarkService(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 8 with BookmarkFolder

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

the class AbstractBookmarkTreeField method getParentBookmarkFolder.

private BookmarkFolder getParentBookmarkFolder(ITreeNode node) {
    BookmarkFolder folder = getBookmarkRootFolder();
    ITreeNode parentNode = node.getParentNode();
    if (isFolderNode(parentNode)) {
        folder = (BookmarkFolder) parentNode.getCell().getValue();
    }
    return folder;
}
Also used : ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) BookmarkFolder(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder)

Example 9 with BookmarkFolder

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

the class AbstractBookmarkTreeField method populateFolderContentRec.

/**
 * @return true if populate of delta was successful
 */
private void populateFolderContentRec(ITreeNode parent, BookmarkFolder newParent) {
    for (BookmarkFolder newFolder : newParent.getFolders()) {
        FolderNode newNode = new FolderNode(newFolder);
        getTree().addChildNode(parent, newNode);
        populateFolderContentRec(newNode, newFolder);
    }
    for (Bookmark b : newParent.getBookmarks()) {
        BookmarkNode newNode = new BookmarkNode();
        newNode.getCellForUpdate().setValue(b);
        getTree().addChildNode(parent, newNode);
    }
}
Also used : Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) BookmarkFolder(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder)

Example 10 with BookmarkFolder

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

the class AbstractBookmarkStorageService method storeBookmarkData.

@Override
public BookmarkData storeBookmarkData(BookmarkData newData) {
    Object userId = getCurrentUserId();
    BookmarkFolder existingUserFolder = readUserFolder(userId);
    if (existingUserFolder != null) {
        BookmarkFolder existingSpoolFolder = existingUserFolder.getFolder(Bookmark.SPOOL_FOLDER_NAME);
        if (existingSpoolFolder != null) {
            newData.getUserBookmarks().getFolders().add(existingSpoolFolder);
            processSpoolToInbox(newData.getUserBookmarks());
        }
    }
    writeBookmarks(newData, userId);
    return readBookmarks(userId);
}
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