Search in sources :

Example 1 with IBookmarkVisitor

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

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 IBookmarkService (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)1 Bookmark (org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark)1 IBookmarkVisitor (org.eclipse.scout.rt.shared.services.common.bookmark.IBookmarkVisitor)1 ILookupRow (org.eclipse.scout.rt.shared.services.lookup.ILookupRow)1 LookupRow (org.eclipse.scout.rt.shared.services.lookup.LookupRow)1