Search in sources :

Example 1 with IBookmarkService

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

Example 2 with IBookmarkService

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();
}
Also used : IBookmarkService(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)

Example 3 with IBookmarkService

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);
}
Also used : IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) ArrayList(java.util.ArrayList) AbstractMenuSeparator(org.eclipse.scout.rt.client.ui.action.menu.AbstractMenuSeparator) MenuSeparator(org.eclipse.scout.rt.client.ui.action.menu.MenuSeparator) IBookmarkService(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)

Example 4 with IBookmarkService

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();
        }
    }
}
Also used : Bookmark(org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark) BookmarkFolder(org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder) BookmarkForm(org.eclipse.scout.rt.client.ui.desktop.bookmark.BookmarkForm) IBookmarkForm(org.eclipse.scout.rt.client.ui.desktop.bookmark.IBookmarkForm) IBookmarkForm(org.eclipse.scout.rt.client.ui.desktop.bookmark.IBookmarkForm) IBookmarkService(org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Aggregations

IBookmarkService (org.eclipse.scout.rt.client.services.common.bookmark.IBookmarkService)4 ArrayList (java.util.ArrayList)2 Bookmark (org.eclipse.scout.rt.shared.services.common.bookmark.Bookmark)2 HashMap (java.util.HashMap)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 AbstractMenuSeparator (org.eclipse.scout.rt.client.ui.action.menu.AbstractMenuSeparator)1 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)1 MenuSeparator (org.eclipse.scout.rt.client.ui.action.menu.MenuSeparator)1 BookmarkForm (org.eclipse.scout.rt.client.ui.desktop.bookmark.BookmarkForm)1 IBookmarkForm (org.eclipse.scout.rt.client.ui.desktop.bookmark.IBookmarkForm)1 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)1 BookmarkFolder (org.eclipse.scout.rt.shared.services.common.bookmark.BookmarkFolder)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