Revision as of 09:40, 22 February 2012 by Psomol (Talk | contribs)

Date: 21 FEB 2012 Author: Miloslav Metelka, Petr Somol


Editor Bookmarks Support in NetBeans

Introduction - Current State

Current state: Bookmark symbol is displayed to the left of the bookmarked line. Hovering mouse over displays a tooltip with always the same text 'Bookmark'
Current state: With more than one annotation per line only one is displayed. Clicking the black arrow cycles the annotation symbols (and shows possibly hidden bookmark symbol).
Current state: Right-click on bookmark symbol opens the shared annotation menu. The bookmark submenu puts on show the three currently defined bookmark actions/shortcuts.

Existing bookmarks support in NetBeans consists of three shortcuts:

  • Ctrl+Shift+M for Toggle Bookmark on current line in the currently focused document
  • Ctrl+Shift+Comma and Ctrl+Shift+Period for cycling through bookmarks back/forward in a currently focused document. The choice of these particular shortcuts is good from UEX point of view because the respective keys carry the symbols < and >, what visually underpins the respective cycling directions.

At the moment bookmark navigation is limited to a single file only. Bookmarks are unnamed. Any number of bookmarks can be set in each file, but no shortcuts to access particular bookmarks are provided, nor it is possible to cycle across file borders. There is no view/window available to get an overview over all existing bookmarks.

Bookmarks Storage

Bookmarks are physically stored in private.properties file inside a project in which the particular source file with the bookmark resides. This is generally a desirable approach however it means that the IDE always works with bookmarks from currently opened projects only.

Use-Cases and Scenarios To Be Addressed

Navigation Across Files

Users need to navigate through bookmarks across files. Since a global list of bookmarks can become large it is desirable to have more navigation options than just cycle through previous/next bookmark.

Named Bookmarks

Some users demand to create named bookmarks which many editors support. But they also want to retain unnamed bookmarks which are faster to create and work with.

Bookmark Management

Users need to see a list of all bookmarks in a window (similarly like e.g. a list of all breakpoints). Bookmark window will enable quick navigation. Possibly it would provide also other bookmark management actions: various modes of view sorting/grouping (by name, by file, by project), renaming, search by name, enabling/disabling, adding/removing.

Bookmark Improvements Proposed for NetBeans 7.2

Updated Bookmark's Definition

In addition to the current properties of a bookmark (source-file and line-number) the bookmark would newly have a name (auto-generated names "bookmark1", "bookmark2" etc. for unnamed bookmarks, may be renamed by user) and a keyboard shortcut consisting of a prefix shortcut Ctrl+Shift+G (alternatively Ctrl+J) followed by a single digit or character [0-9a-z] except g which is reserved for opening Bookmark Manager window.

Bookmark Manager

A Bookmark Manager window would behave similarly to windows docked usually under the main editor window, like Output, Breakpoints, etc. The Bookmark Manager would show all the currently navigable bookmarks (from all currently opened projects). On the left there would be a table showing each bookmark's properties: name, shortcut, source-file:line-number (tooltip would show full source path). On the right there would be a preview of the code where the bookmark is located. If a new bookmark was created by Ctrl+Shift+M the window would preselect it when invoked so that the user can easily turn the recently created unnamed bookmark to a named one.

Updated Navigation Keyboard Shortcuts

  • Ctrl+Shift+M toggles (add/delete) an unnamed bookmark on the current line. If applied to an existing named bookmark, the named bookmark is not immediately deleted but a confirmation messagebox is displayed first.
  • Ctrl+Shift+Comma and Ctrl+Shift+Period semantics would be changed to navigate in Bookmarks History which would be similar to Jump List navigation (or a browser navigation history). A bookmark would be added to bookmark history when it gets created (by toggling) or when it is navigated to explicitly either using direct shortcut (using "Ctrl+Shift+G") or from Navigator Window.
  • Ctrl+Shift+G then [0-9a-z] except g (or alternatively Ctrl+J then [0-9a-z] except j) would navigate to a concrete bookmark. If no bookmark is assigned to the shortcut yet then a dialog would be displayed allowing a new bookmark creation.
  • Ctrl+Shift+G then g (or alternatively Ctrl+J then j) opens Bookmark Manager window.
  • Ctrg+G opens Go To dialog used so far for line number navigation only. The improved dialog should enable entering either a line number or a bookmark name

Remark: The shortcuts Ctrl+Shift+G and Ctrl-J are so far unused. Ctrl+Shift+G is suitable for bookmark navigation because: letter G suggests 'Go to..'; the prefix Ctrl+Shift corresponds with all bookmark shortcuts used so far and thus feels natural to users accustomed with previous bookmark support; the convention of pressing Ctrl+Shift+G then a single key is used both for quick navigation and to open bookmark navigator, thus limiting the number of new shortcuts the user needs to learn; and the location of key G in the center of keyboard is optimal in terms of minimum necessary subsequent hand movement to press the final key leading to concrete bookmark. However, Ctrl+Shift+G can be perceived as inconvenient on Mac where Ctrl and Shift keys are located farther from each other and for a potentially heavy-use shortcut a shorter one is preferable - hence the definition of Ctrl+J.

Improved Go To dialog

Currently the shortcut Ctrl+G opens the simple Go To dialog allowing to enter a line number to go to. The functionality should be extended to accept also bookmark names. The semantics can be kept simple: as long as the entered text is numeric only, it is interpreted as line number; when a [a-z] character appears, the text starts to be interpreted as bookmark, and the dialog switches on code-completion drop-down list with appropriate bookmark names.

Accordingly the dialog and its entry in Navigation menu would be renamed to Go To Line Or Bookmark.

Bookmark Line Annotation Symbol

The annotation symbol is used to mark lines with bookmarks in editor. When mouse over, it will show the bookmark name. Right-click will enable editing bookmark properties: changing name or shortcut. Left click? would show the bookmark in Bookmark Navigator.

Bookmark Scope and Possible Conflicts

Bookmarks will be stored on a per-project basis. A conflict in name and shortcut may thus arise across opened projects.

  • Name conflicts can be resolved by using 'extended' names consisting of project-file-bookmark name.
  • Conflict in shortcuts can be bypassed by automatically preferring the shortcut in closer scope (navigate to project in focus instead of other project). Additionally, repeated pressing of the same shortcut would cycle through conflicting bookmarks.

Bookmark Manager can warn about both conflicting name and/or shortcut by showing them in red in the table (tooltip would show conflicting bookmark description).

Another issue to decide is the limited number of assignable shortcut keys. What to do when they get exhausted ?

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo