Package org.locationtech.udig.bookmarks

Examples of org.locationtech.udig.bookmarks.Bookmark


    @Test
    public void testAddBookmark() {
        Collection<IBookmark> bookmarks = service.getBookmarks();
        assertTrue(bookmarks.isEmpty());
       
        bookmark = new Bookmark(referencedEnvelope, mapID, "Test Bookmark 1");
        service.addBookmark(bookmark);
        bookmarks = service.getBookmarks();
        assertEquals(1, bookmarks.size());
       
        Bookmark bookmark2 = new Bookmark(referencedEnvelope, mapID, "Test Bookmark 1");
        service.addBookmark(bookmark2);
        bookmarks = service.getBookmarks();
        assertEquals(2, bookmarks.size());
       
    }
View Full Code Here


                        if (MessageDialog
                                .openConfirm(
                                        Display.getCurrent().getActiveShell(),
                                        Messages.BookmarkAction_dialogtitle_removebookmark,
                                        Messages.BookmarkAction_dialogprompt_removebookmark)) {
                            Bookmark bookmark = (Bookmark) selection
                                    .getFirstElement();
                            if (bmManager == null) {
                                bmManager = BookmarksPlugin
                                        .getBookmarkService();
                            }
                            bmManager.removeBookmark(bookmark);
                        }
                    }
                    refreshView();
                }
            } else if (GOTO_BOOKMARK_ACTION_ID.equals(action.getId())) {
                Bookmark bookmark = (Bookmark) selection.getFirstElement();
                gotoBookmark(bookmark);
            } else if (ADD_BOOKMARK_ACTION_ID.equals(action.getId())) {
                IMap map = ApplicationGIS.getActiveMap();
                if (map != ApplicationGIS.NO_MAP) {
                    IViewportModel v = map.getViewportModel();
                    Envelope env = v.getBounds();
                    ReferencedEnvelope bounds;
                    if (env instanceof ReferencedEnvelope) {
                        bounds = (ReferencedEnvelope) env;
                    } else {
                        bounds = new ReferencedEnvelope(env, v.getCRS());
                    }
                    MapReference ref = bmManager.getMapReference(map);
                    Bookmark bookmark = new Bookmark(bounds, ref, null);
                    InputDialog dialog = new InputDialog(
                            Display.getCurrent().getActiveShell(),
                            Messages.BookmarkAction_dialogtitle_bookmarklocation,
                            Messages.BookmarkAction_dialogprompt_enterbookmarkname,
                            bookmark.getName(), null);
                    dialog.open();
                    if (dialog.getReturnCode() == Window.OK) {
                        String name = dialog.getValue();
                        bookmark.setName(name);
                        bmManager = BookmarksPlugin.getBookmarkService();
                        bmManager.addBookmark(bookmark);
                        refreshView();
                    }
                    ((BookmarksView) view)
                            .selectReveal(new StructuredSelection(bookmark));
                }
            } else if (RENAME_BOOKMARK_ACTION_ID.equals(action.getId())) {
                IBookmark bookmark = (IBookmark) selection.getFirstElement();
                InputDialog dialog = new InputDialog(Display.getCurrent()
                        .getActiveShell(),
                        Messages.BookmarkAction_dialogtitle_renamebookmark,
                        Messages.BookmarkAction_dialogprompt_enterbookmarkname,
                        bookmark.getName(), null);
                dialog.open();
                if (dialog.getReturnCode() == Window.OK) {
                    String name = dialog.getValue();
                    bookmark.setName(name);
                    refreshView();
                }
            } else if (SAVE_BOOKMARKS_ACTION_ID.equals(action.getId())) {
                BookmarksPlugin.getDefault().storeToPreferences();
            } else if (RESTORE_BOOKMARKS_ACTION_ID.equals(action.getId())) {
View Full Code Here

    public void doubleClick(DoubleClickEvent event) {
        final IStructuredSelection eventSelection = (IStructuredSelection) event
                .getSelection();
        if (eventSelection.size() > 0
                && eventSelection.getFirstElement() instanceof Bookmark) {
            Bookmark bookmark = (Bookmark) eventSelection.getFirstElement();
            gotoBookmark(bookmark);
        }
    }
View Full Code Here

    @Override
    public void removeBookmarks( Collection<IBookmark> elements ) {
        for( Object element : elements ) {
            if (element instanceof Bookmark) {
                Bookmark bmark = (Bookmark) element;
                this.removeBookmark(bmark);
            }
        }
        notifyListeners(new BookmarkListener.Event(elements));
    }
View Full Code Here

    }

    public Object getParent( Object element ) {
        Object parent = null;
        if (element instanceof Bookmark) {
            Bookmark bookmark = (Bookmark) element;
            parent = bookmark.getMap();
        }
        return parent;
    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.bookmarks.Bookmark

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.