73
73
import javax .swing .JTabbedPane ;
74
74
import javax .swing .JToggleButton ;
75
75
import javax .swing .JToolBar ;
76
+ import javax .swing .KeyStroke ;
76
77
import javax .swing .SwingUtilities ;
77
78
import javax .swing .UIManager ;
78
79
import javax .swing .plaf .basic .BasicSplitPaneDivider ;
111
112
// "OQLConsoleView_ViewName=Results",
112
113
"RConsoleView_RQuery=R Query:" ,
113
114
"RConsoleView_RunAction=Run" ,
114
- "RConsoleView_RunActionTooltip=Execute R script" ,
115
+ "RConsoleView_RunActionTooltip=Execute R script - Crtl+R " ,
115
116
"RConsoleView_CancelAction=Cancel" ,
116
117
"RConsoleView_CancelActionTooltip=Cancel R script execution" ,
117
118
"RConsoleView_LoadAction=Load Script" ,
@@ -492,14 +493,7 @@ private void init() {
492
493
toolbar .add (new GrayLabel (Bundle .RConsoleView_RQuery ()));
493
494
toolbar .addSpace (2 );
494
495
495
- runAction = new AbstractAction (Bundle .RConsoleView_RunAction (), Icons .getIcon (GeneralIcons .START )) {
496
- {
497
- putValue (Action .SHORT_DESCRIPTION , Bundle .RConsoleView_RunActionTooltip ());
498
- }
499
- public void actionPerformed (ActionEvent e ) {
500
- executeQuery ();
501
- }
502
- };
496
+ runAction = new RunAction ();
503
497
504
498
JButton runButton = new JButton (runAction ) {
505
499
public Dimension getPreferredSize () {
@@ -770,6 +764,10 @@ protected void validityChanged(boolean valid) {
770
764
component = new JPanel (new BorderLayout ());
771
765
component .add (masterSplit , BorderLayout .CENTER );
772
766
767
+ JComponent toolbarComp = toolbar .getComponent ();
768
+ setShortcut (runAction , toolbarComp );
769
+ setShortcut (runAction , component );
770
+ toolbarComp .repaint ();
773
771
updateUIState ();
774
772
// } else {
775
773
// component = new JPanel(new BorderLayout());
@@ -783,6 +781,13 @@ protected void validityChanged(boolean valid) {
783
781
// }
784
782
}
785
783
784
+ private void setShortcut (Action a , JComponent jc ) {
785
+ Object actionName = a .getValue (Action .ACTION_COMMAND_KEY );
786
+ KeyStroke shortcut = (KeyStroke ) a .getValue (Action .ACCELERATOR_KEY );
787
+ jc .getInputMap (JComponent .WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put (shortcut , actionName );
788
+ jc .getActionMap ().put (actionName , a );
789
+ }
790
+
786
791
787
792
private static HeapViewerNode getNode (URL url , HeapContext context ) {
788
793
String urls = url .toString ();
@@ -843,6 +848,22 @@ public void run() {
843
848
}
844
849
}
845
850
851
+ private final class RunAction extends AbstractAction {
852
+ private static final String ACTION_NAME = "runScript_Action" ; // NOI18N
853
+ private final KeyStroke shortcut = KeyStroke .getKeyStroke ("ctrl R" ); // NOI18N
854
+
855
+ private RunAction () {
856
+ super (Bundle .RConsoleView_RunAction (), Icons .getIcon (GeneralIcons .START ));
857
+ putValue (Action .SHORT_DESCRIPTION , Bundle .RConsoleView_RunActionTooltip ());
858
+ putValue (Action .ACTION_COMMAND_KEY , ACTION_NAME );
859
+ putValue (Action .ACCELERATOR_KEY , shortcut );
860
+ }
861
+
862
+ public void actionPerformed (ActionEvent e ) {
863
+ executeQuery ();
864
+ }
865
+ }
866
+
846
867
847
868
private class EditorView extends JPanel {
848
869
0 commit comments