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();
}
}
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations