This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 104379

Summary: Keystroke Shortcut for Generators Needed
Product: ruby Reporter: William Leonard <bleonard>
Component: CodeAssignee: issues@ruby <issues>
Status: NEW ---    
Severity: blocker CC: gsporar, olangr
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description William Leonard 2007-05-21 00:57:44 UTC
It's frustrating that the only way to access the Generators is via the Project's
context menu. There should also be a keyboard shortcut.
Comment 1 Jiri Kovalsky 2007-07-03 14:10:21 UTC
Reassigning this issue to newly created 'ruby' component.
Comment 2 _ gsporar 2007-08-23 20:49:28 UTC
Might be nice to also have one for Migrate Database
Comment 3 Torbjorn Norbye 2007-08-23 20:55:30 UTC
Hi Ondrej,

is it too late to get another keybinding or two? Especially for "Generate" (which opens the Rails Code Generator and is
used to generate all kinds of artifacts - source files, application skeletons, etc.).

Gregg, do you really want one for migrating the database, or perhaps one for running the most recent rake target over again?
Comment 4 _ gsporar 2007-08-23 21:10:34 UTC
>Gregg, do you really want one for migrating the database, or perhaps one for running the most recent rake target over

Well, ideally both.  :-)

But I guess if I had to choose, the rake target one would be more heavily used.
Comment 5 Torbjorn Norbye 2007-10-21 17:59:17 UTC
Done. From the commit message:

104379  Keystroke Shortcut for Generators Needed

Add Ctrl-Insert (Command-I, not insert on the mac)

I also discovered a potential conflict in method names: AbstractAction defines getName() to return a -localized- name of
the action, whereas EditorAction.getName() wants an -internal- name of the action (which is used as a bundle key), so to
make it possible for an action to implement both (which the GenerateAction now does) rename EditorAction's getName to

(GenerateAction is only bound to Ctrl-Insert/Cmd-I from Ruby editor files, not as a global shortcut action since it
needs to be different on Mac from others. Also, this is the same keybinding used for code generation in other languages
so it's better to make it editor specific.)

IDE: [10/21/07 9:58 AM] Committing started
cvs server: scheduling file `org.netbeans.api.gsf.EditorAction' for addition
cvs server: use 'cvs commit' to add this file permanently
IDE: [10/21/07 9:58 AM] Committing finished
Checking in editing/src/org/netbeans/modules/ruby/;
/cvs/ruby/editing/src/org/netbeans/modules/ruby/,v  <--
new revision: 1.11; previous revision: 1.10
Checking in editing/src/org/netbeans/modules/ruby/DefaultKeyBindings.xml;
/cvs/ruby/editing/src/org/netbeans/modules/ruby/DefaultKeyBindings.xml,v  <--  DefaultKeyBindings.xml
new revision: 1.12; previous revision: 1.11
Checking in editing/src/org/netbeans/modules/ruby/DefaultKeyBindings-Mac.xml;
/cvs/ruby/editing/src/org/netbeans/modules/ruby/DefaultKeyBindings-Mac.xml,v  <--  DefaultKeyBindings-Mac.xml
new revision: 1.6; previous revision: 1.5
Checking in railsprojects/src/org/netbeans/modules/ruby/railsprojects/;
/cvs/ruby/railsprojects/src/org/netbeans/modules/ruby/railsprojects/,v  <--
new revision: 1.7; previous revision: 1.6
Checking in railsprojects/src/org/netbeans/modules/ruby/railsprojects/;
/cvs/ruby/railsprojects/src/org/netbeans/modules/ruby/railsprojects/,v  <--
new revision: 1.14; previous revision: 1.13
IDE: [10/21/07 9:58 AM] Diffing finished
Checking in gsf/src/org/netbeans/modules/gsf/;
/cvs/ruby/gsf/src/org/netbeans/modules/gsf/,v  <--
new revision: 1.9; previous revision: 1.8
RCS file: /cvs/ruby/railsprojects/src/META-INF/services/org.netbeans.api.gsf.EditorAction,v
Checking in railsprojects/src/META-INF/services/org.netbeans.api.gsf.EditorAction;
/cvs/ruby/railsprojects/src/META-INF/services/org.netbeans.api.gsf.EditorAction,v  <--  org.netbeans.api.gsf.EditorAction
initial revision: 1.1
Checking in gsf/api/src/org/netbeans/api/gsf/;
/cvs/ruby/gsf/api/src/org/netbeans/api/gsf/,v  <--
new revision: 1.3; previous revision: 1.2
Checking in rspec/src/org/netbeans/modules/ruby/rspec/;
/cvs/ruby/rspec/src/org/netbeans/modules/ruby/rspec/,v  <--
new revision: 1.6; previous revision: 1.5
Checking in rspec/src/org/netbeans/modules/ruby/rspec/;
/cvs/ruby/rspec/src/org/netbeans/modules/ruby/rspec/,v  <--
new revision: 1.2; previous revision: 1.1
IDE: [10/21/07 9:58 AM] Committing finished

Comment 6 _ gsporar 2007-11-16 16:56:55 UTC
This issue does not seem completely fixed to me.

The problem is discoverability (is that a word? :-) ).

If I right-click a Rails project the context menu displays "Generate..." and there is no keyboard shortcut listed.  Why
is that?  I'm assuming this is because the shortcut (Alt-Insert on a PC, Ctrl-I on a Mac) only works when a .rb file has
focus.  In other words, since the shortcut does not work when the Projects window has focus, it is kind of misleading to
display a keyboard shortcut in a menu that is only accessible from the Projects window.

So if that is the case, then that makes sense to me.  But I still think this is not completely fixed because with just
the base IDE and Ruby pack installed there is no menu entry anywhere (at least that I can find) that lets me know that
Alt-Insert brings up the Generate dialog.  

Another indicator of the broken-ness (another non-word? :-) ) is in the Options dialog.  Under the Edit category of the
keyboard shortcuts there is an entry called "Generate..."  That entry is for the Project window's context menu entry and
by default it does not have a keyboard shortcut.

There is *another* "Generate..." entry under the Other category of the keyboard shortcuts.  By default it has the
keyboard shortcut (Alt-Insert on the PC, Ctrl-I on the Mac) assigned to it.  Having two entries with the same name is

I wish I could propose a really good solution, but I cannot think of one.  :-/  One approach would be to just go ahead
and enable the "Insert Code" entry in the IDE's Source menu when .rb files in Rails projects have focus and assign the
keyboard shortcuts to it so that it looks the same as when the focus is on a .java file.  This approach would at least
make the keyboard shortcuts visible.  A user would try it and hopefully it would make some sense to him/her when the
Generate dialog popped up.

In thinking about this more, though, it seems like using the same keyboard shortcut as "Insert Code" is a bit
short-sighted.  Will there be a point in the future where the IDE might offer similar code insertion features for .rb
file editing as it currently offers for .java file editing?  For example, "Insert Code" in a .java file offers to create
a constructor - at some point will the IDE have the ability to generate an initialize() method for a class in a .rb
file?  If so, then hooking up Alt-Insert to the Generate dialog was probably the wrong keyboard shortcut....
Comment 7 Erno Mononen 2008-02-29 15:01:17 UTC
Hmm, Ctrl-Insert or Alt-Insert don't seem to do anything on my Linux box.
Comment 8 _ gsporar 2008-02-29 15:26:16 UTC
Do you have focus set to an .rb file in a Rails project?
Comment 9 Erno Mononen 2008-02-29 15:49:16 UTC
I did, but nothing happened. So I went to options -> Keymap to check to the shortcut and noticed in the Edit category 
there was 'Generate...' which had no shortcut assigned. First I tried to assign it to Alt-Insert, but was warned that 
it is already assigned to the 'Generate...' action, which must refer to the Java editor generate action (and which does 
work by default). Seems like there is a conflict between these two generate actions. After I assigned another shortcut 
for the Rails generate action it did work.