use of org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder 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.BookmarkFolder in project scout.rt by eclipse.
the class AbstractBookmarkTreeField method refreshBookmarkModel.
/**
* Only some values have changed, just save the model
*/
private void refreshBookmarkModel() {
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();
for (ITreeNode n : node.getChildNodes()) {
if (isFolderNode(n)) {
bmFolder.getFolders().add((BookmarkFolder) n.getCell().getValue());
} else 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.BookmarkFolder 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.BookmarkFolder in project scout.rt by eclipse.
the class AbstractBookmarkStorageService method readBookmarks.
protected BookmarkData readBookmarks(Object userId) {
BookmarkData model = new BookmarkData();
// user
BookmarkFolder folder = readUserFolder(userId);
if (folder != null) {
model.setUserBookmarks(folder);
}
// global
if (ACCESS.check(new ReadGlobalBookmarkPermission())) {
folder = readGlobalFolder();
if (folder != null) {
model.setGlobalBookmarks(folder);
}
}
return model;
}
use of org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder in project scout.rt by eclipse.
the class AbstractSqlBookmarkStorageService method readGlobalFolder.
@Override
protected BookmarkFolder readGlobalFolder() {
Object[][] data = execSelectGlobalBookmarkFolder();
for (int r = 0; r < data.length; r++) {
Object[] row = data[r];
long id = ((Number) row[0]).longValue();
try {
BookmarkFolder folder = execResolveBookmarkFolder(id, row[1]);
if (folder != null) {
folder.setId(id);
return folder;
}
} catch (RuntimeException p) {
LOG.warn("invalid bookmark folder binary data for id={}: {}", id, p);
}
}
return null;
}
Aggregations