Search in sources :

Example 11 with Bookmark

use of org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark 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 12 with Bookmark

use of org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark 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 13 with Bookmark

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

the class BookmarkUtilityTest method testBookmarkKeyLegacy.

/**
 * Tests that Bookmark is converted to String when legacySupport is true
 */
@Test
public void testBookmarkKeyLegacy() {
    Bookmark in = new Bookmark();
    Object out = BookmarkUtility.makeSerializableKey(in, true);
    assertTrue(out instanceof String);
}
Also used : Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) Test(org.junit.Test)

Example 14 with Bookmark

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

the class BookmarkUtilityTest method testBookmarkKey.

/**
 * Tests that Bookmark is converted to String when legacySupport is false
 */
@Test
public void testBookmarkKey() {
    Bookmark in = new Bookmark();
    Object out = BookmarkUtility.makeSerializableKey(in, false);
    assertTrue(out instanceof Bookmark);
}
Also used : Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) Test(org.junit.Test)

Example 15 with Bookmark

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

the class BookmarkServiceTest method testDeleteBookmark.

@Test
public void testDeleteBookmark() throws Exception {
    Bookmark bookmark = new Bookmark();
    bookmark.setText("My Bookmark Text");
    Mockito.when(m_mockDesktop.createBookmark()).thenReturn(bookmark);
    IBookmarkService s = BEANS.get(IBookmarkService.class);
    Assert.assertNotNull(s);
    s.setStartBookmark();
    // Get the Bookmark
    Bookmark startBookmark = s.getStartBookmark();
    assertNotNull(startBookmark);
    // Delete the bookmark
    s.deleteStartBookmark();
    startBookmark = s.getStartBookmark();
    assertNull(startBookmark);
}
Also used : Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) Test(org.junit.Test)

Aggregations

Bookmark (org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark)15 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 BookmarkFolder (org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder)4 IBookmarkService (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)3 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)2 IDesktop (org.eclipse.scout.rt.client.ui.desktop.IDesktop)2 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 IBookmarkAdapter (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkAdapter)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 ITreeVisitor (org.eclipse.scout.rt.client.ui.basic.tree.ITreeVisitor)1 BookmarkForm (org.eclipse.scout.rt.client.ui.desktop.bookmark.BookmarkForm)1 IBookmarkForm (org.eclipse.scout.rt.client.ui.desktop.bookmark.IBookmarkForm)1 IOutline (org.eclipse.scout.rt.client.ui.desktop.outline.IOutline)1