Search in sources :

Example 1 with IBookmarkForm

use of org.eclipse.scout.rt.client.ui.desktop.bookmark.IBookmarkForm 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)

Aggregations

IBookmarkService (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)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 Bookmark (org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark)1 BookmarkFolder (org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder)1