Search in sources :

Example 1 with Bookmark

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

the class KeyStrokeLookupCall method execCreateLookupRows.

@Override
protected List<ILookupRow<String>> execCreateLookupRows() {
    final HashMap<String, Integer> keyStrokesUpper = new HashMap<String, Integer>();
    // build possible keyStrokes
    for (int i = 1; i <= 12; i++) {
        keyStrokesUpper.put("SHIFT-F" + i, Integer.valueOf(i));
    }
    // remove used keyStrokes
    IBookmarkService service = BEANS.get(IBookmarkService.class);
    IBookmarkVisitor v = new IBookmarkVisitor() {

        @Override
        public boolean visitFolder(List<BookmarkFolder> path) {
            return true;
        }

        @Override
        public boolean visitBookmark(List<BookmarkFolder> path, Bookmark b) {
            String keyStroke = b.getKeyStroke();
            if (keyStroke != null) {
                if (m_currentKeyStroke != null && m_currentKeyStroke.equalsIgnoreCase(keyStroke)) {
                // keep it
                } else {
                    keyStrokesUpper.remove(keyStroke.toUpperCase(Locale.ENGLISH));
                }
            }
            return true;
        }
    };
    service.getBookmarkData().getGlobalBookmarks().visit(v);
    service.getBookmarkData().getUserBookmarks().visit(v);
    // 
    TreeSet<Integer> availableNumbers = new TreeSet<Integer>(keyStrokesUpper.values());
    ArrayList<ILookupRow<String>> resultList = new ArrayList<ILookupRow<String>>();
    for (Integer i : availableNumbers) {
        String key = "Shift-F" + i;
        String text = "Shift-F" + i;
        ILookupRow<String> row = new LookupRow<String>(key, text);
        resultList.add(row);
    }
    return resultList;
}
Also used : ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) LookupRow(org.eclipse.scout.rt.shared.services.lookup.LookupRow) ILookupRow(org.eclipse.scout.rt.shared.services.lookup.ILookupRow) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) IBookmarkVisitor(org.eclipse.scout.rt.shared.services.common.bookmark.IBookmarkVisitor) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) List(java.util.List) IBookmarkService(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)

Example 2 with Bookmark

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

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

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

the class BookmarkServiceTest method testSetStartBookmark.

@Test
public void testSetStartBookmark() 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();
    assertEquals("Kind", Bookmark.USER_BOOKMARK, startBookmark.getKind());
    assertEquals("Text", "My Bookmark Text", startBookmark.getText());
}
Also used : Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) Test(org.junit.Test)

Example 5 with Bookmark

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

the class BookmarkService method getStartBookmark.

@Override
public Bookmark getStartBookmark() {
    ServiceState state = getServiceState();
    Bookmark b = state.m_model.getUserBookmarks().getStartupBookmark();
    if (b == null) {
        b = state.m_model.getGlobalBookmarks().getStartupBookmark();
    }
    return b;
}
Also used : Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark)

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