6262import com .mirth .connect .client .ui .components .rsta .actions .ExpandFoldAction ;
6363import com .mirth .connect .client .ui .components .rsta .actions .FindNextAction ;
6464import com .mirth .connect .client .ui .components .rsta .actions .FindReplaceAction ;
65+ import com .mirth .connect .client .ui .components .rsta .actions .FormatCodeAction ;
6566import com .mirth .connect .client .ui .components .rsta .actions .GoToMatchingBracketAction ;
6667import com .mirth .connect .client .ui .components .rsta .actions .HorizontalPageAction ;
6768import com .mirth .connect .client .ui .components .rsta .actions .InsertBreakAction ;
@@ -127,6 +128,9 @@ public class MirthRSyntaxTextArea extends RSyntaxTextArea implements MirthTextIn
127128 private CustomJCheckBoxMenuItem showWhitespaceMenuItem ;
128129 private CustomJCheckBoxMenuItem showLineEndingsMenuItem ;
129130 private CustomJCheckBoxMenuItem wrapLinesMenuItem ;
131+ private JMenu codeMenu ;
132+ private CustomMenuItem formatCodeMenuItem ;
133+ private CustomMenuItem toggleCommentMenuItem ;
130134 private JMenu macroMenu ;
131135 private CustomMenuItem beginMacroMenuItem ;
132136 private CustomMenuItem endMacroMenuItem ;
@@ -228,6 +232,9 @@ public void keyPressed(KeyEvent e) {
228232 showWhitespaceMenuItem = new CustomJCheckBoxMenuItem (this , new ShowWhitespaceAction (this ), ActionInfo .DISPLAY_SHOW_WHITESPACE );
229233 showLineEndingsMenuItem = new CustomJCheckBoxMenuItem (this , new ShowLineEndingsAction (this ), ActionInfo .DISPLAY_SHOW_LINE_ENDINGS );
230234 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 );
231238 macroMenu = new JMenu ("Macro" );
232239 beginMacroMenuItem = new CustomMenuItem (this , new BeginMacroAction (), ActionInfo .MACRO_BEGIN );
233240 endMacroMenuItem = new CustomMenuItem (this , new EndMacroAction (), ActionInfo .MACRO_END );
@@ -239,7 +246,8 @@ public void keyPressed(KeyEvent e) {
239246 getActionMap ().put (ActionInfo .DELETE_LINE .getActionMapKey (), new DeleteLineAction ());
240247 getActionMap ().put (ActionInfo .JOIN_LINE .getActionMapKey (), new JoinLineAction ());
241248 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 ));
243251 getActionMap ().put (ActionInfo .DOCUMENT_START .getActionMapKey (), new DocumentStartAction (false ));
244252 getActionMap ().put (ActionInfo .DOCUMENT_SELECT_START .getActionMapKey (), new DocumentStartAction (true ));
245253 getActionMap ().put (ActionInfo .DOCUMENT_END .getActionMapKey (), new DocumentEndAction (false ));
@@ -489,6 +497,11 @@ protected JPopupMenu createPopupMenu() {
489497 menu .add (displayMenu );
490498 menu .addSeparator ();
491499
500+ codeMenu .add (formatCodeMenuItem );
501+ codeMenu .add (toggleCommentMenuItem );
502+ menu .add (codeMenu );
503+ menu .addSeparator ();
504+
492505 macroMenu .add (beginMacroMenuItem );
493506 macroMenu .add (endMacroMenuItem );
494507 macroMenu .add (playbackMacroMenuItem );
@@ -514,6 +527,8 @@ protected void configurePopupMenu(JPopupMenu popupMenu) {
514527 findNextMenuItem .setEnabled (findNextMenuItem .getAction ().isEnabled () && CollectionUtils .isNotEmpty (rstaPreferences .getFindReplaceProperties ().getFindHistory ()));
515528 clearMarkedOccurrencesMenuItem .setEnabled (clearMarkedOccurrencesMenuItem .getAction ().isEnabled () && canType && ((RSyntaxTextAreaHighlighter ) getHighlighter ()).getMarkAllHighlightCount () > 0 );
516529 foldingMenu .setEnabled (getFoldManager ().isCodeFoldingSupportedAndEnabled ());
530+ formatCodeMenuItem .setEnabled (formatCodeMenuItem .getAction ().isEnabled ());
531+ toggleCommentMenuItem .setEnabled (toggleCommentMenuItem .getAction ().isEnabled ());
517532 beginMacroMenuItem .setEnabled (!isRecordingMacro ());
518533 endMacroMenuItem .setEnabled (isRecordingMacro ());
519534 playbackMacroMenuItem .setEnabled (!isRecordingMacro () && getCurrentMacro () != null );
@@ -533,6 +548,8 @@ protected void configurePopupMenu(JPopupMenu popupMenu) {
533548 collapseAllFoldsMenuItem .updateAccelerator ();
534549 collapseAllCommentFoldsMenuItem .updateAccelerator ();
535550 expandAllFoldsMenuItem .updateAccelerator ();
551+ formatCodeMenuItem .updateAccelerator ();
552+ toggleCommentMenuItem .updateAccelerator ();
536553 beginMacroMenuItem .updateAccelerator ();
537554 endMacroMenuItem .updateAccelerator ();
538555 playbackMacroMenuItem .updateAccelerator ();
@@ -550,4 +567,4 @@ public void setSyntaxEditingStyle(String styleKey) {
550567 public Action [] getActions () {
551568 return actions != null ? actions : getUI ().getEditorKit (this ).getActions ();
552569 }
553- }
570+ }
0 commit comments