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.

View | Details | Raw Unified | Return to bug 150875
Collapse All | Expand All

(-)a/editor.lib/src/org/netbeans/editor/ActionFactory.java (-109 / +159 lines)
Lines 71-81 Link Here
71
import javax.swing.JCheckBoxMenuItem;
71
import javax.swing.JCheckBoxMenuItem;
72
import java.awt.event.ItemListener;
72
import java.awt.event.ItemListener;
73
import java.awt.event.ItemEvent;
73
import java.awt.event.ItemEvent;
74
import javax.swing.ImageIcon;
75
import javax.swing.JToggleButton;
74
import javax.swing.JToggleButton;
76
import javax.swing.event.ChangeListener;
75
import javax.swing.event.ChangeListener;
77
import javax.swing.text.AbstractDocument;
76
import javax.swing.text.AbstractDocument;
78
import javax.swing.text.View;
77
import javax.swing.text.View;
78
import org.netbeans.api.editor.EditorActionRegistration;
79
import org.netbeans.api.editor.fold.Fold;
79
import org.netbeans.api.editor.fold.Fold;
80
import org.netbeans.api.editor.fold.FoldHierarchy;
80
import org.netbeans.api.editor.fold.FoldHierarchy;
81
import org.netbeans.api.editor.fold.FoldUtilities;
81
import org.netbeans.api.editor.fold.FoldUtilities;
Lines 102-114 Link Here
102
    private ActionFactory() {
102
    private ActionFactory() {
103
        // no instantiation
103
        // no instantiation
104
    }
104
    }
105
    
105
106
    // No registration since shared instance gets created
107
    //@EditorActionRegistration(name = BaseKit.removeTabAction)
106
    public static class RemoveTabAction extends LocalBaseAction {
108
    public static class RemoveTabAction extends LocalBaseAction {
107
109
108
        static final long serialVersionUID =-1537748600593395706L;
110
        static final long serialVersionUID =-1537748600593395706L;
109
111
110
        public RemoveTabAction() {
112
        public RemoveTabAction() {
111
            super(BaseKit.removeTabAction, MAGIC_POSITION_RESET | ABBREV_RESET | WORD_MATCH_RESET);
113
            super(BaseKit.removeTabAction,
114
                    MAGIC_POSITION_RESET | ABBREV_RESET | WORD_MATCH_RESET);
112
        }
115
        }
113
116
114
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
117
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
Lines 197-206 Link Here
197
    }
200
    }
198
     */
201
     */
199
202
203
    @EditorActionRegistration(name = BaseKit.removePreviousWordAction)
200
    public static class RemoveWordPreviousAction extends LocalBaseAction {
204
    public static class RemoveWordPreviousAction extends LocalBaseAction {
201
205
202
        public RemoveWordPreviousAction() {
206
        public RemoveWordPreviousAction() {
203
            super(BaseKit.removePreviousWordAction, MAGIC_POSITION_RESET
207
            super(MAGIC_POSITION_RESET
204
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
208
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
205
        }
209
        }
206
210
Lines 233-244 Link Here
233
        }
237
        }
234
    }
238
    }
235
239
236
    
240
    @EditorActionRegistration(name = BaseKit.removeNextWordAction)
237
    public static class RemoveWordNextAction extends LocalBaseAction {
241
    public static class RemoveWordNextAction extends LocalBaseAction {
238
242
239
        public RemoveWordNextAction() {
243
        public RemoveWordNextAction() {
240
            super(BaseKit.removeNextWordAction, MAGIC_POSITION_RESET
244
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
241
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
242
        }
245
        }
243
246
244
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
247
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 271-283 Link Here
271
    }
274
    }
272
275
273
    
276
    
277
    @EditorActionRegistration(name = BaseKit.removeLineBeginAction)
274
    public static class RemoveLineBeginAction extends LocalBaseAction {
278
    public static class RemoveLineBeginAction extends LocalBaseAction {
275
279
276
        static final long serialVersionUID =9193117196412195554L;
280
        static final long serialVersionUID =9193117196412195554L;
277
281
278
        public RemoveLineBeginAction() {
282
        public RemoveLineBeginAction() {
279
            super(BaseKit.removeLineBeginAction, MAGIC_POSITION_RESET
283
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
280
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
281
        }
284
        }
282
285
283
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
286
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 321-333 Link Here
321
        }
324
        }
322
    }
325
    }
323
326
327
    @EditorActionRegistration(name = BaseKit.removeLineAction)
324
    public static class RemoveLineAction extends LocalBaseAction {
328
    public static class RemoveLineAction extends LocalBaseAction {
325
329
326
        static final long serialVersionUID =-536315497241419877L;
330
        static final long serialVersionUID =-536315497241419877L;
327
331
328
        public RemoveLineAction() {
332
        public RemoveLineAction() {
329
            super(BaseKit.removeLineAction, MAGIC_POSITION_RESET
333
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
330
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
331
        }
334
        }
332
335
333
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
336
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 359-371 Link Here
359
        }
362
        }
360
    }
363
    }
361
    
364
    
362
    /* package */ static class MoveSelectionElseLineUpAction extends LocalBaseAction {
365
    @EditorActionRegistration(name = BaseKit.moveSelectionElseLineUpAction)
366
    public static class MoveSelectionElseLineUpAction extends LocalBaseAction {
363
367
364
        static final long serialVersionUID = 1L;
368
        static final long serialVersionUID = 1L;
365
369
366
        public MoveSelectionElseLineUpAction() {
370
        public MoveSelectionElseLineUpAction() {
367
            super(BaseKit.moveSelectionElseLineUpAction, MAGIC_POSITION_RESET
371
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
368
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
369
        }
372
        }
370
373
371
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
374
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 455-467 Link Here
455
        }
458
        }
456
    }
459
    }
457
    
460
    
458
    /* package */ static class MoveSelectionElseLineDownAction extends LocalBaseAction {
461
    @EditorActionRegistration(name = BaseKit.moveSelectionElseLineDownAction)
462
    public static class MoveSelectionElseLineDownAction extends LocalBaseAction {
459
463
460
        static final long serialVersionUID = 1L;
464
        static final long serialVersionUID = 1L;
461
465
462
        public MoveSelectionElseLineDownAction() {
466
        public MoveSelectionElseLineDownAction() {
463
            super(BaseKit.moveSelectionElseLineDownAction, MAGIC_POSITION_RESET
467
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
464
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
465
        }
468
        }
466
469
467
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
470
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 552-564 Link Here
552
        }
555
        }
553
    }
556
    }
554
    
557
    
555
    /* package */ static class CopySelectionElseLineUpAction extends LocalBaseAction {
558
    @EditorActionRegistration(name = BaseKit.copySelectionElseLineUpAction)
559
    public static class CopySelectionElseLineUpAction extends LocalBaseAction {
556
560
557
        static final long serialVersionUID = 1L;
561
        static final long serialVersionUID = 1L;
558
        
562
        
559
        public CopySelectionElseLineUpAction() {
563
        public CopySelectionElseLineUpAction() {
560
            super(BaseKit.copySelectionElseLineUpAction, MAGIC_POSITION_RESET
564
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
561
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
562
        }
565
        }
563
566
564
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
567
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 639-651 Link Here
639
        }
642
        }
640
    }
643
    }
641
    
644
    
642
    /* package */ static class CopySelectionElseLineDownAction extends LocalBaseAction {
645
    @EditorActionRegistration(name = BaseKit.copySelectionElseLineDownAction)
646
    public static class CopySelectionElseLineDownAction extends LocalBaseAction {
643
647
644
        static final long serialVersionUID = 1L;
648
        static final long serialVersionUID = 1L;
645
649
646
        public CopySelectionElseLineDownAction() {
650
        public CopySelectionElseLineDownAction() {
647
            super(BaseKit.copySelectionElseLineDownAction, MAGIC_POSITION_RESET
651
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
648
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
649
        }
652
        }
650
653
651
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
654
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 727-739 Link Here
727
    }
730
    }
728
731
729
    /* Useful for popup menu - remove selected block or do nothing */
732
    /* Useful for popup menu - remove selected block or do nothing */
733
    // No annotation registration since shared instance exists in BaseKit
734
    //@EditorActionRegistration(name = BaseKit.removeSelectionAction)
730
    public static class RemoveSelectionAction extends LocalBaseAction {
735
    public static class RemoveSelectionAction extends LocalBaseAction {
731
736
732
        static final long serialVersionUID =-1419424594746686573L;
737
        static final long serialVersionUID =-1419424594746686573L;
733
738
734
        public RemoveSelectionAction() {
739
        public RemoveSelectionAction() {
735
            super(BaseKit.removeSelectionAction, MAGIC_POSITION_RESET
740
            super(BaseKit.removeSelectionAction,
736
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
741
                    MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
737
            //#54893 putValue ("helpID", RemoveSelectionAction.class.getName ()); // NOI18N
742
            //#54893 putValue ("helpID", RemoveSelectionAction.class.getName ()); // NOI18N
738
        }
743
        }
739
744
Lines 760-771 Link Here
760
    }
765
    }
761
766
762
    /** Switch to overwrite mode or back to insert mode */
767
    /** Switch to overwrite mode or back to insert mode */
768
    @EditorActionRegistration(name = BaseKit.toggleTypingModeAction)
763
    public static class ToggleTypingModeAction extends LocalBaseAction {
769
    public static class ToggleTypingModeAction extends LocalBaseAction {
764
770
765
        static final long serialVersionUID =-2431132686507799723L;
771
        static final long serialVersionUID =-2431132686507799723L;
766
772
767
        public ToggleTypingModeAction() {
773
        public ToggleTypingModeAction() {
768
            super(BaseKit.toggleTypingModeAction);
774
            super();
769
        }
775
        }
770
776
771
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
777
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 916-921 Link Here
916
     * @deprecated Without any replacement. This action is not used anymore.
922
     * @deprecated Without any replacement. This action is not used anymore.
917
     */
923
     */
918
    public static class StartMacroRecordingAction extends LocalBaseAction {
924
    public static class StartMacroRecordingAction extends LocalBaseAction {
925
    // Not registered by annotation since it's not actively used
919
926
920
        static final long serialVersionUID =1L;
927
        static final long serialVersionUID =1L;
921
928
Lines 937-942 Link Here
937
     * is no longer functional.
944
     * is no longer functional.
938
     */
945
     */
939
    public static class StopMacroRecordingAction extends LocalBaseAction {
946
    public static class StopMacroRecordingAction extends LocalBaseAction {
947
    // Not registered by annotation since it's not actively used
940
948
941
        static final long serialVersionUID =1L;
949
        static final long serialVersionUID =1L;
942
950
Lines 1010-1022 Link Here
1010
1018
1011
    public static class ChangeCaseAction extends LocalBaseAction {
1019
    public static class ChangeCaseAction extends LocalBaseAction {
1012
1020
1021
        @EditorActionRegistration(name = BaseKit.toUpperCaseAction)
1022
        public static ChangeCaseAction createToUpperCase() {
1023
            return new ChangeCaseAction(Utilities.CASE_UPPER);
1024
        }
1025
1026
        @EditorActionRegistration(name = BaseKit.toLowerCaseAction)
1027
        public static ChangeCaseAction createToLowerCase() {
1028
            return new ChangeCaseAction(Utilities.CASE_LOWER);
1029
        }
1030
1031
        @EditorActionRegistration(name = BaseKit.switchCaseAction)
1032
        public static ChangeCaseAction createSwitchCase() {
1033
            return new ChangeCaseAction(Utilities.CASE_SWITCH);
1034
        }
1035
1013
        int changeCaseMode;
1036
        int changeCaseMode;
1014
1037
1015
        static final long serialVersionUID =5680212865619897402L;
1038
        static final long serialVersionUID =5680212865619897402L;
1016
1039
1017
        public ChangeCaseAction(String name, int changeCaseMode) {
1040
        public ChangeCaseAction(int changeCaseMode) {
1018
            super(name, ABBREV_RESET
1041
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1019
                  | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1020
            this.changeCaseMode = changeCaseMode;
1042
            this.changeCaseMode = changeCaseMode;
1021
        }
1043
        }
1022
1044
Lines 1047-1062 Link Here
1047
        }
1069
        }
1048
    }
1070
    }
1049
1071
1050
1072
    @EditorActionRegistration(name = BaseKit.findNextAction,
1073
            iconResource = "org/netbeans/modules/editor/resources/find_next.png") // NOI18N
1051
    public static class FindNextAction extends LocalBaseAction {
1074
    public static class FindNextAction extends LocalBaseAction {
1052
1075
1053
        static final long serialVersionUID =6878814427731642684L;
1076
        static final long serialVersionUID =6878814427731642684L;
1054
1077
1055
        public FindNextAction() {
1078
        public FindNextAction() {
1056
            super(BaseKit.findNextAction, ABBREV_RESET
1079
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1057
                  | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1058
            putValue(BaseAction.ICON_RESOURCE_PROPERTY,
1059
                "org/netbeans/modules/editor/resources/find_next.png"); // NOI18N
1060
        }
1080
        }
1061
1081
1062
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1082
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1066-1080 Link Here
1066
        }
1086
        }
1067
    }
1087
    }
1068
1088
1089
    @EditorActionRegistration(name = BaseKit.findPreviousAction,
1090
            iconResource = "org/netbeans/modules/editor/resources/find_previous.png") // NOI18N
1069
    public static class FindPreviousAction extends LocalBaseAction {
1091
    public static class FindPreviousAction extends LocalBaseAction {
1070
1092
1071
        static final long serialVersionUID =-43746947902694926L;
1093
        static final long serialVersionUID =-43746947902694926L;
1072
1094
1073
        public FindPreviousAction() {
1095
        public FindPreviousAction() {
1074
            super(BaseKit.findPreviousAction, ABBREV_RESET
1096
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1075
                  | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1076
            putValue(BaseAction.ICON_RESOURCE_PROPERTY,
1077
                "org/netbeans/modules/editor/resources/find_previous.png"); // NOI18N
1078
        }
1097
        }
1079
1098
1080
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1099
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1087-1100 Link Here
1087
    /** Finds either selection or if there's no selection it finds
1106
    /** Finds either selection or if there's no selection it finds
1088
    * the word where the cursor is standing.
1107
    * the word where the cursor is standing.
1089
    */
1108
    */
1109
    @EditorActionRegistration(name = BaseKit.findSelectionAction,
1110
            iconResource = "org/netbeans/modules/editor/resources/find_selection.png") // NOI18N
1090
    public static class FindSelectionAction extends LocalBaseAction {
1111
    public static class FindSelectionAction extends LocalBaseAction {
1091
1112
1092
        static final long serialVersionUID =-5601618936504699565L;
1113
        static final long serialVersionUID =-5601618936504699565L;
1093
1114
1094
        public FindSelectionAction() {
1115
        public FindSelectionAction() {
1095
            super(BaseKit.findSelectionAction);
1116
            super();
1096
            putValue(BaseAction.ICON_RESOURCE_PROPERTY,
1097
                "org/netbeans/modules/editor/resources/find_selection.png"); // NOI18N
1098
        }
1117
        }
1099
1118
1100
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1119
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1152-1164 Link Here
1152
        }
1171
        }
1153
    }
1172
    }
1154
1173
1174
    @EditorActionRegistration(name = BaseKit.toggleHighlightSearchAction,
1175
            iconResource = "org/netbeans/modules/editor/resources/toggle_highlight.png")
1155
    public static class ToggleHighlightSearchAction extends LocalBaseAction implements Presenter.Toolbar {
1176
    public static class ToggleHighlightSearchAction extends LocalBaseAction implements Presenter.Toolbar {
1156
1177
1157
        static final long serialVersionUID =4603809175771743200L;
1178
        static final long serialVersionUID =4603809175771743200L;
1158
1179
1159
        public ToggleHighlightSearchAction() {
1180
        public ToggleHighlightSearchAction() {
1160
            super(BaseKit.toggleHighlightSearchAction, CLEAR_STATUS_TEXT);
1181
            super(CLEAR_STATUS_TEXT);
1161
            putValue(Action.SMALL_ICON, ImageUtilities.loadImageIcon("org/netbeans/modules/editor/resources/toggle_highlight.png", false)); // NOI18N
1162
        }
1182
        }
1163
1183
1164
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1184
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1301-1322 Link Here
1301
        }
1321
        }
1302
    }
1322
    }
1303
1323
1324
    @EditorActionRegistration(name = { BaseKit.wordMatchNextAction, BaseKit.wordMatchPrevAction },
1325
            iconResource = { "org/netbeans/modules/editor/resources/next_matching.png",
1326
                             "org/netbeans/modules/editor/resources/previous_matching.png" }
1327
    )
1304
    public static class WordMatchAction extends LocalBaseAction {
1328
    public static class WordMatchAction extends LocalBaseAction {
1305
1329
1306
        private boolean direction;
1330
        private boolean matchNext;
1307
1331
1308
        static final long serialVersionUID =595571114685133170L;
1332
        static final long serialVersionUID =595571114685133170L;
1309
1333
1310
        public WordMatchAction(String name, boolean direction) {
1334
        public WordMatchAction() {
1311
            super(name, ABBREV_RESET
1335
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1312
                  | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1336
        }
1313
            this.direction = direction;
1337
1314
            putValue(BaseAction.ICON_RESOURCE_PROPERTY,
1338
        @Override
1315
                direction
1339
        protected void actionNameUpdate(String actionName) {
1316
                    ? "org/netbeans/modules/editor/resources/next_matching.png" // NOI18N
1340
            super.actionNameUpdate(actionName);
1317
                    : "org/netbeans/modules/editor/resources/previous_matching.png" // NOI18N
1341
            this.matchNext = BaseKit.wordMatchNextAction.equals(actionName);
1318
            );
1319
                        
1320
        }
1342
        }
1321
1343
1322
        public void actionPerformed(final ActionEvent evt, final  JTextComponent target) {
1344
        public void actionPerformed(final ActionEvent evt, final  JTextComponent target) {
Lines 1336-1342 Link Here
1336
                }
1358
                }
1337
1359
1338
                final int dotPos = caret.getDot();
1360
                final int dotPos = caret.getDot();
1339
                final String s = editorUI.getWordMatch().getMatchWord(dotPos, direction);
1361
                final String s = editorUI.getWordMatch().getMatchWord(dotPos, matchNext);
1340
                final String prevWord = editorUI.getWordMatch().getPreviousWord();
1362
                final String prevWord = editorUI.getWordMatch().getPreviousWord();
1341
                if (s != null) {
1363
                if (s != null) {
1342
                    doc.runAtomicAsUser (new Runnable () {
1364
                    doc.runAtomicAsUser (new Runnable () {
Lines 1359-1382 Link Here
1359
                }
1381
                }
1360
            }
1382
            }
1361
        }
1383
        }
1384
1362
    }
1385
    }
1363
1386
1364
1387
1388
    @EditorActionRegistration(name = { BaseKit.shiftLineLeftAction, BaseKit.shiftLineRightAction },
1389
            iconResource = { "org/netbeans/modules/editor/resources/shift_line_left.png",
1390
                             "org/netbeans/modules/editor/resources/shift_line_right.png" }
1391
    )
1365
    public static class ShiftLineAction extends LocalBaseAction {
1392
    public static class ShiftLineAction extends LocalBaseAction {
1366
1393
1367
        boolean right;
1368
1369
        static final long serialVersionUID =-5124732597493699582L;
1394
        static final long serialVersionUID =-5124732597493699582L;
1370
1395
1371
        public ShiftLineAction(String name, boolean right) {
1396
        public ShiftLineAction() {
1372
            super(name, MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1397
            super(MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1373
            this.right = right;
1398
        }
1374
            putValue(BaseAction.ICON_RESOURCE_PROPERTY,
1375
                right
1376
                    ? "org/netbeans/modules/editor/resources/shift_line_right.png" // NOI18N
1377
                    : "org/netbeans/modules/editor/resources/shift_line_left.png" // NOI18N
1378
            );
1379
1399
1400
        @Override
1401
        protected void actionNameUpdate(String actionName) {
1402
            super.actionNameUpdate(actionName);
1380
        }
1403
        }
1381
1404
1382
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
1405
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 1393-1398 Link Here
1393
                        DocumentUtilities.setTypingModification(doc, true);
1416
                        DocumentUtilities.setTypingModification(doc, true);
1394
                        Formatter.pushFormattingContextDocument(doc);
1417
                        Formatter.pushFormattingContextDocument(doc);
1395
                        try {
1418
                        try {
1419
                            boolean right = BaseKit.shiftLineRightAction.equals(getValue(Action.NAME));
1396
                            if (Utilities.isSelectionShowing(caret)) {
1420
                            if (Utilities.isSelectionShowing(caret)) {
1397
                                doc.getFormatter().changeBlockIndent(doc,
1421
                                doc.getFormatter().changeBlockIndent(doc,
1398
                                target.getSelectionStart(), target.getSelectionEnd(),
1422
                                target.getSelectionStart(), target.getSelectionEnd(),
Lines 1414-1427 Link Here
1414
        }
1438
        }
1415
    }
1439
    }
1416
1440
1441
    @EditorActionRegistration(name = BaseKit.reindentLineAction)
1417
    public static class ReindentLineAction extends LocalBaseAction {
1442
    public static class ReindentLineAction extends LocalBaseAction {
1418
1443
1419
        static final long serialVersionUID =1L;
1444
        static final long serialVersionUID =1L;
1420
1445
1421
        public ReindentLineAction() {
1446
        public ReindentLineAction() {
1422
            // TODO: figure out what these flags are all about
1447
            // TODO: figure out what these flags are all about
1423
            super(BaseKit.reindentLineAction,
1448
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1424
                  ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1425
            //putValue ("helpID", ReindentLineAction.class.getName ());
1449
            //putValue ("helpID", ReindentLineAction.class.getName ());
1426
        }
1450
        }
1427
1451
Lines 1495-1506 Link Here
1495
    
1519
    
1496
    public static class AdjustWindowAction extends LocalBaseAction {
1520
    public static class AdjustWindowAction extends LocalBaseAction {
1497
1521
1522
        @EditorActionRegistration(name = BaseKit.adjustWindowTopAction)
1523
        public static AdjustWindowAction createAdjustTop() {
1524
            return new AdjustWindowAction(0);
1525
        }
1526
1527
        @EditorActionRegistration(name = BaseKit.adjustWindowCenterAction)
1528
        public static AdjustWindowAction createAdjustCenter() {
1529
            return new AdjustWindowAction(50);
1530
        }
1531
1532
        @EditorActionRegistration(name = BaseKit.adjustWindowBottomAction)
1533
        public static AdjustWindowAction createAdjustBottom() {
1534
            return new AdjustWindowAction(100);
1535
        }
1536
1498
        int percentFromWindowTop;
1537
        int percentFromWindowTop;
1499
1538
1500
        static final long serialVersionUID =8864278998999643292L;
1539
        static final long serialVersionUID =8864278998999643292L;
1501
1540
1502
        public AdjustWindowAction(String name, int percentFromWindowTop) {
1541
        public AdjustWindowAction(int percentFromWindowTop) {
1503
            super(name);
1504
            this.percentFromWindowTop = percentFromWindowTop;
1542
            this.percentFromWindowTop = percentFromWindowTop;
1505
        }
1543
        }
1506
1544
Lines 1513-1524 Link Here
1513
1551
1514
    public static class AdjustCaretAction extends LocalBaseAction {
1552
    public static class AdjustCaretAction extends LocalBaseAction {
1515
1553
1554
        @EditorActionRegistration(name = BaseKit.adjustCaretTopAction)
1555
        public static AdjustCaretAction createAdjustTop() {
1556
            return new AdjustCaretAction(0);
1557
        }
1558
1559
        @EditorActionRegistration(name = BaseKit.adjustCaretCenterAction)
1560
        public static AdjustCaretAction createAdjustCenter() {
1561
            return new AdjustCaretAction(50);
1562
        }
1563
1564
        @EditorActionRegistration(name = BaseKit.adjustCaretBottomAction)
1565
        public static AdjustCaretAction createAdjustBottom() {
1566
            return new AdjustCaretAction(100);
1567
        }
1568
1516
        int percentFromWindowTop;
1569
        int percentFromWindowTop;
1517
1570
1518
        static final long serialVersionUID =3223383913531191066L;
1571
        static final long serialVersionUID =3223383913531191066L;
1519
1572
1520
        public AdjustCaretAction(String name, int percentFromWindowTop) {
1573
        public AdjustCaretAction(int percentFromWindowTop) {
1521
            super(name);
1522
            this.percentFromWindowTop = percentFromWindowTop;
1574
            this.percentFromWindowTop = percentFromWindowTop;
1523
        }
1575
        }
1524
1576
Lines 1529-1541 Link Here
1529
        }
1581
        }
1530
    }
1582
    }
1531
1583
1584
    @EditorActionRegistration(name = BaseKit.formatAction)
1532
    public static class FormatAction extends LocalBaseAction {
1585
    public static class FormatAction extends LocalBaseAction {
1533
1586
1534
        static final long serialVersionUID =-7666172828961171865L;
1587
        static final long serialVersionUID =-7666172828961171865L;
1535
1588
1536
        public FormatAction() {
1589
        public FormatAction() {
1537
            super(BaseKit.formatAction,
1590
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1538
                  ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1539
            //#54893 putValue ("helpID", FormatAction.class.getName ()); // NOI18N
1591
            //#54893 putValue ("helpID", FormatAction.class.getName ()); // NOI18N
1540
        }
1592
        }
1541
1593
Lines 1619-1634 Link Here
1619
        
1671
        
1620
    }
1672
    }
1621
1673
1674
    @EditorActionRegistration(name = { BaseKit.firstNonWhiteAction, BaseKit.selectionFirstNonWhiteAction })
1622
    public static class FirstNonWhiteAction extends LocalBaseAction {
1675
    public static class FirstNonWhiteAction extends LocalBaseAction {
1623
1676
1624
        boolean select;
1625
1626
        static final long serialVersionUID =-5888439539790901158L;
1677
        static final long serialVersionUID =-5888439539790901158L;
1627
1678
1628
        public FirstNonWhiteAction(String nm, boolean select) {
1679
        public FirstNonWhiteAction() {
1629
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
1680
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1630
                  | WORD_MATCH_RESET);
1631
            this.select = select;
1632
        }
1681
        }
1633
1682
1634
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1683
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1638-1643 Link Here
1638
                    int pos = Utilities.getRowFirstNonWhite((BaseDocument)target.getDocument(),
1687
                    int pos = Utilities.getRowFirstNonWhite((BaseDocument)target.getDocument(),
1639
                                                            caret.getDot());
1688
                                                            caret.getDot());
1640
                    if (pos >= 0) {
1689
                    if (pos >= 0) {
1690
                        boolean select = BaseKit.selectionFirstNonWhiteAction.equals(getValue(Action.NAME));
1641
                        if (select) {
1691
                        if (select) {
1642
                            caret.moveDot(pos);
1692
                            caret.moveDot(pos);
1643
                        } else {
1693
                        } else {
Lines 1651-1666 Link Here
1651
        }
1701
        }
1652
    }
1702
    }
1653
1703
1704
    @EditorActionRegistration(name = { BaseKit.lastNonWhiteAction, BaseKit.selectionLastNonWhiteAction })
1654
    public static class LastNonWhiteAction extends LocalBaseAction {
1705
    public static class LastNonWhiteAction extends LocalBaseAction {
1655
1706
1656
        boolean select;
1657
1658
        static final long serialVersionUID =4503533041729712917L;
1707
        static final long serialVersionUID =4503533041729712917L;
1659
1708
1660
        public LastNonWhiteAction(String nm, boolean select) {
1709
        public LastNonWhiteAction() {
1661
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
1710
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1662
                  | WORD_MATCH_RESET);
1663
            this.select = select;
1664
        }
1711
        }
1665
1712
1666
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1713
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1670-1675 Link Here
1670
                    int pos = Utilities.getRowLastNonWhite((BaseDocument)target.getDocument(),
1717
                    int pos = Utilities.getRowLastNonWhite((BaseDocument)target.getDocument(),
1671
                                                           caret.getDot());
1718
                                                           caret.getDot());
1672
                    if (pos >= 0) {
1719
                    if (pos >= 0) {
1720
                        boolean select = BaseKit.selectionLastNonWhiteAction.equals(getValue(Action.NAME));
1673
                        if (select) {
1721
                        if (select) {
1674
                            caret.moveDot(pos);
1722
                            caret.moveDot(pos);
1675
                        } else {
1723
                        } else {
Lines 1683-1694 Link Here
1683
        }
1731
        }
1684
    }
1732
    }
1685
1733
1734
    @EditorActionRegistration(name = BaseKit.selectIdentifierAction)
1686
    public static class SelectIdentifierAction extends LocalBaseAction {
1735
    public static class SelectIdentifierAction extends LocalBaseAction {
1687
1736
1688
        static final long serialVersionUID =-7288216961333147873L;
1737
        static final long serialVersionUID =-7288216961333147873L;
1689
1738
1690
        public SelectIdentifierAction() {
1739
        public SelectIdentifierAction() {
1691
            super(BaseKit.selectIdentifierAction, MAGIC_POSITION_RESET);
1740
            super(MAGIC_POSITION_RESET);
1692
        }
1741
        }
1693
1742
1694
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1743
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1712-1717 Link Here
1712
        }
1761
        }
1713
    }
1762
    }
1714
1763
1764
    @EditorActionRegistration(name = BaseKit.selectNextParameterAction)
1715
    public static class SelectNextParameterAction extends LocalBaseAction {
1765
    public static class SelectNextParameterAction extends LocalBaseAction {
1716
1766
1717
        static final long serialVersionUID =8045372985336370934L;
1767
        static final long serialVersionUID =8045372985336370934L;
Lines 1762-1767 Link Here
1762
     * in the editor module.
1812
     * in the editor module.
1763
     */
1813
     */
1764
    public static class JumpListNextAction extends LocalBaseAction {
1814
    public static class JumpListNextAction extends LocalBaseAction {
1815
    // Not registered by annotation since it's not actively used
1765
1816
1766
        static final long serialVersionUID =6891721278404990446L;
1817
        static final long serialVersionUID =6891721278404990446L;
1767
        PropertyChangeListener pcl;
1818
        PropertyChangeListener pcl;
Lines 1790-1795 Link Here
1790
     * in the editor module.
1841
     * in the editor module.
1791
     */
1842
     */
1792
    public static class JumpListPrevAction extends LocalBaseAction {
1843
    public static class JumpListPrevAction extends LocalBaseAction {
1844
    // Not registered by annotation since it's not actively used
1793
1845
1794
        static final long serialVersionUID =7174907031986424265L;
1846
        static final long serialVersionUID =7174907031986424265L;
1795
        PropertyChangeListener pcl;
1847
        PropertyChangeListener pcl;
Lines 1818-1823 Link Here
1818
     * in the editor module.
1870
     * in the editor module.
1819
     */
1871
     */
1820
    public static class JumpListNextComponentAction extends LocalBaseAction {
1872
    public static class JumpListNextComponentAction extends LocalBaseAction {
1873
    // Not registered by annotation since it's not actively used
1821
1874
1822
        static final long serialVersionUID =-2059070050865876892L;
1875
        static final long serialVersionUID =-2059070050865876892L;
1823
1876
Lines 1837-1842 Link Here
1837
     * in the editor module.
1890
     * in the editor module.
1838
     */
1891
     */
1839
    public static class JumpListPrevComponentAction extends LocalBaseAction {
1892
    public static class JumpListPrevComponentAction extends LocalBaseAction {
1893
    // Not registered by annotation since it's not actively used
1840
1894
1841
        static final long serialVersionUID =2032230534727849525L;
1895
        static final long serialVersionUID =2032230534727849525L;
1842
1896
Lines 1851-1860 Link Here
1851
        }
1905
        }
1852
    }
1906
    }
1853
1907
1908
    @EditorActionRegistration(name = BaseKit.scrollUpAction)
1854
    public static class ScrollUpAction extends LocalBaseAction {
1909
    public static class ScrollUpAction extends LocalBaseAction {
1855
1910
1856
        public ScrollUpAction() {
1911
        public ScrollUpAction() {
1857
            super(BaseKit.scrollUpAction);
1858
        }
1912
        }
1859
1913
1860
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1914
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1869-1878 Link Here
1869
1923
1870
    }
1924
    }
1871
1925
1926
    @EditorActionRegistration(name = BaseKit.scrollDownAction)
1872
    public static class ScrollDownAction extends LocalBaseAction {
1927
    public static class ScrollDownAction extends LocalBaseAction {
1873
1928
1874
        public ScrollDownAction() {
1929
        public ScrollDownAction() {
1875
            super(BaseKit.scrollDownAction);
1876
        }
1930
        }
1877
1931
1878
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1932
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1887-1899 Link Here
1887
1941
1888
    }
1942
    }
1889
1943
1944
    @EditorActionRegistration(name = BaseKit.insertDateTimeAction)
1890
    public static class InsertDateTimeAction extends LocalBaseAction {
1945
    public static class InsertDateTimeAction extends LocalBaseAction {
1891
        
1946
        
1892
        static final long serialVersionUID =2865619897402L;
1947
        static final long serialVersionUID =2865619897402L;
1893
        
1948
        
1894
        public InsertDateTimeAction() {
1949
        public InsertDateTimeAction() {
1895
            super(BaseKit.insertDateTimeAction,
1950
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1896
            ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1897
        }
1951
        }
1898
        
1952
        
1899
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1953
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1921-1932 Link Here
1921
    }
1975
    }
1922
    
1976
    
1923
    /** Select text of whole document */
1977
    /** Select text of whole document */
1978
    @EditorActionRegistration(name = BaseKit.generateGutterPopupAction)
1924
    public static class GenerateGutterPopupAction extends LocalBaseAction {
1979
    public static class GenerateGutterPopupAction extends LocalBaseAction {
1925
1980
1926
        static final long serialVersionUID =-3502499718130556525L;
1981
        static final long serialVersionUID =-3502499718130556525L;
1927
1982
1928
        public GenerateGutterPopupAction() {
1983
        public GenerateGutterPopupAction() {
1929
            super(BaseKit.generateGutterPopupAction);
1930
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1984
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1931
        }
1985
        }
1932
1986
Lines 1945-1950 Link Here
1945
    }
1999
    }
1946
2000
1947
    /** Switch visibility of line numbers in editor */
2001
    /** Switch visibility of line numbers in editor */
2002
    @EditorActionRegistration(name = BaseKit.toggleLineNumbersAction)
1948
    public static class ToggleLineNumbersAction extends LocalBaseAction {
2003
    public static class ToggleLineNumbersAction extends LocalBaseAction {
1949
2004
1950
        static final long serialVersionUID =-3502499718130556526L;
2005
        static final long serialVersionUID =-3502499718130556526L;
Lines 1952-1958 Link Here
1952
        private JCheckBoxMenuItem item = null;
2007
        private JCheckBoxMenuItem item = null;
1953
2008
1954
        public ToggleLineNumbersAction() {
2009
        public ToggleLineNumbersAction() {
1955
            super(BaseKit.toggleLineNumbersAction);
2010
            super(BaseKit.toggleLineNumbersAction); // Due to creation from MainMenuAction
1956
        }
2011
        }
1957
2012
1958
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2013
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1981-1990 Link Here
1981
    }
2036
    }
1982
    
2037
    
1983
    /** Cycle through annotations on the current line */
2038
    /** Cycle through annotations on the current line */
2039
    @EditorActionRegistration(name = BaseKit.annotationsCyclingAction)
1984
    public static class AnnotationsCyclingAction extends LocalBaseAction {
2040
    public static class AnnotationsCyclingAction extends LocalBaseAction {
1985
        
2041
        
1986
        public AnnotationsCyclingAction() {
2042
        public AnnotationsCyclingAction() {
1987
            super(BaseKit.annotationsCyclingAction);
1988
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
2043
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1989
        }
2044
        }
1990
2045
Lines 2079-2087 Link Here
2079
    }
2134
    }
2080
    
2135
    
2081
    /** Collapse a fold. Depends on the current caret position. */
2136
    /** Collapse a fold. Depends on the current caret position. */
2137
    @EditorActionRegistration(name = BaseKit.collapseFoldAction)
2082
    public static class CollapseFold extends LocalBaseAction {
2138
    public static class CollapseFold extends LocalBaseAction {
2083
        public CollapseFold(){
2139
        public CollapseFold(){
2084
            super(BaseKit.collapseFoldAction);
2085
        }
2140
        }
2086
        
2141
        
2087
        private boolean dotInFoldArea(JTextComponent target, Fold fold, int dot) throws BadLocationException{
2142
        private boolean dotInFoldArea(JTextComponent target, Fold fold, int dot) throws BadLocationException{
Lines 2121-2129 Link Here
2121
    }
2176
    }
2122
    
2177
    
2123
    /** Expand a fold. Depends on the current caret position. */
2178
    /** Expand a fold. Depends on the current caret position. */
2179
    @EditorActionRegistration(name = BaseKit.expandFoldAction)
2124
    public static class ExpandFold extends LocalBaseAction {
2180
    public static class ExpandFold extends LocalBaseAction {
2125
        public ExpandFold(){
2181
        public ExpandFold(){
2126
            super(BaseKit.expandFoldAction);
2127
        }
2182
        }
2128
        
2183
        
2129
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2184
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2148-2156 Link Here
2148
    }
2203
    }
2149
    
2204
    
2150
    /** Collapse all existing folds in the document. */
2205
    /** Collapse all existing folds in the document. */
2206
    @EditorActionRegistration(name = BaseKit.collapseAllFoldsAction)
2151
    public static class CollapseAllFolds extends LocalBaseAction {
2207
    public static class CollapseAllFolds extends LocalBaseAction {
2152
        public CollapseAllFolds(){
2208
        public CollapseAllFolds(){
2153
            super(BaseKit.collapseAllFoldsAction);
2154
        }
2209
        }
2155
        
2210
        
2156
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2211
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2161-2169 Link Here
2161
    }
2216
    }
2162
2217
2163
    /** Expand all existing folds in the document. */
2218
    /** Expand all existing folds in the document. */
2219
    @EditorActionRegistration(name = BaseKit.expandAllFoldsAction)
2164
    public static class ExpandAllFolds extends LocalBaseAction {
2220
    public static class ExpandAllFolds extends LocalBaseAction {
2165
        public ExpandAllFolds(){
2221
        public ExpandAllFolds(){
2166
            super(BaseKit.expandAllFoldsAction);
2167
        }
2222
        }
2168
        
2223
        
2169
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2224
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2174-2183 Link Here
2174
    }
2229
    }
2175
2230
2176
    /** Expand all existing folds in the document. */
2231
    /** Expand all existing folds in the document. */
2232
    @EditorActionRegistration(name = "dump-view-hierarchy")
2177
    public static class DumpViewHierarchyAction extends LocalBaseAction {
2233
    public static class DumpViewHierarchyAction extends LocalBaseAction {
2178
2234
2179
        public DumpViewHierarchyAction() {
2235
        public DumpViewHierarchyAction() {
2180
            super("dump-view-hierarchy"); // NOI18N
2181
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
2236
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
2182
        }
2237
        }
2183
        
2238
        
Lines 2223-2232 Link Here
2223
    }
2278
    }
2224
    
2279
    
2225
    /** Starts a new line in code. */
2280
    /** Starts a new line in code. */
2281
    @EditorActionRegistration(name = BaseKit.startNewLineAction)
2226
    public static class StartNewLine extends LocalBaseAction {
2282
    public static class StartNewLine extends LocalBaseAction {
2227
        public StartNewLine(){
2283
        public StartNewLine(){
2228
            super( BaseKit.startNewLineAction, ABBREV_RESET
2284
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
2229
                  | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
2230
        }
2285
        }
2231
        
2286
        
2232
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
2287
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 2268-2289 Link Here
2268
     * Cut text from the caret position to either begining or end
2323
     * Cut text from the caret position to either begining or end
2269
     * of the line with the caret.
2324
     * of the line with the caret.
2270
     */
2325
     */
2326
    @EditorActionRegistration(name = { BaseKit.cutToLineBeginAction, BaseKit.cutToLineEndAction })
2271
    public static class CutToLineBeginOrEndAction extends LocalBaseAction {
2327
    public static class CutToLineBeginOrEndAction extends LocalBaseAction {
2272
        
2328
        
2273
        /**
2329
        /**
2274
         * Whether cutting to line end instead of line begin.
2275
         */
2276
        private final boolean toLineEnd;
2277
        
2278
        /**
2279
         * Construct new action.
2330
         * Construct new action.
2280
         *
2331
         *
2281
         * @param toLineEnd whether cutting to line end instead of line begin.
2332
         * @param toLineEnd whether cutting to line end instead of line begin.
2282
         */
2333
         */
2283
        public CutToLineBeginOrEndAction(boolean toLineEnd) {
2334
        public CutToLineBeginOrEndAction() {
2284
            super(toLineEnd ? BaseKit.cutToLineEndAction : BaseKit.cutToLineBeginAction,
2335
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
2285
                ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
2286
            this.toLineEnd = toLineEnd;
2287
        }
2336
        }
2288
        
2337
        
2289
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
2338
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 2304-2309 Link Here
2304
                    if (actionMap != null && (cutAction = actionMap.get(DefaultEditorKit.cutAction)) != null) {
2353
                    if (actionMap != null && (cutAction = actionMap.get(DefaultEditorKit.cutAction)) != null) {
2305
                        Caret caret = target.getCaret();
2354
                        Caret caret = target.getCaret();
2306
                        int caretOffset = caret.getDot();
2355
                        int caretOffset = caret.getDot();
2356
                        boolean toLineEnd = BaseKit.cutToLineEndAction.equals(getValue(Action.NAME));
2307
                        int boundOffset = toLineEnd
2357
                        int boundOffset = toLineEnd
2308
                                ? Utilities.getRowEnd(target, caretOffset)
2358
                                ? Utilities.getRowEnd(target, caretOffset)
2309
                                : Utilities.getRowStart(target, caretOffset);
2359
                                : Utilities.getRowStart(target, caretOffset);
(-)a/editor.lib/src/org/netbeans/editor/BaseAction.java (-1 / +28 lines)
Lines 127-132 Link Here
127
127
128
    static final long serialVersionUID =-4255521122272110786L;
128
    static final long serialVersionUID =-4255521122272110786L;
129
129
130
    public BaseAction() {
131
        this(null);
132
    }
133
134
    public BaseAction(int updateMask) {
135
        this(null, updateMask);
136
    }
137
130
    public BaseAction(String name) {
138
    public BaseAction(String name) {
131
        this(name, 0);
139
        this(name, 0);
132
    }
140
    }
Lines 156-162 Link Here
156
164
157
        return obj;
165
        return obj;
158
    }
166
    }
159
    
167
168
    @Override
169
    public void putValue(String key, Object value) {
170
        super.putValue(key, value);
171
        if (Action.NAME.equals(key) && value instanceof String) {
172
            actionNameUpdate((String)value);
173
        }
174
    }
175
176
    /**
177
     * Called by {@link #putValue(String,String)} when {@link Action#NAME} property
178
     * is set to a non-null String value. This allows a "polymorphic" action (with
179
     * Action.NAME-specific behavior) to update certain properties (e.g. an icon)
180
     * according to the name that was set.
181
     *
182
     * @param actionName non-null action's name (value of Action.NAME property).
183
     */
184
    protected void actionNameUpdate(String actionName) {
185
    }
186
160
    /**
187
    /**
161
     * This method is called when there is no value for the particular key.
188
     * This method is called when there is no value for the particular key.
162
     * <br/>
189
     * <br/>
(-)a/editor.lib/src/org/netbeans/editor/BaseKit.java (-191 / +198 lines)
Lines 77-82 Link Here
77
import javax.swing.text.AbstractDocument;
77
import javax.swing.text.AbstractDocument;
78
import javax.swing.text.EditorKit;
78
import javax.swing.text.EditorKit;
79
import javax.swing.text.Position;
79
import javax.swing.text.Position;
80
import org.netbeans.api.editor.EditorActionRegistration;
80
import org.netbeans.api.editor.mimelookup.MimeLookup;
81
import org.netbeans.api.editor.mimelookup.MimeLookup;
81
import org.netbeans.api.editor.mimelookup.MimePath;
82
import org.netbeans.api.editor.mimelookup.MimePath;
82
import org.netbeans.api.editor.settings.KeyBindingSettings;
83
import org.netbeans.api.editor.settings.KeyBindingSettings;
Lines 691-699 Link Here
691
    */
692
    */
692
    public static Map<String, Action> actionsToMap(Action[] actions) {
693
    public static Map<String, Action> actionsToMap(Action[] actions) {
693
        Map<String, Action> map = new HashMap<String, Action>();
694
        Map<String, Action> map = new HashMap<String, Action>();
694
        for (Action a : actions) {
695
        for (int i = 0; i < actions.length; i++) {
696
            Action a = actions[i];
697
            if (a == null) {
698
                throw new IllegalStateException("actions[] contains null at index " + i +
699
                        ((i > 0) ? ". Preceding action is " + actions[i - 1] : ""));
700
            }
695
            String name = (String) a.getValue(Action.NAME);
701
            String name = (String) a.getValue(Action.NAME);
696
            map.put(((name != null) ? name : ""), a); // NOI18N
702
            if (name == null) {
703
                throw new IllegalStateException("Null Action.NAME property of action " + a);
704
            }
705
            map.put(name, a); // NOI18N
697
        }
706
        }
698
        return map;
707
        return map;
699
    }
708
    }
Lines 824-930 Link Here
824
    */
833
    */
825
    protected Action[] createActions() {
834
    protected Action[] createActions() {
826
        return new Action[] {
835
        return new Action[] {
827
                   new DefaultKeyTypedAction(),
836
// annotation-registration                   new DefaultKeyTypedAction(),
828
                   new InsertContentAction(),
837
// annotation-registration                   new InsertContentAction(),
829
                   insertBreakActionDef,
838
                   insertBreakActionDef,
830
		   new SplitLineAction(),
839
// annotation-registration                   new SplitLineAction(),
831
                   insertTabActionDef,
840
                   insertTabActionDef,
832
                   deletePrevCharActionDef,
841
                   deletePrevCharActionDef,
833
                   deleteNextCharActionDef,
842
                   deleteNextCharActionDef,
834
                   new ReadOnlyAction(),
843
// annotation-registration                   new ReadOnlyAction(),
835
                   new WritableAction(),
844
// annotation-registration                   new WritableAction(),
836
                   cutActionDef,
845
                   cutActionDef,
837
                   copyActionDef,
846
                   copyActionDef,
838
                   pasteActionDef,
847
                   pasteActionDef,
839
                   new PasteAction(true),
848
                   new PasteAction(true),
840
                   new BeepAction(),
849
// annotation-registration                   new BeepAction(),
841
                   new UpAction(upAction, false),
850
// annotation-registration                   new UpAction(upAction, false),
842
                   new UpAction(selectionUpAction, true),
851
// annotation-registration                   new UpAction(selectionUpAction, true),
843
                   new PageUpAction(pageUpAction, false),
852
// annotation-registration                   new PageUpAction(pageUpAction, false),
844
                   new PageUpAction(selectionPageUpAction, true),
853
// annotation-registration                   new PageUpAction(selectionPageUpAction, true),
845
                   new DownAction(downAction, false),
854
// annotation-registration                   new DownAction(downAction, false),
846
                   new DownAction(selectionDownAction, true),
855
// annotation-registration                   new DownAction(selectionDownAction, true),
847
                   new PageDownAction(selectionPageDownAction, true),
856
// annotation-registration                   new PageDownAction(selectionPageDownAction, true),
848
                   new PageDownAction(pageDownAction, false),
857
// annotation-registration                   new PageDownAction(pageDownAction, false),
849
                   new ForwardAction(forwardAction, false),
858
// annotation-registration                   new ForwardAction(forwardAction, false),
850
                   new ForwardAction(selectionForwardAction, true),
859
// annotation-registration                   new ForwardAction(selectionForwardAction, true),
851
                   new BackwardAction(backwardAction, false),
860
// annotation-registration                   new BackwardAction(backwardAction, false),
852
                   new BackwardAction(selectionBackwardAction, true),
861
// annotation-registration                   new BackwardAction(selectionBackwardAction, true),
853
                   new BeginLineAction(lineFirstColumnAction, false, true),
862
// annotation-registration                   new BeginLineAction(lineFirstColumnAction, false, true),
854
                   new BeginLineAction(selectionLineFirstColumnAction, true, true),
863
// annotation-registration                   new BeginLineAction(selectionLineFirstColumnAction, true, true),
855
                   new BeginLineAction(beginLineAction, false),
864
// annotation-registration                   new BeginLineAction(beginLineAction, false),
856
                   new BeginLineAction(selectionBeginLineAction, true),
865
// annotation-registration                   new BeginLineAction(selectionBeginLineAction, true),
857
                   new EndLineAction(endLineAction, false),
866
// annotation-registration                   new EndLineAction(endLineAction, false),
858
                   new EndLineAction(selectionEndLineAction, true),
867
// annotation-registration                   new EndLineAction(selectionEndLineAction, true),
859
                   new BeginAction(beginAction, false),
868
// annotation-registration                   new BeginAction(beginAction, false),
860
                   new BeginAction(selectionBeginAction, true),
869
// annotation-registration                   new BeginAction(selectionBeginAction, true),
861
                   new EndAction(endAction, false),
870
// annotation-registration                   new EndAction(endAction, false),
862
                   new EndAction(selectionEndAction, true),
871
// annotation-registration                   new EndAction(selectionEndAction, true),
863
                   new NextWordAction(nextWordAction, false),
872
// annotation-registration                   new NextWordAction(nextWordAction, false),
864
                   new NextWordAction(selectionNextWordAction, true),
873
// annotation-registration                   new NextWordAction(selectionNextWordAction, true),
865
                   new PreviousWordAction(previousWordAction, false),
874
// annotation-registration                   new PreviousWordAction(previousWordAction, false),
866
                   new PreviousWordAction(selectionPreviousWordAction, true),
875
// annotation-registration                   new PreviousWordAction(selectionPreviousWordAction, true),
867
                   new BeginWordAction(beginWordAction, false),
876
// annotation-registration                   new BeginWordAction(beginWordAction, false),
868
                   new BeginWordAction(selectionBeginWordAction, true),
877
// annotation-registration                   new BeginWordAction(selectionBeginWordAction, true),
869
                   new EndWordAction(endWordAction, false),
878
// annotation-registration                   new EndWordAction(endWordAction, false),
870
                   new EndWordAction(selectionEndWordAction, true),
879
// annotation-registration                   new EndWordAction(selectionEndWordAction, true),
871
                   new SelectWordAction(),
880
// annotation-registration                   new SelectWordAction(),
872
                   new SelectLineAction(),
881
// annotation-registration                   new SelectLineAction(),
873
                   new SelectAllAction(),
882
// annotation-registration                   new SelectAllAction(),
874
                   new RemoveTrailingSpacesAction(),
883
// annotation-registration                   new RemoveTrailingSpacesAction(),
875
                   removeTabActionDef,
884
                   removeTabActionDef,
876
                   //new ActionFactory.RemoveWordAction(), #47709
885
                   //new ActionFactory.RemoveWordAction(), #47709
877
                   new ActionFactory.RemoveWordPreviousAction(),
886
// annotation-registration                   new ActionFactory.RemoveWordPreviousAction(),
878
                   new ActionFactory.RemoveWordNextAction(),
887
// annotation-registration                   new ActionFactory.RemoveWordNextAction(),
879
                   new ActionFactory.RemoveLineBeginAction(),
888
// annotation-registration                   new ActionFactory.RemoveLineBeginAction(),
880
                   new ActionFactory.RemoveLineAction(),
889
// annotation-registration                   new ActionFactory.RemoveLineAction(),
881
                   new ActionFactory.MoveSelectionElseLineUpAction(),
890
// annotation-registration                   new ActionFactory.MoveSelectionElseLineUpAction(),
882
                   new ActionFactory.MoveSelectionElseLineDownAction(),
891
// annotation-registration                   new ActionFactory.MoveSelectionElseLineDownAction(),
883
                   new ActionFactory.CopySelectionElseLineUpAction(),
892
// annotation-registration                   new ActionFactory.CopySelectionElseLineUpAction(),
884
                   new ActionFactory.CopySelectionElseLineDownAction(),
893
// annotation-registration                   new ActionFactory.CopySelectionElseLineDownAction(),
885
                   removeSelectionActionDef,
894
                   removeSelectionActionDef,
886
                   new ActionFactory.ToggleTypingModeAction(),
895
// annotation-registration                   new ActionFactory.ToggleTypingModeAction(),
887
                   new ActionFactory.ChangeCaseAction(toUpperCaseAction, Utilities.CASE_UPPER),
896
// annotation-registration                   new ActionFactory.ChangeCaseAction(toUpperCaseAction, Utilities.CASE_UPPER),
888
                   new ActionFactory.ChangeCaseAction(toLowerCaseAction, Utilities.CASE_LOWER),
897
// annotation-registration                   new ActionFactory.ChangeCaseAction(toLowerCaseAction, Utilities.CASE_LOWER),
889
                   new ActionFactory.ChangeCaseAction(switchCaseAction, Utilities.CASE_SWITCH),
898
// annotation-registration                   new ActionFactory.ChangeCaseAction(switchCaseAction, Utilities.CASE_SWITCH),
890
                   new ActionFactory.FindNextAction(),
899
// annotation-registration                   new ActionFactory.FindNextAction(),
891
                   new ActionFactory.FindPreviousAction(),
900
// annotation-registration                   new ActionFactory.FindPreviousAction(),
892
                   new ActionFactory.FindSelectionAction(),
901
// annotation-registration                   new ActionFactory.FindSelectionAction(),
893
                   new ActionFactory.ToggleHighlightSearchAction(),
902
// annotation-registration                   new ActionFactory.ToggleHighlightSearchAction(),
894
                   undoActionDef,
903
                   undoActionDef,
895
                   redoActionDef,
904
                   redoActionDef,
896
                   new ActionFactory.WordMatchAction(wordMatchNextAction, true),
905
// annotation-registration                   new ActionFactory.WordMatchAction(wordMatchNextAction, true),
897
                   new ActionFactory.WordMatchAction(wordMatchPrevAction, false),
906
// annotation-registration                   new ActionFactory.WordMatchAction(wordMatchPrevAction, false),
898
                   new ActionFactory.ReindentLineAction(),
907
// annotation-registration                   new ActionFactory.ReindentLineAction(),
899
                   new ActionFactory.ShiftLineAction(shiftLineLeftAction, false),
908
// annotation-registration                   new ActionFactory.ShiftLineAction(shiftLineLeftAction, false),
900
                   new ActionFactory.ShiftLineAction(shiftLineRightAction, true),
909
// annotation-registration                   new ActionFactory.ShiftLineAction(shiftLineRightAction, true),
901
                   new ActionFactory.AdjustWindowAction(adjustWindowTopAction, 0),
910
// annotation-registration                   new ActionFactory.AdjustWindowAction(adjustWindowTopAction, 0),
902
                   new ActionFactory.AdjustWindowAction(adjustWindowCenterAction, 50),
911
// annotation-registration                   new ActionFactory.AdjustWindowAction(adjustWindowCenterAction, 50),
903
                   new ActionFactory.AdjustWindowAction(adjustWindowBottomAction, 100),
912
// annotation-registration                   new ActionFactory.AdjustWindowAction(adjustWindowBottomAction, 100),
904
                   new ActionFactory.AdjustCaretAction(adjustCaretTopAction, 0),
913
// annotation-registration                   new ActionFactory.AdjustCaretAction(adjustCaretTopAction, 0),
905
                   new ActionFactory.AdjustCaretAction(adjustCaretCenterAction, 50),
914
// annotation-registration                   new ActionFactory.AdjustCaretAction(adjustCaretCenterAction, 50),
906
                   new ActionFactory.AdjustCaretAction(adjustCaretBottomAction, 100),
915
// annotation-registration                   new ActionFactory.AdjustCaretAction(adjustCaretBottomAction, 100),
907
                   new ActionFactory.FormatAction(),
916
// annotation-registration                   new ActionFactory.FormatAction(),
908
                   new ActionFactory.FirstNonWhiteAction(firstNonWhiteAction, false),
917
// annotation-registration                   new ActionFactory.FirstNonWhiteAction(firstNonWhiteAction, false),
909
                   new ActionFactory.FirstNonWhiteAction(selectionFirstNonWhiteAction, true),
918
// annotation-registration                   new ActionFactory.FirstNonWhiteAction(selectionFirstNonWhiteAction, true),
910
                   new ActionFactory.LastNonWhiteAction(lastNonWhiteAction, false),
919
// annotation-registration                   new ActionFactory.LastNonWhiteAction(lastNonWhiteAction, false),
911
                   new ActionFactory.LastNonWhiteAction(selectionLastNonWhiteAction, true),
920
// annotation-registration                   new ActionFactory.LastNonWhiteAction(selectionLastNonWhiteAction, true),
912
                   new ActionFactory.SelectIdentifierAction(),
921
// annotation-registration                   new ActionFactory.SelectIdentifierAction(),
913
                   new ActionFactory.SelectNextParameterAction(),
922
// annotation-registration                   new ActionFactory.SelectNextParameterAction(),
914
                   new ActionFactory.ScrollUpAction(),
923
// annotation-registration                   new ActionFactory.ScrollUpAction(),
915
                   new ActionFactory.ScrollDownAction(),
924
// annotation-registration                   new ActionFactory.ScrollDownAction(),
916
                   new ActionFactory.InsertDateTimeAction(),
925
// annotation-registration                   new ActionFactory.InsertDateTimeAction(),
917
                   new ActionFactory.GenerateGutterPopupAction(),
926
// annotation-registration                   new ActionFactory.GenerateGutterPopupAction(),
918
                   new ActionFactory.ToggleLineNumbersAction(),
927
// annotation-registration                   new ActionFactory.ToggleLineNumbersAction(),
919
                   new ActionFactory.AnnotationsCyclingAction(),
928
// annotation-registration                   new ActionFactory.AnnotationsCyclingAction(),
920
                   new ActionFactory.CollapseFold(),
929
// annotation-registration                   new ActionFactory.CollapseFold(),
921
                   new ActionFactory.ExpandFold(),
930
// annotation-registration                   new ActionFactory.ExpandFold(),
922
                   new ActionFactory.CollapseAllFolds(),
931
// annotation-registration                   new ActionFactory.CollapseAllFolds(),
923
                   new ActionFactory.ExpandAllFolds(),
932
// annotation-registration                   new ActionFactory.ExpandAllFolds(),
924
                   new ActionFactory.DumpViewHierarchyAction(),
933
// annotation-registration                   new ActionFactory.DumpViewHierarchyAction(),
925
                   new ActionFactory.StartNewLine(),
934
// annotation-registration                   new ActionFactory.StartNewLine(),
926
                   new ActionFactory.CutToLineBeginOrEndAction(false),
935
// annotation-registration                   new ActionFactory.CutToLineBeginOrEndAction(false),
927
                   new ActionFactory.CutToLineBeginOrEndAction(true),
936
// annotation-registration                   new ActionFactory.CutToLineBeginOrEndAction(true),
928
937
929
                   // Self test actions
938
                   // Self test actions
930
                   //      new EditorDebug.SelfTestAction(),
939
                   //      new EditorDebug.SelfTestAction(),
Lines 1033-1043 Link Here
1033
1042
1034
1043
1035
    /** Default typed action */
1044
    /** Default typed action */
1045
    @EditorActionRegistration(name = defaultKeyTypedAction)
1036
    public static class DefaultKeyTypedAction extends LocalBaseAction {
1046
    public static class DefaultKeyTypedAction extends LocalBaseAction {
1037
1047
1038
        static final long serialVersionUID =3069164318144463899L;
1048
        static final long serialVersionUID =3069164318144463899L;
1039
1049
1040
        public DefaultKeyTypedAction() {
1050
        public DefaultKeyTypedAction() {
1051
            // Construct with defaultKeyTypedAction name to retain full compatibility for extending actions
1041
            super(defaultKeyTypedAction, MAGIC_POSITION_RESET | CLEAR_STATUS_TEXT);
1052
            super(defaultKeyTypedAction, MAGIC_POSITION_RESET | CLEAR_STATUS_TEXT);
1042
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1053
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1043
            LOG.fine("DefaultKeyTypedAction with enhanced logging, see issue #145306"); //NOI18N
1054
            LOG.fine("DefaultKeyTypedAction with enhanced logging, see issue #145306"); //NOI18N
Lines 1246-1257 Link Here
1246
      }
1257
      }
1247
    }
1258
    }
1248
1259
1260
    @EditorActionRegistration(name = splitLineAction)
1249
    public static class SplitLineAction extends LocalBaseAction {
1261
    public static class SplitLineAction extends LocalBaseAction {
1250
1262
1251
        static final long serialVersionUID =7966576342334158659L;
1263
        static final long serialVersionUID =7966576342334158659L;
1252
1264
1253
        public SplitLineAction() {
1265
        public SplitLineAction() {
1254
	  super(splitLineAction, MAGIC_POSITION_RESET | ABBREV_RESET | WORD_MATCH_RESET);
1266
	  super(MAGIC_POSITION_RESET | ABBREV_RESET | WORD_MATCH_RESET);
1255
        }
1267
        }
1256
1268
1257
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
1269
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
Lines 1417-1422 Link Here
1417
1429
1418
        static final long serialVersionUID =8415246475764264835L;
1430
        static final long serialVersionUID =8415246475764264835L;
1419
1431
1432
        public KitCompoundAction(String actionNames[]) {
1433
            this(0, actionNames);
1434
        }
1435
1436
        public KitCompoundAction(int resetMask, String actionNames[]) {
1437
            super(resetMask);
1438
            this.actionNames = actionNames;
1439
        }
1440
1420
        public KitCompoundAction(String nm, String actionNames[]) {
1441
        public KitCompoundAction(String nm, String actionNames[]) {
1421
            this(nm, 0, actionNames);
1442
            this(nm, 0, actionNames);
1422
        }
1443
        }
Lines 1445-1457 Link Here
1445
        }
1466
        }
1446
    }
1467
    }
1447
1468
1469
    @EditorActionRegistration(name = insertContentAction)
1448
    public static class InsertContentAction extends LocalBaseAction {
1470
    public static class InsertContentAction extends LocalBaseAction {
1449
1471
1450
        static final long serialVersionUID =5647751370952797218L;
1472
        static final long serialVersionUID =5647751370952797218L;
1451
1473
1452
        public InsertContentAction() {
1474
        public InsertContentAction() {
1453
            super(insertContentAction, MAGIC_POSITION_RESET | ABBREV_RESET
1475
            super(MAGIC_POSITION_RESET | ABBREV_RESET | WORD_MATCH_RESET);
1454
                  | WORD_MATCH_RESET);
1455
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1476
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1456
        }
1477
        }
1457
1478
Lines 1559-1570 Link Here
1559
      }
1580
      }
1560
    }
1581
    }
1561
1582
1583
    @EditorActionRegistration(name = readOnlyAction)
1562
    public static class ReadOnlyAction extends LocalBaseAction {
1584
    public static class ReadOnlyAction extends LocalBaseAction {
1563
1585
1564
        static final long serialVersionUID =9204335480208463193L;
1586
        static final long serialVersionUID =9204335480208463193L;
1565
1587
1566
        public ReadOnlyAction() {
1588
        public ReadOnlyAction() {
1567
            super(readOnlyAction);
1568
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1589
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1569
        }
1590
        }
1570
1591
Lines 1575-1586 Link Here
1575
        }
1596
        }
1576
    }
1597
    }
1577
1598
1599
    @EditorActionRegistration(name = writableAction)
1578
    public static class WritableAction extends LocalBaseAction {
1600
    public static class WritableAction extends LocalBaseAction {
1579
1601
1580
        static final long serialVersionUID =-5982547952800937954L;
1602
        static final long serialVersionUID =-5982547952800937954L;
1581
1603
1582
        public WritableAction() {
1604
        public WritableAction() {
1583
            super(writableAction);
1584
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1605
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1585
        }
1606
        }
1586
1607
Lines 1668-1679 Link Here
1668
    public static class PasteAction extends LocalBaseAction {
1689
    public static class PasteAction extends LocalBaseAction {
1669
1690
1670
        static final long serialVersionUID =5839791453996432149L;
1691
        static final long serialVersionUID =5839791453996432149L;
1671
        private boolean formatted;
1672
1692
1673
        public PasteAction(boolean formated) {
1693
        public PasteAction(boolean formatted) {
1674
            super(formated ? pasteFormatedAction : pasteAction, ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1694
            super(formatted ? pasteFormatedAction : pasteAction,
1675
            //#54893 putValue ("helpID", PasteAction.class.getName ()); // NOI18N
1695
                ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1676
            this.formatted = formated;
1677
        }
1696
        }
1678
1697
1679
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
1698
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
Lines 1694-1699 Link Here
1694
                }
1713
                }
1695
1714
1696
                final Formatter formatter = doc.getFormatter();
1715
                final Formatter formatter = doc.getFormatter();
1716
                final boolean formatted = pasteFormatedAction.equals(getValue(Action.NAME));
1697
                if (formatted) {
1717
                if (formatted) {
1698
                    formatter.reformatLock();
1718
                    formatter.reformatLock();
1699
                }
1719
                }
Lines 1792-1804 Link Here
1792
    }
1812
    }
1793
1813
1794
1814
1795
1815
    @EditorActionRegistration(name = beepAction)
1796
    public static class BeepAction extends LocalBaseAction {
1816
    public static class BeepAction extends LocalBaseAction {
1797
1817
1798
        static final long serialVersionUID =-4474054576633223968L;
1818
        static final long serialVersionUID =-4474054576633223968L;
1799
1819
1800
        public BeepAction() {
1820
        public BeepAction() {
1801
            super(beepAction);
1802
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1821
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1803
        }
1822
        }
1804
1823
Lines 1810-1825 Link Here
1810
    }
1829
    }
1811
1830
1812
1831
1832
    @EditorActionRegistration(name = { upAction, selectionUpAction })
1813
    public static class UpAction extends LocalBaseAction {
1833
    public static class UpAction extends LocalBaseAction {
1814
1834
1815
        boolean select;
1816
1817
        static final long serialVersionUID =4621760742646981563L;
1835
        static final long serialVersionUID =4621760742646981563L;
1818
1836
1819
        public UpAction(String nm, boolean select) {
1837
        public UpAction() {
1820
            super(nm, ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET
1838
            super(ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
1821
            | CLEAR_STATUS_TEXT);
1822
            this.select = select;
1823
        }
1839
        }
1824
1840
1825
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1841
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1839-1844 Link Here
1839
                    }
1855
                    }
1840
                    try {
1856
                    try {
1841
                        dot = Utilities.getPositionAbove(target, dot, p.x);
1857
                        dot = Utilities.getPositionAbove(target, dot, p.x);
1858
                        boolean select = selectionUpAction.equals(getValue(Action.NAME));
1842
                        if (select) {
1859
                        if (select) {
1843
                            caret.moveDot(dot);
1860
                            caret.moveDot(dot);
1844
                        } else {
1861
                        } else {
Lines 1854-1869 Link Here
1854
        }
1871
        }
1855
    }
1872
    }
1856
1873
1874
    @EditorActionRegistration(name = { downAction, selectionDownAction })
1857
    public static class DownAction extends LocalBaseAction {
1875
    public static class DownAction extends LocalBaseAction {
1858
1876
1859
        boolean select;
1860
1861
        static final long serialVersionUID =-5635702355125266822L;
1877
        static final long serialVersionUID =-5635702355125266822L;
1862
1878
1863
        public DownAction(String nm, boolean select) {
1879
        public DownAction() {
1864
            super(nm, ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET
1880
            super(ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
1865
            | CLEAR_STATUS_TEXT);
1866
            this.select = select;
1867
        }
1881
        }
1868
1882
1869
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1883
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1883-1888 Link Here
1883
                    }
1897
                    }
1884
                    try {
1898
                    try {
1885
                        dot = Utilities.getPositionBelow(target, dot, p.x);
1899
                        dot = Utilities.getPositionBelow(target, dot, p.x);
1900
                        boolean select = selectionDownAction.equals(getValue(Action.NAME));
1886
                        if (select) {
1901
                        if (select) {
1887
                            caret.moveDot(dot);
1902
                            caret.moveDot(dot);
1888
                        } else {
1903
                        } else {
Lines 1899-1914 Link Here
1899
    }
1914
    }
1900
1915
1901
    /** Go one page up */
1916
    /** Go one page up */
1917
    @EditorActionRegistration(name = { pageUpAction, selectionPageUpAction })
1902
    public static class PageUpAction extends LocalBaseAction {
1918
    public static class PageUpAction extends LocalBaseAction {
1903
1919
1904
        boolean select;
1905
1906
        static final long serialVersionUID =-3107382148581661079L;
1920
        static final long serialVersionUID =-3107382148581661079L;
1907
1921
1908
        public PageUpAction(String nm, boolean select) {
1922
        public PageUpAction() {
1909
            super(nm, ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET
1923
            super(ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
1910
            | CLEAR_STATUS_TEXT);
1911
            this.select = select;
1912
        }
1924
        }
1913
1925
1914
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1926
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1985-1991 Link Here
1985
                        newCaretOffset = target.viewToModel(newCaretPoint);
1997
                        newCaretOffset = target.viewToModel(newCaretPoint);
1986
                        newCaretBounds = target.modelToView(newCaretOffset);
1998
                        newCaretBounds = target.modelToView(newCaretOffset);
1987
                    }
1999
                    }
1988
                    
2000
2001
                    boolean select = selectionPageUpAction.equals(getValue(Action.NAME));
1989
                    if (select) {
2002
                    if (select) {
1990
                        caret.moveDot(newCaretOffset);
2003
                        caret.moveDot(newCaretOffset);
1991
                    } else {
2004
                    } else {
Lines 2003-2018 Link Here
2003
        }
2016
        }
2004
    }
2017
    }
2005
2018
2019
    @EditorActionRegistration(name = { forwardAction, selectionForwardAction })
2006
    public static class ForwardAction extends LocalBaseAction {
2020
    public static class ForwardAction extends LocalBaseAction {
2007
2021
2008
        boolean select;
2009
2010
        static final long serialVersionUID =8007293230193334414L;
2022
        static final long serialVersionUID =8007293230193334414L;
2011
2023
2012
        public ForwardAction(String nm, boolean select) {
2024
        public ForwardAction() {
2013
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2025
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2014
            | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2026
                | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2015
            this.select = select;
2016
        }
2027
        }
2017
2028
2018
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2029
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2020-2025 Link Here
2020
                Caret caret = target.getCaret();
2031
                Caret caret = target.getCaret();
2021
                try {
2032
                try {
2022
                    int pos;
2033
                    int pos;
2034
                    boolean select = selectionForwardAction.equals(getValue(Action.NAME));
2023
                    if (!select && Utilities.isSelectionShowing(caret))
2035
                    if (!select && Utilities.isSelectionShowing(caret))
2024
                    {
2036
                    {
2025
                        pos = target.getSelectionEnd(); 
2037
                        pos = target.getSelectionEnd(); 
Lines 2048-2070 Link Here
2048
    }
2060
    }
2049
2061
2050
    /** Go one page down */
2062
    /** Go one page down */
2063
    @EditorActionRegistration(name = { pageDownAction, selectionPageDownAction })
2051
    public static class PageDownAction extends LocalBaseAction {
2064
    public static class PageDownAction extends LocalBaseAction {
2052
2065
2053
        boolean select;
2054
2055
        static final long serialVersionUID =8942534850985048862L;
2066
        static final long serialVersionUID =8942534850985048862L;
2056
2067
2057
        public PageDownAction(String nm, boolean select) {
2068
        public PageDownAction() {
2058
            super(nm, ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET
2069
            super(ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET
2059
            | CLEAR_STATUS_TEXT);
2070
                | CLEAR_STATUS_TEXT);
2060
            this.select = select;
2061
        }
2071
        }
2062
2072
2063
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2073
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2064
            if (target != null) {
2074
            if (target != null) {
2065
                try {
2075
                try {
2066
                    Caret caret = target.getCaret();
2076
                    Caret caret = target.getCaret();
2067
                    BaseDocument doc = (BaseDocument)target.getDocument();
2068
                    int caretOffset = caret.getDot();
2077
                    int caretOffset = caret.getDot();
2069
                    Rectangle caretBounds = ((BaseTextUI)target.getUI()).modelToView(target, caretOffset);
2078
                    Rectangle caretBounds = ((BaseTextUI)target.getUI()).modelToView(target, caretOffset);
2070
                    if (caretBounds == null) {
2079
                    if (caretBounds == null) {
Lines 2129-2135 Link Here
2129
                        newCaretOffset = target.viewToModel(newCaretPoint);
2138
                        newCaretOffset = target.viewToModel(newCaretPoint);
2130
                        newCaretBounds = target.modelToView(newCaretOffset);
2139
                        newCaretBounds = target.modelToView(newCaretOffset);
2131
                    }
2140
                    }
2132
                    
2141
2142
                    boolean select = selectionPageDownAction.equals(getValue(Action.NAME));
2133
                    if (select) {
2143
                    if (select) {
2134
                        caret.moveDot(newCaretOffset);
2144
                        caret.moveDot(newCaretOffset);
2135
                    } else {
2145
                    } else {
Lines 2147-2162 Link Here
2147
        }
2157
        }
2148
    }
2158
    }
2149
2159
2160
    @EditorActionRegistration(name = { backwardAction, selectionBackwardAction })
2150
    public static class BackwardAction extends LocalBaseAction {
2161
    public static class BackwardAction extends LocalBaseAction {
2151
2162
2152
        boolean select;
2153
2154
        static final long serialVersionUID =-3048379822817847356L;
2163
        static final long serialVersionUID =-3048379822817847356L;
2155
2164
2156
        public BackwardAction(String nm, boolean select) {
2165
        public BackwardAction() {
2157
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2166
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2158
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2167
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2159
            this.select = select;
2160
        }
2168
        }
2161
2169
2162
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2170
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2164-2169 Link Here
2164
                Caret caret = target.getCaret();
2172
                Caret caret = target.getCaret();
2165
                try {
2173
                try {
2166
                    int pos;
2174
                    int pos;
2175
                    boolean select = selectionBackwardAction.equals(getValue(Action.NAME));
2167
                    if (!select && Utilities.isSelectionShowing(caret))
2176
                    if (!select && Utilities.isSelectionShowing(caret))
2168
                    {
2177
                    {
2169
                        pos = target.getSelectionStart(); 
2178
                        pos = target.getSelectionStart(); 
Lines 2193-2199 Link Here
2193
2202
2194
    public static class BeginLineAction extends LocalBaseAction {
2203
    public static class BeginLineAction extends LocalBaseAction {
2195
2204
2196
        protected boolean select;
2205
        @EditorActionRegistration(name = { beginLineAction, selectionBeginLineAction })
2206
        public static BeginLineAction create() {
2207
            return new BeginLineAction(false);
2208
        }
2209
2210
        @EditorActionRegistration(name = { lineFirstColumnAction, selectionLineFirstColumnAction })
2211
        public static BeginLineAction createColumnOne() {
2212
            return new BeginLineAction(true);
2213
        }
2197
2214
2198
        /** Whether the action should go to the begining of
2215
        /** Whether the action should go to the begining of
2199
         * the text on the line or to the first column on the line*/
2216
         * the text on the line or to the first column on the line*/
Lines 2201-2215 Link Here
2201
2218
2202
        static final long serialVersionUID =3269462923524077779L;
2219
        static final long serialVersionUID =3269462923524077779L;
2203
2220
2204
        public BeginLineAction(String nm, boolean select) {
2221
        public BeginLineAction(boolean columnOne) {
2205
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2222
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2206
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2223
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2207
            this.select = select;
2208
            homeKeyColumnOne = false;
2209
        }
2210
2211
        public BeginLineAction(String nm, boolean select, boolean columnOne) {
2212
            this(nm, select);
2213
            homeKeyColumnOne = columnOne;
2224
            homeKeyColumnOne = columnOne;
2214
        }
2225
        }
2215
2226
Lines 2235-2240 Link Here
2235
                            dot = textStartPos;
2246
                            dot = textStartPos;
2236
                        }
2247
                        }
2237
                    }
2248
                    }
2249
                    String actionName = (String) getValue(Action.NAME);
2250
                    boolean select = selectionBeginLineAction.equals(actionName)
2251
                            || selectionLineFirstColumnAction.equals(actionName);
2238
                    if (select) {
2252
                    if (select) {
2239
                        caret.moveDot(dot);
2253
                        caret.moveDot(dot);
2240
                    } else {
2254
                    } else {
Lines 2247-2262 Link Here
2247
        }
2261
        }
2248
    }
2262
    }
2249
2263
2264
    @EditorActionRegistration(name = { endLineAction, selectionEndLineAction })
2250
    public static class EndLineAction extends LocalBaseAction {
2265
    public static class EndLineAction extends LocalBaseAction {
2251
2266
2252
        protected boolean select;
2253
2254
        static final long serialVersionUID =5216077634055190170L;
2267
        static final long serialVersionUID =5216077634055190170L;
2255
2268
2256
        public EndLineAction(String nm, boolean select) {
2269
        public EndLineAction() {
2257
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2270
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2258
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2271
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2259
            this.select = select;
2260
        }
2272
        }
2261
2273
2262
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2274
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2264-2269 Link Here
2264
                Caret caret = target.getCaret();
2276
                Caret caret = target.getCaret();
2265
                try {
2277
                try {
2266
                    int dot = Utilities.getRowEnd(target, caret.getDot());
2278
                    int dot = Utilities.getRowEnd(target, caret.getDot());
2279
                    boolean select = selectionEndLineAction.equals(getValue(Action.NAME));
2267
                    if (select) {
2280
                    if (select) {
2268
                        caret.moveDot(dot);
2281
                        caret.moveDot(dot);
2269
                    } else {
2282
                    } else {
Lines 2283-2304 Link Here
2283
        }
2296
        }
2284
    }
2297
    }
2285
2298
2299
    @EditorActionRegistration(name = { beginAction, selectionBeginAction })
2286
    public static class BeginAction extends LocalBaseAction {
2300
    public static class BeginAction extends LocalBaseAction {
2287
2301
2288
        boolean select;
2289
2290
        static final long serialVersionUID =3463563396210234361L;
2302
        static final long serialVersionUID =3463563396210234361L;
2291
2303
2292
        public BeginAction(String nm, boolean select) {
2304
        public BeginAction() {
2293
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2305
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2294
                  | WORD_MATCH_RESET | SAVE_POSITION | CLEAR_STATUS_TEXT);
2306
                  | WORD_MATCH_RESET | SAVE_POSITION | CLEAR_STATUS_TEXT);
2295
            this.select = select;
2296
        }
2307
        }
2297
2308
2298
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2309
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2299
            if (target != null) {
2310
            if (target != null) {
2300
                Caret caret = target.getCaret();
2311
                Caret caret = target.getCaret();
2301
                int dot = 0; // begin of document
2312
                int dot = 0; // begin of document
2313
                boolean select = selectionBeginAction.equals(getValue(Action.NAME));
2302
                if (select) {
2314
                if (select) {
2303
                    caret.moveDot(dot);
2315
                    caret.moveDot(dot);
2304
                } else {
2316
                } else {
Lines 2308-2329 Link Here
2308
        }
2320
        }
2309
    }
2321
    }
2310
2322
2323
    @EditorActionRegistration(name = { endAction, selectionEndAction })
2311
    public static class EndAction extends LocalBaseAction {
2324
    public static class EndAction extends LocalBaseAction {
2312
2325
2313
        boolean select;
2314
2315
        static final long serialVersionUID =8547506353130203657L;
2326
        static final long serialVersionUID =8547506353130203657L;
2316
2327
2317
        public EndAction(String nm, boolean select) {
2328
        public EndAction() {
2318
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2329
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2319
                  | WORD_MATCH_RESET | SAVE_POSITION | CLEAR_STATUS_TEXT);
2330
                  | WORD_MATCH_RESET | SAVE_POSITION | CLEAR_STATUS_TEXT);
2320
            this.select = select;
2321
        }
2331
        }
2322
2332
2323
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2333
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2324
            if (target != null) {
2334
            if (target != null) {
2325
                Caret caret = target.getCaret();
2335
                Caret caret = target.getCaret();
2326
                int dot = target.getDocument().getLength(); // end of document
2336
                int dot = target.getDocument().getLength(); // end of document
2337
                boolean select = selectionEndAction.equals(getValue(Action.NAME));
2327
                if (select) {
2338
                if (select) {
2328
                    caret.moveDot(dot);
2339
                    caret.moveDot(dot);
2329
                } else {
2340
                } else {
Lines 2333-2348 Link Here
2333
        }
2344
        }
2334
    }
2345
    }
2335
2346
2347
    @EditorActionRegistration(name = { nextWordAction, selectionNextWordAction })
2336
    public static class NextWordAction extends LocalBaseAction {
2348
    public static class NextWordAction extends LocalBaseAction {
2337
2349
2338
        boolean select;
2339
2340
        static final long serialVersionUID =-5909906947175434032L;
2350
        static final long serialVersionUID =-5909906947175434032L;
2341
2351
2342
        public NextWordAction(String nm, boolean select) {
2352
        public NextWordAction() {
2343
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2353
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2344
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2354
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2345
            this.select = select;
2346
        }
2355
        }
2347
2356
2348
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2357
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2351-2356 Link Here
2351
                try {
2360
                try {
2352
                    int dotPos = caret.getDot();
2361
                    int dotPos = caret.getDot();
2353
                    dotPos = Utilities.getNextWord(target, dotPos);
2362
                    dotPos = Utilities.getNextWord(target, dotPos);
2363
                    boolean select = selectionNextWordAction.equals(getValue(Action.NAME));
2354
                    if (caret instanceof BaseCaret){
2364
                    if (caret instanceof BaseCaret){
2355
                        BaseCaret bCaret = (BaseCaret) caret;
2365
                        BaseCaret bCaret = (BaseCaret) caret;
2356
                        if (select) {
2366
                        if (select) {
Lines 2372-2387 Link Here
2372
        }
2382
        }
2373
    }
2383
    }
2374
2384
2385
    @EditorActionRegistration(name = { previousWordAction, selectionPreviousWordAction })
2375
    public static class PreviousWordAction extends LocalBaseAction {
2386
    public static class PreviousWordAction extends LocalBaseAction {
2376
2387
2377
        boolean select;
2378
2379
        static final long serialVersionUID =-5465143382669785799L;
2388
        static final long serialVersionUID =-5465143382669785799L;
2380
2389
2381
        public PreviousWordAction(String nm, boolean select) {
2390
        public PreviousWordAction() {
2382
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2391
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2383
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2392
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2384
            this.select = select;
2385
        }
2393
        }
2386
2394
2387
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2395
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2389-2394 Link Here
2389
                Caret caret = target.getCaret();
2397
                Caret caret = target.getCaret();
2390
                try {
2398
                try {
2391
                    int dot = Utilities.getPreviousWord(target, caret.getDot());
2399
                    int dot = Utilities.getPreviousWord(target, caret.getDot());
2400
                    boolean select = selectionPreviousWordAction.equals(getValue(Action.NAME));
2392
                    if (caret instanceof BaseCaret){
2401
                    if (caret instanceof BaseCaret){
2393
                        BaseCaret bCaret = (BaseCaret) caret;
2402
                        BaseCaret bCaret = (BaseCaret) caret;
2394
                        if (select) {
2403
                        if (select) {
Lines 2410-2425 Link Here
2410
        }
2419
        }
2411
    }
2420
    }
2412
2421
2422
    @EditorActionRegistration(name = { beginWordAction, selectionBeginAction })
2413
    public static class BeginWordAction extends LocalBaseAction {
2423
    public static class BeginWordAction extends LocalBaseAction {
2414
2424
2415
        boolean select;
2416
2417
        static final long serialVersionUID =3991338381212491110L;
2425
        static final long serialVersionUID =3991338381212491110L;
2418
2426
2419
        public BeginWordAction(String nm, boolean select) {
2427
        public BeginWordAction() {
2420
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2428
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2421
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2429
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2422
            this.select = select;
2423
        }
2430
        }
2424
2431
2425
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2432
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2427-2432 Link Here
2427
                Caret caret = target.getCaret();
2434
                Caret caret = target.getCaret();
2428
                try {
2435
                try {
2429
                    int dot = Utilities.getWordStart(target, caret.getDot());
2436
                    int dot = Utilities.getWordStart(target, caret.getDot());
2437
                    boolean select = selectionBeginAction.equals(getValue(Action.NAME));
2430
                    if (select) {
2438
                    if (select) {
2431
                        caret.moveDot(dot);
2439
                        caret.moveDot(dot);
2432
                    } else {
2440
                    } else {
Lines 2439-2454 Link Here
2439
        }
2447
        }
2440
    }
2448
    }
2441
2449
2450
    @EditorActionRegistration(name = { endWordAction, selectionEndWordAction })
2442
    public static class EndWordAction extends LocalBaseAction {
2451
    public static class EndWordAction extends LocalBaseAction {
2443
2452
2444
        boolean select;
2445
2446
        static final long serialVersionUID =3812523676620144633L;
2453
        static final long serialVersionUID =3812523676620144633L;
2447
2454
2448
        public EndWordAction(String nm, boolean select) {
2455
        public EndWordAction() {
2449
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2456
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2450
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2457
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2451
            this.select = select;
2452
        }
2458
        }
2453
2459
2454
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2460
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2456-2461 Link Here
2456
                Caret caret = target.getCaret();
2462
                Caret caret = target.getCaret();
2457
                try {
2463
                try {
2458
                    int dot = Utilities.getWordEnd(target, caret.getDot());
2464
                    int dot = Utilities.getWordEnd(target, caret.getDot());
2465
                    boolean select = selectionEndWordAction.equals(getValue(Action.NAME));
2459
                    if (select) {
2466
                    if (select) {
2460
                        caret.moveDot(dot);
2467
                        caret.moveDot(dot);
2461
                    } else {
2468
                    } else {
Lines 2469-2481 Link Here
2469
    }
2476
    }
2470
2477
2471
    /** Select word around caret */
2478
    /** Select word around caret */
2479
    @EditorActionRegistration(name = selectWordAction)
2472
    public static class SelectWordAction extends KitCompoundAction {
2480
    public static class SelectWordAction extends KitCompoundAction {
2473
2481
2474
        static final long serialVersionUID =7678848538073016357L;
2482
        static final long serialVersionUID =7678848538073016357L;
2475
2483
2476
        public SelectWordAction() {
2484
        public SelectWordAction() {
2477
            super(selectWordAction,
2485
            super(new String[] {
2478
                  new String[] {
2479
                      beginWordAction,
2486
                      beginWordAction,
2480
                      selectionEndWordAction
2487
                      selectionEndWordAction
2481
                  }
2488
                  }
Lines 2485-2496 Link Here
2485
    }
2492
    }
2486
2493
2487
    /** Select line around caret */
2494
    /** Select line around caret */
2495
    @EditorActionRegistration(name = selectLineAction)
2488
    public static class SelectLineAction extends LocalBaseAction {
2496
    public static class SelectLineAction extends LocalBaseAction {
2489
2497
2490
        static final long serialVersionUID =-7407681863035740281L;
2498
        static final long serialVersionUID =-7407681863035740281L;
2491
2499
2492
        public SelectLineAction() {
2500
        public SelectLineAction() {
2493
            super(selectLineAction);
2494
        }
2501
        }
2495
2502
2496
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
2503
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
Lines 2519-2531 Link Here
2519
    }
2526
    }
2520
2527
2521
    /** Select text of whole document */
2528
    /** Select text of whole document */
2529
    @EditorActionRegistration(name = selectAllAction)
2522
    public static class SelectAllAction extends KitCompoundAction {
2530
    public static class SelectAllAction extends KitCompoundAction {
2523
2531
2524
        static final long serialVersionUID =-3502499718130556524L;
2532
        static final long serialVersionUID =-3502499718130556524L;
2525
2533
2526
        public SelectAllAction() {
2534
        public SelectAllAction() {
2527
            super(selectAllAction,
2535
            super(new String[] {
2528
                  new String[] {
2529
                      beginAction,
2536
                      beginAction,
2530
                      selectionEndAction
2537
                      selectionEndAction
2531
                  }
2538
                  }
Lines 2533-2543 Link Here
2533
        }
2540
        }
2534
2541
2535
    }
2542
    }
2536
    
2543
2544
    @EditorActionRegistration(name = removeTrailingSpacesAction)
2537
    public static class RemoveTrailingSpacesAction extends LocalBaseAction {
2545
    public static class RemoveTrailingSpacesAction extends LocalBaseAction {
2538
        
2546
        
2539
        public RemoveTrailingSpacesAction() {
2547
        public RemoveTrailingSpacesAction() {
2540
            super(removeTrailingSpacesAction);
2541
        }
2548
        }
2542
2549
2543
        protected boolean asynchonous() {
2550
        protected boolean asynchonous() {
(-)a/editor.lib/src/org/netbeans/editor/LocalBaseAction.java (+8 lines)
Lines 51-56 Link Here
51
51
52
abstract class LocalBaseAction extends BaseAction {
52
abstract class LocalBaseAction extends BaseAction {
53
53
54
    public LocalBaseAction() {
55
        super();
56
    }
57
58
    public LocalBaseAction(int updateMask) {
59
        super(updateMask);
60
    }
61
54
    public LocalBaseAction(String name) {
62
    public LocalBaseAction(String name) {
55
        super(name);
63
        super(name);
56
    }
64
    }
(-)a/editor.lib/src/org/netbeans/editor/ext/ExtKit.java (-20 / +58 lines)
Lines 56-61 Link Here
56
import javax.swing.text.JTextComponent;
56
import javax.swing.text.JTextComponent;
57
import javax.swing.text.TextAction;
57
import javax.swing.text.TextAction;
58
import javax.swing.text.BadLocationException;
58
import javax.swing.text.BadLocationException;
59
import org.netbeans.api.editor.EditorActionRegistration;
59
import org.netbeans.api.editor.mimelookup.MimeLookup;
60
import org.netbeans.api.editor.mimelookup.MimeLookup;
60
import org.netbeans.editor.BaseKit;
61
import org.netbeans.editor.BaseKit;
61
import org.netbeans.editor.EditorUI;
62
import org.netbeans.editor.EditorUI;
Lines 171-176 Link Here
171
    private static ReplaceAction replaceActionDef = new ReplaceAction();
172
    private static ReplaceAction replaceActionDef = new ReplaceAction();
172
    private static GotoAction gotoActionDef = new GotoAction();
173
    private static GotoAction gotoActionDef = new GotoAction();
173
174
175
    private static final String editorBundleHash = "org.netbeans.editor.Bundle#";
174
176
175
    /** Whether editor popup menu creation should be dumped to console */
177
    /** Whether editor popup menu creation should be dumped to console */
176
    private static final boolean debugPopupMenu
178
    private static final boolean debugPopupMenu
Lines 214-235 Link Here
214
    protected @Override Action[] createActions() {
216
    protected @Override Action[] createActions() {
215
        ArrayList<Action> actions = new ArrayList<Action>();
217
        ArrayList<Action> actions = new ArrayList<Action>();
216
        
218
        
217
        actions.add(new BuildPopupMenuAction());
219
// annotation-registration        actions.add(new BuildPopupMenuAction());
218
        actions.add(new ShowPopupMenuAction());
220
// annotation-registration        actions.add(new ShowPopupMenuAction());
219
        actions.add(new BuildToolTipAction());
221
// annotation-registration        actions.add(new BuildToolTipAction());
220
        actions.add(replaceActionDef);
222
        actions.add(replaceActionDef);
221
        actions.add(gotoActionDef);
223
        actions.add(gotoActionDef);
222
        actions.add(new ToggleCaseIdentifierBeginAction());
224
// annotation-registration        actions.add(new ToggleCaseIdentifierBeginAction());
223
// XXX: remove
225
// XXX: remove
224
//        if (!ExtCaret.NO_HIGHLIGHT_BRACE_LAYER) {
226
//        if (!ExtCaret.NO_HIGHLIGHT_BRACE_LAYER) {
225
//            actions.add(new MatchBraceAction(matchBraceAction, false));
227
//            actions.add(new MatchBraceAction(matchBraceAction, false));
226
//            actions.add(new MatchBraceAction(selectionMatchBraceAction, true));
228
//            actions.add(new MatchBraceAction(selectionMatchBraceAction, true));
227
//        }
229
//        }
228
        actions.add(new ExtDefaultKeyTypedAction());
230
// annotation-registration        actions.add(new ExtDefaultKeyTypedAction());
229
        actions.add(new CompletionShowAction());
231
// annotation-registration        actions.add(new CompletionShowAction());
230
        actions.add(new AllCompletionShowAction());
232
// annotation-registration        actions.add(new AllCompletionShowAction());
231
        actions.add(new DocumentationShowAction());
233
// annotation-registration        actions.add(new DocumentationShowAction());
232
        actions.add(new CompletionTooltipShowAction());
234
// annotation-registration        actions.add(new CompletionTooltipShowAction());
233
        actions.add(new CommentAction()); // to make ctrl-shift-T in Netbeans55 profile work
235
        actions.add(new CommentAction()); // to make ctrl-shift-T in Netbeans55 profile work
234
        actions.add(new UncommentAction()); // to make ctrl-shift-D in Netbeans55 profile work
236
        actions.add(new UncommentAction()); // to make ctrl-shift-D in Netbeans55 profile work
235
                
237
                
Lines 242-248 Link Here
242
     * <code>BaseKit.class</code> is used as a bundle class.
244
     * <code>BaseKit.class</code> is used as a bundle class.
243
     */
245
     */
244
    private abstract static class BaseKitLocalizedAction extends BaseAction {
246
    private abstract static class BaseKitLocalizedAction extends BaseAction {
245
        
247
248
        public BaseKitLocalizedAction() {
249
            super();
250
        }
251
252
        public BaseKitLocalizedAction(int updateMask) {
253
            super(updateMask);
254
        }
255
246
        public BaseKitLocalizedAction(String name) {
256
        public BaseKitLocalizedAction(String name) {
247
            super(name);
257
            super(name);
248
        }
258
        }
Lines 260-271 Link Here
260
    /** Called before the popup menu is shown to possibly rebuild
270
    /** Called before the popup menu is shown to possibly rebuild
261
    * the popup menu.
271
    * the popup menu.
262
    */
272
    */
273
    @EditorActionRegistration(
274
            name = buildPopupMenuAction,
275
            shortDescription = editorBundleHash + buildPopupMenuAction
276
    )
263
    public static class BuildPopupMenuAction extends BaseKitLocalizedAction {
277
    public static class BuildPopupMenuAction extends BaseKitLocalizedAction {
264
278
265
        static final long serialVersionUID =4257043398248915291L;
279
        static final long serialVersionUID =4257043398248915291L;
266
280
267
        public BuildPopupMenuAction() {
281
        public BuildPopupMenuAction() {
268
            super(buildPopupMenuAction, NO_RECORDING);
282
            super(NO_RECORDING);
269
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
283
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
270
        }
284
        }
271
285
Lines 396-407 Link Here
396
410
397
    /** Show the popup menu.
411
    /** Show the popup menu.
398
    */
412
    */
413
    @EditorActionRegistration(
414
            name = showPopupMenuAction,
415
            shortDescription = editorBundleHash + showPopupMenuAction
416
    )
399
    public static class ShowPopupMenuAction extends BaseKitLocalizedAction {
417
    public static class ShowPopupMenuAction extends BaseKitLocalizedAction {
400
418
401
        static final long serialVersionUID =4257043398248915291L;
419
        static final long serialVersionUID =4257043398248915291L;
402
420
403
        public ShowPopupMenuAction() {
421
        public ShowPopupMenuAction() {
404
            super(showPopupMenuAction, NO_RECORDING);
422
            super(NO_RECORDING);
405
        }
423
        }
406
424
407
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
425
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 423-436 Link Here
423
441
424
    }
442
    }
425
443
444
    @EditorActionRegistration(
445
            name = buildToolTipAction,
446
            shortDescription = editorBundleHash + buildToolTipAction
447
    )
426
    public static class BuildToolTipAction extends BaseAction {
448
    public static class BuildToolTipAction extends BaseAction {
427
449
428
        static final long serialVersionUID =-2701131863705941250L;
450
        static final long serialVersionUID =-2701131863705941250L;
429
451
430
        public BuildToolTipAction() {
452
        public BuildToolTipAction() {
431
            super(buildToolTipAction, NO_RECORDING);
453
            super(NO_RECORDING);
432
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
454
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
433
            putValue(Action.SHORT_DESCRIPTION, ""); // No explicit description NOI18N
434
        }
455
        }
435
456
436
        protected String buildText(JTextComponent target) {
457
        protected String buildText(JTextComponent target) {
Lines 455-460 Link Here
455
     * @deprecated Without any replacement.
476
     * @deprecated Without any replacement.
456
     */
477
     */
457
    public static class FindAction extends BaseKitLocalizedAction {
478
    public static class FindAction extends BaseKitLocalizedAction {
479
    // Not registered by annotation since it's not actively used
458
480
459
        static final long serialVersionUID =719554648887497427L;
481
        static final long serialVersionUID =719554648887497427L;
460
482
Lines 577-589 Link Here
577
        }
599
        }
578
    }
600
    }
579
601
602
    @EditorActionRegistration(name = toggleCaseIdentifierBeginAction, shortDescription = "")
580
    public static class ToggleCaseIdentifierBeginAction extends BaseKitLocalizedAction {
603
    public static class ToggleCaseIdentifierBeginAction extends BaseKitLocalizedAction {
581
604
582
        static final long serialVersionUID =584392193824931979L;
605
        static final long serialVersionUID =584392193824931979L;
583
606
584
        ToggleCaseIdentifierBeginAction() {
607
        ToggleCaseIdentifierBeginAction() {
585
            super(toggleCaseIdentifierBeginAction, ABBREV_RESET
608
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
586
                  | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
587
        }
609
        }
588
610
589
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
611
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 997-1002 Link Here
997
1019
998
1020
999
    // Completion customized actions
1021
    // Completion customized actions
1022
    @EditorActionRegistration(
1023
            name = defaultKeyTypedAction,
1024
            shortDescription = editorBundleHash + defaultKeyTypedAction
1025
    )
1000
    public static class ExtDefaultKeyTypedAction extends DefaultKeyTypedAction {
1026
    public static class ExtDefaultKeyTypedAction extends DefaultKeyTypedAction {
1001
1027
1002
        static final long serialVersionUID =5273032708909044812L;
1028
        static final long serialVersionUID =5273032708909044812L;
Lines 1104-1115 Link Here
1104
     * @deprecated Please use Editor Code Completion API instead, for details see
1130
     * @deprecated Please use Editor Code Completion API instead, for details see
1105
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1131
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1106
     */
1132
     */
1133
    @EditorActionRegistration(
1134
            name = completionShowAction,
1135
            shortDescription = editorBundleHash + completionShowAction
1136
    )
1107
    public static class CompletionShowAction extends BaseKitLocalizedAction {
1137
    public static class CompletionShowAction extends BaseKitLocalizedAction {
1108
1138
1109
        static final long serialVersionUID =1050644925893851146L;
1139
        static final long serialVersionUID =1050644925893851146L;
1110
1140
1111
        public CompletionShowAction() {
1141
        public CompletionShowAction() {
1112
            super(completionShowAction);
1113
        }
1142
        }
1114
1143
1115
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1144
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1121-1130 Link Here
1121
     * @deprecated Please use Editor Code Completion API instead, for details see
1150
     * @deprecated Please use Editor Code Completion API instead, for details see
1122
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1151
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1123
     */
1152
     */
1153
    @EditorActionRegistration(
1154
            name = allCompletionShowAction,
1155
            shortDescription = editorBundleHash + allCompletionShowAction
1156
    )
1124
    public static class AllCompletionShowAction extends BaseKitLocalizedAction {
1157
    public static class AllCompletionShowAction extends BaseKitLocalizedAction {
1125
1158
1126
        public AllCompletionShowAction() {
1159
        public AllCompletionShowAction() {
1127
            super(allCompletionShowAction);
1128
        }
1160
        }
1129
1161
1130
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1162
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1136-1145 Link Here
1136
     * @deprecated Please use Editor Code Completion API instead, for details see
1168
     * @deprecated Please use Editor Code Completion API instead, for details see
1137
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1169
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1138
     */
1170
     */
1171
    @EditorActionRegistration(
1172
            name = documentationShowAction,
1173
            shortDescription = editorBundleHash + documentationShowAction
1174
    )
1139
    public static class DocumentationShowAction extends BaseKitLocalizedAction {
1175
    public static class DocumentationShowAction extends BaseKitLocalizedAction {
1140
1176
1141
        public DocumentationShowAction() {
1177
        public DocumentationShowAction() {
1142
            super(documentationShowAction);
1143
        }
1178
        }
1144
1179
1145
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1180
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1151-1160 Link Here
1151
     * @deprecated Please use Editor Code Completion API instead, for details see
1186
     * @deprecated Please use Editor Code Completion API instead, for details see
1152
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1187
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1153
     */
1188
     */
1189
    @EditorActionRegistration(
1190
            name = completionTooltipShowAction,
1191
            shortDescription = editorBundleHash + completionTooltipShowAction
1192
    )
1154
    public static class CompletionTooltipShowAction extends BaseKitLocalizedAction {
1193
    public static class CompletionTooltipShowAction extends BaseKitLocalizedAction {
1155
1194
1156
        public CompletionTooltipShowAction() {
1195
        public CompletionTooltipShowAction() {
1157
            super(completionTooltipShowAction);
1158
        }
1196
        }
1159
1197
1160
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1198
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
(-)a/editor.lib2/apichanges.xml (-1 / +15 lines)
Lines 105-110 Link Here
105
105
106
    <changes>
106
    <changes>
107
107
108
        <change id="added-editoractionregistration">
109
            <summary>EditorActionRegistration annotation added</summary>
110
            <version major="1" minor="10"/>
111
            <date day="11" month="3" year="2009"/>
112
            <author login="mmetelka"/>
113
            <compatibility binary="compatible" source="compatible" semantic="compatible" addition="yes"/>
114
            <description>
115
                The EditorActionRegistration allows to easily register an editor action
116
                into the list of actions of an editor kit. It also allows a lazy
117
                action's class loading (more details in javadoc).
118
            </description>
119
            <issue number="150875"/>
120
        </change>
121
108
        <change id="added-codegen-spi">
122
        <change id="added-codegen-spi">
109
            <summary>Code Generation SPI added</summary>
123
            <summary>Code Generation SPI added</summary>
110
            <version major="1" minor="8"/>
124
            <version major="1" minor="8"/>
Lines 118-124 Link Here
118
                them into documents on the Insert Code editor action invocation.
132
                them into documents on the Insert Code editor action invocation.
119
                The <code>CodeGeneratorContextProvider</code> implementations
133
                The <code>CodeGeneratorContextProvider</code> implementations
120
                registered for the mime types could provide the respective
134
                registered for the mime types could provide the respective
121
                CodeGenerators with an additional context information. 
135
                CodeGenerators with an additional context information.
122
            </description>
136
            </description>
123
            <issue number="134239"/>
137
            <issue number="134239"/>
124
        </change>
138
        </change>
(-)a/editor.lib2/nbproject/project.properties (-1 / +2 lines)
Lines 40-46 Link Here
40
is.autoload=true
40
is.autoload=true
41
javac.source=1.5
41
javac.source=1.5
42
javac.compilerargs=-Xlint:unchecked
42
javac.compilerargs=-Xlint:unchecked
43
spec.version.base=1.9.0
43
spec.version.base=1.10.0
44
cp.extra=${nb_all}/apisupport.harness/external/openjdk-javac-6-b12.jar
44
45
45
javadoc.arch=${basedir}/arch.xml
46
javadoc.arch=${basedir}/arch.xml
46
javadoc.apichanges=${basedir}/apichanges.xml
47
javadoc.apichanges=${basedir}/apichanges.xml
(-)a/editor.lib2/nbproject/project.xml (-1 / +4 lines)
Lines 87-93 Link Here
87
                    <build-prerequisite/>
87
                    <build-prerequisite/>
88
                    <compile-dependency/>
88
                    <compile-dependency/>
89
                    <run-dependency>
89
                    <run-dependency>
90
                        <specification-version>7.0</specification-version>
90
                        <specification-version>7.6</specification-version>
91
                    </run-dependency>
91
                    </run-dependency>
92
                </dependency>
92
                </dependency>
93
                <dependency>
93
                <dependency>
Lines 144-149 Link Here
144
                        <code-name-base>org.netbeans.modules.editor.mimelookup.impl</code-name-base>
144
                        <code-name-base>org.netbeans.modules.editor.mimelookup.impl</code-name-base>
145
                        <recursive/>
145
                        <recursive/>
146
                    </test-dependency>
146
                    </test-dependency>
147
                    <test-dependency>
148
                        <code-name-base>org.openide.loaders</code-name-base>
149
                    </test-dependency>
147
                </test-type>
150
                </test-type>
148
                <test-type>
151
                <test-type>
149
                    <name>qa-functional</name>
152
                    <name>qa-functional</name>
(-)a/editor.lib2/src/org/netbeans/api/editor/EditorActionRegistration.java (+135 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.api.editor;
43
44
/**
45
 * Registration of an editor action so that it's automatically added into the list
46
 * of editor actions even without being explicitly created by <code>BaseKit.createActions()</code>.
47
 * <br/>
48
 * The corresponding annotation processor will build a xml-layer entry file
49
 * in the corresponding <i>/Editors/&lt;mime-type&gt;/Actions</code> folder.
50
 *
51
 * @since 1.10
52
 * @author Miloslav Metelka
53
 */
54
public @interface EditorActionRegistration {
55
56
    /**
57
     * Name(s) of the action that will appear as <code>Action.NAME</code> attribute's value.
58
     * <br/>
59
     * If array is given then multiple registrations (for each name) will be done
60
     * (the action may internally switch its functioning according to its Action.NAME).
61
     * <br/>
62
     * The Swing's text package actions use convention of lowercase letters with hyphens
63
     * - see String constants in {@link javax.swing.text.DefaultEditorKit}.
64
     *
65
     * @return value of Action.NAME attribute.
66
     */
67
    String[] name();
68
69
    /**
70
     * Mime type for which the action will be registered.
71
     * <br/>
72
     * It implies the target folder of the registration <i>/Editors/&lt;mime-type&gt;/Actions</code>.
73
     *
74
     * @return mime-type of the action registration (for example "text/x-java"
75
     *  or empty string which means that the action will be registered as global (for all mime-types).
76
     */
77
    String mimeType() default "";
78
79
    /**
80
     * Resource specification(s) for small icon.
81
     * If multiple names are given in {@link #name()} then the same-size array
82
     * should be used for icon resources.
83
     *
84
     * @return icon resource specification or default (empty string which means no icon).
85
     */
86
    String[] iconResource() default "";
87
88
    /**
89
     * Short description bundle key(s) of the registered action(s).
90
     * Several constructions are allowed:<ul>
91
     *   <li>
92
     *      Leave the annotation's default value which means that the short description
93
     *      will be searched in a bundle located in the same package as the action's class
94
     *      by a key equal to action's name (value of Action.NAME property).
95
     *   </li>
96
     *   <li>
97
     *      Value starting with a hash "#key" searches in a bundle in the same package
98
     *      as the action's class.
99
     *   </li>
100
     *   <li>
101
     *      "bundle#key" allows specification of both bundle and a corresponding key.
102
     *   </li>
103
     *   <li>
104
     *      Empty string "" means that nothing will be generated and delegate action
105
     *      will be created and asked for the value of Action.SHORT_DESCRIPTION property.
106
     *   </li>
107
     * </ul>
108
     */
109
    String[] shortDescription() default "BY_ACTION_NAME";
110
111
    /**
112
     * Menu text bundle key(s) of the registered action(s).
113
     * If an empty string is used (the default) it will be set to the same value
114
     * like action's short description.
115
     * <br/>
116
     * Value starting with a hash "#key" searches in a bundle in the same package
117
     * as the action's class.
118
     * <br/>
119
     * "bundle#key" allows specification of both bundle and a corresponding key.
120
     */
121
    String[] menuText() default "";
122
123
    /**
124
     * Popup menu text bundle key(s) of the registered action(s).
125
     * If an empty string is used (the default) it will be set to the same value
126
     * like menu text.
127
     * <br/>
128
     * Value starting with a hash "#key" searches in a bundle in the same package
129
     * as the action's class.
130
     * <br/>
131
     * "bundle#key" allows specification of both bundle and a corresponding key.
132
     */
133
    String[] popupText() default "";
134
135
}
(-)a/editor.lib2/src/org/netbeans/modules/editor/lib2/EditorActionRegistrationProcessor.java (+343 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.editor.lib2;
41
42
import java.io.IOException;
43
import java.util.MissingResourceException;
44
import java.util.PropertyResourceBundle;
45
import java.util.ResourceBundle;
46
import java.util.Set;
47
import javax.annotation.processing.Filer;
48
import javax.annotation.processing.Processor;
49
import javax.annotation.processing.RoundEnvironment;
50
import javax.annotation.processing.SupportedAnnotationTypes;
51
import javax.annotation.processing.SupportedSourceVersion;
52
import javax.lang.model.SourceVersion;
53
import javax.lang.model.element.Element;
54
import javax.lang.model.element.ExecutableElement;
55
import javax.lang.model.element.Modifier;
56
import javax.lang.model.element.TypeElement;
57
import javax.lang.model.type.TypeMirror;
58
import javax.lang.model.util.ElementFilter;
59
import javax.swing.Action;
60
import javax.tools.StandardLocation;
61
import org.netbeans.api.editor.EditorActionRegistration;
62
import org.openide.filesystems.annotations.LayerBuilder;
63
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
64
import org.openide.filesystems.annotations.LayerGenerationException;
65
import org.openide.util.lookup.ServiceProvider;
66
67
/**
68
 * Annotation processor for
69
 */
70
@ServiceProvider(service=Processor.class)
71
@SupportedSourceVersion(SourceVersion.RELEASE_6)
72
@SupportedAnnotationTypes("org.netbeans.api.editor.EditorActionRegistration")//NOI18N
73
public final class EditorActionRegistrationProcessor extends LayerGeneratingProcessor {
74
75
    @Override
76
    protected boolean handleProcess(Set<? extends TypeElement> annotations,
77
            RoundEnvironment roundEnv) throws LayerGenerationException
78
    {
79
        if (roundEnv.processingOver()) {
80
            return false;
81
        }
82
        for (Element e : roundEnv.getElementsAnnotatedWith(EditorActionRegistration.class)) {
83
            EditorActionRegistration annotation = e.getAnnotation(EditorActionRegistration.class);
84
            String className;
85
            String methodName;
86
            TypeMirror swingActionType = processingEnv.getTypeUtils().getDeclaredType(
87
                    processingEnv.getElementUtils().getTypeElement("javax.swing.Action"));
88
89
            switch (e.getKind()) {
90
                case CLASS:
91
                    className = processingEnv.getElementUtils().getBinaryName((TypeElement)e).toString();
92
                    if (e.getModifiers().contains(Modifier.ABSTRACT)) {
93
                        throw new LayerGenerationException(className + " must not be abstract", e);
94
                    }
95
                    boolean hasDefaultCtor = false;
96
                    for (ExecutableElement constructor : ElementFilter.constructorsIn(e.getEnclosedElements())) {
97
                        if (constructor.getParameters().isEmpty()) {
98
                            hasDefaultCtor = true;
99
                            break;
100
                        }
101
                    }
102
                    if (!hasDefaultCtor) {
103
                        throw new LayerGenerationException(className + " must have a no-argument constructor", e);
104
                    }
105
106
                    if (!processingEnv.getTypeUtils().isAssignable(e.asType(), swingActionType)) {
107
                        throw new LayerGenerationException(className + " is not assignable to javax.swing.Action", e);
108
                    }
109
110
                    methodName = null;
111
                    break;
112
113
                case METHOD:
114
                    className = processingEnv.getElementUtils().getBinaryName((TypeElement) e.getEnclosingElement()).toString();
115
                    methodName = e.getSimpleName().toString();
116
                    if (!e.getModifiers().contains(Modifier.STATIC)) {
117
                        throw new LayerGenerationException(className + "." + methodName + " must be static", e);
118
                    }
119
                    if (!((ExecutableElement) e).getParameters().isEmpty()) {
120
                        throw new LayerGenerationException(className + "." + methodName + " must not take arguments", e);
121
                    }
122
                    if (swingActionType != null && !processingEnv.getTypeUtils().isAssignable(((ExecutableElement)e).getReturnType(), swingActionType)) {
123
                        throw new LayerGenerationException(className + "." + methodName + " is not assignable to javax.swing.Action", e);
124
                    }
125
                    break;
126
127
                default:
128
                    throw new IllegalArgumentException("Annotated element is not loadable as an instance: " + e);
129
130
            }
131
132
            String[] actionNames = annotation.name(); // name() is Array of names
133
            String[] iconResources = annotation.iconResource(); // Array of strings in fact
134
            String[] shortDescriptions = annotation.shortDescription();
135
            String[] menuTexts = annotation.menuText();
136
            String[] popupTexts = annotation.popupText();
137
            BundleHandler commonBundleHandler = null; // Bundle in action's package
138
139
            // For more than one name the same amount of icon resources is expected
140
            // If annotation's default value is used an array with one default item is passed.
141
            // If non-default single value is used then it's possibly used for all declared actions.
142
            checkArraySize(actionNames, iconResources, "iconResource", className);
143
            checkArraySize(actionNames, shortDescriptions, "shortDescription", className);
144
            checkArraySize(actionNames, menuTexts, "menuText", className);
145
            checkArraySize(actionNames, popupTexts, "popupText", className);
146
147
            for (int i = 0; i < actionNames.length; i++) {
148
                String actionName = actionNames[i];
149
                StringBuilder filePath = new StringBuilder(50);
150
                filePath.append("Editors");
151
                if (annotation.mimeType().length() > 0) {
152
                    filePath.append("/").append(annotation.mimeType());
153
                }
154
                filePath.append("/Actions/").append(actionName).append(".instance");
155
                LayerBuilder.File file = layer(e).file(filePath.toString());
156
157
                file.stringvalue("displayName", actionName);
158
159
                // Resolve icon resource
160
                String iconResource = (iconResources.length > 1) ? iconResources[i] : iconResources[0];
161
                if (iconResource.length() > 0) {
162
                    file.stringvalue("iconBase", iconResource);
163
                }
164
165
                // Resolve short description bundle key
166
                String shortDescription = (shortDescriptions.length > 1)
167
                        ? shortDescriptions[i]
168
                        : shortDescriptions[0];
169
                if (shortDescription.length() > 0) {
170
                    BundleHandler bundleHandler = new BundleHandler(actionName, className);
171
                    String key;
172
                    if ("BY_ACTION_NAME".equals(shortDescription)) {
173
                        // Leave bundlePkg and bundleName null
174
                        key = actionName;
175
                    } else {
176
                        key = bundleHandler.parseKey(shortDescription);
177
                    }
178
                    if (bundleHandler.initBundle(commonBundleHandler)) {
179
                        commonBundleHandler = bundleHandler;
180
                    }
181
                    bundleHandler.verifyBundleKey(key);
182
                    shortDescription = bundleHandler.completeKey(key);
183
                    file.bundlevalue(Action.SHORT_DESCRIPTION, shortDescription);
184
                }
185
186
                // Resolve menu text bundle key
187
                String menuText = (menuTexts.length > 1) ? menuTexts[i] : menuTexts[0];
188
                if (menuText.length() > 0) {
189
                    BundleHandler bundleHandler = new BundleHandler(actionName, className);
190
                    String key = bundleHandler.parseKey(menuText);
191
                    if (bundleHandler.initBundle(commonBundleHandler)) {
192
                        commonBundleHandler = bundleHandler;
193
                    }
194
                    bundleHandler.verifyBundleKey(key);
195
                    menuText = bundleHandler.completeKey(key);
196
                    file.bundlevalue("menuText", menuText);
197
                } else if (shortDescription.length() > 0) { // Use shortDesc (already verified)
198
                    menuText = shortDescription;
199
                    file.bundlevalue("menuText", menuText);
200
                }
201
202
                // Resolve popup menu text bundle key
203
                String popupText = (popupTexts.length > 1) ? popupTexts[i] : popupTexts[0];
204
                if (popupText.length() > 0) {
205
                    BundleHandler bundleHandler = new BundleHandler(actionName, className);
206
                    String key = bundleHandler.parseKey(popupText);
207
                    if (bundleHandler.initBundle(commonBundleHandler)) {
208
                        commonBundleHandler = bundleHandler;
209
                    }
210
                    bundleHandler.verifyBundleKey(key);
211
                    popupText = bundleHandler.completeKey(key);
212
                    file.bundlevalue("popupText", popupText);
213
                } else if (menuText.length() > 0) { // Use shortDesc (already verified)
214
                    popupText = menuText;
215
                    file.bundlevalue("popupText", popupText);
216
                }
217
218
                file.methodvalue("instanceCreate", "org.openide.awt.Actions", "alwaysEnabled");
219
                if (methodName != null) {
220
                    file.methodvalue("delegate", className, methodName);
221
                } else {
222
                    file.newvalue("delegate", className);
223
                }
224
                file.write();
225
            }
226
        }
227
        return true;
228
    }
229
230
231
232
    private final class BundleHandler {
233
234
        String bundlePkg;
235
236
        String bundleName;
237
238
        ResourceBundle bundle;
239
240
        final String actionName;
241
242
        final String actionClassName;
243
244
        BundleHandler(String actionName, String actionClassName) {
245
            this.actionName = actionName;
246
            this.actionClassName = actionClassName;
247
        }
248
249
        String parseKey(String keyDescription) throws LayerGenerationException {
250
            String key;
251
            if (keyDescription.startsWith("#")) {
252
                // Leave bundlePkg and bundleName null
253
                key = keyDescription.substring(1);
254
            } else { // Full spec "bundle#key"
255
                int hashIndex = keyDescription.indexOf('#');
256
                if (hashIndex == -1) {
257
                    throw new LayerGenerationException("Annotation \"" + actionName + // NOI18N
258
                            ", class=" + actionClassName + // NOI18N
259
                            ": bundle key description does not contain '#': " + keyDescription);
260
                }
261
                // Bundle-pkg.bundle-name format
262
                bundlePkg = keyDescription.substring(0, hashIndex);
263
                int lastDotIndex = bundlePkg.lastIndexOf('.');
264
                if (lastDotIndex == -1) {
265
                    lastDotIndex = 0;
266
                }
267
                bundleName = bundlePkg.substring(lastDotIndex + 1);
268
                bundlePkg = bundlePkg.substring(0, lastDotIndex);
269
                key = keyDescription.substring(hashIndex + 1);
270
            }
271
            return key;
272
        }
273
274
        boolean initBundle(BundleHandler commonHandler) throws LayerGenerationException {
275
            boolean useAsCommon = (commonHandler == null && bundlePkg == null);
276
            if (commonHandler != null) {
277
                if ((bundlePkg == null || bundlePkg.equals(commonHandler.bundlePkg)) &&
278
                    (bundleName == null || bundleName.equals(commonHandler.bundleName)))
279
                {
280
                    bundle = commonHandler.bundle;
281
                    bundlePkg = commonHandler.bundlePkg;
282
                    bundleName = commonHandler.bundleName;
283
284
                }
285
            }
286
            if (bundle == null) {
287
                if (bundlePkg == null) { // Use common bundle in action's package
288
                    assert (bundleName == null);
289
                    int lastDotIndex = actionClassName.lastIndexOf('.');
290
                    if (lastDotIndex == -1) // no dots
291
                    {
292
                        lastDotIndex = 0;
293
                    }
294
                    bundlePkg = actionClassName.substring(0, lastDotIndex);
295
                    bundleName = "Bundle";
296
                }
297
            }
298
            assert (bundlePkg != null && bundleName != null);
299
            try {
300
                String bundleNameSuffix = bundleName + ".properties";
301
                javax.tools.FileObject bundleFileObject = processingEnv.getFiler().getResource(
302
                        StandardLocation.SOURCE_PATH, bundlePkg, bundleNameSuffix);
303
                bundle = new PropertyResourceBundle(bundleFileObject.openInputStream());
304
            } catch (IOException ex) {
305
//            ex.printStackTrace(); // Print the queried file
306
                throw new LayerGenerationException("Action annotation \"" + actionName + // NOI18N
307
                        "\", class=" + actionClassName + // NOI18N
308
                        ": Bundle \"" + bundlePkg + '.' + bundleName + // NOI18N
309
                        "\" not found."); // NOI18N
310
            }
311
            return useAsCommon;
312
        }
313
314
        void verifyBundleKey(String key) throws LayerGenerationException {
315
            try {
316
                bundle.getString(key); // would throw MissingResourceException
317
            } catch (MissingResourceException ex) {
318
                throw new LayerGenerationException("Action annotation \"" + actionName + // NOI18N
319
                        "\", class=" + actionClassName + // NOI18N
320
                        ": Bundle \"" + bundlePkg + '.' + bundleName + // NOI18N
321
                        "\" does not contain key \"" + key + '"'); // NOI18N
322
            }
323
        }
324
325
        String completeKey(String key) {
326
            return bundlePkg + '.' + bundleName + '#' + key;
327
        }
328
329
    }
330
331
    private void checkArraySize(String[] actionNames, String[] array, String propertyName,
332
            String actionClassName) throws LayerGenerationException
333
    {
334
        // If annotation's default value is used an array with one default item is passed
335
        // so test checks for that case.
336
        if (actionNames.length > 1 && array.length > 1 && actionNames.length != array.length) {
337
            throw new LayerGenerationException("Action annotation \"" + actionNames[0] + // NOI18N
338
                    "\", class=" + actionClassName + ": annotation.name().length=" + actionNames.length + // NOI18N
339
                    " != " + propertyName + "().length=" + array.length); // NOI18N
340
        }
341
    }
342
343
}
(-)a/editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/testactionsregistration/Bundle.properties (+46 lines)
Line 0 Link Here
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
#
3
# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
4
#
5
# The contents of this file are subject to the terms of either the GNU
6
# General Public License Version 2 only ("GPL") or the Common
7
# Development and Distribution License("CDDL") (collectively, the
8
# "License"). You may not use this file except in compliance with the
9
# License. You can obtain a copy of the License at
10
# http://www.netbeans.org/cddl-gplv2.html
11
# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
12
# specific language governing permissions and limitations under the
13
# License.  When distributing the software, include this License Header
14
# Notice in each file and include the License file at
15
# nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
16
# particular file as subject to the "Classpath" exception as provided
17
# by Sun in the GPL Version 2 section of the License file that
18
# accompanied this code. If applicable, add the following below the
19
# License Header, with the fields enclosed by brackets [] replaced by
20
# your own identifying information:
21
# "Portions Copyrighted [year] [name of copyright owner]"
22
#
23
# Contributor(s):
24
#
25
# The Original Software is NetBeans. The Initial Developer of the Original
26
# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
27
# Microsystems, Inc. All Rights Reserved.
28
#
29
# If you wish your version of this file to be governed by only the CDDL
30
# or only the GPL Version 2, indicate your decision by adding
31
# "[Contributor] elects to include this software in this distribution
32
# under the [CDDL or GPL Version 2] license." If you do not indicate a
33
# single choice of license, a recipient has the option to distribute
34
# your version of this file under either the CDDL, the GPL Version 2 or
35
# to extend the choice of license to its licensees as provided above.
36
# However, if you add GPL Version 2 code and therefore, elected the GPL
37
# Version 2 license, then the option applies only if the new code is
38
# made subject to such option by the copyright holder.
39
40
# Editor Testing Actions short descriptions
41
editor-test-action1=Short Desc1
42
editor-test-action-explicit=Short Desc2
43
editor-test-action3=Short Desc3
44
editor-test-action2_menu_text=Menu Text2
45
editor-test-action3_menu_text=Menu Text3
46
editor-test-action3_popup_text=Popup Text3
(-)a/editor.lib2/test/unit/src/org/netbeans/modules/editor/lib2/testactionsregistration/EditorActionRegistrationTest.java (+132 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.modules.editor.lib2.testactionsregistration;
43
44
import java.awt.event.ActionEvent;
45
import javax.swing.AbstractAction;
46
import javax.swing.Action;
47
import org.netbeans.junit.NbTestCase;
48
import org.netbeans.api.editor.EditorActionRegistration;
49
import org.openide.filesystems.FileObject;
50
import org.openide.filesystems.FileUtil;
51
52
/**
53
 * Test registration of editor actions through an annotation.
54
 *
55
 * @author Miloslav Metelka
56
 */
57
public class EditorActionRegistrationTest extends NbTestCase {
58
    
59
    private static final String NAME1 = "editor-test-action1";
60
    private static final String NAME2 = "editor-test-action2";
61
    private static final String NAME3 = "editor-test-action3";
62
    private static final String NAME4 = "editor-test-action4";
63
64
    private static final String bundleHash = "org.netbeans.modules.editor.lib2.testactionsregistration.Bundle#";
65
66
    public EditorActionRegistrationTest(String name) {
67
        super(name);
68
    }
69
70
    public void testRegistration() throws Exception {
71
        FileObject fo = FileUtil.getConfigFile("/Editors/Actions/" + NAME1 + ".instance");
72
        assertNotNull(fo);
73
        assertEquals(NAME1, fo.getAttribute("displayName"));
74
        assertEquals("Short Desc1", fo.getAttribute(Action.SHORT_DESCRIPTION));
75
        assertEquals("Short Desc1", fo.getAttribute("menuText"));
76
        assertEquals("Short Desc1", fo.getAttribute("popupText"));
77
78
        fo = FileUtil.getConfigFile("/Editors/Actions/" + NAME2 + ".instance");
79
        assertNotNull(fo);
80
        assertEquals(NAME2, fo.getAttribute("displayName"));
81
        assertEquals("Short Desc2", fo.getAttribute(Action.SHORT_DESCRIPTION));
82
        assertEquals("Menu Text2", fo.getAttribute("menuText"));
83
        assertEquals("Menu Text2", fo.getAttribute("popupText"));
84
85
        fo = FileUtil.getConfigFile("/Editors/Actions/" + NAME3 + ".instance");
86
        assertNotNull(fo);
87
        assertEquals(NAME3, fo.getAttribute("displayName"));
88
        assertEquals("Short Desc3", fo.getAttribute(Action.SHORT_DESCRIPTION));
89
        assertEquals("Menu Text3", fo.getAttribute("menuText"));
90
        assertEquals("Popup Text3", fo.getAttribute("popupText"));
91
    }
92
93
    @EditorActionRegistration(name = NAME1)
94
    public static final class EditorTestAction extends AbstractAction {
95
96
        public EditorTestAction() {
97
        }
98
99
        @Override
100
        public void actionPerformed(ActionEvent evt) {
101
        }
102
103
    }
104
105
    @EditorActionRegistration(
106
            name = NAME2,
107
            shortDescription="#editor-test-action-explicit",
108
            menuText = bundleHash + NAME2 + "_menu_text"
109
            // popupText same like menuText
110
    )
111
    public static EditorTestAction createAction2() {
112
        return new EditorTestAction();
113
    }
114
115
    @EditorActionRegistration(
116
            name = NAME3,
117
            menuText = "#" + NAME3 + "_menu_text",
118
            popupText = "#" + NAME3 + "_popup_text"
119
    )
120
    public static EditorTestAction createAction3() {
121
        return new EditorTestAction();
122
    }
123
124
    @EditorActionRegistration(
125
            name = NAME4,
126
            shortDescription=""
127
    )
128
    public static EditorTestAction createAction4() {
129
        return new EditorTestAction();
130
    }
131
132
}
(-)a/editor/src/org/netbeans/modules/editor/Bundle.properties (+4 lines)
Lines 59-64 Link Here
59
CTL_Toolbar_hint=Toolbar contents customization
59
CTL_Toolbar_hint=Toolbar contents customization
60
PROP_addToolbarSeparator=Add Separator
60
PROP_addToolbarSeparator=Add Separator
61
61
62
build-popup-menu=Build Popup Menu
63
build-tool-tip=Build Tool Tip
62
generate-goto-popup=Generate Goto Popup
64
generate-goto-popup=Generate Goto Popup
63
generate-fold-popup=Generate Fold Popup
65
generate-fold-popup=Generate Fold Popup
64
goto_source_main_menu_edit_item=Go to &Source
66
goto_source_main_menu_edit_item=Go to &Source
Lines 69-74 Link Here
69
jump_back_main_menu_item=&Back
71
jump_back_main_menu_item=&Back
70
jump_forward_main_menu_item=For&ward
72
jump_forward_main_menu_item=For&ward
71
toggle_comment_main_menu_item=Toggle Co&mment
73
toggle_comment_main_menu_item=Toggle Co&mment
74
toggle-line-numbers=Toggle Line Numbers
75
toggle-toolbar=Toggle Toolbar
72
comment_main_menu_item=Co&mment
76
comment_main_menu_item=Co&mment
73
uncomment_main_menu_item=&Uncomment
77
uncomment_main_menu_item=&Uncomment
74
shift_line_left_main_menu_item=Shift &Left
78
shift_line_left_main_menu_item=Shift &Left
(-)a/editor/src/org/netbeans/modules/editor/NbEditorKit.java (-13 / +19 lines)
Lines 69-74 Link Here
69
import javax.swing.text.JTextComponent;
69
import javax.swing.text.JTextComponent;
70
import javax.swing.text.TextAction;
70
import javax.swing.text.TextAction;
71
import javax.swing.text.Keymap;
71
import javax.swing.text.Keymap;
72
import org.netbeans.api.editor.EditorActionRegistration;
72
import org.netbeans.api.editor.mimelookup.MimeLookup;
73
import org.netbeans.api.editor.mimelookup.MimeLookup;
73
import org.netbeans.api.editor.mimelookup.MimePath;
74
import org.netbeans.api.editor.mimelookup.MimePath;
74
import org.netbeans.api.editor.settings.SimpleValueNames;
75
import org.netbeans.api.editor.settings.SimpleValueNames;
Lines 185-200 Link Here
185
186
186
    protected @Override Action[] createActions() {
187
    protected @Override Action[] createActions() {
187
        Action[] nbEditorActions = new Action[] {
188
        Action[] nbEditorActions = new Action[] {
188
                                       new NbBuildPopupMenuAction(),
189
// annotation-registration                                       new NbBuildPopupMenuAction(),
189
                                       nbUndoActionDef,
190
                                       nbUndoActionDef,
190
                                       nbRedoActionDef,
191
                                       nbRedoActionDef,
191
                                       new NbBuildToolTipAction(),
192
// annotation-registration                                       new NbBuildToolTipAction(),
192
                                       new NbToggleLineNumbersAction(),
193
// annotation-registration                                       new NbToggleLineNumbersAction(),
193
                                       new ToggleToolbarAction(),
194
// annotation-registration                                       new ToggleToolbarAction(),
194
                                       new NbGenerateGoToPopupAction(),
195
// annotation-registration                                       new NbGenerateGoToPopupAction(),
195
                                       new GenerateFoldPopupAction(),
196
                                       new GenerateFoldPopupAction(),
196
                                       new NbGenerateCodeAction(),
197
// annotation-registration                                       new NbGenerateCodeAction(),
197
                                       new NavigationHistoryLastEditAction(),
198
// annotation-registration                                       new NavigationHistoryLastEditAction(),
198
                                       new NavigationHistoryBackAction(),
199
                                       new NavigationHistoryBackAction(),
199
                                       new NavigationHistoryForwardAction(),
200
                                       new NavigationHistoryForwardAction(),
200
                                       new SearchBar.IncrementalSearchForwardAction(),
201
                                       new SearchBar.IncrementalSearchForwardAction(),
Lines 242-248 Link Here
242
        addSystemActionMapping(deleteNextCharAction, org.openide.actions.DeleteAction.class);
243
        addSystemActionMapping(deleteNextCharAction, org.openide.actions.DeleteAction.class);
243
        addSystemActionMapping(showPopupMenuAction, org.openide.actions.PopupAction.class);
244
        addSystemActionMapping(showPopupMenuAction, org.openide.actions.PopupAction.class);
244
245
245
        addSystemActionMapping(SearchBar.IncrementalSearchForwardAction.ACTION_NAME, org.openide.actions.FindAction.class);
246
        addSystemActionMapping(SearchBar.INCREMENTAL_SEARCH_FORWARD, org.openide.actions.FindAction.class);
246
        addSystemActionMapping(replaceAction, org.openide.actions.ReplaceAction.class);
247
        addSystemActionMapping(replaceAction, org.openide.actions.ReplaceAction.class);
247
        addSystemActionMapping(gotoAction, org.openide.actions.GotoAction.class);
248
        addSystemActionMapping(gotoAction, org.openide.actions.GotoAction.class);
248
249
Lines 280-290 Link Here
280
        return bundle;
281
        return bundle;
281
    }
282
    }
282
    
283
    
283
    
284
    @EditorActionRegistration(name = toggleToolbarAction)
284
    public static class ToggleToolbarAction extends BaseAction {
285
    public static class ToggleToolbarAction extends BaseAction {
285
286
286
        public ToggleToolbarAction() {
287
        public ToggleToolbarAction() {
287
            super(ExtKit.toggleToolbarAction);
288
            super(toggleToolbarAction); // Due to creation from MainMenuAction
288
            putValue ("helpID", ToggleToolbarAction.class.getName ()); // NOI18N
289
            putValue ("helpID", ToggleToolbarAction.class.getName ()); // NOI18N
289
        }
290
        }
290
291
Lines 366-371 Link Here
366
        }
367
        }
367
    }
368
    }
368
369
370
    @EditorActionRegistration(name = buildPopupMenuAction)
369
    public class NbBuildPopupMenuAction extends BuildPopupMenuAction {
371
    public class NbBuildPopupMenuAction extends BuildPopupMenuAction {
370
372
371
        static final long serialVersionUID =-8623762627678464181L;
373
        static final long serialVersionUID =-8623762627678464181L;
Lines 567-572 Link Here
567
    }
569
    }
568
570
569
    /** Switch visibility of line numbers in editor */
571
    /** Switch visibility of line numbers in editor */
572
    @EditorActionRegistration(name = BaseKit.toggleLineNumbersAction)
570
    public static class NbToggleLineNumbersAction extends ActionFactory.ToggleLineNumbersAction {
573
    public static class NbToggleLineNumbersAction extends ActionFactory.ToggleLineNumbersAction {
571
574
572
        public NbToggleLineNumbersAction() {
575
        public NbToggleLineNumbersAction() {
Lines 584-593 Link Here
584
        }
587
        }
585
    }
588
    }
586
589
590
    @EditorActionRegistration(name = generateGoToPopupAction)
587
    public static class NbGenerateGoToPopupAction extends BaseAction {
591
    public static class NbGenerateGoToPopupAction extends BaseAction {
588
592
589
        public NbGenerateGoToPopupAction() {
593
        public NbGenerateGoToPopupAction() {
590
            super(generateGoToPopupAction);
591
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
594
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
592
        }
595
        }
593
596
Lines 601-606 Link Here
601
    }
604
    }
602
605
603
606
607
    @EditorActionRegistration(name = buildToolTipAction)
604
    public static class NbBuildToolTipAction extends BuildToolTipAction {
608
    public static class NbBuildToolTipAction extends BuildToolTipAction {
605
609
606
        public @Override void actionPerformed(ActionEvent evt, JTextComponent target) {
610
        public @Override void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 610-616 Link Here
610
        }
614
        }
611
615
612
    }
616
    }
613
    
617
618
// No registration - NO_KEYBINDING property in constructor
619
//    @EditorActionRegistration(name = generateFoldPopupAction)
614
    public static class GenerateFoldPopupAction extends BaseAction {
620
    public static class GenerateFoldPopupAction extends BaseAction {
615
621
616
        private boolean addSeparatorBeforeNextAction;
622
        private boolean addSeparatorBeforeNextAction;
Lines 749-755 Link Here
749
        }
755
        }
750
        
756
        
751
        public LayerSubFolderMenu(JTextComponent target, FileObject folder) {
757
        public LayerSubFolderMenu(JTextComponent target, FileObject folder) {
752
            this(target, getLocalizedName(folder), ActionsList.convert(sort(folder.getChildren())));
758
            this(target, getLocalizedName(folder), ActionsList.convert(sort(folder.getChildren()), false));
753
        }
759
        }
754
        
760
        
755
        private static List<FileObject> sort( FileObject[] children ) {
761
        private static List<FileObject> sort( FileObject[] children ) {
(-)a/editor/src/org/netbeans/modules/editor/NbEditorUI.java (-1 / +1 lines)
Lines 174-180 Link Here
174
        super.installUI(c);
174
        super.installUI(c);
175
175
176
        if (!attached){
176
        if (!attached){
177
            attachSystemActionPerformer(SearchBar.IncrementalSearchForwardAction.ACTION_NAME);
177
            attachSystemActionPerformer(SearchBar.INCREMENTAL_SEARCH_FORWARD);
178
            attachSystemActionPerformer(ExtKit.replaceAction);
178
            attachSystemActionPerformer(ExtKit.replaceAction);
179
            attachSystemActionPerformer(ExtKit.gotoAction);
179
            attachSystemActionPerformer(ExtKit.gotoAction);
180
            attachSystemActionPerformer(ExtKit.showPopupMenuAction);
180
            attachSystemActionPerformer(ExtKit.showPopupMenuAction);
(-)a/editor/src/org/netbeans/modules/editor/codegen/NbGenerateCodeAction.java (-3 / +6 lines)
Lines 56-61 Link Here
56
import javax.swing.SwingUtilities;
56
import javax.swing.SwingUtilities;
57
import javax.swing.text.BadLocationException;
57
import javax.swing.text.BadLocationException;
58
import javax.swing.text.JTextComponent;
58
import javax.swing.text.JTextComponent;
59
import org.netbeans.api.editor.EditorActionRegistration;
59
import org.netbeans.api.editor.mimelookup.MimeLookup;
60
import org.netbeans.api.editor.mimelookup.MimeLookup;
60
import org.netbeans.editor.BaseAction;
61
import org.netbeans.editor.BaseAction;
61
import org.netbeans.editor.ext.ExtKit;
62
import org.netbeans.editor.ext.ExtKit;
Lines 69-83 Link Here
69
 *
70
 *
70
 * @author Dusan Balek, Jan Lahoda
71
 * @author Dusan Balek, Jan Lahoda
71
 */
72
 */
73
@EditorActionRegistration(
74
        name = "generate-code",
75
        shortDescription = "#desc-generate-code",
76
        popupText = "#popup-generate-code"
77
) // NOI18N
72
public class NbGenerateCodeAction extends BaseAction {
78
public class NbGenerateCodeAction extends BaseAction {
73
79
74
    public static final String generateCode = "generate-code"; //NOI18N
80
    public static final String generateCode = "generate-code"; //NOI18N
75
    
81
    
76
    public NbGenerateCodeAction(){
82
    public NbGenerateCodeAction(){
77
        super(generateCode);
78
        putValue(ExtKit.TRIMMED_TEXT, NbBundle.getBundle(NbGenerateCodeAction.class).getString("generate-code-trimmed")); //NOI18N
83
        putValue(ExtKit.TRIMMED_TEXT, NbBundle.getBundle(NbGenerateCodeAction.class).getString("generate-code-trimmed")); //NOI18N
79
        putValue(SHORT_DESCRIPTION, NbBundle.getBundle(NbGenerateCodeAction.class).getString("desc-generate-code")); //NOI18N
80
        putValue(POPUP_MENU_TEXT, NbBundle.getBundle(NbGenerateCodeAction.class).getString("popup-generate-code")); //NOI18N
81
    }
84
    }
82
    
85
    
83
    public void actionPerformed(ActionEvent evt, final JTextComponent target) {
86
    public void actionPerformed(ActionEvent evt, final JTextComponent target) {
(-)a/editor/src/org/netbeans/modules/editor/impl/ActionsList.java (-15 / +45 lines)
Lines 28-49 Link Here
28
 * @author Vita Stejskal
28
 * @author Vita Stejskal
29
 */
29
 */
30
public class ActionsList {
30
public class ActionsList {
31
    
31
32
    // -J-Dorg.netbeans.modules.editor.impl.ActionsList.level=FINE
32
    private static final Logger LOG = Logger.getLogger(ActionsList.class.getName());
33
    private static final Logger LOG = Logger.getLogger(ActionsList.class.getName());
33
    
34
    
34
    private final List<Object> all;
35
    private final List<Object> all;
35
    private final List<Action> actions;
36
    private final List<Action> actions;
36
37
37
    /**
38
    /**
38
     * Create a new <code>ActionList</code> instance by calling<code>this(keys, false)</code>.
39
     * 
40
     * @param keys The list of objects to convert to <code>Action</code>s
41
     */
42
    protected ActionsList(List<FileObject> keys) {
43
        this(keys, false);
44
    }
45
    
46
    /**
47
     * Create a new <code>ActionList</code> instance. The <code>ActionList</code>
39
     * Create a new <code>ActionList</code> instance. The <code>ActionList</code>
48
     * converts a list of objects (keys) to the list of <code>Action</code>s
40
     * converts a list of objects (keys) to the list of <code>Action</code>s
49
     * or other instances that can potentially be used in actions based UI such
41
     * or other instances that can potentially be used in actions based UI such
Lines 53-61 Link Here
53
     * 
45
     * 
54
     * @param keys The list of objects to convert to <code>Action</code>s
46
     * @param keys The list of objects to convert to <code>Action</code>s
55
     * @param ignoreFolders <code>true</code> if the conversion should skipp folders
47
     * @param ignoreFolders <code>true</code> if the conversion should skipp folders
48
     * @param prohibitSeparatorsAndActionNames Treat separators and references to actions
49
     *  by using their Action.NAME as errors. This is useful for
56
     */
50
     */
57
    protected ActionsList(List<FileObject> keys, boolean ignoreFolders) {
51
    protected ActionsList(List<FileObject> keys, boolean ignoreFolders,
58
        Pair p = convertImpl(keys == null ? Collections.<FileObject>emptyList() : keys, ignoreFolders);
52
            boolean prohibitSeparatorsAndActionNames)
53
    {
54
        Pair p = convertImpl(keys == null ? Collections.<FileObject>emptyList() : keys, ignoreFolders,
55
                prohibitSeparatorsAndActionNames);
59
        this.all = p.all;
56
        this.all = p.all;
60
        this.actions = p.actions;
57
        this.actions = p.actions;
61
    }
58
    }
Lines 68-75 Link Here
68
        return actions;
65
        return actions;
69
    }
66
    }
70
67
71
    public static List<Object> convert(List<FileObject> keys) {
68
    public static List<Object> convert(List<FileObject> keys, boolean prohibitSeparatorsAndActionNames) {
72
        return convertImpl(keys, false).all;
69
        return convertImpl(keys, false, prohibitSeparatorsAndActionNames).all;
73
    }
70
    }
74
    
71
    
75
    private static class Pair {
72
    private static class Pair {
Lines 77-83 Link Here
77
        List<Action> actions;
74
        List<Action> actions;
78
    }
75
    }
79
    
76
    
80
    private static Pair convertImpl(List<FileObject> keys, boolean ignoreFolders) {
77
    private static Pair convertImpl(List<FileObject> keys, boolean ignoreFolders,
78
            boolean prohibitSeparatorsAndActionNames)
79
    {
81
        List<Object> all = new ArrayList<Object>();
80
        List<Object> all = new ArrayList<Object>();
82
        List<Action> actions = new ArrayList<Action>();
81
        List<Action> actions = new ArrayList<Action>();
83
82
Lines 85-100 Link Here
85
            DataObject dob;
84
            DataObject dob;
86
            try {
85
            try {
87
                dob = DataObject.find(item);
86
                dob = DataObject.find(item);
87
                if (dob == null && prohibitSeparatorsAndActionNames) {
88
                    if (LOG.isLoggable(Level.WARNING)) {
89
                        LOG.warning("ActionsList: DataObject is null for item=" + item + "\n");
90
                    }
91
                }
88
            } catch (DataObjectNotFoundException dnfe) {
92
            } catch (DataObjectNotFoundException dnfe) {
93
                if (prohibitSeparatorsAndActionNames) {
94
                    if (LOG.isLoggable(Level.WARNING)) {
95
                        LOG.warning("ActionsList: DataObject not found for item=" + item + "\n");
96
                    }
97
                } else {
98
                    if (LOG.isLoggable(Level.FINE)) {
99
                        LOG.log(Level.FINE, "DataObject not found for action fileObject=" + item);
100
                    }
101
                }
89
                continue; // ignore
102
                continue; // ignore
90
            }
103
            }
91
104
92
            Object toAdd = null;
105
            Object toAdd = null;
93
            InstanceCookie ic = dob.getLookup().lookup(InstanceCookie.class);
106
            InstanceCookie ic = dob.getLookup().lookup(InstanceCookie.class);
107
            if (prohibitSeparatorsAndActionNames && ic == null) {
108
                if (LOG.isLoggable(Level.WARNING)) {
109
                    LOG.warning("ActionsList: InstanceCookie not found for item=" + item + "\n");
110
                }
111
                continue;
112
            }
94
            if (ic != null) {
113
            if (ic != null) {
95
                try {
114
                try {
96
                    if (!isSeparator(ic)) {
115
                    if (!isSeparator(ic)) {
97
                        toAdd = ic.instanceCreate();
116
                        toAdd = ic.instanceCreate();
117
                        if (toAdd == null && prohibitSeparatorsAndActionNames) {
118
                            if (LOG.isLoggable(Level.WARNING)) {
119
                                LOG.warning("ActionsList: InstanceCookie.instanceCreate() null for item=" +
120
                                        item + "\n");
121
                            }
122
                        }
98
                    }
123
                    }
99
                } catch (Exception e) {
124
                } catch (Exception e) {
100
                    LOG.log(Level.WARNING, "Can't instantiate object", e); //NOI18N
125
                    LOG.log(Level.WARNING, "Can't instantiate object", e); //NOI18N
Lines 120-125 Link Here
120
            if (toAdd instanceof Action) {
145
            if (toAdd instanceof Action) {
121
                actions.add((Action) toAdd);
146
                actions.add((Action) toAdd);
122
            } else if (isSeparator(toAdd)) {
147
            } else if (isSeparator(toAdd)) {
148
                if (prohibitSeparatorsAndActionNames) {
149
                    if (LOG.isLoggable(Level.WARNING)) {
150
                        LOG.warning("ActionsList: Separator for item=" + item + "\n");
151
                    }
152
                }
123
                actions.add(null);
153
                actions.add(null);
124
            }
154
            }
125
            all.add(toAdd);
155
            all.add(toAdd);
(-)a/editor/src/org/netbeans/modules/editor/impl/EditorActionsProvider.java (-2 / +2 lines)
Lines 73-83 Link Here
73
    }
73
    }
74
    
74
    
75
    public EditorActionsProvider() {
75
    public EditorActionsProvider() {
76
        super(null);
76
        this(null);
77
    }
77
    }
78
78
79
    private EditorActionsProvider(List<FileObject> keys) {
79
    private EditorActionsProvider(List<FileObject> keys) {
80
        super(keys);
80
        super(keys, false, true); // prohibit separators and action-names
81
    }
81
    }
82
    
82
    
83
    public Class<EditorActionsProvider> getClazz(){
83
    public Class<EditorActionsProvider> getClazz(){
(-)a/editor/src/org/netbeans/modules/editor/impl/GlyphGutterActionsProvider.java (-2 / +2 lines)
Lines 65-75 Link Here
65
    }
65
    }
66
    
66
    
67
    public GlyphGutterActionsProvider() {
67
    public GlyphGutterActionsProvider() {
68
        super(null);
68
        super(null, false, false);
69
    }
69
    }
70
70
71
    private GlyphGutterActionsProvider(List<FileObject> keys) {
71
    private GlyphGutterActionsProvider(List<FileObject> keys) {
72
        super(keys);
72
        super(keys, false, false);
73
    }
73
    }
74
    
74
    
75
    public Class<GlyphGutterActionsProvider> getClazz() {
75
    public Class<GlyphGutterActionsProvider> getClazz() {
(-)a/editor/src/org/netbeans/modules/editor/impl/LazyEditorAction.java (+123 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.modules.editor.impl;
41
42
import java.awt.event.ActionEvent;
43
import java.beans.PropertyChangeListener;
44
import javax.swing.Action;
45
import org.openide.filesystems.FileObject;
46
47
/**
48
 * Action that only provides <code>getValue(Action.NAME)</code> by itself
49
 * and loads a delegate action class for all other opertions.
50
 *
51
 * @author Miloslav Metelka
52
 */
53
public class LazyEditorAction implements Action {
54
55
    public static LazyEditorAction create(FileObject fileObject) {
56
        return new LazyEditorAction(fileObject);
57
    }
58
59
    private final FileObject fileObject;
60
61
    private final String actionName;
62
63
    private Action delegate;
64
65
    LazyEditorAction(FileObject fileObject) {
66
        this.fileObject = fileObject;
67
        this.actionName = (String) fileObject.getAttribute("actionName");
68
    }
69
70
    public Object getValue(String key) {
71
        if (Action.NAME.equals(key)) {
72
            return actionName;
73
        }
74
75
        if (delegate == null)
76
            initDelegate();
77
        return delegate.getValue(key);
78
    }
79
80
    public void putValue(String key, Object value) {
81
        if (delegate == null)
82
            initDelegate();
83
        delegate.putValue(key, value);
84
    }
85
86
    public void setEnabled(boolean enabled) {
87
        if (delegate == null)
88
            initDelegate();
89
        delegate.setEnabled(enabled);
90
    }
91
92
    public boolean isEnabled() {
93
        if (delegate == null)
94
            initDelegate();
95
        return delegate.isEnabled();
96
    }
97
98
    public void addPropertyChangeListener(PropertyChangeListener listener) {
99
        if (delegate == null)
100
            initDelegate();
101
        delegate.addPropertyChangeListener(listener);
102
    }
103
104
    public void removePropertyChangeListener(PropertyChangeListener listener) {
105
        if (delegate == null)
106
            initDelegate();
107
        delegate.removePropertyChangeListener(listener);
108
    }
109
110
    public void actionPerformed(ActionEvent evt) {
111
        if (delegate == null)
112
            initDelegate();
113
        delegate.actionPerformed(evt);
114
    }
115
116
    private void initDelegate() {
117
        String instanceCreate = (String) fileObject.getAttribute("delegateInstanceCreate");
118
        if (instanceCreate != null) {
119
        }
120
        String instanceClass = (String) fileObject.getAttribute("delegateInstanceClass");
121
    }
122
123
}
(-)a/editor/src/org/netbeans/modules/editor/impl/PopupMenuActionsProvider.java (-2 / +2 lines)
Lines 65-75 Link Here
65
    }
65
    }
66
    
66
    
67
    public PopupMenuActionsProvider() {
67
    public PopupMenuActionsProvider() {
68
        super(null);
68
        super(null, false, false);
69
    }
69
    }
70
70
71
    private PopupMenuActionsProvider(List<FileObject> keys) {
71
    private PopupMenuActionsProvider(List<FileObject> keys) {
72
        super(keys);
72
        super(keys, false, false);
73
    }
73
    }
74
    
74
    
75
    public Class<PopupMenuActionsProvider> getClazz(){
75
    public Class<PopupMenuActionsProvider> getClazz(){
(-)a/editor/src/org/netbeans/modules/editor/impl/SearchBar.java (-15 / +19 lines)
Lines 100-105 Link Here
100
import javax.swing.event.PopupMenuListener;
100
import javax.swing.event.PopupMenuListener;
101
import javax.swing.text.JTextComponent;
101
import javax.swing.text.JTextComponent;
102
import javax.swing.text.Keymap;
102
import javax.swing.text.Keymap;
103
import org.netbeans.api.editor.EditorActionRegistration;
103
import org.netbeans.api.editor.EditorRegistry;
104
import org.netbeans.api.editor.EditorRegistry;
104
import org.netbeans.modules.editor.lib2.search.EditorFindSupport;
105
import org.netbeans.modules.editor.lib2.search.EditorFindSupport;
105
import org.openide.awt.Mnemonics;
106
import org.openide.awt.Mnemonics;
Lines 127-132 Link Here
127
    private static final int defaultIncremantalSearchComboWidth = 200;
128
    private static final int defaultIncremantalSearchComboWidth = 200;
128
    private static final int maxIncremantalSearchComboWidth = 350;
129
    private static final int maxIncremantalSearchComboWidth = 350;
129
    
130
    
131
    public static final String INCREMENTAL_SEARCH_FORWARD = "incremental-search-forward";
132
    public static final String INCREMENTAL_SEARCH_BACKWARD = "incremental-search-backward";
133
130
    /** Shared mouse listener used for setting the border painting property
134
    /** Shared mouse listener used for setting the border painting property
131
     * of the toolbar buttons and for invoking the popup menu.
135
     * of the toolbar buttons and for invoking the popup menu.
132
     */
136
     */
Lines 213-228 Link Here
213
            Action[] actions = component.getActions();
217
            Action[] actions = component.getActions();
214
            for(Action action:actions) {
218
            for(Action action:actions) {
215
                // Discover the keyStrokes for incremental-search-forward
219
                // Discover the keyStrokes for incremental-search-forward
216
                if (action.getValue(Action.NAME).equals(IncrementalSearchForwardAction.ACTION_NAME)) {
220
                String actionName = (String) action.getValue(Action.NAME);
221
                if (actionName == null) {
222
                    LOG.warning("SearchBar: Null Action.NAME property of action: " + action + "\n");
223
                }
224
                if (actionName.equals(INCREMENTAL_SEARCH_FORWARD)) {
217
                    Action incrementalSearchForwardAction = action;
225
                    Action incrementalSearchForwardAction = action;
218
                    KeyStroke[] keyStrokes = multiKeymap.getKeyStrokesForAction(incrementalSearchForwardAction);
226
                    KeyStroke[] keyStrokes = multiKeymap.getKeyStrokesForAction(incrementalSearchForwardAction);
219
                    if (keyStrokes != null) {
227
                    if (keyStrokes != null) {
220
                        InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
228
                        InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
221
                        for(KeyStroke ks : keyStrokes) {
229
                        for(KeyStroke ks : keyStrokes) {
222
                            LOG.fine("found IncrementalSearchForwardAction, " + ks); //NOI18N
230
                            LOG.fine("found IncrementalSearchForwardAction, " + ks); //NOI18N
223
                            inputMap.put(ks, IncrementalSearchForwardAction.ACTION_NAME);
231
                            inputMap.put(ks, INCREMENTAL_SEARCH_FORWARD);
224
                        }
232
                        }
225
                        getActionMap().put(IncrementalSearchForwardAction.ACTION_NAME,
233
                        getActionMap().put(INCREMENTAL_SEARCH_FORWARD,
226
                            new AbstractAction() {
234
                            new AbstractAction() {
227
                                public void actionPerformed(ActionEvent e) {
235
                                public void actionPerformed(ActionEvent e) {
228
                                    findNext();
236
                                    findNext();
Lines 230-245 Link Here
230
                            });
238
                            });
231
                    }
239
                    }
232
                // Discover the keyStrokes for incremental-search-backward
240
                // Discover the keyStrokes for incremental-search-backward
233
                } else if (action.getValue(Action.NAME).equals(IncrementalSearchBackwardAction.ACTION_NAME)) {
241
                } else if (action.getValue(Action.NAME).equals(INCREMENTAL_SEARCH_BACKWARD)) {
234
                    Action incrementalSearchBackwardAction = action;
242
                    Action incrementalSearchBackwardAction = action;
235
                    KeyStroke[] keyStrokes = multiKeymap.getKeyStrokesForAction(incrementalSearchBackwardAction);
243
                    KeyStroke[] keyStrokes = multiKeymap.getKeyStrokesForAction(incrementalSearchBackwardAction);
236
                    if (keyStrokes != null) {
244
                    if (keyStrokes != null) {
237
                        InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
245
                        InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
238
                        for(KeyStroke ks : keyStrokes) {
246
                        for(KeyStroke ks : keyStrokes) {
239
                            LOG.fine("found IncrementalSearchBackwardAction, " + ks); //NOI18N
247
                            LOG.fine("found IncrementalSearchBackwardAction, " + ks); //NOI18N
240
                            inputMap.put(ks, IncrementalSearchBackwardAction.ACTION_NAME);
248
                            inputMap.put(ks, INCREMENTAL_SEARCH_BACKWARD);
241
                        }
249
                        }
242
                        getActionMap().put(IncrementalSearchBackwardAction.ACTION_NAME,
250
                        getActionMap().put(INCREMENTAL_SEARCH_BACKWARD,
243
                            new AbstractAction() {
251
                            new AbstractAction() {
244
                                public void actionPerformed(ActionEvent e) {
252
                                public void actionPerformed(ActionEvent e) {
245
                                    findPrevious();
253
                                    findPrevious();
Lines 871-883 Link Here
871
879
872
    public static class IncrementalSearchForwardAction extends BaseAction {
880
    public static class IncrementalSearchForwardAction extends BaseAction {
873
        
881
        
874
        public static final String ACTION_NAME = "incremental-search-forward"; // NOI18N
875
    
876
        static final long serialVersionUID = -1;
882
        static final long serialVersionUID = -1;
877
        
883
        
878
        public IncrementalSearchForwardAction() {
884
        public IncrementalSearchForwardAction() {
879
            super(ACTION_NAME, CLEAR_STATUS_TEXT);
885
            super(INCREMENTAL_SEARCH_FORWARD, CLEAR_STATUS_TEXT);
880
            putValue(SHORT_DESCRIPTION, NbBundle.getMessage(IncrementalSearchForwardAction.class, ACTION_NAME));
886
            putValue(SHORT_DESCRIPTION, NbBundle.getMessage(IncrementalSearchForwardAction.class, INCREMENTAL_SEARCH_FORWARD));
881
        }
887
        }
882
        
888
        
883
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
889
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 895-910 Link Here
895
            }
901
            }
896
        }
902
        }
897
    }
903
    }
898
    
904
899
    public static class IncrementalSearchBackwardAction extends BaseAction {
905
    public static class IncrementalSearchBackwardAction extends BaseAction {
900
        
906
        
901
        public static final String ACTION_NAME = "incremental-search-backward"; // NOI18N
902
903
        static final long serialVersionUID = -1;
907
        static final long serialVersionUID = -1;
904
        
908
        
905
        public IncrementalSearchBackwardAction() {
909
        public IncrementalSearchBackwardAction() {
906
            super(ACTION_NAME, CLEAR_STATUS_TEXT);
910
            super(INCREMENTAL_SEARCH_BACKWARD, CLEAR_STATUS_TEXT);
907
            putValue(SHORT_DESCRIPTION, NbBundle.getMessage(IncrementalSearchBackwardAction.class, ACTION_NAME));
911
            putValue(SHORT_DESCRIPTION, NbBundle.getMessage(IncrementalSearchBackwardAction.class, INCREMENTAL_SEARCH_BACKWARD));
908
        }
912
        }
909
        
913
        
910
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
914
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
(-)a/editor/src/org/netbeans/modules/editor/impl/ToolbarActionsProvider.java (-4 / +4 lines)
Lines 77-87 Link Here
77
    }
77
    }
78
    
78
    
79
    public ToolbarActionsProvider() {
79
    public ToolbarActionsProvider() {
80
        super(null);
80
        super(null, false, false);
81
    }
81
    }
82
82
83
    private ToolbarActionsProvider(List<FileObject> keys) {
83
    private ToolbarActionsProvider(List<FileObject> keys) {
84
        super(keys, true);
84
        super(keys, true, false);
85
    }
85
    }
86
    
86
    
87
    public Class<ToolbarActionsProvider> getClazz(){
87
    public Class<ToolbarActionsProvider> getClazz(){
Lines 107-117 Link Here
107
    public static final class LegacyToolbarActionsProvider extends ActionsList implements Class2LayerFolder<LegacyToolbarActionsProvider>, InstanceProvider<LegacyToolbarActionsProvider> {
107
    public static final class LegacyToolbarActionsProvider extends ActionsList implements Class2LayerFolder<LegacyToolbarActionsProvider>, InstanceProvider<LegacyToolbarActionsProvider> {
108
108
109
        public LegacyToolbarActionsProvider() {
109
        public LegacyToolbarActionsProvider() {
110
            super(null);
110
            this(null);
111
        }
111
        }
112
112
113
        private LegacyToolbarActionsProvider(List<FileObject> keys) {
113
        private LegacyToolbarActionsProvider(List<FileObject> keys) {
114
            super(keys);
114
            super(keys, false, false);
115
        }
115
        }
116
116
117
        public Class<LegacyToolbarActionsProvider> getClazz(){
117
        public Class<LegacyToolbarActionsProvider> getClazz(){
(-)a/editor/src/org/netbeans/modules/editor/impl/actions/NavigationHistoryBackAction.java (-2 / +2 lines)
Lines 60-65 Link Here
60
import javax.swing.text.Element;
60
import javax.swing.text.Element;
61
import javax.swing.text.JTextComponent;
61
import javax.swing.text.JTextComponent;
62
import javax.swing.text.TextAction;
62
import javax.swing.text.TextAction;
63
import org.netbeans.api.editor.EditorActionRegistration;
63
import org.netbeans.editor.BaseDocument;
64
import org.netbeans.editor.BaseDocument;
64
import org.netbeans.editor.BaseKit;
65
import org.netbeans.editor.BaseKit;
65
import org.netbeans.modules.editor.lib.NavigationHistory;
66
import org.netbeans.modules.editor.lib.NavigationHistory;
Lines 97-105 Link Here
97
98
98
    private NavigationHistoryBackAction(JTextComponent component, NavigationHistory.Waypoint waypoint, String actionName) {
99
    private NavigationHistoryBackAction(JTextComponent component, NavigationHistory.Waypoint waypoint, String actionName) {
99
        super(BaseKit.jumpListPrevAction);
100
        super(BaseKit.jumpListPrevAction);
100
        
101
        this.component = component;
101
        this.component = component;
102
        this.waypoint = waypoint;
102
        this.waypoint = waypoint;
103
        putValue(SMALL_ICON, ImageUtilities.loadImageIcon("org/netbeans/modules/editor/resources/navigate_back_16.png", false)); //NOI18N
103
        
104
        
104
        if (waypoint != null) {
105
        if (waypoint != null) {
105
            putValue(NAME, actionName);
106
            putValue(NAME, actionName);
Lines 107-113 Link Here
107
                "NavigationHistoryBackAction_Tooltip", actionName)); //NOI18N
108
                "NavigationHistoryBackAction_Tooltip", actionName)); //NOI18N
108
            this.popupMenu = null;
109
            this.popupMenu = null;
109
        } else if (component != null) {
110
        } else if (component != null) {
110
            putValue(SMALL_ICON, ImageUtilities.loadImageIcon("org/netbeans/modules/editor/resources/navigate_back_16.png", false)); //NOI18N
111
            this.popupMenu = new JPopupMenu();
111
            this.popupMenu = new JPopupMenu();
112
            update();
112
            update();
113
            NavigationHistory nav = NavigationHistory.getNavigations();
113
            NavigationHistory nav = NavigationHistory.getNavigations();
(-)a/editor/src/org/netbeans/modules/editor/impl/actions/NavigationHistoryForwardAction.java (-2 / +2 lines)
Lines 53-58 Link Here
53
import javax.swing.JPopupMenu;
53
import javax.swing.JPopupMenu;
54
import javax.swing.text.JTextComponent;
54
import javax.swing.text.JTextComponent;
55
import javax.swing.text.TextAction;
55
import javax.swing.text.TextAction;
56
import org.netbeans.api.editor.EditorActionRegistration;
56
import org.netbeans.editor.BaseKit;
57
import org.netbeans.editor.BaseKit;
57
import org.netbeans.modules.editor.lib.NavigationHistory;
58
import org.netbeans.modules.editor.lib.NavigationHistory;
58
import org.openide.awt.DropDownButtonFactory;
59
import org.openide.awt.DropDownButtonFactory;
Lines 82-90 Link Here
82
83
83
    private NavigationHistoryForwardAction(JTextComponent component, NavigationHistory.Waypoint waypoint, String actionName) {
84
    private NavigationHistoryForwardAction(JTextComponent component, NavigationHistory.Waypoint waypoint, String actionName) {
84
        super(BaseKit.jumpListNextAction);
85
        super(BaseKit.jumpListNextAction);
85
        
86
        this.component = component;
86
        this.component = component;
87
        this.waypoint = waypoint;
87
        this.waypoint = waypoint;
88
        putValue(SMALL_ICON, ImageUtilities.loadImageIcon("org/netbeans/modules/editor/resources/navigate_forward_16.png", false)); //NOI18N
88
        
89
        
89
        if (waypoint != null) {
90
        if (waypoint != null) {
90
            putValue(NAME, actionName);
91
            putValue(NAME, actionName);
Lines 92-98 Link Here
92
                "NavigationHistoryForwardAction_Tooltip", actionName)); //NOI18N
93
                "NavigationHistoryForwardAction_Tooltip", actionName)); //NOI18N
93
            this.popupMenu = null;
94
            this.popupMenu = null;
94
        } else if (component != null) {
95
        } else if (component != null) {
95
            putValue(SMALL_ICON, ImageUtilities.loadImageIcon("org/netbeans/modules/editor/resources/navigate_forward_16.png", false)); //NOI18N
96
            this.popupMenu = new JPopupMenu();
96
            this.popupMenu = new JPopupMenu();
97
            update();
97
            update();
98
            NavigationHistory nav = NavigationHistory.getNavigations();
98
            NavigationHistory nav = NavigationHistory.getNavigations();
(-)a/editor/src/org/netbeans/modules/editor/impl/actions/NavigationHistoryLastEditAction.java (-5 / +6 lines)
Lines 47-52 Link Here
47
import java.util.logging.Logger;
47
import java.util.logging.Logger;
48
import javax.swing.JMenuItem;
48
import javax.swing.JMenuItem;
49
import javax.swing.text.JTextComponent;
49
import javax.swing.text.JTextComponent;
50
import org.netbeans.api.editor.EditorActionRegistration;
50
import org.netbeans.editor.BaseAction;
51
import org.netbeans.editor.BaseAction;
51
import org.netbeans.modules.editor.MainMenuAction;
52
import org.netbeans.modules.editor.MainMenuAction;
52
import org.netbeans.modules.editor.lib.NavigationHistory;
53
import org.netbeans.modules.editor.lib.NavigationHistory;
Lines 57-70 Link Here
57
 *
58
 *
58
 * @author Vita Stejskal
59
 * @author Vita Stejskal
59
 */
60
 */
61
@EditorActionRegistration(
62
        name = "jump-list-last-edit",
63
        iconResource = "org/netbeans/modules/editor/resources/last_edit_location_16.png",
64
        shortDescription = "#NavigationHistoryLastEditAction_Tooltip_simple"
65
)
60
public final class NavigationHistoryLastEditAction extends BaseAction implements PropertyChangeListener {
66
public final class NavigationHistoryLastEditAction extends BaseAction implements PropertyChangeListener {
61
    
67
    
62
    private static final Logger LOG = Logger.getLogger(NavigationHistoryLastEditAction.class.getName());
68
    private static final Logger LOG = Logger.getLogger(NavigationHistoryLastEditAction.class.getName());
63
    
69
    
64
    public NavigationHistoryLastEditAction() {
70
    public NavigationHistoryLastEditAction() {
65
        super("jump-list-last-edit"); //NOI18N
66
        putValue(ICON_RESOURCE_PROPERTY, "org/netbeans/modules/editor/resources/last_edit_location_16.png"); // NOI18N
67
68
        update();
71
        update();
69
        NavigationHistory nav = NavigationHistory.getEdits();
72
        NavigationHistory nav = NavigationHistory.getEdits();
70
        nav.addPropertyChangeListener(WeakListeners.propertyChange(this, nav));
73
        nav.addPropertyChangeListener(WeakListeners.propertyChange(this, nav));
Lines 97-104 Link Here
97
    
100
    
98
    private void update() {
101
    private void update() {
99
        NavigationHistory nav = NavigationHistory.getEdits();
102
        NavigationHistory nav = NavigationHistory.getEdits();
100
        putValue(SHORT_DESCRIPTION, NbBundle.getMessage(NavigationHistoryLastEditAction.class, 
101
            "NavigationHistoryLastEditAction_Tooltip_simple"));
102
        setEnabled(nav.hasNextWaypoints() || nav.hasPreviousWaypoints() || null != nav.getCurrentWaypoint());
103
        setEnabled(nav.hasNextWaypoints() || nav.hasPreviousWaypoints() || null != nav.getCurrentWaypoint());
103
    }
104
    }
104
 
105
 
(-)a/ide.kit/test/qa-functional/data/blacklist.txt (+3 lines)
Lines 281-286 Link Here
281
#org.netbeans.modules.xml.text.syntax.DTDKit
281
#org.netbeans.modules.xml.text.syntax.DTDKit
282
#org.netbeans.modules.xml.text.syntax.XMLKit
282
#org.netbeans.modules.xml.text.syntax.XMLKit
283
283
284
# Editor Actions
285
#org.netbeans.editor.BaseKit.BeepAction
286
284
# Mobility
287
# Mobility
285
org.netbeans.modules.mobility.project.security.KeyStoreRepository
288
org.netbeans.modules.mobility.project.security.KeyStoreRepository
286
org.netbeans.modules.mobility.project.security.KeyStoreRepositoryWarmUp
289
org.netbeans.modules.mobility.project.security.KeyStoreRepositoryWarmUp
(-)a/java.editor/src/org/netbeans/modules/editor/java/Bundle.properties (+1 lines)
Lines 48-53 Link Here
48
array_length_field_javadoc=Length of array.
48
array_length_field_javadoc=Length of array.
49
class_constant_javadoc=java.lang.Class constant.
49
class_constant_javadoc=java.lang.Class constant.
50
generate-goto-popup=Go To
50
generate-goto-popup=Go To
51
goto-source=Go to Source
51
goto_source_open_source_not_formatted=Go to Source
52
goto_source_open_source_not_formatted=Go to Source
52
goto_source_package_not_found=Package {0} not found.
53
goto_source_package_not_found=Package {0} not found.
53
goto_source_source_not_found=Source file for {0} not found.
54
goto_source_source_not_found=Source file for {0} not found.
(-)a/java.editor/src/org/netbeans/modules/editor/java/JavaKit.java (-67 / +102 lines)
Lines 51-56 Link Here
51
import javax.swing.JMenuItem;
51
import javax.swing.JMenuItem;
52
import javax.swing.KeyStroke;
52
import javax.swing.KeyStroke;
53
import javax.swing.text.*;
53
import javax.swing.text.*;
54
import org.netbeans.api.editor.EditorActionRegistration;
54
import org.netbeans.api.editor.fold.FoldHierarchy;
55
import org.netbeans.api.editor.fold.FoldHierarchy;
55
import org.netbeans.api.editor.fold.FoldUtilities;
56
import org.netbeans.api.editor.fold.FoldUtilities;
56
import org.netbeans.api.editor.mimelookup.MimeLookup;
57
import org.netbeans.api.editor.mimelookup.MimeLookup;
Lines 212-265 Link Here
212
213
213
    /* package */ static final String deleteNextCamelCasePosition = "delete-next-camel-case-position"; //NOI18N
214
    /* package */ static final String deleteNextCamelCasePosition = "delete-next-camel-case-position"; //NOI18N
214
215
215
    public static Action create(FileObject file) {
216
//    public static Action create(FileObject file) {
216
        initialize();
217
//        initialize();
218
//
219
//        return name2Action.get(file.getName());
220
//    }
221
//
222
//    private static Map<String, Action> name2Action;
223
//
224
//    private static synchronized void initialize() {
225
//        if (name2Action != null) {
226
//            return ;
227
//        }
228
//
229
//        name2Action = new HashMap<String, Action>();
230
//
231
//        for (BaseAction a : createActionsForLayer()) {
232
//            name2Action.put((String) a.getValue(Action.NAME), a);
233
//
234
////            System.err.println("<file name=\"" + (String) a.getValue(Action.NAME) + ".instance\">");
235
////            System.err.println("    <attr name=\"instanceCreate\" methodvalue=\"org.netbeans.modules.editor.java.JavaKit.create\" />");
236
////            System.err.println("</file>");
237
//        }
238
//    }
217
239
218
        return name2Action.get(file.getName());
219
    }
220
240
221
    private static Map<String, Action> name2Action;
241
    @Override
242
    protected Action[] createActions() {
243
        Action[] superActions = super.createActions();
222
244
223
    private static synchronized void initialize() {
245
        Action[] actions = new BaseAction[] {
224
        if (name2Action != null) {
225
            return ;
226
        }
227
228
        name2Action = new HashMap<String, Action>();
229
230
        for (BaseAction a : createActionsForLayer()) {
231
            name2Action.put((String) a.getValue(Action.NAME), a);
232
233
//            System.err.println("<file name=\"" + (String) a.getValue(Action.NAME) + ".instance\">");
234
//            System.err.println("    <attr name=\"instanceCreate\" methodvalue=\"org.netbeans.modules.editor.java.JavaKit.create\" />");
235
//            System.err.println("</file>");
236
        }
237
    }
238
239
    private static BaseAction[] createActionsForLayer() {
240
        Action[] superActions = new NbEditorKit().getActions();
241
242
        return new BaseAction[] {
243
            new JavaDefaultKeyTypedAction(),
246
            new JavaDefaultKeyTypedAction(),
244
            new PrefixMakerAction(makeGetterAction, "get", getSetIsPrefixes), // NOI18N
247
            new PrefixMakerAction(makeGetterAction, "get", getSetIsPrefixes), // NOI18N
245
            new PrefixMakerAction(makeSetterAction, "set", getSetIsPrefixes), // NOI18N
248
            new PrefixMakerAction(makeSetterAction, "set", getSetIsPrefixes), // NOI18N
246
            new PrefixMakerAction(makeIsAction, "is", getSetIsPrefixes), // NOI18N
249
            new PrefixMakerAction(makeIsAction, "is", getSetIsPrefixes), // NOI18N
247
            new AbbrevDebugLineAction(),
250
// annotation-registration            new AbbrevDebugLineAction(),
248
            new ToggleCommentAction("//"), // NOI18N
251
            new ToggleCommentAction("//"), // NOI18N
249
            new JavaGenerateGoToPopupAction(),
252
// annotation-registration            new JavaGenerateGoToPopupAction(),
250
            new JavaInsertBreakAction(),
253
            new JavaInsertBreakAction(),
251
            new JavaDeleteCharAction(deletePrevCharAction, false),
254
            new JavaDeleteCharAction(deletePrevCharAction, false),
252
            new JavaDeleteCharAction(deleteNextCharAction, true),
255
            new JavaDeleteCharAction(deleteNextCharAction, true),
253
            new ExpandAllJavadocFolds(),
256
// annotation-registration            new ExpandAllJavadocFolds(),
254
            new CollapseAllJavadocFolds(),
257
// annotation-registration            new CollapseAllJavadocFolds(),
255
            new ExpandAllCodeBlockFolds(),
258
// annotation-registration            new ExpandAllCodeBlockFolds(),
256
            new CollapseAllCodeBlockFolds(),
259
// annotation-registration            new CollapseAllCodeBlockFolds(),
257
            new JavaGenerateFoldPopupAction(),
260
            new JavaGenerateFoldPopupAction(), // NO_KEYBINDING in super
258
            new JavaGoToDeclarationAction(),
261
            new JavaGoToDeclarationAction(),
259
            new JavaGoToSourceAction(),
262
// annotation-registration            new JavaGoToSourceAction(),
260
            new JavaGotoHelpAction(),
263
// annotation-registration            new JavaGotoHelpAction(),
261
            new InstantRenameAction(),
264
            new InstantRenameAction(),
262
            new JavaFixImports(),
265
// annotation-registration            new JavaFixImports(),
263
            new InsertSemicolonAction(true),
266
            new InsertSemicolonAction(true),
264
            new InsertSemicolonAction(false),
267
            new InsertSemicolonAction(false),
265
            new SelectCodeElementAction(selectNextElementAction, true),
268
            new SelectCodeElementAction(selectNextElementAction, true),
Lines 278-283 Link Here
278
            new GoToMarkOccurrencesAction(false),
281
            new GoToMarkOccurrencesAction(false),
279
            new GoToMarkOccurrencesAction(true),
282
            new GoToMarkOccurrencesAction(true),
280
        };
283
        };
284
285
        return TextAction.augmentList(superActions, actions);
281
    }
286
    }
282
287
283
    private static Action findAction(Action [] actions, String name) {
288
    private static Action findAction(Action [] actions, String name) {
Lines 354-360 Link Here
354
        }
359
        }
355
    }
360
    }
356
361
357
362
    @EditorActionRegistration(name = generateGoToPopupAction, mimeType = JAVA_MIME_TYPE)
358
    public static class JavaGenerateGoToPopupAction extends NbGenerateGoToPopupAction {
363
    public static class JavaGenerateGoToPopupAction extends NbGenerateGoToPopupAction {
359
364
360
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
365
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 449-459 Link Here
449
454
450
    }
455
    }
451
456
452
457
    @EditorActionRegistration(
458
            name = abbrevDebugLineAction,
459
            mimeType = JAVA_MIME_TYPE,
460
            shortDescription = ""
461
    )
453
    public static class AbbrevDebugLineAction extends BaseAction {
462
    public static class AbbrevDebugLineAction extends BaseAction {
454
463
455
        public AbbrevDebugLineAction() {
464
        public AbbrevDebugLineAction() {
456
            super(abbrevDebugLineAction);
457
        }
465
        }
458
466
459
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
467
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 670-680 Link Here
670
        }
678
        }
671
    }
679
    }
672
680
673
    public static class ExpandAllJavadocFolds extends BaseAction{
681
    @EditorActionRegistration(
682
            name = expandAllJavadocFolds,
683
            mimeType = JAVA_MIME_TYPE,
684
            popupText = "#popup-expand-all-javadoc-folds"
685
    )
686
    public static class ExpandAllJavadocFolds extends BaseAction {
687
674
        public ExpandAllJavadocFolds(){
688
        public ExpandAllJavadocFolds(){
675
            super(expandAllJavadocFolds);
676
            putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("expand-all-javadoc-folds"));
677
            putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-expand-all-javadoc-folds"));
678
        }
689
        }
679
690
680
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
691
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 684-694 Link Here
684
        }
695
        }
685
    }
696
    }
686
697
698
    @EditorActionRegistration(
699
            name = collapseAllJavadocFolds,
700
            mimeType = JAVA_MIME_TYPE,
701
            shortDescription = "#popup-collapse-all-javadoc-folds"
702
    )
687
    public static class CollapseAllJavadocFolds extends BaseAction{
703
    public static class CollapseAllJavadocFolds extends BaseAction{
704
688
        public CollapseAllJavadocFolds(){
705
        public CollapseAllJavadocFolds(){
689
            super(collapseAllJavadocFolds);
690
            putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("collapse-all-javadoc-folds"));
691
            putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-collapse-all-javadoc-folds"));
692
        }
706
        }
693
707
694
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
708
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 698-708 Link Here
698
        }
712
        }
699
    }
713
    }
700
714
715
    @EditorActionRegistration(
716
            name = expandAllCodeBlockFolds,
717
            mimeType = JAVA_MIME_TYPE,
718
            popupText = "#popup-expand-all-code-block-folds"
719
720
    )
701
    public static class ExpandAllCodeBlockFolds extends BaseAction{
721
    public static class ExpandAllCodeBlockFolds extends BaseAction{
722
702
        public ExpandAllCodeBlockFolds(){
723
        public ExpandAllCodeBlockFolds(){
703
            super(expandAllCodeBlockFolds);
704
            putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("expand-all-code-block-folds"));
705
            putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-expand-all-code-block-folds"));
706
        }
724
        }
707
725
708
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
726
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 715-725 Link Here
715
        }
733
        }
716
    }
734
    }
717
735
718
    public static class CollapseAllCodeBlockFolds extends BaseAction{
736
    @EditorActionRegistration(
737
            name = collapseAllCodeBlockFolds,
738
            mimeType = JAVA_MIME_TYPE,
739
            shortDescription = "#popup-collapse-all-code-block-folds"
740
    )
741
    public static class CollapseAllCodeBlockFolds extends BaseAction {
742
719
        public CollapseAllCodeBlockFolds(){
743
        public CollapseAllCodeBlockFolds(){
720
            super(collapseAllCodeBlockFolds);
721
            putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("collapse-all-code-block-folds"));
722
            putValue(BaseAction.POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-collapse-all-code-block-folds"));
723
        }
744
        }
724
745
725
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
746
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 732-738 Link Here
732
        }
753
        }
733
    }
754
    }
734
755
735
    public static class JavaGenerateFoldPopupAction extends GenerateFoldPopupAction{
756
// extends from NbEditorKit
757
//    @EditorActionRegistration(name = generateFoldPopupAction, mimeType = JAVA_MIME_TYPE)
758
    public static class JavaGenerateFoldPopupAction extends GenerateFoldPopupAction {
736
759
737
        protected void addAdditionalItems(JTextComponent target, JMenu menu){
760
        protected void addAdditionalItems(JTextComponent target, JMenu menu){
738
            addAction(target, menu, collapseAllJavadocFolds);
761
            addAction(target, menu, collapseAllJavadocFolds);
Lines 744-750 Link Here
744
767
745
    }
768
    }
746
769
747
    private static class JavaGoToDeclarationAction extends GotoDeclarationAction {
770
// extends from NbEditorKit
771
//    @EditorActionRegistration(name = gotoDeclarationAction, mimeType = JAVA_MIME_TYPE)
772
    public static class JavaGoToDeclarationAction extends GotoDeclarationAction {
773
774
        public JavaGoToDeclarationAction() {
775
        }
776
748
        public @Override boolean gotoDeclaration(JTextComponent target) {
777
        public @Override boolean gotoDeclaration(JTextComponent target) {
749
            if (!(target.getDocument() instanceof BaseDocument)) // Fixed #113062
778
            if (!(target.getDocument() instanceof BaseDocument)) // Fixed #113062
750
                return false;
779
                return false;
Lines 753-768 Link Here
753
        }
782
        }
754
    }
783
    }
755
784
756
    private static class JavaGoToSourceAction extends BaseAction {
785
    @EditorActionRegistration(
786
            name = gotoSourceAction,
787
            mimeType = JAVA_MIME_TYPE
788
    )
789
    public static class JavaGoToSourceAction extends BaseAction {
757
790
758
        static final long serialVersionUID =-6440495023918097760L;
791
        static final long serialVersionUID =-6440495023918097760L;
759
792
760
        public JavaGoToSourceAction() {
793
        public JavaGoToSourceAction() {
761
            super(gotoSourceAction,
794
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET
762
                  ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET
763
                  | SAVE_POSITION
795
                  | SAVE_POSITION
764
                 );
796
                 );
765
            putValue(TRIMMED_TEXT, LocaleSupport.getString("goto-source-trimmed"));  //NOI18N
766
        }
797
        }
767
798
768
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
799
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 780-791 Link Here
780
        }
811
        }
781
    }
812
    }
782
813
783
    private static class JavaFixImports extends BaseAction {
814
    @EditorActionRegistration(
815
            name = fixImportsAction,
816
            mimeType = JAVA_MIME_TYPE
817
    )
818
    public static class JavaFixImports extends BaseAction {
784
819
785
        public JavaFixImports() {
820
        public JavaFixImports() {
786
            super(fixImportsAction,
821
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
787
                  ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET
788
                 );
789
            putValue(TRIMMED_TEXT, NbBundle.getBundle(JavaKit.class).getString("fix-imports-trimmed"));
822
            putValue(TRIMMED_TEXT, NbBundle.getBundle(JavaKit.class).getString("fix-imports-trimmed"));
790
            putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("desc-fix-imports")); // NOI18N
823
            putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("desc-fix-imports")); // NOI18N
791
            putValue(POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-fix-imports")); // NOI18N
824
            putValue(POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-fix-imports")); // NOI18N
Lines 827-840 Link Here
827
        }
860
        }
828
    } // End of JavaFixImports action
861
    } // End of JavaFixImports action
829
862
830
    private static class JavaGotoHelpAction extends BaseAction {
863
    @EditorActionRegistration(
864
            name = gotoHelpAction,
865
            mimeType = JAVA_MIME_TYPE,
866
            shortDescription = "#java-desc-goto-help"
867
    )
868
    public static class JavaGotoHelpAction extends BaseAction {
831
869
832
        public JavaGotoHelpAction() {
870
        public JavaGotoHelpAction() {
833
            super(gotoHelpAction, ABBREV_RESET | MAGIC_POSITION_RESET
871
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET |SAVE_POSITION);
834
                    | UNDO_MERGE_RESET |SAVE_POSITION);
835
            putValue ("helpID", JavaGotoHelpAction.class.getName ()); // NOI18N
872
            putValue ("helpID", JavaGotoHelpAction.class.getName ()); // NOI18N
836
            // fix of #25090; [PENDING] there should be more systematic solution for this problem
837
            putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("java-desc-goto-help"));
838
        }
873
        }
839
874
840
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
875
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
(-)a/java.editor/src/org/netbeans/modules/java/editor/resources/layer.xml (-1 / +2 lines)
Lines 182-188 Link Here
182
                </folder>
182
                </folder>
183
183
184
                <folder name="Actions">
184
                <folder name="Actions">
185
                    <file name="default-typed.instance">
185
<!--                    <file name="default-typed.instance">
186
                        <attr name="instanceCreate" methodvalue="org.netbeans.modules.editor.java.JavaKit.create" />
186
                        <attr name="instanceCreate" methodvalue="org.netbeans.modules.editor.java.JavaKit.create" />
187
                    </file>
187
                    </file>
188
                    <file name="make-getter.instance">
188
                    <file name="make-getter.instance">
Lines 284-289 Link Here
284
                    <file name="java-next-marked-occurrence.instance">
284
                    <file name="java-next-marked-occurrence.instance">
285
                        <attr name="instanceCreate" methodvalue="org.netbeans.modules.editor.java.JavaKit.create" />
285
                        <attr name="instanceCreate" methodvalue="org.netbeans.modules.editor.java.JavaKit.create" />
286
                    </file>
286
                    </file>
287
-->
287
                </folder>
288
                </folder>
288
                
289
                
289
                <folder name="Popup">
290
                <folder name="Popup">
(-)a/openide.awt/src/org/openide/awt/AlwaysEnabledAction.java (-2 / +41 lines)
Lines 9-14 Link Here
9
import java.beans.PropertyChangeListener;
9
import java.beans.PropertyChangeListener;
10
import java.net.URL;
10
import java.net.URL;
11
import java.util.Map;
11
import java.util.Map;
12
import java.util.logging.Level;
13
import java.util.logging.Logger;
12
import javax.swing.AbstractAction;
14
import javax.swing.AbstractAction;
13
import javax.swing.Action;
15
import javax.swing.Action;
14
import javax.swing.Icon;
16
import javax.swing.Icon;
Lines 24-29 Link Here
24
 */
26
 */
25
final class AlwaysEnabledAction extends AbstractAction
27
final class AlwaysEnabledAction extends AbstractAction
26
implements PropertyChangeListener, ContextAwareAction {
28
implements PropertyChangeListener, ContextAwareAction {
29
30
    // -J-Dorg.openide.awt.AlwaysEnabledAction.level=FINE
31
    private static final Logger LOG = Logger.getLogger(AlwaysEnabledAction.class.getName());
32
27
    private final Map map;
33
    private final Map map;
28
    private ActionListener delegate;
34
    private ActionListener delegate;
29
    private final Lookup context;
35
    private final Lookup context;
Lines 61-75 Link Here
61
            }
67
            }
62
            delegate = bindToContext((ActionListener)listener, context);
68
            delegate = bindToContext((ActionListener)listener, context);
63
            if (delegate instanceof Action) {
69
            if (delegate instanceof Action) {
64
                ((Action)delegate).addPropertyChangeListener(this);
70
                Action actionDelegate = (Action) delegate;
71
                actionDelegate.addPropertyChangeListener(this);
72
                // Ensure display names and other properties are in sync or propagate them
73
                syncActionDelegateProperty(Action.NAME, actionDelegate);
74
                syncActionDelegateProperty(Action.SHORT_DESCRIPTION, actionDelegate);
75
                syncActionDelegateProperty("menuText", actionDelegate);
76
                syncActionDelegateProperty("popupText", actionDelegate);
65
            }
77
            }
66
        }
78
        }
67
        return delegate;
79
        return delegate;
68
    }
80
    }
69
81
82
    private void syncActionDelegateProperty(String propertyName, Action actionDelegate) {
83
        Object value = extractCommonAttribute(map, this, propertyName);
84
        Object delegateValue = actionDelegate.getValue(propertyName);
85
        if (value != null) {
86
            if (delegateValue == null) {
87
                actionDelegate.putValue(propertyName, value);
88
            } else {
89
                if (!delegateValue.equals(value)) { // Values differ
90
                    LOG.warning("Value of property \"" + propertyName +
91
                            "\" of AlwaysEnabledAction is \"" +
92
                            value + "\" but delegate has \"" + delegateValue +
93
                            "\"\ndelegate:" + delegate + '\n');
94
                }
95
            }
96
        } // else either both values are null or
97
        // this has null and delegate has non-null which is probably fine (declarer does not care)
98
    }
99
70
    @Override
100
    @Override
71
    public boolean isEnabled() {
101
    public boolean isEnabled() {
72
        assert EventQueue.isDispatchThread();
102
//        assert EventQueue.isDispatchThread();
73
        if (delegate instanceof Action) {
103
        if (delegate instanceof Action) {
74
            return ((Action)delegate).isEnabled();
104
            return ((Action)delegate).isEnabled();
75
        }
105
        }
Lines 143-148 Link Here
143
                return arr.length > 0 ? arr[0] : null;
173
                return arr.length > 0 ? arr[0] : null;
144
            }
174
            }
145
        }
175
        }
176
        if (Action.SHORT_DESCRIPTION.equals(name)) {
177
            return fo.get(Action.SHORT_DESCRIPTION);
178
        }
179
        if ("menuText".equals(name)) {
180
            return fo.get("menuText");
181
        }
182
        if ("popupText".equals(name)) {
183
            return fo.get("popupText");
184
        }
146
185
147
        return null;
186
        return null;
148
    }
187
    }
(-)a/openide.awt/test/unit/src/org/openide/awt/AlwaysEnabledActionTest.java (+17 lines)
Lines 287-292 Link Here
287
        assertTrue("Actions expected to be equal", a1.equals(a11));
287
        assertTrue("Actions expected to be equal", a1.equals(a11));
288
    }
288
    }
289
    
289
    
290
    public void testExtraPropertiesAndNamePropagation() throws Exception {
291
        Action a = readAction("testExtraProperties.instance");
292
        assertNull(MyAction.last);
293
        assertNotNull("Action created", a);
294
        a.actionPerformed(new ActionEvent(this, 0, ""));
295
        assertNotNull(MyAction.last);
296
        assertPropertyPropagated(Action.NAME, "Name1", a, MyAction.last);
297
        assertPropertyPropagated(Action.SHORT_DESCRIPTION, "Short Desc1", a, MyAction.last);
298
        assertPropertyPropagated("menuText", "Menu Text1", a, MyAction.last);
299
        assertPropertyPropagated("popupText", "Popup Text1", a, MyAction.last);
300
    }
301
302
    private static void assertPropertyPropagated(String propertyName, Object value, Action a, Action delegate) {
303
        assertEquals("Action's property \"" + propertyName + "\"", value, a.getValue(propertyName));
304
        assertEquals("Delegate's property \"" + propertyName + "\"", value, delegate.getValue(propertyName));
305
    }
306
290
    private static int myListenerCounter;
307
    private static int myListenerCounter;
291
    private static int myListenerCalled;
308
    private static int myListenerCalled;
292
    private static ActionListener myListener() {
309
    private static ActionListener myListener() {
(-)a/openide.awt/test/unit/src/org/openide/awt/test-layer.xml (+6 lines)
Lines 79-84 Link Here
79
                    <attr name='delegate' methodvalue='org.openide.awt.AlwaysEnabledActionTest.myContextAction'/>
79
                    <attr name='delegate' methodvalue='org.openide.awt.AlwaysEnabledActionTest.myContextAction'/>
80
                    <attr name='displayName' bundlevalue='org.openide.awt.TestBundle#Always'/>
80
                    <attr name='displayName' bundlevalue='org.openide.awt.TestBundle#Always'/>
81
                </file>
81
                </file>
82
                <file name="testExtraProperties.instance">
83
                    <attr name='delegate' methodvalue='org.openide.awt.AlwaysEnabledActionTest.myAction'/>
84
                    <attr name='displayName' stringvalue='Name1'/>
85
                    <attr name='ShortDescription' stringvalue='Short Desc1'/>
86
                    <attr name='menuText' stringvalue='Menu Text1'/>
87
                    <attr name='popupText' stringvalue='Popup Text1'/>
82
            </folder>
88
            </folder>
83
        </folder>
89
        </folder>
84
    </folder> 
90
    </folder> 

Return to bug 150875