Revision as of 17:17, 27 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 Management Improvements Proposed for NetBeans 7.2

Updated Bookmark 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 an optional key to enable quick navigation. The key is a single digit or character [0-9a-z]. It is assigned automatically to next free value on bookmark creation, if a free value exists. The key can be redefined by user at any time. Editing a key or name is possible in Bookmark Manager window, or through a right-click menu on existing bookmark icon in text editor. In both cases it should be possible to request next free key value, to prevent the necessity for users to remember exactly all key assignments. Note that assigning a conflicting name or key (used already in, e.g., another project) should be permitted but a conflict should be emphasized. The proposed option is to set conflicting name/key in red instead of default black.

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+J opens Go To Bookmark dialog. Optimized for quick navigation.
  • Ctrl+Shift+J opens Bookmark Manager dockable window. Provides hierarchical overview over all bookmarks including location context preview. Enables editing bookmark name/key.
  • 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+J and Ctrl+Shift+J are so far unused and are suitable for bookmark navigation because the location of key J is just above M which has long been used to toggle bookmarks and the letter J suggests 'Jump to..'.

Go To Bookmark Dialog

Go To Bookmark would enable quick navigation to bookmark location, while helping to resolve bookmark name/key ambiguities.

Go To Bookmark enables quick navigation to bookmark location.

The dialog provides the ordered list of most recently accessed bookmarks (the last accessed bookmark displayed first). The selection in list is initially put on the most recently accessed bookmark; if cursor in editor is currently located at this bookmark's location, it may be better to pre-select the next most recent bookmark.

Initially the list contains a number of bookmarks (up to a reasonable limit to keep the dialog construction quick). The list can be reduced by user by modifying any (one or more) of the filtering fields above. On opening the dialog focus is in the Key field, enabling the user to press a single key to quickly select a specific bookmark. Typically this would reduce the list to a single bookmark for which the key has been defined. In case of conflicts all conflicting bookmarks are listed, while the closest to current scope is pre-selected.

If any string is typed in the fields Name, File, or Project, the list of bookmarks is continually reduced to only those that match the filter (the respective bookmark name, file name, project name contains as substring what is being typed). If in this way a previously selected bookmark disappears from list, selection moves to the currently closest bookmark to current scope. Note that the filters are actually drop-down lists - this is to provide filter history for each of the filters.

Pressing Up or Down arrow keys moves the selection in list.

Pressing Go To button closes the dialog and navigates to the bookmark in focus. Or, double-clicking any bookmark in list navigates to its location.

The checkbox Auto Proceed if Choice Unambiguous gives experienced users the option to accelerate the navigation to a maximum. If checked, than if at any moment the list of bookmarks gets reduced to exactly one bookmark, the dialog closes and IDE navigates to the bookmark's location as if the user explicitly clicked Go To. In this way experienced users can navigate to bookmarks almost as quickly as if there was a direct shortcut Ctrl+J+key defined. The dialog would interfere with this quick navigation only in case of key definition conflicts. The state of the checkbox is remembered across sessions.

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.

Bookmark Manager in list view mode, should enable in-place editing of bookmark name and shortcut. Conflicting bookmark shortcut illustrated in red.

In Bookmark Manager list view mode, clicking a bookmark line moves focus to the bookmark and shows bookmark context in the right code snippet window, double-clicking the line in place of name or shortcut field enables in-place editor, double-clicking the bookmark line elsewhere navigates to the bookmark in main editor. When shortcut in-place editor is active, the definition is possible by pressing the single key, or the whole Ctrl-J + key sequence.

Bookmark Manager in tree view mode.

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 shows a code-completion drop-down list with appropriate bookmark names as the user continues to type.

To code-completion list should include both the valid bookmark names and the list of previous choices (including line numbers).

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

Improved Go To dialog would enable entering line number or bookmark name.

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) or opening Bookmark Manager with the current bookmark shown in it.

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-bookmark name. When defining the name in Bookmark Manager the name would turn red while typing as long as the name being typed is in conflict.
  • Conflict in shortcuts can be bypassed when navigating 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. When defining a shortcut for a bookmark the user can either ask for a free shortcut or can define a shortcut directly. If defining directly and the shortcut has been previously defined for a different bookmark in the same project, a confirmation/warning is displayed. If the shortcut exists already in another opened project, the definition is accepted but displayed in red.

Bookmark Manager warns about conflicting names and/or shortcuts by showing them in red in the table; a tooltip would show conflicting bookmark description.

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