62
62
import com .mirth .connect .client .ui .components .rsta .actions .ExpandFoldAction ;
63
63
import com .mirth .connect .client .ui .components .rsta .actions .FindNextAction ;
64
64
import com .mirth .connect .client .ui .components .rsta .actions .FindReplaceAction ;
65
+ import com .mirth .connect .client .ui .components .rsta .actions .FormatCodeAction ;
65
66
import com .mirth .connect .client .ui .components .rsta .actions .GoToMatchingBracketAction ;
66
67
import com .mirth .connect .client .ui .components .rsta .actions .HorizontalPageAction ;
67
68
import com .mirth .connect .client .ui .components .rsta .actions .InsertBreakAction ;
@@ -127,6 +128,9 @@ public class MirthRSyntaxTextArea extends RSyntaxTextArea implements MirthTextIn
127
128
private CustomJCheckBoxMenuItem showWhitespaceMenuItem ;
128
129
private CustomJCheckBoxMenuItem showLineEndingsMenuItem ;
129
130
private CustomJCheckBoxMenuItem wrapLinesMenuItem ;
131
+ private JMenu codeMenu ;
132
+ private CustomMenuItem formatCodeMenuItem ;
133
+ private CustomMenuItem toggleCommentMenuItem ;
130
134
private JMenu macroMenu ;
131
135
private CustomMenuItem beginMacroMenuItem ;
132
136
private CustomMenuItem endMacroMenuItem ;
@@ -228,6 +232,9 @@ public void keyPressed(KeyEvent e) {
228
232
showWhitespaceMenuItem = new CustomJCheckBoxMenuItem (this , new ShowWhitespaceAction (this ), ActionInfo .DISPLAY_SHOW_WHITESPACE );
229
233
showLineEndingsMenuItem = new CustomJCheckBoxMenuItem (this , new ShowLineEndingsAction (this ), ActionInfo .DISPLAY_SHOW_LINE_ENDINGS );
230
234
wrapLinesMenuItem = new CustomJCheckBoxMenuItem (this , new WrapLinesAction (this ), ActionInfo .DISPLAY_WRAP_LINES );
235
+ codeMenu = new JMenu ("Code" );
236
+ formatCodeMenuItem = new CustomMenuItem (this , new FormatCodeAction (this ), ActionInfo .FORMAT_CODE );
237
+ toggleCommentMenuItem = new CustomMenuItem (this , new ToggleCommentAction (this ), ActionInfo .TOGGLE_COMMENT );
231
238
macroMenu = new JMenu ("Macro" );
232
239
beginMacroMenuItem = new CustomMenuItem (this , new BeginMacroAction (), ActionInfo .MACRO_BEGIN );
233
240
endMacroMenuItem = new CustomMenuItem (this , new EndMacroAction (), ActionInfo .MACRO_END );
@@ -239,7 +246,8 @@ public void keyPressed(KeyEvent e) {
239
246
getActionMap ().put (ActionInfo .DELETE_LINE .getActionMapKey (), new DeleteLineAction ());
240
247
getActionMap ().put (ActionInfo .JOIN_LINE .getActionMapKey (), new JoinLineAction ());
241
248
getActionMap ().put (ActionInfo .GO_TO_MATCHING_BRACKET .getActionMapKey (), new GoToMatchingBracketAction ());
242
- getActionMap ().put (ActionInfo .TOGGLE_COMMENT .getActionMapKey (), new ToggleCommentAction ());
249
+ getActionMap ().put (ActionInfo .FORMAT_CODE .getActionMapKey (), new FormatCodeAction (this ));
250
+ getActionMap ().put (ActionInfo .TOGGLE_COMMENT .getActionMapKey (), new ToggleCommentAction (this ));
243
251
getActionMap ().put (ActionInfo .DOCUMENT_START .getActionMapKey (), new DocumentStartAction (false ));
244
252
getActionMap ().put (ActionInfo .DOCUMENT_SELECT_START .getActionMapKey (), new DocumentStartAction (true ));
245
253
getActionMap ().put (ActionInfo .DOCUMENT_END .getActionMapKey (), new DocumentEndAction (false ));
@@ -489,6 +497,11 @@ protected JPopupMenu createPopupMenu() {
489
497
menu .add (displayMenu );
490
498
menu .addSeparator ();
491
499
500
+ codeMenu .add (formatCodeMenuItem );
501
+ codeMenu .add (toggleCommentMenuItem );
502
+ menu .add (codeMenu );
503
+ menu .addSeparator ();
504
+
492
505
macroMenu .add (beginMacroMenuItem );
493
506
macroMenu .add (endMacroMenuItem );
494
507
macroMenu .add (playbackMacroMenuItem );
@@ -514,6 +527,8 @@ protected void configurePopupMenu(JPopupMenu popupMenu) {
514
527
findNextMenuItem .setEnabled (findNextMenuItem .getAction ().isEnabled () && CollectionUtils .isNotEmpty (rstaPreferences .getFindReplaceProperties ().getFindHistory ()));
515
528
clearMarkedOccurrencesMenuItem .setEnabled (clearMarkedOccurrencesMenuItem .getAction ().isEnabled () && canType && ((RSyntaxTextAreaHighlighter ) getHighlighter ()).getMarkAllHighlightCount () > 0 );
516
529
foldingMenu .setEnabled (getFoldManager ().isCodeFoldingSupportedAndEnabled ());
530
+ formatCodeMenuItem .setEnabled (formatCodeMenuItem .getAction ().isEnabled ());
531
+ toggleCommentMenuItem .setEnabled (toggleCommentMenuItem .getAction ().isEnabled ());
517
532
beginMacroMenuItem .setEnabled (!isRecordingMacro ());
518
533
endMacroMenuItem .setEnabled (isRecordingMacro ());
519
534
playbackMacroMenuItem .setEnabled (!isRecordingMacro () && getCurrentMacro () != null );
@@ -533,6 +548,8 @@ protected void configurePopupMenu(JPopupMenu popupMenu) {
533
548
collapseAllFoldsMenuItem .updateAccelerator ();
534
549
collapseAllCommentFoldsMenuItem .updateAccelerator ();
535
550
expandAllFoldsMenuItem .updateAccelerator ();
551
+ formatCodeMenuItem .updateAccelerator ();
552
+ toggleCommentMenuItem .updateAccelerator ();
536
553
beginMacroMenuItem .updateAccelerator ();
537
554
endMacroMenuItem .updateAccelerator ();
538
555
playbackMacroMenuItem .updateAccelerator ();
0 commit comments