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())) {