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