use of org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService 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.client.services.common.bookmark.IBookmarkService in project scout.rt by eclipse.
the class BookmarkViewForm method refreshFormState.
private void refreshFormState() {
IBookmarkService bmService = BEANS.get(IBookmarkService.class);
getUserBookmarkTreeField().setBookmarkRootFolder(bmService.getBookmarkData().getUserBookmarks());
getUserBookmarkTreeField().populateTree();
}
use of org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService in project scout.rt by eclipse.
the class AbstractBookmarkMenu method handleBookmarksChanged.
protected void handleBookmarksChanged() {
IBookmarkService service = BEANS.get(IBookmarkService.class);
List<IMenu> oldList = getChildActions();
List<IMenu> newList = new ArrayList<IMenu>();
for (IMenu m : oldList) {
if (m.getClass() == AddUserBookmarkMenu.class) {
newList.add(m);
} else if (m.getClass() == AddGlobalBookmarkMenu.class) {
newList.add(m);
} else if (m.getClass() == ManageBookmarksMenu.class) {
newList.add(m);
} else if (m.getClass() == StartBookmarkMenu.class) {
newList.add(m);
} else if (m.getClass() == Separator1Menu.class) {
newList.add(m);
} else {
// ignore the rest
break;
}
}
// add global bookmarks
newList.add(new MenuSeparator());
addBookmarkTreeInternal(service.getBookmarkData().getGlobalBookmarks(), newList);
// add user bookmarks
newList.add(new MenuSeparator());
addBookmarkTreeInternal(service.getBookmarkData().getUserBookmarks(), newList);
setChildActions(newList);
}
use of org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService 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();
}
}
}
Aggregations