KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > editor > MainMenuAction


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.editor;
21
22 import java.awt.event.InputEvent JavaDoc;
23 import java.awt.event.KeyEvent JavaDoc;
24 import java.util.List JavaDoc;
25 import javax.swing.Action JavaDoc;
26 import javax.swing.ActionMap JavaDoc;
27 import javax.swing.Icon JavaDoc;
28 import javax.swing.ImageIcon JavaDoc;
29 import javax.swing.JCheckBoxMenuItem JavaDoc;
30 import javax.swing.JEditorPane JavaDoc;
31 import javax.swing.JMenuItem JavaDoc;
32 import javax.swing.KeyStroke JavaDoc;
33 import javax.swing.event.ChangeEvent JavaDoc;
34 import javax.swing.event.ChangeListener JavaDoc;
35 import javax.swing.text.JTextComponent JavaDoc;
36 import javax.swing.text.Keymap JavaDoc;
37 import org.netbeans.api.editor.mimelookup.MimeLookup;
38 import org.netbeans.api.editor.mimelookup.MimePath;
39 import org.netbeans.api.editor.settings.KeyBindingSettings;
40 import org.netbeans.api.editor.settings.MultiKeyBinding;
41 import org.netbeans.editor.BaseKit;
42 import org.netbeans.editor.Registry;
43 import org.netbeans.editor.Settings;
44 import org.netbeans.editor.SettingsNames;
45 import org.netbeans.editor.Utilities;
46 import org.netbeans.editor.ext.ExtKit;
47 import org.netbeans.modules.editor.options.BaseOptions;
48 import org.openide.awt.Mnemonics;
49 import org.openide.util.HelpCtx;
50 import org.openide.util.Lookup;
51 import org.openide.util.NbBundle;
52 import org.openide.util.actions.Presenter;
53
54 /**
55  * Main menu action, like Edit/Go to Source, Edit/Go to Line...,
56  * View/Show Editor Toolbar, View/Show Line Numbers
57  * This is the action implements Presenter.Menu and delegates on specific actions like
58  * ExtKit.toggleToolbarAction or ExtKit.gotoSuperImplementationAction
59  *
60  * @author Martin Roskanin
61  */

62 public abstract class MainMenuAction extends GlobalContextAction implements Presenter.Menu, ChangeListener JavaDoc {
63
64     public static final Icon JavaDoc BLANK_ICON = new ImageIcon JavaDoc(org.openide.util.Utilities.loadImage("org/netbeans/modules/editor/resources/empty.gif"));
65     public boolean menuInitialized = false;
66     /** icon of the action, null means no icon */
67     private final Icon JavaDoc forcedIcon;
68     /** true when icon of original action should be ignored */
69     private boolean forceIcon;
70     
71     /** Creates a new instance of ShowLineNumbersAction */
72     public MainMenuAction() {
73         // force no icon
74
this(true, null);
75     }
76     
77     public MainMenuAction (boolean forceIcon, Icon JavaDoc forcedIcon) {
78         // needs to listen on Registry - resultChanged event is fired before
79
// TopComponent is really focused - this causes problems in getComponent method
80
Registry.addChangeListener(this);
81         this.forceIcon = forceIcon;
82         this.forcedIcon = forcedIcon;
83     }
84     
85     public void resultChanged(org.openide.util.LookupEvent ev){
86         setMenu();
87     }
88     
89     public void stateChanged(ChangeEvent JavaDoc e) {
90         setMenu();
91     }
92     
93     public org.openide.util.HelpCtx getHelpCtx() {
94         return HelpCtx.DEFAULT_HELP;
95     }
96
97     public String JavaDoc getName() {
98         return getMenuItemText();
99     }
100
101     /** Returns focused editor component */
102     private static JTextComponent JavaDoc getComponent(){
103         return Utilities.getFocusedComponent();
104     }
105
106     /** Returns the action by given name */
107     private static Action JavaDoc getActionByName(String JavaDoc actionName){
108         BaseKit bKit = getKit();
109         if (bKit!=null){
110             Action JavaDoc action = bKit.getActionByName(actionName);
111             return action;
112         }
113         return null;
114     }
115     
116     /** Adds accelerators to given JMenuItem taken from the action */
117     protected static void addAccelerators(Action JavaDoc a, JMenuItem JavaDoc item, JTextComponent JavaDoc target){
118         if (target == null || a==null || item==null) return;
119         
120         // get accelerators from kitAction
121
Action JavaDoc kitAction = getActionByName((String JavaDoc)a.getValue(Action.NAME));
122         if (kitAction!=null) a = kitAction;
123         // Try to get the accelerator, TopComponent action could be obsoleted
124
Keymap JavaDoc km = target.getKeymap();
125
126         if (km != null) {
127             KeyStroke JavaDoc[] keys = km.getKeyStrokesForAction(a);
128             KeyStroke JavaDoc itemAccelerator = item.getAccelerator();
129             
130             if (keys != null && keys.length > 0) {
131                 if (itemAccelerator==null || !itemAccelerator.equals(keys[0])){
132                     item.setAccelerator(keys[0]);
133                 }
134             }else{
135                 if (itemAccelerator!=null && kitAction!=null){
136                     item.setAccelerator(null);
137                 }
138             }
139         }
140     }
141     
142     /** Gets the editor kit */
143     private static BaseKit getKit(){
144         JTextComponent JavaDoc component = getComponent();
145         return (component == null) ? null : Utilities.getKit(component);
146     }
147     
148     public boolean isEnabled() {
149         return false;
150     }
151     
152     private static Object JavaDoc getSettingValue(BaseKit kit, String JavaDoc settingName) {
153         return Settings.getValue(kit.getClass(), settingName);
154     }
155
156     /** Get the value of the boolean setting from the <code>Settings</code>
157      * @param settingName name of the setting to get.
158      */

159     private static boolean getSettingBoolean(BaseKit kit, String JavaDoc settingName) {
160         Boolean JavaDoc val = (Boolean JavaDoc)getSettingValue(kit, settingName);
161         return (val != null) ? val.booleanValue() : false;
162     }
163
164     /** If there is no kit sensitive action, some global kit action can be returned
165      * by subclasses. Returning null by default */

166     protected Action JavaDoc getGlobalKitAction(){
167         return null;
168     }
169     
170     
171     /** Sets the state of JMenuItem*/
172     protected void setMenu(){
173         ActionMap JavaDoc am = getContextActionMap();
174         Action JavaDoc action = null;
175         JMenuItem JavaDoc presenter = getMenuPresenter();
176         if (am!=null){
177             action = am.get(getActionName());
178             if (action == null){
179                 action = getGlobalKitAction();
180             }
181             Action JavaDoc presenterAction = presenter.getAction();
182             if (presenterAction == null){
183                 if (action != null){
184                     presenter.setAction(action);
185                     presenter.setToolTipText(null); /* bugfix #62872 */
186                     menuInitialized = false;
187                 }
188             }else{
189                 if ((action!=null && !action.equals(presenterAction))){
190                     presenter.setAction(action);
191                     presenter.setToolTipText(null); /* bugfix #62872 */
192                     menuInitialized = false;
193                 }else if (action == null){
194                     presenter.setEnabled(false);
195                 }
196             }
197         }
198
199         if (!menuInitialized){
200             Mnemonics.setLocalizedText(presenter, getMenuItemText());
201             menuInitialized = true;
202         }
203         
204         presenter.setEnabled(action != null);
205         JTextComponent JavaDoc comp = Utilities.getFocusedComponent();
206         if (comp != null && comp instanceof JEditorPane JavaDoc){
207             addAccelerators(action, presenter, comp);
208         } else {
209             presenter.setAccelerator(getDefaultAccelerator());
210         }
211         
212         if (forceIcon) {
213             presenter.setIcon(forcedIcon);
214         }
215     }
216     
217     /** Get the text of the menu item */
218     protected abstract String JavaDoc getMenuItemText();
219     
220     /** Get the action name */
221     protected abstract String JavaDoc getActionName();
222     
223     /** Get default accelerator */
224     protected KeyStroke JavaDoc getDefaultAccelerator(){
225         Lookup ml = MimeLookup.getLookup(MimePath.get("text/x-java")); //NOI18N
226
KeyBindingSettings kbs = (KeyBindingSettings) ml.lookup(KeyBindingSettings.class);
227         if (kbs != null){
228             List JavaDoc lst = kbs.getKeyBindings();
229             if (lst != null){
230                 for (int i=0; i<lst.size(); i++){
231                     MultiKeyBinding mkb = (MultiKeyBinding)lst.get(i);
232                     String JavaDoc an = mkb.getActionName();
233                     if (an != null && an.equals(getActionName())){
234                         if (mkb.getKeyStrokeCount() == 1){// we do not support multi KB in mnemonics
235
return mkb.getKeyStroke(0);
236                         }
237                     }
238                 }
239             }
240         }
241         return null;
242     }
243     
244     public static class ShowToolBarAction extends MainMenuAction{
245
246         private static JCheckBoxMenuItem JavaDoc SHOW_TOOLBAR_MENU;
247             
248         public ShowToolBarAction(){
249             super(false, null);
250             SHOW_TOOLBAR_MENU = new JCheckBoxMenuItem JavaDoc(getMenuItemText());
251             setMenu();
252         }
253
254         /*
255         protected Action getGlobalKitAction(){
256             BaseKit kit = BaseKit.getKit(NbEditorKit.class);
257             return (kit!=null) ? kit.getActionByName(getActionName()) : null;
258         }
259          */

260         
261         protected void setMenu(){
262             super.setMenu();
263             SHOW_TOOLBAR_MENU.setState(isToolbarVisible());
264         }
265         
266         public JMenuItem JavaDoc getMenuPresenter() {
267             return SHOW_TOOLBAR_MENU;
268         }
269
270         private static boolean isToolbarVisible(){
271             BaseKit kit = getKit();
272             if (kit==null) return false;
273             return getSettingBoolean(kit, BaseOptions.TOOLBAR_VISIBLE_PROP);
274         }
275         
276         protected String JavaDoc getMenuItemText(){
277             return NbBundle.getBundle(MainMenuAction.class).getString(
278                 "show_editor_toolbar_main_menu_view_item"); //NOI18N
279
}
280         
281         protected String JavaDoc getActionName() {
282             return ExtKit.toggleToolbarAction;
283         }
284         
285     }
286     
287     
288     public static class ShowLineNumbersAction extends MainMenuAction{
289
290         private JCheckBoxMenuItem JavaDoc SHOW_LINE_MENU;
291         
292         public ShowLineNumbersAction(){
293             super(false, null);
294             SHOW_LINE_MENU = new JCheckBoxMenuItem JavaDoc(getMenuItemText());
295             setMenu();
296         }
297         
298         protected void setMenu(){
299             super.setMenu();
300             SHOW_LINE_MENU.setState(isLineNumbersVisible());
301         }
302         
303         protected String JavaDoc getMenuItemText(){
304             return NbBundle.getBundle(MainMenuAction.class).getString(
305                 "show_line_numbers_main_menu_view_item"); //NOI18N
306
}
307         
308         public String JavaDoc getName() {
309             return getMenuItemText();
310         }
311         
312         public javax.swing.JMenuItem JavaDoc getMenuPresenter() {
313             return SHOW_LINE_MENU;
314         }
315         
316         private static boolean isLineNumbersVisible(){
317             BaseKit kit = getKit();
318             if (kit==null) return false;
319             return getSettingBoolean(kit, SettingsNames.LINE_NUMBER_VISIBLE);
320         }
321         
322         protected String JavaDoc getActionName() {
323             return ExtKit.toggleLineNumbersAction;
324         }
325         
326     }
327     
328     
329     public static class GoToSourceAction extends MainMenuAction{
330         
331         private JMenuItem JavaDoc GOTO_SOURCE_MENU;
332
333         public GoToSourceAction(){
334             super();
335             GOTO_SOURCE_MENU = new JMenuItem JavaDoc(getMenuItemText());
336             setMenu();
337         }
338         
339         protected String JavaDoc getMenuItemText(){
340             return NbBundle.getBundle(MainMenuAction.class).getString(
341                 "goto_source_main_menu_edit_item"); //NOI18N
342
}
343         
344         public JMenuItem JavaDoc getMenuPresenter() {
345             return GOTO_SOURCE_MENU;
346         }
347
348         protected String JavaDoc getActionName() {
349             return ExtKit.gotoSourceAction;
350         }
351         
352         protected KeyStroke JavaDoc getDefaultAccelerator(){
353             return KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.ALT_MASK);
354         }
355         
356     }
357
358     
359     public static class GoToSuperAction extends MainMenuAction{
360         
361         private JMenuItem JavaDoc GOTO_SUPER_MENU;
362
363         public GoToSuperAction(){
364             super();
365             GOTO_SUPER_MENU = new JMenuItem JavaDoc(getMenuItemText());
366             setMenu();
367         }
368         
369         protected String JavaDoc getMenuItemText(){
370             return NbBundle.getBundle(MainMenuAction.class).getString(
371                 "goto_super_implementation_main_menu_edit_item"); //NOI18N
372
}
373         
374         public JMenuItem JavaDoc getMenuPresenter() {
375             return GOTO_SUPER_MENU;
376         }
377
378         protected String JavaDoc getActionName() {
379             return ExtKit.gotoSuperImplementationAction;
380         }
381         
382         protected KeyStroke JavaDoc getDefaultAccelerator(){
383             return KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_MASK);
384         }
385         
386     }
387
388     public static class GoToDeclarationAction extends MainMenuAction{
389         
390         private JMenuItem JavaDoc GOTO_DECL_MENU;
391
392         public GoToDeclarationAction(){
393             super();
394             GOTO_DECL_MENU = new JMenuItem JavaDoc(getMenuItemText());
395             setMenu();
396         }
397         
398         protected String JavaDoc getMenuItemText(){
399             return NbBundle.getBundle(MainMenuAction.class).getString(
400                 "goto_declaration_main_menu_edit_item"); //NOI18N
401
}
402
403         public JMenuItem JavaDoc getMenuPresenter() {
404             return GOTO_DECL_MENU;
405         }
406
407         protected String JavaDoc getActionName() {
408             return ExtKit.gotoDeclarationAction;
409         }
410         
411         protected KeyStroke JavaDoc getDefaultAccelerator(){
412             return KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.ALT_MASK);
413         }
414         
415     }
416
417     /** Back action in Go To main menu, wrapper for BaseKit.jumpListPrevAction
418      */

419     public static final class JumpBackAction extends MainMenuAction {
420         
421         private JMenuItem JavaDoc jumpBackMenuItem;
422
423         public JumpBackAction () {
424             super();
425             jumpBackMenuItem = new JMenuItem JavaDoc(getMenuItemText());
426             setMenu();
427         }
428         
429         protected String JavaDoc getMenuItemText () {
430             return NbBundle.getBundle(JumpBackAction.class).getString(
431                 "jump_back_main_menu_item"); //NOI18N
432
}
433
434         public JMenuItem JavaDoc getMenuPresenter () {
435             return jumpBackMenuItem;
436         }
437
438         protected String JavaDoc getActionName () {
439             return BaseKit.jumpListPrevAction;
440         }
441         
442         protected KeyStroke JavaDoc getDefaultAccelerator () {
443             return KeyStroke.getKeyStroke(KeyEvent.VK_K, InputEvent.ALT_MASK);
444         }
445         
446     } // end of JumpBackAction
447

448     /** Forward action in Go To main menu, wrapper for BaseKit.jumpListNextAction
449      */

450     public static final class JumpForwardAction extends MainMenuAction {
451         
452         private JMenuItem JavaDoc jumpForwardMenuItem;
453
454         public JumpForwardAction () {
455             super();
456             jumpForwardMenuItem = new JMenuItem JavaDoc(getMenuItemText());
457             setMenu();
458         }
459         
460         protected String JavaDoc getMenuItemText () {
461             return NbBundle.getBundle(JumpForwardAction.class).getString(
462                 "jump_forward_main_menu_item"); //NOI18N
463
}
464
465         public JMenuItem JavaDoc getMenuPresenter () {
466             return jumpForwardMenuItem;
467         }
468
469         protected String JavaDoc getActionName () {
470             return BaseKit.jumpListNextAction;
471         }
472         
473         protected KeyStroke JavaDoc getDefaultAccelerator () {
474             return KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.ALT_MASK);
475         }
476         
477     } // end of JumpForwardAction
478

479     /** Reformat Code action in Source main menu, wrapper for BaseKit.formatAction
480      */

481     public static final class FormatAction extends MainMenuAction {
482         
483         private JMenuItem JavaDoc formatMenuItem;
484
485         public FormatAction () {
486             super();
487             formatMenuItem = new JMenuItem JavaDoc(getMenuItemText());
488             setMenu();
489         }
490         
491         protected String JavaDoc getMenuItemText () {
492             return NbBundle.getBundle(FormatAction.class).getString(
493                 "format_main_menu_item"); //NOI18N
494
}
495
496         public JMenuItem JavaDoc getMenuPresenter () {
497             return formatMenuItem;
498         }
499
500         protected String JavaDoc getActionName () {
501             return BaseKit.formatAction;
502         }
503         
504     } // end of FormatAction
505

506     /** Shift Left action in Source main menu, wrapper for BaseKit.shiftLineLeftAction
507      */

508     public static final class ShiftLineLeftAction extends MainMenuAction {
509         
510         private JMenuItem JavaDoc menuItem;
511
512         public ShiftLineLeftAction () {
513             super();
514             menuItem = new JMenuItem JavaDoc(getMenuItemText());
515             setMenu();
516         }
517         
518         protected String JavaDoc getMenuItemText () {
519             return NbBundle.getBundle(ShiftLineLeftAction.class).getString(
520                 "shift_line_left_main_menu_item"); //NOI18N
521
}
522
523         public JMenuItem JavaDoc getMenuPresenter () {
524             return menuItem;
525         }
526
527         protected String JavaDoc getActionName () {
528             return BaseKit.shiftLineLeftAction;
529         }
530         
531     } // end of ShiftLineLeftAction
532

533     /** Shift Right action in Source main menu, wrapper for BaseKit.shiftLineRightAction
534      */

535     public static final class ShiftLineRightAction extends MainMenuAction {
536         
537         private JMenuItem JavaDoc menuItem;
538
539         public ShiftLineRightAction () {
540             super();
541             menuItem = new JMenuItem JavaDoc(getMenuItemText());
542             setMenu();
543         }
544         
545         protected String JavaDoc getMenuItemText () {
546             return NbBundle.getBundle(ShiftLineRightAction.class).getString(
547                 "shift_line_right_main_menu_item"); //NOI18N
548
}
549
550         public JMenuItem JavaDoc getMenuPresenter () {
551             return menuItem;
552         }
553
554         protected String JavaDoc getActionName () {
555             return BaseKit.shiftLineRightAction;
556         }
557         
558     } // end of ShiftLineRightAction
559

560     /** Comment action in Source main menu, wrapper for ExtKit.commentAction
561      */

562     public static final class CommentAction extends MainMenuAction {
563         
564         private JMenuItem JavaDoc menuItem;
565
566         public CommentAction () {
567             super();
568             menuItem = new JMenuItem JavaDoc(getMenuItemText());
569             setMenu();
570         }
571         
572         protected String JavaDoc getMenuItemText () {
573             return NbBundle.getBundle(CommentAction.class).getString(
574                 "comment_main_menu_item"); //NOI18N
575
}
576
577         public JMenuItem JavaDoc getMenuPresenter () {
578             return menuItem;
579         }
580
581         protected String JavaDoc getActionName () {
582             return ExtKit.commentAction;
583         }
584         
585     } // end of CommentAction
586

587     /** Uncomment action in Source main menu, wrapper for ExtKit.uncommentAction
588      */

589     public static final class UncommentAction extends MainMenuAction {
590         
591         private JMenuItem JavaDoc menuItem;
592
593         public UncommentAction () {
594             super();
595             menuItem = new JMenuItem JavaDoc(getMenuItemText());
596             setMenu();
597         }
598         
599         protected String JavaDoc getMenuItemText () {
600             return NbBundle.getBundle(UncommentAction.class).getString(
601                 "uncomment_main_menu_item"); //NOI18N
602
}
603
604         public JMenuItem JavaDoc getMenuPresenter () {
605             return menuItem;
606         }
607
608         protected String JavaDoc getActionName () {
609             return ExtKit.uncommentAction;
610         }
611         
612     } // end of UncommentAction
613

614     /** Insert Next Matching Word action in Source main menu, wrapper for BaseKit.wordMatchNextAction
615      */

616     public static final class WordMatchNextAction extends MainMenuAction {
617         
618         private JMenuItem JavaDoc menuItem;
619
620         public WordMatchNextAction () {
621             super();
622             menuItem = new JMenuItem JavaDoc(getMenuItemText());
623             setMenu();
624         }
625         
626         protected String JavaDoc getMenuItemText () {
627             return NbBundle.getBundle(WordMatchNextAction.class).getString(
628                 "word_match_next_main_menu_item"); //NOI18N
629
}
630
631         public JMenuItem JavaDoc getMenuPresenter () {
632             return menuItem;
633         }
634
635         protected String JavaDoc getActionName () {
636             return BaseKit.wordMatchNextAction;
637         }
638         
639     } // end of WordMatchNextAction
640

641     /** Insert Previous Matching Word action in Source main menu, wrapper for BaseKit.wordMatchPrevAction
642      */

643     public static final class WordMatchPrevAction extends MainMenuAction {
644         
645         private JMenuItem JavaDoc menuItem;
646
647         public WordMatchPrevAction () {
648             super();
649             menuItem = new JMenuItem JavaDoc(getMenuItemText());
650             setMenu();
651         }
652         
653         protected String JavaDoc getMenuItemText () {
654             return NbBundle.getBundle(WordMatchPrevAction.class).getString(
655                 "word_match_previous_main_menu_item"); //NOI18N
656
}
657
658         public JMenuItem JavaDoc getMenuPresenter () {
659             return menuItem;
660         }
661
662         protected String JavaDoc getActionName () {
663             return BaseKit.wordMatchPrevAction;
664         }
665         
666     } // end of WordMatchPrevAction
667

668     /** Find Next action in Edit main menu, wrapper for BaseKit.findNextAction
669      */

670     public static final class FindNextAction extends MainMenuAction {
671         
672         private JMenuItem JavaDoc menuItem;
673
674         public FindNextAction () {
675             super(true, BLANK_ICON);
676             menuItem = new JMenuItem JavaDoc(getMenuItemText());
677             setMenu();
678         }
679         
680         protected String JavaDoc getMenuItemText () {
681             return NbBundle.getBundle(FindNextAction.class).getString(
682                 "find_next_main_menu_item"); //NOI18N
683
}
684
685         public JMenuItem JavaDoc getMenuPresenter () {
686             return menuItem;
687         }
688
689         protected String JavaDoc getActionName () {
690             return BaseKit.findNextAction;
691         }
692         
693     } // end of FindNextAction
694

695     
696     /** Find Previous action in Edit main menu, wrapper for BaseKit.findPreviousAction
697      */

698     public static final class FindPreviousAction extends MainMenuAction {
699         
700         private JMenuItem JavaDoc menuItem;
701
702         public FindPreviousAction () {
703             super(true, BLANK_ICON);
704             menuItem = new JMenuItem JavaDoc(getMenuItemText());
705             setMenu();
706         }
707         
708         protected String JavaDoc getMenuItemText () {
709             return NbBundle.getBundle(FindNextAction.class).getString(
710                 "find_previous_main_menu_item"); //NOI18N
711
}
712
713         public JMenuItem JavaDoc getMenuPresenter () {
714             return menuItem;
715         }
716
717         protected String JavaDoc getActionName () {
718             return BaseKit.findPreviousAction;
719         }
720         
721     } // end of FindPreviousAction
722

723     /** Find Selection action in Edit main menu, wrapper for BaseKit.findSelectionAction
724      */

725     public static final class FindSelectionAction extends MainMenuAction {
726         
727         private JMenuItem JavaDoc menuItem;
728
729         public FindSelectionAction () {
730             super(true, BLANK_ICON);
731             menuItem = new JMenuItem JavaDoc(getMenuItemText());
732             setMenu();
733         }
734         
735         protected String JavaDoc getMenuItemText () {
736             return NbBundle.getBundle(FindNextAction.class).getString(
737                 "find_selection_main_menu_item"); //NOI18N
738
}
739
740         public JMenuItem JavaDoc getMenuPresenter () {
741             return menuItem;
742         }
743
744         protected String JavaDoc getActionName () {
745             return BaseKit.findSelectionAction;
746         }
747         
748     } // end of FindSelectionAction
749

750     /** Start Macro Recording action in View main menu, wrapper for BaseKit.startMacroRecordingAction
751      */

752     public static final class StartMacroRecordingAction extends MainMenuAction {
753         
754         private JMenuItem JavaDoc menuItem;
755
756         public StartMacroRecordingAction () {
757             super(true, BLANK_ICON);
758             menuItem = new JMenuItem JavaDoc(getMenuItemText());
759             setMenu();
760         }
761         
762         protected String JavaDoc getMenuItemText () {
763             return NbBundle.getBundle(StartMacroRecordingAction.class).getString(
764                 "start_macro_recording_main_menu_item"); //NOI18N
765
}
766
767         public JMenuItem JavaDoc getMenuPresenter () {
768             return menuItem;
769         }
770
771         protected String JavaDoc getActionName () {
772             return BaseKit.startMacroRecordingAction;
773         }
774         
775     } // end of StartMacroRecordingAction
776

777     /** Stop Macro Recording action in View main menu, wrapper for BaseKit.stopMacroRecordingAction
778      */

779     public static final class StopMacroRecordingAction extends MainMenuAction {
780         
781         private JMenuItem JavaDoc menuItem;
782
783         public StopMacroRecordingAction () {
784             super(true, BLANK_ICON);
785             menuItem = new JMenuItem JavaDoc(getMenuItemText());
786             setMenu();
787         }
788         
789         protected String JavaDoc getMenuItemText () {
790             return NbBundle.getBundle(StopMacroRecordingAction.class).getString(
791                 "stop_macro_recording_main_menu_item"); //NOI18N
792
}
793
794         public JMenuItem JavaDoc getMenuPresenter () {
795             return menuItem;
796         }
797
798         protected String JavaDoc getActionName () {
799             return BaseKit.stopMacroRecordingAction;
800         }
801         
802     } // end of StopMacroRecordingAction
803

804     /** Remove Trailing Spaces action in View main menu, wrapper for BaseKit.removeTrailingSpaces
805      */

806     public static final class RemoveTrailingSpacesAction extends MainMenuAction {
807
808         private JMenuItem JavaDoc menuItem;
809
810         public RemoveTrailingSpacesAction() {
811             super(true, null);
812             menuItem = new JMenuItem JavaDoc(getMenuItemText());
813             setMenu();
814         }
815
816         protected String JavaDoc getMenuItemText () {
817             return NbBundle.getBundle(RemoveTrailingSpacesAction.class).getString(
818                 "remove_trailing_spaces_main_menu_item"); //NOI18N
819
}
820
821         public JMenuItem JavaDoc getMenuPresenter () {
822             return menuItem;
823         }
824
825         protected String JavaDoc getActionName () {
826             return BaseKit.removeTrailingSpacesAction;
827         }
828
829     } // end of RemoveTrailingSpacesAction
830

831     /** Paste Formatted action in Edit main menu, wrapper for BaseKit.pasteFormattedAction
832      */

833     public static final class PasteFormattedAction extends MainMenuAction {
834
835         private JMenuItem JavaDoc menuItem;
836
837         public PasteFormattedAction() {
838             super(true, BLANK_ICON);
839             menuItem = new JMenuItem JavaDoc(getMenuItemText());
840             setMenu();
841         }
842
843         protected String JavaDoc getMenuItemText () {
844             return NbBundle.getBundle(PasteFormattedAction.class).getString(
845                 "paste_formatted_main_menu_item"); //NOI18N
846
}
847
848         public JMenuItem JavaDoc getMenuPresenter () {
849             return menuItem;
850         }
851
852         protected String JavaDoc getActionName () {
853             return BaseKit.pasteFormatedAction;
854         }
855
856     } // end of PasteFormattedAction
857

858 }
859     
Popular Tags