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