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/nbproject/project.properties (-1 / +1 lines)
Lines 39-45 Link Here
39
39
40
javac.compilerargs=-Xlint:unchecked
40
javac.compilerargs=-Xlint:unchecked
41
javac.source=1.5
41
javac.source=1.5
42
spec.version.base=1.33.0
42
spec.version.base=1.34.0
43
is.autoload=true
43
is.autoload=true
44
44
45
javadoc.arch=${basedir}/arch.xml
45
javadoc.arch=${basedir}/arch.xml
(-)a/editor.lib/nbproject/project.xml (-1 / +1 lines)
Lines 104-110 Link Here
104
                    <build-prerequisite/>
104
                    <build-prerequisite/>
105
                    <compile-dependency/>
105
                    <compile-dependency/>
106
                    <run-dependency>
106
                    <run-dependency>
107
                        <specification-version>6.5</specification-version>
107
                        <specification-version>7.7</specification-version>
108
                    </run-dependency>
108
                    </run-dependency>
109
                </dependency>
109
                </dependency>
110
                <dependency>
110
                <dependency>
(-)a/editor.lib/src/org/netbeans/editor/ActionFactory.java (-109 / +173 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.EditorActionRegistrations;
79
import org.netbeans.api.editor.fold.Fold;
80
import org.netbeans.api.editor.fold.Fold;
80
import org.netbeans.api.editor.fold.FoldHierarchy;
81
import org.netbeans.api.editor.fold.FoldHierarchy;
81
import org.netbeans.api.editor.fold.FoldUtilities;
82
import org.netbeans.api.editor.fold.FoldUtilities;
Lines 102-114 Link Here
102
    private ActionFactory() {
103
    private ActionFactory() {
103
        // no instantiation
104
        // no instantiation
104
    }
105
    }
105
    
106
107
    // No registration since shared instance gets created
108
    //@EditorActionRegistration(name = BaseKit.removeTabAction)
106
    public static class RemoveTabAction extends LocalBaseAction {
109
    public static class RemoveTabAction extends LocalBaseAction {
107
110
108
        static final long serialVersionUID =-1537748600593395706L;
111
        static final long serialVersionUID =-1537748600593395706L;
109
112
110
        public RemoveTabAction() {
113
        public RemoveTabAction() {
111
            super(BaseKit.removeTabAction, MAGIC_POSITION_RESET | ABBREV_RESET | WORD_MATCH_RESET);
114
            super(BaseKit.removeTabAction,
115
                    MAGIC_POSITION_RESET | ABBREV_RESET | WORD_MATCH_RESET);
112
        }
116
        }
113
117
114
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
118
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
Lines 197-206 Link Here
197
    }
201
    }
198
     */
202
     */
199
203
204
    @EditorActionRegistration(name = BaseKit.removePreviousWordAction)
200
    public static class RemoveWordPreviousAction extends LocalBaseAction {
205
    public static class RemoveWordPreviousAction extends LocalBaseAction {
201
206
202
        public RemoveWordPreviousAction() {
207
        public RemoveWordPreviousAction() {
203
            super(BaseKit.removePreviousWordAction, MAGIC_POSITION_RESET
208
            super(MAGIC_POSITION_RESET
204
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
209
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
205
        }
210
        }
206
211
Lines 233-244 Link Here
233
        }
238
        }
234
    }
239
    }
235
240
236
    
241
    @EditorActionRegistration(name = BaseKit.removeNextWordAction)
237
    public static class RemoveWordNextAction extends LocalBaseAction {
242
    public static class RemoveWordNextAction extends LocalBaseAction {
238
243
239
        public RemoveWordNextAction() {
244
        public RemoveWordNextAction() {
240
            super(BaseKit.removeNextWordAction, MAGIC_POSITION_RESET
245
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
241
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
242
        }
246
        }
243
247
244
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
248
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 271-283 Link Here
271
    }
275
    }
272
276
273
    
277
    
278
    @EditorActionRegistration(name = BaseKit.removeLineBeginAction)
274
    public static class RemoveLineBeginAction extends LocalBaseAction {
279
    public static class RemoveLineBeginAction extends LocalBaseAction {
275
280
276
        static final long serialVersionUID =9193117196412195554L;
281
        static final long serialVersionUID =9193117196412195554L;
277
282
278
        public RemoveLineBeginAction() {
283
        public RemoveLineBeginAction() {
279
            super(BaseKit.removeLineBeginAction, MAGIC_POSITION_RESET
284
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
280
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
281
        }
285
        }
282
286
283
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
287
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 321-333 Link Here
321
        }
325
        }
322
    }
326
    }
323
327
328
    @EditorActionRegistration(name = BaseKit.removeLineAction)
324
    public static class RemoveLineAction extends LocalBaseAction {
329
    public static class RemoveLineAction extends LocalBaseAction {
325
330
326
        static final long serialVersionUID =-536315497241419877L;
331
        static final long serialVersionUID =-536315497241419877L;
327
332
328
        public RemoveLineAction() {
333
        public RemoveLineAction() {
329
            super(BaseKit.removeLineAction, MAGIC_POSITION_RESET
334
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
330
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
331
        }
335
        }
332
336
333
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
337
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 359-371 Link Here
359
        }
363
        }
360
    }
364
    }
361
    
365
    
362
    /* package */ static class MoveSelectionElseLineUpAction extends LocalBaseAction {
366
    @EditorActionRegistration(name = BaseKit.moveSelectionElseLineUpAction)
367
    public static class MoveSelectionElseLineUpAction extends LocalBaseAction {
363
368
364
        static final long serialVersionUID = 1L;
369
        static final long serialVersionUID = 1L;
365
370
366
        public MoveSelectionElseLineUpAction() {
371
        public MoveSelectionElseLineUpAction() {
367
            super(BaseKit.moveSelectionElseLineUpAction, MAGIC_POSITION_RESET
372
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
368
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
369
        }
373
        }
370
374
371
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
375
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 455-467 Link Here
455
        }
459
        }
456
    }
460
    }
457
    
461
    
458
    /* package */ static class MoveSelectionElseLineDownAction extends LocalBaseAction {
462
    @EditorActionRegistration(name = BaseKit.moveSelectionElseLineDownAction)
463
    public static class MoveSelectionElseLineDownAction extends LocalBaseAction {
459
464
460
        static final long serialVersionUID = 1L;
465
        static final long serialVersionUID = 1L;
461
466
462
        public MoveSelectionElseLineDownAction() {
467
        public MoveSelectionElseLineDownAction() {
463
            super(BaseKit.moveSelectionElseLineDownAction, MAGIC_POSITION_RESET
468
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
464
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
465
        }
469
        }
466
470
467
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
471
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 552-564 Link Here
552
        }
556
        }
553
    }
557
    }
554
    
558
    
555
    /* package */ static class CopySelectionElseLineUpAction extends LocalBaseAction {
559
    @EditorActionRegistration(name = BaseKit.copySelectionElseLineUpAction)
560
    public static class CopySelectionElseLineUpAction extends LocalBaseAction {
556
561
557
        static final long serialVersionUID = 1L;
562
        static final long serialVersionUID = 1L;
558
        
563
        
559
        public CopySelectionElseLineUpAction() {
564
        public CopySelectionElseLineUpAction() {
560
            super(BaseKit.copySelectionElseLineUpAction, MAGIC_POSITION_RESET
565
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
561
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
562
        }
566
        }
563
567
564
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
568
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 639-651 Link Here
639
        }
643
        }
640
    }
644
    }
641
    
645
    
642
    /* package */ static class CopySelectionElseLineDownAction extends LocalBaseAction {
646
    @EditorActionRegistration(name = BaseKit.copySelectionElseLineDownAction)
647
    public static class CopySelectionElseLineDownAction extends LocalBaseAction {
643
648
644
        static final long serialVersionUID = 1L;
649
        static final long serialVersionUID = 1L;
645
650
646
        public CopySelectionElseLineDownAction() {
651
        public CopySelectionElseLineDownAction() {
647
            super(BaseKit.copySelectionElseLineDownAction, MAGIC_POSITION_RESET
652
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
648
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
649
        }
653
        }
650
654
651
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
655
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 727-739 Link Here
727
    }
731
    }
728
732
729
    /* Useful for popup menu - remove selected block or do nothing */
733
    /* Useful for popup menu - remove selected block or do nothing */
734
    // No annotation registration since shared instance exists in BaseKit
735
    //@EditorActionRegistration(name = BaseKit.removeSelectionAction)
730
    public static class RemoveSelectionAction extends LocalBaseAction {
736
    public static class RemoveSelectionAction extends LocalBaseAction {
731
737
732
        static final long serialVersionUID =-1419424594746686573L;
738
        static final long serialVersionUID =-1419424594746686573L;
733
739
734
        public RemoveSelectionAction() {
740
        public RemoveSelectionAction() {
735
            super(BaseKit.removeSelectionAction, MAGIC_POSITION_RESET
741
            super(BaseKit.removeSelectionAction,
736
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
742
                    MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
737
            //#54893 putValue ("helpID", RemoveSelectionAction.class.getName ()); // NOI18N
743
            //#54893 putValue ("helpID", RemoveSelectionAction.class.getName ()); // NOI18N
738
        }
744
        }
739
745
Lines 760-771 Link Here
760
    }
766
    }
761
767
762
    /** Switch to overwrite mode or back to insert mode */
768
    /** Switch to overwrite mode or back to insert mode */
769
    @EditorActionRegistration(name = BaseKit.toggleTypingModeAction)
763
    public static class ToggleTypingModeAction extends LocalBaseAction {
770
    public static class ToggleTypingModeAction extends LocalBaseAction {
764
771
765
        static final long serialVersionUID =-2431132686507799723L;
772
        static final long serialVersionUID =-2431132686507799723L;
766
773
767
        public ToggleTypingModeAction() {
774
        public ToggleTypingModeAction() {
768
            super(BaseKit.toggleTypingModeAction);
775
            super();
769
        }
776
        }
770
777
771
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
778
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 916-921 Link Here
916
     * @deprecated Without any replacement. This action is not used anymore.
923
     * @deprecated Without any replacement. This action is not used anymore.
917
     */
924
     */
918
    public static class StartMacroRecordingAction extends LocalBaseAction {
925
    public static class StartMacroRecordingAction extends LocalBaseAction {
926
    // Not registered by annotation since it's not actively used
919
927
920
        static final long serialVersionUID =1L;
928
        static final long serialVersionUID =1L;
921
929
Lines 937-942 Link Here
937
     * is no longer functional.
945
     * is no longer functional.
938
     */
946
     */
939
    public static class StopMacroRecordingAction extends LocalBaseAction {
947
    public static class StopMacroRecordingAction extends LocalBaseAction {
948
    // Not registered by annotation since it's not actively used
940
949
941
        static final long serialVersionUID =1L;
950
        static final long serialVersionUID =1L;
942
951
Lines 1010-1022 Link Here
1010
1019
1011
    public static class ChangeCaseAction extends LocalBaseAction {
1020
    public static class ChangeCaseAction extends LocalBaseAction {
1012
1021
1022
        @EditorActionRegistration(name = BaseKit.toUpperCaseAction)
1023
        public static ChangeCaseAction createToUpperCase() {
1024
            return new ChangeCaseAction(Utilities.CASE_UPPER);
1025
        }
1026
1027
        @EditorActionRegistration(name = BaseKit.toLowerCaseAction)
1028
        public static ChangeCaseAction createToLowerCase() {
1029
            return new ChangeCaseAction(Utilities.CASE_LOWER);
1030
        }
1031
1032
        @EditorActionRegistration(name = BaseKit.switchCaseAction)
1033
        public static ChangeCaseAction createSwitchCase() {
1034
            return new ChangeCaseAction(Utilities.CASE_SWITCH);
1035
        }
1036
1013
        int changeCaseMode;
1037
        int changeCaseMode;
1014
1038
1015
        static final long serialVersionUID =5680212865619897402L;
1039
        static final long serialVersionUID =5680212865619897402L;
1016
1040
1017
        public ChangeCaseAction(String name, int changeCaseMode) {
1041
        private ChangeCaseAction(int changeCaseMode) {
1018
            super(name, ABBREV_RESET
1042
            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;
1043
            this.changeCaseMode = changeCaseMode;
1021
        }
1044
        }
1022
1045
Lines 1047-1062 Link Here
1047
        }
1070
        }
1048
    }
1071
    }
1049
1072
1050
1073
    @EditorActionRegistration(name = BaseKit.findNextAction,
1074
            iconResource = "org/netbeans/modules/editor/resources/find_next.png") // NOI18N
1051
    public static class FindNextAction extends LocalBaseAction {
1075
    public static class FindNextAction extends LocalBaseAction {
1052
1076
1053
        static final long serialVersionUID =6878814427731642684L;
1077
        static final long serialVersionUID =6878814427731642684L;
1054
1078
1055
        public FindNextAction() {
1079
        public FindNextAction() {
1056
            super(BaseKit.findNextAction, ABBREV_RESET
1080
            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
        }
1081
        }
1061
1082
1062
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1083
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1066-1080 Link Here
1066
        }
1087
        }
1067
    }
1088
    }
1068
1089
1090
    @EditorActionRegistration(name = BaseKit.findPreviousAction,
1091
            iconResource = "org/netbeans/modules/editor/resources/find_previous.png") // NOI18N
1069
    public static class FindPreviousAction extends LocalBaseAction {
1092
    public static class FindPreviousAction extends LocalBaseAction {
1070
1093
1071
        static final long serialVersionUID =-43746947902694926L;
1094
        static final long serialVersionUID =-43746947902694926L;
1072
1095
1073
        public FindPreviousAction() {
1096
        public FindPreviousAction() {
1074
            super(BaseKit.findPreviousAction, ABBREV_RESET
1097
            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
        }
1098
        }
1079
1099
1080
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1100
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1087-1100 Link Here
1087
    /** Finds either selection or if there's no selection it finds
1107
    /** Finds either selection or if there's no selection it finds
1088
    * the word where the cursor is standing.
1108
    * the word where the cursor is standing.
1089
    */
1109
    */
1110
    @EditorActionRegistration(name = BaseKit.findSelectionAction,
1111
            iconResource = "org/netbeans/modules/editor/resources/find_selection.png") // NOI18N
1090
    public static class FindSelectionAction extends LocalBaseAction {
1112
    public static class FindSelectionAction extends LocalBaseAction {
1091
1113
1092
        static final long serialVersionUID =-5601618936504699565L;
1114
        static final long serialVersionUID =-5601618936504699565L;
1093
1115
1094
        public FindSelectionAction() {
1116
        public FindSelectionAction() {
1095
            super(BaseKit.findSelectionAction);
1117
            super();
1096
            putValue(BaseAction.ICON_RESOURCE_PROPERTY,
1097
                "org/netbeans/modules/editor/resources/find_selection.png"); // NOI18N
1098
        }
1118
        }
1099
1119
1100
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1120
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1152-1164 Link Here
1152
        }
1172
        }
1153
    }
1173
    }
1154
1174
1175
    @EditorActionRegistration(name = BaseKit.toggleHighlightSearchAction,
1176
            iconResource = "org/netbeans/modules/editor/resources/toggle_highlight.png")
1155
    public static class ToggleHighlightSearchAction extends LocalBaseAction implements Presenter.Toolbar {
1177
    public static class ToggleHighlightSearchAction extends LocalBaseAction implements Presenter.Toolbar {
1156
1178
1157
        static final long serialVersionUID =4603809175771743200L;
1179
        static final long serialVersionUID =4603809175771743200L;
1158
1180
1159
        public ToggleHighlightSearchAction() {
1181
        public ToggleHighlightSearchAction() {
1160
            super(BaseKit.toggleHighlightSearchAction, CLEAR_STATUS_TEXT);
1182
            super(CLEAR_STATUS_TEXT);
1161
            putValue(Action.SMALL_ICON, ImageUtilities.loadImageIcon("org/netbeans/modules/editor/resources/toggle_highlight.png", false)); // NOI18N
1162
        }
1183
        }
1163
1184
1164
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1185
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1301-1322 Link Here
1301
        }
1322
        }
1302
    }
1323
    }
1303
1324
1325
    @EditorActionRegistrations({
1326
        @EditorActionRegistration(name = BaseKit.wordMatchNextAction,
1327
            iconResource = "org/netbeans/modules/editor/resources/next_matching.png"),
1328
        @EditorActionRegistration(name = BaseKit.wordMatchPrevAction,
1329
            iconResource = "org/netbeans/modules/editor/resources/previous_matching.png")
1330
    })
1304
    public static class WordMatchAction extends LocalBaseAction {
1331
    public static class WordMatchAction extends LocalBaseAction {
1305
1332
1306
        private boolean direction;
1333
        private boolean matchNext;
1307
1334
1308
        static final long serialVersionUID =595571114685133170L;
1335
        static final long serialVersionUID =595571114685133170L;
1309
1336
1310
        public WordMatchAction(String name, boolean direction) {
1337
        public WordMatchAction() {
1311
            super(name, ABBREV_RESET
1338
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1312
                  | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1339
        }
1313
            this.direction = direction;
1340
1314
            putValue(BaseAction.ICON_RESOURCE_PROPERTY,
1341
        @Override
1315
                direction
1342
        protected void actionNameUpdate(String actionName) {
1316
                    ? "org/netbeans/modules/editor/resources/next_matching.png" // NOI18N
1343
            super.actionNameUpdate(actionName);
1317
                    : "org/netbeans/modules/editor/resources/previous_matching.png" // NOI18N
1344
            this.matchNext = BaseKit.wordMatchNextAction.equals(actionName);
1318
            );
1319
                        
1320
        }
1345
        }
1321
1346
1322
        public void actionPerformed(final ActionEvent evt, final  JTextComponent target) {
1347
        public void actionPerformed(final ActionEvent evt, final  JTextComponent target) {
Lines 1336-1342 Link Here
1336
                }
1361
                }
1337
1362
1338
                final int dotPos = caret.getDot();
1363
                final int dotPos = caret.getDot();
1339
                final String s = editorUI.getWordMatch().getMatchWord(dotPos, direction);
1364
                final String s = editorUI.getWordMatch().getMatchWord(dotPos, matchNext);
1340
                final String prevWord = editorUI.getWordMatch().getPreviousWord();
1365
                final String prevWord = editorUI.getWordMatch().getPreviousWord();
1341
                if (s != null) {
1366
                if (s != null) {
1342
                    doc.runAtomicAsUser (new Runnable () {
1367
                    doc.runAtomicAsUser (new Runnable () {
Lines 1359-1382 Link Here
1359
                }
1384
                }
1360
            }
1385
            }
1361
        }
1386
        }
1387
1362
    }
1388
    }
1363
1389
1364
1390
1391
    @EditorActionRegistrations({
1392
        @EditorActionRegistration(name = BaseKit.shiftLineLeftAction,
1393
            iconResource = "org/netbeans/modules/editor/resources/shift_line_left.png"),
1394
        @EditorActionRegistration(name = BaseKit.shiftLineRightAction,
1395
            iconResource = "org/netbeans/modules/editor/resources/shift_line_right.png")
1396
    })
1365
    public static class ShiftLineAction extends LocalBaseAction {
1397
    public static class ShiftLineAction extends LocalBaseAction {
1366
1398
1367
        boolean right;
1368
1369
        static final long serialVersionUID =-5124732597493699582L;
1399
        static final long serialVersionUID =-5124732597493699582L;
1370
1400
1371
        public ShiftLineAction(String name, boolean right) {
1401
        public ShiftLineAction() {
1372
            super(name, MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1402
            super(MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1373
            this.right = right;
1403
        }
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
1404
1405
        @Override
1406
        protected void actionNameUpdate(String actionName) {
1407
            super.actionNameUpdate(actionName);
1380
        }
1408
        }
1381
1409
1382
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
1410
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 1393-1398 Link Here
1393
                        DocumentUtilities.setTypingModification(doc, true);
1421
                        DocumentUtilities.setTypingModification(doc, true);
1394
                        Formatter.pushFormattingContextDocument(doc);
1422
                        Formatter.pushFormattingContextDocument(doc);
1395
                        try {
1423
                        try {
1424
                            boolean right = BaseKit.shiftLineRightAction.equals(getValue(Action.NAME));
1396
                            if (Utilities.isSelectionShowing(caret)) {
1425
                            if (Utilities.isSelectionShowing(caret)) {
1397
                                doc.getFormatter().changeBlockIndent(doc,
1426
                                doc.getFormatter().changeBlockIndent(doc,
1398
                                target.getSelectionStart(), target.getSelectionEnd(),
1427
                                target.getSelectionStart(), target.getSelectionEnd(),
Lines 1414-1427 Link Here
1414
        }
1443
        }
1415
    }
1444
    }
1416
1445
1446
    @EditorActionRegistration(name = BaseKit.reindentLineAction)
1417
    public static class ReindentLineAction extends LocalBaseAction {
1447
    public static class ReindentLineAction extends LocalBaseAction {
1418
1448
1419
        static final long serialVersionUID =1L;
1449
        static final long serialVersionUID =1L;
1420
1450
1421
        public ReindentLineAction() {
1451
        public ReindentLineAction() {
1422
            // TODO: figure out what these flags are all about
1452
            // TODO: figure out what these flags are all about
1423
            super(BaseKit.reindentLineAction,
1453
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1424
                  ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
1425
            //putValue ("helpID", ReindentLineAction.class.getName ());
1454
            //putValue ("helpID", ReindentLineAction.class.getName ());
1426
        }
1455
        }
1427
1456
Lines 1495-1506 Link Here
1495
    
1524
    
1496
    public static class AdjustWindowAction extends LocalBaseAction {
1525
    public static class AdjustWindowAction extends LocalBaseAction {
1497
1526
1527
        @EditorActionRegistration(name = BaseKit.adjustWindowTopAction)
1528
        public static AdjustWindowAction createAdjustTop() {
1529
            return new AdjustWindowAction(0);
1530
        }
1531
1532
        @EditorActionRegistration(name = BaseKit.adjustWindowCenterAction)
1533
        public static AdjustWindowAction createAdjustCenter() {
1534
            return new AdjustWindowAction(50);
1535
        }
1536
1537
        @EditorActionRegistration(name = BaseKit.adjustWindowBottomAction)
1538
        public static AdjustWindowAction createAdjustBottom() {
1539
            return new AdjustWindowAction(100);
1540
        }
1541
1498
        int percentFromWindowTop;
1542
        int percentFromWindowTop;
1499
1543
1500
        static final long serialVersionUID =8864278998999643292L;
1544
        static final long serialVersionUID =8864278998999643292L;
1501
1545
1502
        public AdjustWindowAction(String name, int percentFromWindowTop) {
1546
        public AdjustWindowAction(int percentFromWindowTop) {
1503
            super(name);
1504
            this.percentFromWindowTop = percentFromWindowTop;
1547
            this.percentFromWindowTop = percentFromWindowTop;
1505
        }
1548
        }
1506
1549
Lines 1513-1524 Link Here
1513
1556
1514
    public static class AdjustCaretAction extends LocalBaseAction {
1557
    public static class AdjustCaretAction extends LocalBaseAction {
1515
1558
1559
        @EditorActionRegistration(name = BaseKit.adjustCaretTopAction)
1560
        public static AdjustCaretAction createAdjustTop() {
1561
            return new AdjustCaretAction(0);
1562
        }
1563
1564
        @EditorActionRegistration(name = BaseKit.adjustCaretCenterAction)
1565
        public static AdjustCaretAction createAdjustCenter() {
1566
            return new AdjustCaretAction(50);
1567
        }
1568
1569
        @EditorActionRegistration(name = BaseKit.adjustCaretBottomAction)
1570
        public static AdjustCaretAction createAdjustBottom() {
1571
            return new AdjustCaretAction(100);
1572
        }
1573
1516
        int percentFromWindowTop;
1574
        int percentFromWindowTop;
1517
1575
1518
        static final long serialVersionUID =3223383913531191066L;
1576
        static final long serialVersionUID =3223383913531191066L;
1519
1577
1520
        public AdjustCaretAction(String name, int percentFromWindowTop) {
1578
        public AdjustCaretAction(int percentFromWindowTop) {
1521
            super(name);
1522
            this.percentFromWindowTop = percentFromWindowTop;
1579
            this.percentFromWindowTop = percentFromWindowTop;
1523
        }
1580
        }
1524
1581
Lines 1529-1541 Link Here
1529
        }
1586
        }
1530
    }
1587
    }
1531
1588
1589
    @EditorActionRegistration(name = BaseKit.formatAction)
1532
    public static class FormatAction extends LocalBaseAction {
1590
    public static class FormatAction extends LocalBaseAction {
1533
1591
1534
        static final long serialVersionUID =-7666172828961171865L;
1592
        static final long serialVersionUID =-7666172828961171865L;
1535
1593
1536
        public FormatAction() {
1594
        public FormatAction() {
1537
            super(BaseKit.formatAction,
1595
            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
1596
            //#54893 putValue ("helpID", FormatAction.class.getName ()); // NOI18N
1540
        }
1597
        }
1541
1598
Lines 1619-1634 Link Here
1619
        
1676
        
1620
    }
1677
    }
1621
1678
1679
    @EditorActionRegistrations({
1680
        @EditorActionRegistration(name = BaseKit.firstNonWhiteAction),
1681
        @EditorActionRegistration(name = BaseKit.selectionFirstNonWhiteAction)
1682
    })
1622
    public static class FirstNonWhiteAction extends LocalBaseAction {
1683
    public static class FirstNonWhiteAction extends LocalBaseAction {
1623
1684
1624
        boolean select;
1625
1626
        static final long serialVersionUID =-5888439539790901158L;
1685
        static final long serialVersionUID =-5888439539790901158L;
1627
1686
1628
        public FirstNonWhiteAction(String nm, boolean select) {
1687
        public FirstNonWhiteAction() {
1629
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
1688
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1630
                  | WORD_MATCH_RESET);
1631
            this.select = select;
1632
        }
1689
        }
1633
1690
1634
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1691
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1638-1643 Link Here
1638
                    int pos = Utilities.getRowFirstNonWhite((BaseDocument)target.getDocument(),
1695
                    int pos = Utilities.getRowFirstNonWhite((BaseDocument)target.getDocument(),
1639
                                                            caret.getDot());
1696
                                                            caret.getDot());
1640
                    if (pos >= 0) {
1697
                    if (pos >= 0) {
1698
                        boolean select = BaseKit.selectionFirstNonWhiteAction.equals(getValue(Action.NAME));
1641
                        if (select) {
1699
                        if (select) {
1642
                            caret.moveDot(pos);
1700
                            caret.moveDot(pos);
1643
                        } else {
1701
                        } else {
Lines 1651-1666 Link Here
1651
        }
1709
        }
1652
    }
1710
    }
1653
1711
1712
    @EditorActionRegistrations({
1713
        @EditorActionRegistration(name = BaseKit.lastNonWhiteAction),
1714
        @EditorActionRegistration(name = BaseKit.selectionLastNonWhiteAction)
1715
    })
1654
    public static class LastNonWhiteAction extends LocalBaseAction {
1716
    public static class LastNonWhiteAction extends LocalBaseAction {
1655
1717
1656
        boolean select;
1657
1658
        static final long serialVersionUID =4503533041729712917L;
1718
        static final long serialVersionUID =4503533041729712917L;
1659
1719
1660
        public LastNonWhiteAction(String nm, boolean select) {
1720
        public LastNonWhiteAction() {
1661
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
1721
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1662
                  | WORD_MATCH_RESET);
1663
            this.select = select;
1664
        }
1722
        }
1665
1723
1666
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1724
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1670-1675 Link Here
1670
                    int pos = Utilities.getRowLastNonWhite((BaseDocument)target.getDocument(),
1728
                    int pos = Utilities.getRowLastNonWhite((BaseDocument)target.getDocument(),
1671
                                                           caret.getDot());
1729
                                                           caret.getDot());
1672
                    if (pos >= 0) {
1730
                    if (pos >= 0) {
1731
                        boolean select = BaseKit.selectionLastNonWhiteAction.equals(getValue(Action.NAME));
1673
                        if (select) {
1732
                        if (select) {
1674
                            caret.moveDot(pos);
1733
                            caret.moveDot(pos);
1675
                        } else {
1734
                        } else {
Lines 1683-1694 Link Here
1683
        }
1742
        }
1684
    }
1743
    }
1685
1744
1745
    @EditorActionRegistration(name = BaseKit.selectIdentifierAction)
1686
    public static class SelectIdentifierAction extends LocalBaseAction {
1746
    public static class SelectIdentifierAction extends LocalBaseAction {
1687
1747
1688
        static final long serialVersionUID =-7288216961333147873L;
1748
        static final long serialVersionUID =-7288216961333147873L;
1689
1749
1690
        public SelectIdentifierAction() {
1750
        public SelectIdentifierAction() {
1691
            super(BaseKit.selectIdentifierAction, MAGIC_POSITION_RESET);
1751
            super(MAGIC_POSITION_RESET);
1692
        }
1752
        }
1693
1753
1694
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1754
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1712-1717 Link Here
1712
        }
1772
        }
1713
    }
1773
    }
1714
1774
1775
    @EditorActionRegistration(name = BaseKit.selectNextParameterAction)
1715
    public static class SelectNextParameterAction extends LocalBaseAction {
1776
    public static class SelectNextParameterAction extends LocalBaseAction {
1716
1777
1717
        static final long serialVersionUID =8045372985336370934L;
1778
        static final long serialVersionUID =8045372985336370934L;
Lines 1762-1767 Link Here
1762
     * in the editor module.
1823
     * in the editor module.
1763
     */
1824
     */
1764
    public static class JumpListNextAction extends LocalBaseAction {
1825
    public static class JumpListNextAction extends LocalBaseAction {
1826
    // Not registered by annotation since it's not actively used
1765
1827
1766
        static final long serialVersionUID =6891721278404990446L;
1828
        static final long serialVersionUID =6891721278404990446L;
1767
        PropertyChangeListener pcl;
1829
        PropertyChangeListener pcl;
Lines 1790-1795 Link Here
1790
     * in the editor module.
1852
     * in the editor module.
1791
     */
1853
     */
1792
    public static class JumpListPrevAction extends LocalBaseAction {
1854
    public static class JumpListPrevAction extends LocalBaseAction {
1855
    // Not registered by annotation since it's not actively used
1793
1856
1794
        static final long serialVersionUID =7174907031986424265L;
1857
        static final long serialVersionUID =7174907031986424265L;
1795
        PropertyChangeListener pcl;
1858
        PropertyChangeListener pcl;
Lines 1818-1823 Link Here
1818
     * in the editor module.
1881
     * in the editor module.
1819
     */
1882
     */
1820
    public static class JumpListNextComponentAction extends LocalBaseAction {
1883
    public static class JumpListNextComponentAction extends LocalBaseAction {
1884
    // Not registered by annotation since it's not actively used
1821
1885
1822
        static final long serialVersionUID =-2059070050865876892L;
1886
        static final long serialVersionUID =-2059070050865876892L;
1823
1887
Lines 1837-1842 Link Here
1837
     * in the editor module.
1901
     * in the editor module.
1838
     */
1902
     */
1839
    public static class JumpListPrevComponentAction extends LocalBaseAction {
1903
    public static class JumpListPrevComponentAction extends LocalBaseAction {
1904
    // Not registered by annotation since it's not actively used
1840
1905
1841
        static final long serialVersionUID =2032230534727849525L;
1906
        static final long serialVersionUID =2032230534727849525L;
1842
1907
Lines 1851-1860 Link Here
1851
        }
1916
        }
1852
    }
1917
    }
1853
1918
1919
    @EditorActionRegistration(name = BaseKit.scrollUpAction)
1854
    public static class ScrollUpAction extends LocalBaseAction {
1920
    public static class ScrollUpAction extends LocalBaseAction {
1855
1921
1856
        public ScrollUpAction() {
1922
        public ScrollUpAction() {
1857
            super(BaseKit.scrollUpAction);
1858
        }
1923
        }
1859
1924
1860
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1925
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1869-1878 Link Here
1869
1934
1870
    }
1935
    }
1871
1936
1937
    @EditorActionRegistration(name = BaseKit.scrollDownAction)
1872
    public static class ScrollDownAction extends LocalBaseAction {
1938
    public static class ScrollDownAction extends LocalBaseAction {
1873
1939
1874
        public ScrollDownAction() {
1940
        public ScrollDownAction() {
1875
            super(BaseKit.scrollDownAction);
1876
        }
1941
        }
1877
1942
1878
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1943
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1887-1899 Link Here
1887
1952
1888
    }
1953
    }
1889
1954
1955
    @EditorActionRegistration(name = BaseKit.insertDateTimeAction)
1890
    public static class InsertDateTimeAction extends LocalBaseAction {
1956
    public static class InsertDateTimeAction extends LocalBaseAction {
1891
        
1957
        
1892
        static final long serialVersionUID =2865619897402L;
1958
        static final long serialVersionUID =2865619897402L;
1893
        
1959
        
1894
        public InsertDateTimeAction() {
1960
        public InsertDateTimeAction() {
1895
            super(BaseKit.insertDateTimeAction,
1961
            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
        }
1962
        }
1898
        
1963
        
1899
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1964
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1921-1932 Link Here
1921
    }
1986
    }
1922
    
1987
    
1923
    /** Select text of whole document */
1988
    /** Select text of whole document */
1989
    @EditorActionRegistration(name = BaseKit.generateGutterPopupAction)
1924
    public static class GenerateGutterPopupAction extends LocalBaseAction {
1990
    public static class GenerateGutterPopupAction extends LocalBaseAction {
1925
1991
1926
        static final long serialVersionUID =-3502499718130556525L;
1992
        static final long serialVersionUID =-3502499718130556525L;
1927
1993
1928
        public GenerateGutterPopupAction() {
1994
        public GenerateGutterPopupAction() {
1929
            super(BaseKit.generateGutterPopupAction);
1930
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1995
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1931
        }
1996
        }
1932
1997
Lines 1945-1950 Link Here
1945
    }
2010
    }
1946
2011
1947
    /** Switch visibility of line numbers in editor */
2012
    /** Switch visibility of line numbers in editor */
2013
    @EditorActionRegistration(name = BaseKit.toggleLineNumbersAction)
1948
    public static class ToggleLineNumbersAction extends LocalBaseAction {
2014
    public static class ToggleLineNumbersAction extends LocalBaseAction {
1949
2015
1950
        static final long serialVersionUID =-3502499718130556526L;
2016
        static final long serialVersionUID =-3502499718130556526L;
Lines 1952-1958 Link Here
1952
        private JCheckBoxMenuItem item = null;
2018
        private JCheckBoxMenuItem item = null;
1953
2019
1954
        public ToggleLineNumbersAction() {
2020
        public ToggleLineNumbersAction() {
1955
            super(BaseKit.toggleLineNumbersAction);
2021
            super(BaseKit.toggleLineNumbersAction); // Due to creation from MainMenuAction
1956
        }
2022
        }
1957
2023
1958
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2024
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1981-1990 Link Here
1981
    }
2047
    }
1982
    
2048
    
1983
    /** Cycle through annotations on the current line */
2049
    /** Cycle through annotations on the current line */
2050
    @EditorActionRegistration(name = BaseKit.annotationsCyclingAction)
1984
    public static class AnnotationsCyclingAction extends LocalBaseAction {
2051
    public static class AnnotationsCyclingAction extends LocalBaseAction {
1985
        
2052
        
1986
        public AnnotationsCyclingAction() {
2053
        public AnnotationsCyclingAction() {
1987
            super(BaseKit.annotationsCyclingAction);
1988
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
2054
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1989
        }
2055
        }
1990
2056
Lines 2079-2087 Link Here
2079
    }
2145
    }
2080
    
2146
    
2081
    /** Collapse a fold. Depends on the current caret position. */
2147
    /** Collapse a fold. Depends on the current caret position. */
2148
    @EditorActionRegistration(name = BaseKit.collapseFoldAction)
2082
    public static class CollapseFold extends LocalBaseAction {
2149
    public static class CollapseFold extends LocalBaseAction {
2083
        public CollapseFold(){
2150
        public CollapseFold(){
2084
            super(BaseKit.collapseFoldAction);
2085
        }
2151
        }
2086
        
2152
        
2087
        private boolean dotInFoldArea(JTextComponent target, Fold fold, int dot) throws BadLocationException{
2153
        private boolean dotInFoldArea(JTextComponent target, Fold fold, int dot) throws BadLocationException{
Lines 2121-2129 Link Here
2121
    }
2187
    }
2122
    
2188
    
2123
    /** Expand a fold. Depends on the current caret position. */
2189
    /** Expand a fold. Depends on the current caret position. */
2190
    @EditorActionRegistration(name = BaseKit.expandFoldAction)
2124
    public static class ExpandFold extends LocalBaseAction {
2191
    public static class ExpandFold extends LocalBaseAction {
2125
        public ExpandFold(){
2192
        public ExpandFold(){
2126
            super(BaseKit.expandFoldAction);
2127
        }
2193
        }
2128
        
2194
        
2129
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2195
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2148-2156 Link Here
2148
    }
2214
    }
2149
    
2215
    
2150
    /** Collapse all existing folds in the document. */
2216
    /** Collapse all existing folds in the document. */
2217
    @EditorActionRegistration(name = BaseKit.collapseAllFoldsAction)
2151
    public static class CollapseAllFolds extends LocalBaseAction {
2218
    public static class CollapseAllFolds extends LocalBaseAction {
2152
        public CollapseAllFolds(){
2219
        public CollapseAllFolds(){
2153
            super(BaseKit.collapseAllFoldsAction);
2154
        }
2220
        }
2155
        
2221
        
2156
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2222
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2161-2169 Link Here
2161
    }
2227
    }
2162
2228
2163
    /** Expand all existing folds in the document. */
2229
    /** Expand all existing folds in the document. */
2230
    @EditorActionRegistration(name = BaseKit.expandAllFoldsAction)
2164
    public static class ExpandAllFolds extends LocalBaseAction {
2231
    public static class ExpandAllFolds extends LocalBaseAction {
2165
        public ExpandAllFolds(){
2232
        public ExpandAllFolds(){
2166
            super(BaseKit.expandAllFoldsAction);
2167
        }
2233
        }
2168
        
2234
        
2169
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2235
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2174-2183 Link Here
2174
    }
2240
    }
2175
2241
2176
    /** Expand all existing folds in the document. */
2242
    /** Expand all existing folds in the document. */
2243
    @EditorActionRegistration(name = "dump-view-hierarchy")
2177
    public static class DumpViewHierarchyAction extends LocalBaseAction {
2244
    public static class DumpViewHierarchyAction extends LocalBaseAction {
2178
2245
2179
        public DumpViewHierarchyAction() {
2246
        public DumpViewHierarchyAction() {
2180
            super("dump-view-hierarchy"); // NOI18N
2181
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
2247
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
2182
        }
2248
        }
2183
        
2249
        
Lines 2223-2232 Link Here
2223
    }
2289
    }
2224
    
2290
    
2225
    /** Starts a new line in code. */
2291
    /** Starts a new line in code. */
2292
    @EditorActionRegistration(name = BaseKit.startNewLineAction)
2226
    public static class StartNewLine extends LocalBaseAction {
2293
    public static class StartNewLine extends LocalBaseAction {
2227
        public StartNewLine(){
2294
        public StartNewLine(){
2228
            super( BaseKit.startNewLineAction, ABBREV_RESET
2295
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
2229
                  | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
2230
        }
2296
        }
2231
        
2297
        
2232
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
2298
        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
2334
     * Cut text from the caret position to either begining or end
2269
     * of the line with the caret.
2335
     * of the line with the caret.
2270
     */
2336
     */
2337
    @EditorActionRegistrations({
2338
        @EditorActionRegistration(name = BaseKit.cutToLineBeginAction),
2339
        @EditorActionRegistration(name = BaseKit.cutToLineEndAction)
2340
    })
2271
    public static class CutToLineBeginOrEndAction extends LocalBaseAction {
2341
    public static class CutToLineBeginOrEndAction extends LocalBaseAction {
2272
        
2342
        
2273
        /**
2343
        /**
2274
         * Whether cutting to line end instead of line begin.
2275
         */
2276
        private final boolean toLineEnd;
2277
        
2278
        /**
2279
         * Construct new action.
2344
         * Construct new action.
2280
         *
2345
         *
2281
         * @param toLineEnd whether cutting to line end instead of line begin.
2346
         * @param toLineEnd whether cutting to line end instead of line begin.
2282
         */
2347
         */
2283
        public CutToLineBeginOrEndAction(boolean toLineEnd) {
2348
        public CutToLineBeginOrEndAction() {
2284
            super(toLineEnd ? BaseKit.cutToLineEndAction : BaseKit.cutToLineBeginAction,
2349
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
2285
                ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET);
2286
            this.toLineEnd = toLineEnd;
2287
        }
2350
        }
2288
        
2351
        
2289
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
2352
        public void actionPerformed (final ActionEvent evt, final JTextComponent target) {
Lines 2304-2309 Link Here
2304
                    if (actionMap != null && (cutAction = actionMap.get(DefaultEditorKit.cutAction)) != null) {
2367
                    if (actionMap != null && (cutAction = actionMap.get(DefaultEditorKit.cutAction)) != null) {
2305
                        Caret caret = target.getCaret();
2368
                        Caret caret = target.getCaret();
2306
                        int caretOffset = caret.getDot();
2369
                        int caretOffset = caret.getDot();
2370
                        boolean toLineEnd = BaseKit.cutToLineEndAction.equals(getValue(Action.NAME));
2307
                        int boundOffset = toLineEnd
2371
                        int boundOffset = toLineEnd
2308
                                ? Utilities.getRowEnd(target, caretOffset)
2372
                                ? Utilities.getRowEnd(target, caretOffset)
2309
                                : Utilities.getRowStart(target, caretOffset);
2373
                                : Utilities.getRowStart(target, caretOffset);
(-)a/editor.lib/src/org/netbeans/editor/BaseAction.java (-1 / +29 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
     * @since 1.34
184
     */
185
    protected void actionNameUpdate(String actionName) {
186
    }
187
160
    /**
188
    /**
161
     * This method is called when there is no value for the particular key.
189
     * This method is called when there is no value for the particular key.
162
     * <br/>
190
     * <br/>
(-)a/editor.lib/src/org/netbeans/editor/BaseKit.java (-191 / +156 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;
81
import org.netbeans.api.editor.EditorActionRegistrations;
80
import org.netbeans.api.editor.mimelookup.MimeLookup;
82
import org.netbeans.api.editor.mimelookup.MimeLookup;
81
import org.netbeans.api.editor.mimelookup.MimePath;
83
import org.netbeans.api.editor.mimelookup.MimePath;
82
import org.netbeans.api.editor.settings.KeyBindingSettings;
84
import org.netbeans.api.editor.settings.KeyBindingSettings;
Lines 691-699 Link Here
691
    */
693
    */
692
    public static Map<String, Action> actionsToMap(Action[] actions) {
694
    public static Map<String, Action> actionsToMap(Action[] actions) {
693
        Map<String, Action> map = new HashMap<String, Action>();
695
        Map<String, Action> map = new HashMap<String, Action>();
694
        for (Action a : actions) {
696
        for (int i = 0; i < actions.length; i++) {
697
            Action a = actions[i];
698
            if (a == null) {
699
                throw new IllegalStateException("actions[] contains null at index " + i +
700
                        ((i > 0) ? ". Preceding action is " + actions[i - 1] : ""));
701
            }
695
            String name = (String) a.getValue(Action.NAME);
702
            String name = (String) a.getValue(Action.NAME);
696
            map.put(((name != null) ? name : ""), a); // NOI18N
703
            if (name == null) {
704
                throw new IllegalStateException("Null Action.NAME property of action " + a);
705
            }
706
            map.put(name, a); // NOI18N
697
        }
707
        }
698
        return map;
708
        return map;
699
    }
709
    }
Lines 824-930 Link Here
824
    */
834
    */
825
    protected Action[] createActions() {
835
    protected Action[] createActions() {
826
        return new Action[] {
836
        return new Action[] {
827
                   new DefaultKeyTypedAction(),
828
                   new InsertContentAction(),
829
                   insertBreakActionDef,
837
                   insertBreakActionDef,
830
		   new SplitLineAction(),
831
                   insertTabActionDef,
838
                   insertTabActionDef,
832
                   deletePrevCharActionDef,
839
                   deletePrevCharActionDef,
833
                   deleteNextCharActionDef,
840
                   deleteNextCharActionDef,
834
                   new ReadOnlyAction(),
835
                   new WritableAction(),
836
                   cutActionDef,
841
                   cutActionDef,
837
                   copyActionDef,
842
                   copyActionDef,
838
                   pasteActionDef,
843
                   pasteActionDef,
839
                   new PasteAction(true),
844
                   new PasteAction(true),
840
                   new BeepAction(),
841
                   new UpAction(upAction, false),
842
                   new UpAction(selectionUpAction, true),
843
                   new PageUpAction(pageUpAction, false),
844
                   new PageUpAction(selectionPageUpAction, true),
845
                   new DownAction(downAction, false),
846
                   new DownAction(selectionDownAction, true),
847
                   new PageDownAction(selectionPageDownAction, true),
848
                   new PageDownAction(pageDownAction, false),
849
                   new ForwardAction(forwardAction, false),
850
                   new ForwardAction(selectionForwardAction, true),
851
                   new BackwardAction(backwardAction, false),
852
                   new BackwardAction(selectionBackwardAction, true),
853
                   new BeginLineAction(lineFirstColumnAction, false, true),
854
                   new BeginLineAction(selectionLineFirstColumnAction, true, true),
855
                   new BeginLineAction(beginLineAction, false),
856
                   new BeginLineAction(selectionBeginLineAction, true),
857
                   new EndLineAction(endLineAction, false),
858
                   new EndLineAction(selectionEndLineAction, true),
859
                   new BeginAction(beginAction, false),
860
                   new BeginAction(selectionBeginAction, true),
861
                   new EndAction(endAction, false),
862
                   new EndAction(selectionEndAction, true),
863
                   new NextWordAction(nextWordAction, false),
864
                   new NextWordAction(selectionNextWordAction, true),
865
                   new PreviousWordAction(previousWordAction, false),
866
                   new PreviousWordAction(selectionPreviousWordAction, true),
867
                   new BeginWordAction(beginWordAction, false),
868
                   new BeginWordAction(selectionBeginWordAction, true),
869
                   new EndWordAction(endWordAction, false),
870
                   new EndWordAction(selectionEndWordAction, true),
871
                   new SelectWordAction(),
872
                   new SelectLineAction(),
873
                   new SelectAllAction(),
874
                   new RemoveTrailingSpacesAction(),
875
                   removeTabActionDef,
845
                   removeTabActionDef,
876
                   //new ActionFactory.RemoveWordAction(), #47709
846
                   //new ActionFactory.RemoveWordAction(), #47709
877
                   new ActionFactory.RemoveWordPreviousAction(),
878
                   new ActionFactory.RemoveWordNextAction(),
879
                   new ActionFactory.RemoveLineBeginAction(),
880
                   new ActionFactory.RemoveLineAction(),
881
                   new ActionFactory.MoveSelectionElseLineUpAction(),
882
                   new ActionFactory.MoveSelectionElseLineDownAction(),
883
                   new ActionFactory.CopySelectionElseLineUpAction(),
884
                   new ActionFactory.CopySelectionElseLineDownAction(),
885
                   removeSelectionActionDef,
847
                   removeSelectionActionDef,
886
                   new ActionFactory.ToggleTypingModeAction(),
887
                   new ActionFactory.ChangeCaseAction(toUpperCaseAction, Utilities.CASE_UPPER),
888
                   new ActionFactory.ChangeCaseAction(toLowerCaseAction, Utilities.CASE_LOWER),
889
                   new ActionFactory.ChangeCaseAction(switchCaseAction, Utilities.CASE_SWITCH),
890
                   new ActionFactory.FindNextAction(),
891
                   new ActionFactory.FindPreviousAction(),
892
                   new ActionFactory.FindSelectionAction(),
893
                   new ActionFactory.ToggleHighlightSearchAction(),
894
                   undoActionDef,
848
                   undoActionDef,
895
                   redoActionDef,
849
                   redoActionDef,
896
                   new ActionFactory.WordMatchAction(wordMatchNextAction, true),
897
                   new ActionFactory.WordMatchAction(wordMatchPrevAction, false),
898
                   new ActionFactory.ReindentLineAction(),
899
                   new ActionFactory.ShiftLineAction(shiftLineLeftAction, false),
900
                   new ActionFactory.ShiftLineAction(shiftLineRightAction, true),
901
                   new ActionFactory.AdjustWindowAction(adjustWindowTopAction, 0),
902
                   new ActionFactory.AdjustWindowAction(adjustWindowCenterAction, 50),
903
                   new ActionFactory.AdjustWindowAction(adjustWindowBottomAction, 100),
904
                   new ActionFactory.AdjustCaretAction(adjustCaretTopAction, 0),
905
                   new ActionFactory.AdjustCaretAction(adjustCaretCenterAction, 50),
906
                   new ActionFactory.AdjustCaretAction(adjustCaretBottomAction, 100),
907
                   new ActionFactory.FormatAction(),
908
                   new ActionFactory.FirstNonWhiteAction(firstNonWhiteAction, false),
909
                   new ActionFactory.FirstNonWhiteAction(selectionFirstNonWhiteAction, true),
910
                   new ActionFactory.LastNonWhiteAction(lastNonWhiteAction, false),
911
                   new ActionFactory.LastNonWhiteAction(selectionLastNonWhiteAction, true),
912
                   new ActionFactory.SelectIdentifierAction(),
913
                   new ActionFactory.SelectNextParameterAction(),
914
                   new ActionFactory.ScrollUpAction(),
915
                   new ActionFactory.ScrollDownAction(),
916
                   new ActionFactory.InsertDateTimeAction(),
917
                   new ActionFactory.GenerateGutterPopupAction(),
918
                   new ActionFactory.ToggleLineNumbersAction(),
919
                   new ActionFactory.AnnotationsCyclingAction(),
920
                   new ActionFactory.CollapseFold(),
921
                   new ActionFactory.ExpandFold(),
922
                   new ActionFactory.CollapseAllFolds(),
923
                   new ActionFactory.ExpandAllFolds(),
924
                   new ActionFactory.DumpViewHierarchyAction(),
925
                   new ActionFactory.StartNewLine(),
926
                   new ActionFactory.CutToLineBeginOrEndAction(false),
927
                   new ActionFactory.CutToLineBeginOrEndAction(true),
928
850
929
                   // Self test actions
851
                   // Self test actions
930
                   //      new EditorDebug.SelfTestAction(),
852
                   //      new EditorDebug.SelfTestAction(),
Lines 1033-1043 Link Here
1033
955
1034
956
1035
    /** Default typed action */
957
    /** Default typed action */
958
    @EditorActionRegistration(name = defaultKeyTypedAction)
1036
    public static class DefaultKeyTypedAction extends LocalBaseAction {
959
    public static class DefaultKeyTypedAction extends LocalBaseAction {
1037
960
1038
        static final long serialVersionUID =3069164318144463899L;
961
        static final long serialVersionUID =3069164318144463899L;
1039
962
1040
        public DefaultKeyTypedAction() {
963
        public DefaultKeyTypedAction() {
964
            // Construct with defaultKeyTypedAction name to retain full compatibility for extending actions
1041
            super(defaultKeyTypedAction, MAGIC_POSITION_RESET | CLEAR_STATUS_TEXT);
965
            super(defaultKeyTypedAction, MAGIC_POSITION_RESET | CLEAR_STATUS_TEXT);
1042
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
966
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1043
            LOG.fine("DefaultKeyTypedAction with enhanced logging, see issue #145306"); //NOI18N
967
            LOG.fine("DefaultKeyTypedAction with enhanced logging, see issue #145306"); //NOI18N
Lines 1246-1257 Link Here
1246
      }
1170
      }
1247
    }
1171
    }
1248
1172
1173
    @EditorActionRegistration(name = splitLineAction)
1249
    public static class SplitLineAction extends LocalBaseAction {
1174
    public static class SplitLineAction extends LocalBaseAction {
1250
1175
1251
        static final long serialVersionUID =7966576342334158659L;
1176
        static final long serialVersionUID =7966576342334158659L;
1252
1177
1253
        public SplitLineAction() {
1178
        public SplitLineAction() {
1254
	  super(splitLineAction, MAGIC_POSITION_RESET | ABBREV_RESET | WORD_MATCH_RESET);
1179
	  super(MAGIC_POSITION_RESET | ABBREV_RESET | WORD_MATCH_RESET);
1255
        }
1180
        }
1256
1181
1257
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
1182
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
Lines 1417-1422 Link Here
1417
1342
1418
        static final long serialVersionUID =8415246475764264835L;
1343
        static final long serialVersionUID =8415246475764264835L;
1419
1344
1345
        public KitCompoundAction(String actionNames[]) {
1346
            this(0, actionNames);
1347
        }
1348
1349
        public KitCompoundAction(int resetMask, String actionNames[]) {
1350
            super(resetMask);
1351
            this.actionNames = actionNames;
1352
        }
1353
1420
        public KitCompoundAction(String nm, String actionNames[]) {
1354
        public KitCompoundAction(String nm, String actionNames[]) {
1421
            this(nm, 0, actionNames);
1355
            this(nm, 0, actionNames);
1422
        }
1356
        }
Lines 1445-1457 Link Here
1445
        }
1379
        }
1446
    }
1380
    }
1447
1381
1382
    @EditorActionRegistration(name = insertContentAction)
1448
    public static class InsertContentAction extends LocalBaseAction {
1383
    public static class InsertContentAction extends LocalBaseAction {
1449
1384
1450
        static final long serialVersionUID =5647751370952797218L;
1385
        static final long serialVersionUID =5647751370952797218L;
1451
1386
1452
        public InsertContentAction() {
1387
        public InsertContentAction() {
1453
            super(insertContentAction, MAGIC_POSITION_RESET | ABBREV_RESET
1388
            super(MAGIC_POSITION_RESET | ABBREV_RESET | WORD_MATCH_RESET);
1454
                  | WORD_MATCH_RESET);
1455
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1389
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1456
        }
1390
        }
1457
1391
Lines 1559-1570 Link Here
1559
      }
1493
      }
1560
    }
1494
    }
1561
1495
1496
    @EditorActionRegistration(name = readOnlyAction)
1562
    public static class ReadOnlyAction extends LocalBaseAction {
1497
    public static class ReadOnlyAction extends LocalBaseAction {
1563
1498
1564
        static final long serialVersionUID =9204335480208463193L;
1499
        static final long serialVersionUID =9204335480208463193L;
1565
1500
1566
        public ReadOnlyAction() {
1501
        public ReadOnlyAction() {
1567
            super(readOnlyAction);
1568
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1502
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1569
        }
1503
        }
1570
1504
Lines 1575-1586 Link Here
1575
        }
1509
        }
1576
    }
1510
    }
1577
1511
1512
    @EditorActionRegistration(name = writableAction)
1578
    public static class WritableAction extends LocalBaseAction {
1513
    public static class WritableAction extends LocalBaseAction {
1579
1514
1580
        static final long serialVersionUID =-5982547952800937954L;
1515
        static final long serialVersionUID =-5982547952800937954L;
1581
1516
1582
        public WritableAction() {
1517
        public WritableAction() {
1583
            super(writableAction);
1584
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1518
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1585
        }
1519
        }
1586
1520
Lines 1668-1679 Link Here
1668
    public static class PasteAction extends LocalBaseAction {
1602
    public static class PasteAction extends LocalBaseAction {
1669
1603
1670
        static final long serialVersionUID =5839791453996432149L;
1604
        static final long serialVersionUID =5839791453996432149L;
1671
        private boolean formatted;
1672
1605
1673
        public PasteAction(boolean formated) {
1606
        public PasteAction(boolean formatted) {
1674
            super(formated ? pasteFormatedAction : pasteAction, ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1607
            super(formatted ? pasteFormatedAction : pasteAction,
1675
            //#54893 putValue ("helpID", PasteAction.class.getName ()); // NOI18N
1608
                ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
1676
            this.formatted = formated;
1677
        }
1609
        }
1678
1610
1679
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
1611
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
Lines 1694-1699 Link Here
1694
                }
1626
                }
1695
1627
1696
                final Formatter formatter = doc.getFormatter();
1628
                final Formatter formatter = doc.getFormatter();
1629
                final boolean formatted = pasteFormatedAction.equals(getValue(Action.NAME));
1697
                if (formatted) {
1630
                if (formatted) {
1698
                    formatter.reformatLock();
1631
                    formatter.reformatLock();
1699
                }
1632
                }
Lines 1792-1804 Link Here
1792
    }
1725
    }
1793
1726
1794
1727
1795
1728
    @EditorActionRegistration(name = beepAction)
1796
    public static class BeepAction extends LocalBaseAction {
1729
    public static class BeepAction extends LocalBaseAction {
1797
1730
1798
        static final long serialVersionUID =-4474054576633223968L;
1731
        static final long serialVersionUID =-4474054576633223968L;
1799
1732
1800
        public BeepAction() {
1733
        public BeepAction() {
1801
            super(beepAction);
1802
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1734
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
1803
        }
1735
        }
1804
1736
Lines 1810-1825 Link Here
1810
    }
1742
    }
1811
1743
1812
1744
1745
    @EditorActionRegistrations({
1746
        @EditorActionRegistration(name = upAction),
1747
        @EditorActionRegistration(name = selectionUpAction)
1748
    })
1813
    public static class UpAction extends LocalBaseAction {
1749
    public static class UpAction extends LocalBaseAction {
1814
1750
1815
        boolean select;
1816
1817
        static final long serialVersionUID =4621760742646981563L;
1751
        static final long serialVersionUID =4621760742646981563L;
1818
1752
1819
        public UpAction(String nm, boolean select) {
1753
        public UpAction() {
1820
            super(nm, ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET
1754
            super(ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
1821
            | CLEAR_STATUS_TEXT);
1822
            this.select = select;
1823
        }
1755
        }
1824
1756
1825
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1757
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1839-1844 Link Here
1839
                    }
1771
                    }
1840
                    try {
1772
                    try {
1841
                        dot = Utilities.getPositionAbove(target, dot, p.x);
1773
                        dot = Utilities.getPositionAbove(target, dot, p.x);
1774
                        boolean select = selectionUpAction.equals(getValue(Action.NAME));
1842
                        if (select) {
1775
                        if (select) {
1843
                            caret.moveDot(dot);
1776
                            caret.moveDot(dot);
1844
                        } else {
1777
                        } else {
Lines 1854-1869 Link Here
1854
        }
1787
        }
1855
    }
1788
    }
1856
1789
1790
    @EditorActionRegistrations({
1791
        @EditorActionRegistration(name = downAction),
1792
        @EditorActionRegistration(name = selectionDownAction)
1793
    })
1857
    public static class DownAction extends LocalBaseAction {
1794
    public static class DownAction extends LocalBaseAction {
1858
1795
1859
        boolean select;
1860
1861
        static final long serialVersionUID =-5635702355125266822L;
1796
        static final long serialVersionUID =-5635702355125266822L;
1862
1797
1863
        public DownAction(String nm, boolean select) {
1798
        public DownAction() {
1864
            super(nm, ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET
1799
            super(ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
1865
            | CLEAR_STATUS_TEXT);
1866
            this.select = select;
1867
        }
1800
        }
1868
1801
1869
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1802
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1883-1888 Link Here
1883
                    }
1816
                    }
1884
                    try {
1817
                    try {
1885
                        dot = Utilities.getPositionBelow(target, dot, p.x);
1818
                        dot = Utilities.getPositionBelow(target, dot, p.x);
1819
                        boolean select = selectionDownAction.equals(getValue(Action.NAME));
1886
                        if (select) {
1820
                        if (select) {
1887
                            caret.moveDot(dot);
1821
                            caret.moveDot(dot);
1888
                        } else {
1822
                        } else {
Lines 1899-1914 Link Here
1899
    }
1833
    }
1900
1834
1901
    /** Go one page up */
1835
    /** Go one page up */
1836
    @EditorActionRegistrations({
1837
        @EditorActionRegistration(name = pageUpAction),
1838
        @EditorActionRegistration(name = selectionPageUpAction)
1839
    })
1902
    public static class PageUpAction extends LocalBaseAction {
1840
    public static class PageUpAction extends LocalBaseAction {
1903
1841
1904
        boolean select;
1905
1906
        static final long serialVersionUID =-3107382148581661079L;
1842
        static final long serialVersionUID =-3107382148581661079L;
1907
1843
1908
        public PageUpAction(String nm, boolean select) {
1844
        public PageUpAction() {
1909
            super(nm, ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET
1845
            super(ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
1910
            | CLEAR_STATUS_TEXT);
1911
            this.select = select;
1912
        }
1846
        }
1913
1847
1914
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1848
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1985-1991 Link Here
1985
                        newCaretOffset = target.viewToModel(newCaretPoint);
1919
                        newCaretOffset = target.viewToModel(newCaretPoint);
1986
                        newCaretBounds = target.modelToView(newCaretOffset);
1920
                        newCaretBounds = target.modelToView(newCaretOffset);
1987
                    }
1921
                    }
1988
                    
1922
1923
                    boolean select = selectionPageUpAction.equals(getValue(Action.NAME));
1989
                    if (select) {
1924
                    if (select) {
1990
                        caret.moveDot(newCaretOffset);
1925
                        caret.moveDot(newCaretOffset);
1991
                    } else {
1926
                    } else {
Lines 2003-2018 Link Here
2003
        }
1938
        }
2004
    }
1939
    }
2005
1940
1941
    @EditorActionRegistrations({
1942
        @EditorActionRegistration(name = forwardAction),
1943
        @EditorActionRegistration(name = selectionForwardAction)
1944
    })
2006
    public static class ForwardAction extends LocalBaseAction {
1945
    public static class ForwardAction extends LocalBaseAction {
2007
1946
2008
        boolean select;
2009
2010
        static final long serialVersionUID =8007293230193334414L;
1947
        static final long serialVersionUID =8007293230193334414L;
2011
1948
2012
        public ForwardAction(String nm, boolean select) {
1949
        public ForwardAction() {
2013
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
1950
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2014
            | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
1951
                | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2015
            this.select = select;
2016
        }
1952
        }
2017
1953
2018
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1954
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2020-2025 Link Here
2020
                Caret caret = target.getCaret();
1956
                Caret caret = target.getCaret();
2021
                try {
1957
                try {
2022
                    int pos;
1958
                    int pos;
1959
                    boolean select = selectionForwardAction.equals(getValue(Action.NAME));
2023
                    if (!select && Utilities.isSelectionShowing(caret))
1960
                    if (!select && Utilities.isSelectionShowing(caret))
2024
                    {
1961
                    {
2025
                        pos = target.getSelectionEnd(); 
1962
                        pos = target.getSelectionEnd(); 
Lines 2048-2070 Link Here
2048
    }
1985
    }
2049
1986
2050
    /** Go one page down */
1987
    /** Go one page down */
1988
    @EditorActionRegistrations({
1989
        @EditorActionRegistration(name = pageDownAction),
1990
        @EditorActionRegistration(name = selectionPageDownAction)
1991
    })
2051
    public static class PageDownAction extends LocalBaseAction {
1992
    public static class PageDownAction extends LocalBaseAction {
2052
1993
2053
        boolean select;
2054
2055
        static final long serialVersionUID =8942534850985048862L;
1994
        static final long serialVersionUID =8942534850985048862L;
2056
1995
2057
        public PageDownAction(String nm, boolean select) {
1996
        public PageDownAction() {
2058
            super(nm, ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET
1997
            super(ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET
2059
            | CLEAR_STATUS_TEXT);
1998
                | CLEAR_STATUS_TEXT);
2060
            this.select = select;
2061
        }
1999
        }
2062
2000
2063
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2001
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2064
            if (target != null) {
2002
            if (target != null) {
2065
                try {
2003
                try {
2066
                    Caret caret = target.getCaret();
2004
                    Caret caret = target.getCaret();
2067
                    BaseDocument doc = (BaseDocument)target.getDocument();
2068
                    int caretOffset = caret.getDot();
2005
                    int caretOffset = caret.getDot();
2069
                    Rectangle caretBounds = ((BaseTextUI)target.getUI()).modelToView(target, caretOffset);
2006
                    Rectangle caretBounds = ((BaseTextUI)target.getUI()).modelToView(target, caretOffset);
2070
                    if (caretBounds == null) {
2007
                    if (caretBounds == null) {
Lines 2129-2135 Link Here
2129
                        newCaretOffset = target.viewToModel(newCaretPoint);
2066
                        newCaretOffset = target.viewToModel(newCaretPoint);
2130
                        newCaretBounds = target.modelToView(newCaretOffset);
2067
                        newCaretBounds = target.modelToView(newCaretOffset);
2131
                    }
2068
                    }
2132
                    
2069
2070
                    boolean select = selectionPageDownAction.equals(getValue(Action.NAME));
2133
                    if (select) {
2071
                    if (select) {
2134
                        caret.moveDot(newCaretOffset);
2072
                        caret.moveDot(newCaretOffset);
2135
                    } else {
2073
                    } else {
Lines 2147-2162 Link Here
2147
        }
2085
        }
2148
    }
2086
    }
2149
2087
2088
    @EditorActionRegistrations({
2089
        @EditorActionRegistration(name = backwardAction),
2090
        @EditorActionRegistration(name = selectionBackwardAction)
2091
    })
2150
    public static class BackwardAction extends LocalBaseAction {
2092
    public static class BackwardAction extends LocalBaseAction {
2151
2093
2152
        boolean select;
2153
2154
        static final long serialVersionUID =-3048379822817847356L;
2094
        static final long serialVersionUID =-3048379822817847356L;
2155
2095
2156
        public BackwardAction(String nm, boolean select) {
2096
        public BackwardAction() {
2157
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2097
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2158
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2098
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2159
            this.select = select;
2160
        }
2099
        }
2161
2100
2162
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2101
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2164-2169 Link Here
2164
                Caret caret = target.getCaret();
2103
                Caret caret = target.getCaret();
2165
                try {
2104
                try {
2166
                    int pos;
2105
                    int pos;
2106
                    boolean select = selectionBackwardAction.equals(getValue(Action.NAME));
2167
                    if (!select && Utilities.isSelectionShowing(caret))
2107
                    if (!select && Utilities.isSelectionShowing(caret))
2168
                    {
2108
                    {
2169
                        pos = target.getSelectionStart(); 
2109
                        pos = target.getSelectionStart(); 
Lines 2193-2199 Link Here
2193
2133
2194
    public static class BeginLineAction extends LocalBaseAction {
2134
    public static class BeginLineAction extends LocalBaseAction {
2195
2135
2196
        protected boolean select;
2136
        @EditorActionRegistrations({
2137
            @EditorActionRegistration(name = beginLineAction),
2138
            @EditorActionRegistration(name = selectionBeginLineAction)
2139
        })
2140
        public static BeginLineAction create() {
2141
            return new BeginLineAction(false);
2142
        }
2143
2144
        @EditorActionRegistrations({
2145
            @EditorActionRegistration(name = lineFirstColumnAction),
2146
            @EditorActionRegistration(name = selectionLineFirstColumnAction)
2147
        })
2148
        public static BeginLineAction createColumnOne() {
2149
            return new BeginLineAction(true);
2150
        }
2197
2151
2198
        /** Whether the action should go to the begining of
2152
        /** Whether the action should go to the begining of
2199
         * the text on the line or to the first column on the line*/
2153
         * the text on the line or to the first column on the line*/
Lines 2201-2215 Link Here
2201
2155
2202
        static final long serialVersionUID =3269462923524077779L;
2156
        static final long serialVersionUID =3269462923524077779L;
2203
2157
2204
        public BeginLineAction(String nm, boolean select) {
2158
        public BeginLineAction(boolean columnOne) {
2205
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2159
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2206
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2160
                  | 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;
2161
            homeKeyColumnOne = columnOne;
2214
        }
2162
        }
2215
2163
Lines 2235-2240 Link Here
2235
                            dot = textStartPos;
2183
                            dot = textStartPos;
2236
                        }
2184
                        }
2237
                    }
2185
                    }
2186
                    String actionName = (String) getValue(Action.NAME);
2187
                    boolean select = selectionBeginLineAction.equals(actionName)
2188
                            || selectionLineFirstColumnAction.equals(actionName);
2238
                    if (select) {
2189
                    if (select) {
2239
                        caret.moveDot(dot);
2190
                        caret.moveDot(dot);
2240
                    } else {
2191
                    } else {
Lines 2247-2262 Link Here
2247
        }
2198
        }
2248
    }
2199
    }
2249
2200
2201
    @EditorActionRegistrations({
2202
        @EditorActionRegistration(name = endLineAction),
2203
        @EditorActionRegistration(name = selectionEndLineAction)
2204
    })
2250
    public static class EndLineAction extends LocalBaseAction {
2205
    public static class EndLineAction extends LocalBaseAction {
2251
2206
2252
        protected boolean select;
2253
2254
        static final long serialVersionUID =5216077634055190170L;
2207
        static final long serialVersionUID =5216077634055190170L;
2255
2208
2256
        public EndLineAction(String nm, boolean select) {
2209
        public EndLineAction() {
2257
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2210
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2258
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2211
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2259
            this.select = select;
2260
        }
2212
        }
2261
2213
2262
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2214
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2264-2269 Link Here
2264
                Caret caret = target.getCaret();
2216
                Caret caret = target.getCaret();
2265
                try {
2217
                try {
2266
                    int dot = Utilities.getRowEnd(target, caret.getDot());
2218
                    int dot = Utilities.getRowEnd(target, caret.getDot());
2219
                    boolean select = selectionEndLineAction.equals(getValue(Action.NAME));
2267
                    if (select) {
2220
                    if (select) {
2268
                        caret.moveDot(dot);
2221
                        caret.moveDot(dot);
2269
                    } else {
2222
                    } else {
Lines 2283-2304 Link Here
2283
        }
2236
        }
2284
    }
2237
    }
2285
2238
2239
    @EditorActionRegistrations({
2240
        @EditorActionRegistration(name = beginAction),
2241
        @EditorActionRegistration(name = selectionBeginAction)
2242
    })
2286
    public static class BeginAction extends LocalBaseAction {
2243
    public static class BeginAction extends LocalBaseAction {
2287
2244
2288
        boolean select;
2289
2290
        static final long serialVersionUID =3463563396210234361L;
2245
        static final long serialVersionUID =3463563396210234361L;
2291
2246
2292
        public BeginAction(String nm, boolean select) {
2247
        public BeginAction() {
2293
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2248
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2294
                  | WORD_MATCH_RESET | SAVE_POSITION | CLEAR_STATUS_TEXT);
2249
                  | WORD_MATCH_RESET | SAVE_POSITION | CLEAR_STATUS_TEXT);
2295
            this.select = select;
2296
        }
2250
        }
2297
2251
2298
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2252
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2299
            if (target != null) {
2253
            if (target != null) {
2300
                Caret caret = target.getCaret();
2254
                Caret caret = target.getCaret();
2301
                int dot = 0; // begin of document
2255
                int dot = 0; // begin of document
2256
                boolean select = selectionBeginAction.equals(getValue(Action.NAME));
2302
                if (select) {
2257
                if (select) {
2303
                    caret.moveDot(dot);
2258
                    caret.moveDot(dot);
2304
                } else {
2259
                } else {
Lines 2308-2329 Link Here
2308
        }
2263
        }
2309
    }
2264
    }
2310
2265
2266
    @EditorActionRegistrations({
2267
        @EditorActionRegistration(name = endAction),
2268
        @EditorActionRegistration(name = selectionEndAction)
2269
    })
2311
    public static class EndAction extends LocalBaseAction {
2270
    public static class EndAction extends LocalBaseAction {
2312
2271
2313
        boolean select;
2314
2315
        static final long serialVersionUID =8547506353130203657L;
2272
        static final long serialVersionUID =8547506353130203657L;
2316
2273
2317
        public EndAction(String nm, boolean select) {
2274
        public EndAction() {
2318
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2275
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2319
                  | WORD_MATCH_RESET | SAVE_POSITION | CLEAR_STATUS_TEXT);
2276
                  | WORD_MATCH_RESET | SAVE_POSITION | CLEAR_STATUS_TEXT);
2320
            this.select = select;
2321
        }
2277
        }
2322
2278
2323
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2279
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2324
            if (target != null) {
2280
            if (target != null) {
2325
                Caret caret = target.getCaret();
2281
                Caret caret = target.getCaret();
2326
                int dot = target.getDocument().getLength(); // end of document
2282
                int dot = target.getDocument().getLength(); // end of document
2283
                boolean select = selectionEndAction.equals(getValue(Action.NAME));
2327
                if (select) {
2284
                if (select) {
2328
                    caret.moveDot(dot);
2285
                    caret.moveDot(dot);
2329
                } else {
2286
                } else {
Lines 2333-2348 Link Here
2333
        }
2290
        }
2334
    }
2291
    }
2335
2292
2293
    @EditorActionRegistrations({
2294
        @EditorActionRegistration(name = nextWordAction),
2295
        @EditorActionRegistration(name = selectionNextWordAction)
2296
    })
2336
    public static class NextWordAction extends LocalBaseAction {
2297
    public static class NextWordAction extends LocalBaseAction {
2337
2298
2338
        boolean select;
2339
2340
        static final long serialVersionUID =-5909906947175434032L;
2299
        static final long serialVersionUID =-5909906947175434032L;
2341
2300
2342
        public NextWordAction(String nm, boolean select) {
2301
        public NextWordAction() {
2343
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2302
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2344
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2303
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2345
            this.select = select;
2346
        }
2304
        }
2347
2305
2348
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2306
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2351-2356 Link Here
2351
                try {
2309
                try {
2352
                    int dotPos = caret.getDot();
2310
                    int dotPos = caret.getDot();
2353
                    dotPos = Utilities.getNextWord(target, dotPos);
2311
                    dotPos = Utilities.getNextWord(target, dotPos);
2312
                    boolean select = selectionNextWordAction.equals(getValue(Action.NAME));
2354
                    if (caret instanceof BaseCaret){
2313
                    if (caret instanceof BaseCaret){
2355
                        BaseCaret bCaret = (BaseCaret) caret;
2314
                        BaseCaret bCaret = (BaseCaret) caret;
2356
                        if (select) {
2315
                        if (select) {
Lines 2372-2387 Link Here
2372
        }
2331
        }
2373
    }
2332
    }
2374
2333
2334
    @EditorActionRegistrations({
2335
        @EditorActionRegistration(name = previousWordAction),
2336
        @EditorActionRegistration(name = selectionPreviousWordAction)
2337
    })
2375
    public static class PreviousWordAction extends LocalBaseAction {
2338
    public static class PreviousWordAction extends LocalBaseAction {
2376
2339
2377
        boolean select;
2378
2379
        static final long serialVersionUID =-5465143382669785799L;
2340
        static final long serialVersionUID =-5465143382669785799L;
2380
2341
2381
        public PreviousWordAction(String nm, boolean select) {
2342
        public PreviousWordAction() {
2382
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2343
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2383
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2344
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2384
            this.select = select;
2385
        }
2345
        }
2386
2346
2387
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2347
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2389-2394 Link Here
2389
                Caret caret = target.getCaret();
2349
                Caret caret = target.getCaret();
2390
                try {
2350
                try {
2391
                    int dot = Utilities.getPreviousWord(target, caret.getDot());
2351
                    int dot = Utilities.getPreviousWord(target, caret.getDot());
2352
                    boolean select = selectionPreviousWordAction.equals(getValue(Action.NAME));
2392
                    if (caret instanceof BaseCaret){
2353
                    if (caret instanceof BaseCaret){
2393
                        BaseCaret bCaret = (BaseCaret) caret;
2354
                        BaseCaret bCaret = (BaseCaret) caret;
2394
                        if (select) {
2355
                        if (select) {
Lines 2410-2425 Link Here
2410
        }
2371
        }
2411
    }
2372
    }
2412
2373
2374
    @EditorActionRegistrations({
2375
        @EditorActionRegistration(name = beginWordAction),
2376
        @EditorActionRegistration(name = selectionBeginAction)
2377
    })
2413
    public static class BeginWordAction extends LocalBaseAction {
2378
    public static class BeginWordAction extends LocalBaseAction {
2414
2379
2415
        boolean select;
2416
2417
        static final long serialVersionUID =3991338381212491110L;
2380
        static final long serialVersionUID =3991338381212491110L;
2418
2381
2419
        public BeginWordAction(String nm, boolean select) {
2382
        public BeginWordAction() {
2420
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2383
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2421
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2384
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2422
            this.select = select;
2423
        }
2385
        }
2424
2386
2425
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2387
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2427-2432 Link Here
2427
                Caret caret = target.getCaret();
2389
                Caret caret = target.getCaret();
2428
                try {
2390
                try {
2429
                    int dot = Utilities.getWordStart(target, caret.getDot());
2391
                    int dot = Utilities.getWordStart(target, caret.getDot());
2392
                    boolean select = selectionBeginAction.equals(getValue(Action.NAME));
2430
                    if (select) {
2393
                    if (select) {
2431
                        caret.moveDot(dot);
2394
                        caret.moveDot(dot);
2432
                    } else {
2395
                    } else {
Lines 2439-2454 Link Here
2439
        }
2402
        }
2440
    }
2403
    }
2441
2404
2405
    @EditorActionRegistrations({
2406
        @EditorActionRegistration(name = endWordAction),
2407
        @EditorActionRegistration(name = selectionEndWordAction)
2408
    })
2442
    public static class EndWordAction extends LocalBaseAction {
2409
    public static class EndWordAction extends LocalBaseAction {
2443
2410
2444
        boolean select;
2445
2446
        static final long serialVersionUID =3812523676620144633L;
2411
        static final long serialVersionUID =3812523676620144633L;
2447
2412
2448
        public EndWordAction(String nm, boolean select) {
2413
        public EndWordAction() {
2449
            super(nm, MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2414
            super(MAGIC_POSITION_RESET | ABBREV_RESET | UNDO_MERGE_RESET
2450
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2415
                  | WORD_MATCH_RESET | CLEAR_STATUS_TEXT);
2451
            this.select = select;
2452
        }
2416
        }
2453
2417
2454
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
2418
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 2456-2461 Link Here
2456
                Caret caret = target.getCaret();
2420
                Caret caret = target.getCaret();
2457
                try {
2421
                try {
2458
                    int dot = Utilities.getWordEnd(target, caret.getDot());
2422
                    int dot = Utilities.getWordEnd(target, caret.getDot());
2423
                    boolean select = selectionEndWordAction.equals(getValue(Action.NAME));
2459
                    if (select) {
2424
                    if (select) {
2460
                        caret.moveDot(dot);
2425
                        caret.moveDot(dot);
2461
                    } else {
2426
                    } else {
Lines 2469-2481 Link Here
2469
    }
2434
    }
2470
2435
2471
    /** Select word around caret */
2436
    /** Select word around caret */
2437
    @EditorActionRegistration(name = selectWordAction)
2472
    public static class SelectWordAction extends KitCompoundAction {
2438
    public static class SelectWordAction extends KitCompoundAction {
2473
2439
2474
        static final long serialVersionUID =7678848538073016357L;
2440
        static final long serialVersionUID =7678848538073016357L;
2475
2441
2476
        public SelectWordAction() {
2442
        public SelectWordAction() {
2477
            super(selectWordAction,
2443
            super(new String[] {
2478
                  new String[] {
2479
                      beginWordAction,
2444
                      beginWordAction,
2480
                      selectionEndWordAction
2445
                      selectionEndWordAction
2481
                  }
2446
                  }
Lines 2485-2496 Link Here
2485
    }
2450
    }
2486
2451
2487
    /** Select line around caret */
2452
    /** Select line around caret */
2453
    @EditorActionRegistration(name = selectLineAction)
2488
    public static class SelectLineAction extends LocalBaseAction {
2454
    public static class SelectLineAction extends LocalBaseAction {
2489
2455
2490
        static final long serialVersionUID =-7407681863035740281L;
2456
        static final long serialVersionUID =-7407681863035740281L;
2491
2457
2492
        public SelectLineAction() {
2458
        public SelectLineAction() {
2493
            super(selectLineAction);
2494
        }
2459
        }
2495
2460
2496
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
2461
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
Lines 2519-2531 Link Here
2519
    }
2484
    }
2520
2485
2521
    /** Select text of whole document */
2486
    /** Select text of whole document */
2487
    @EditorActionRegistration(name = selectAllAction)
2522
    public static class SelectAllAction extends KitCompoundAction {
2488
    public static class SelectAllAction extends KitCompoundAction {
2523
2489
2524
        static final long serialVersionUID =-3502499718130556524L;
2490
        static final long serialVersionUID =-3502499718130556524L;
2525
2491
2526
        public SelectAllAction() {
2492
        public SelectAllAction() {
2527
            super(selectAllAction,
2493
            super(new String[] {
2528
                  new String[] {
2529
                      beginAction,
2494
                      beginAction,
2530
                      selectionEndAction
2495
                      selectionEndAction
2531
                  }
2496
                  }
Lines 2533-2543 Link Here
2533
        }
2498
        }
2534
2499
2535
    }
2500
    }
2536
    
2501
2502
    @EditorActionRegistration(name = removeTrailingSpacesAction)
2537
    public static class RemoveTrailingSpacesAction extends LocalBaseAction {
2503
    public static class RemoveTrailingSpacesAction extends LocalBaseAction {
2538
        
2504
        
2539
        public RemoveTrailingSpacesAction() {
2505
        public RemoveTrailingSpacesAction() {
2540
            super(removeTrailingSpacesAction);
2541
        }
2506
        }
2542
2507
2543
        protected boolean asynchonous() {
2508
        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 (-21 / +50 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());
218
        actions.add(new ShowPopupMenuAction());
219
        actions.add(new BuildToolTipAction());
220
        actions.add(replaceActionDef);
219
        actions.add(replaceActionDef);
221
        actions.add(gotoActionDef);
220
        actions.add(gotoActionDef);
222
        actions.add(new ToggleCaseIdentifierBeginAction());
223
// XXX: remove
221
// XXX: remove
224
//        if (!ExtCaret.NO_HIGHLIGHT_BRACE_LAYER) {
222
//        if (!ExtCaret.NO_HIGHLIGHT_BRACE_LAYER) {
225
//            actions.add(new MatchBraceAction(matchBraceAction, false));
223
//            actions.add(new MatchBraceAction(matchBraceAction, false));
226
//            actions.add(new MatchBraceAction(selectionMatchBraceAction, true));
224
//            actions.add(new MatchBraceAction(selectionMatchBraceAction, true));
227
//        }
225
//        }
228
        actions.add(new ExtDefaultKeyTypedAction());
229
        actions.add(new CompletionShowAction());
230
        actions.add(new AllCompletionShowAction());
231
        actions.add(new DocumentationShowAction());
232
        actions.add(new CompletionTooltipShowAction());
233
        actions.add(new CommentAction()); // to make ctrl-shift-T in Netbeans55 profile work
226
        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
227
        actions.add(new UncommentAction()); // to make ctrl-shift-D in Netbeans55 profile work
235
                
228
                
Lines 242-248 Link Here
242
     * <code>BaseKit.class</code> is used as a bundle class.
235
     * <code>BaseKit.class</code> is used as a bundle class.
243
     */
236
     */
244
    private abstract static class BaseKitLocalizedAction extends BaseAction {
237
    private abstract static class BaseKitLocalizedAction extends BaseAction {
245
        
238
239
        public BaseKitLocalizedAction() {
240
            super();
241
        }
242
243
        public BaseKitLocalizedAction(int updateMask) {
244
            super(updateMask);
245
        }
246
246
        public BaseKitLocalizedAction(String name) {
247
        public BaseKitLocalizedAction(String name) {
247
            super(name);
248
            super(name);
248
        }
249
        }
Lines 260-271 Link Here
260
    /** Called before the popup menu is shown to possibly rebuild
261
    /** Called before the popup menu is shown to possibly rebuild
261
    * the popup menu.
262
    * the popup menu.
262
    */
263
    */
264
    @EditorActionRegistration(
265
            name = buildPopupMenuAction,
266
            shortDescription = editorBundleHash + buildPopupMenuAction
267
    )
263
    public static class BuildPopupMenuAction extends BaseKitLocalizedAction {
268
    public static class BuildPopupMenuAction extends BaseKitLocalizedAction {
264
269
265
        static final long serialVersionUID =4257043398248915291L;
270
        static final long serialVersionUID =4257043398248915291L;
266
271
267
        public BuildPopupMenuAction() {
272
        public BuildPopupMenuAction() {
268
            super(buildPopupMenuAction, NO_RECORDING);
273
            super(NO_RECORDING);
269
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
274
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
270
        }
275
        }
271
276
Lines 396-407 Link Here
396
401
397
    /** Show the popup menu.
402
    /** Show the popup menu.
398
    */
403
    */
404
    @EditorActionRegistration(
405
            name = showPopupMenuAction,
406
            shortDescription = editorBundleHash + showPopupMenuAction
407
    )
399
    public static class ShowPopupMenuAction extends BaseKitLocalizedAction {
408
    public static class ShowPopupMenuAction extends BaseKitLocalizedAction {
400
409
401
        static final long serialVersionUID =4257043398248915291L;
410
        static final long serialVersionUID =4257043398248915291L;
402
411
403
        public ShowPopupMenuAction() {
412
        public ShowPopupMenuAction() {
404
            super(showPopupMenuAction, NO_RECORDING);
413
            super(NO_RECORDING);
405
        }
414
        }
406
415
407
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
416
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 423-436 Link Here
423
432
424
    }
433
    }
425
434
435
    @EditorActionRegistration(
436
            name = buildToolTipAction,
437
            shortDescription = editorBundleHash + buildToolTipAction
438
    )
426
    public static class BuildToolTipAction extends BaseAction {
439
    public static class BuildToolTipAction extends BaseAction {
427
440
428
        static final long serialVersionUID =-2701131863705941250L;
441
        static final long serialVersionUID =-2701131863705941250L;
429
442
430
        public BuildToolTipAction() {
443
        public BuildToolTipAction() {
431
            super(buildToolTipAction, NO_RECORDING);
444
            super(NO_RECORDING);
432
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
445
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
433
            putValue(Action.SHORT_DESCRIPTION, ""); // No explicit description NOI18N
434
        }
446
        }
435
447
436
        protected String buildText(JTextComponent target) {
448
        protected String buildText(JTextComponent target) {
Lines 455-460 Link Here
455
     * @deprecated Without any replacement.
467
     * @deprecated Without any replacement.
456
     */
468
     */
457
    public static class FindAction extends BaseKitLocalizedAction {
469
    public static class FindAction extends BaseKitLocalizedAction {
470
    // Not registered by annotation since it's not actively used
458
471
459
        static final long serialVersionUID =719554648887497427L;
472
        static final long serialVersionUID =719554648887497427L;
460
473
Lines 577-589 Link Here
577
        }
590
        }
578
    }
591
    }
579
592
593
    @EditorActionRegistration(name = toggleCaseIdentifierBeginAction, shortDescription = "")
580
    public static class ToggleCaseIdentifierBeginAction extends BaseKitLocalizedAction {
594
    public static class ToggleCaseIdentifierBeginAction extends BaseKitLocalizedAction {
581
595
582
        static final long serialVersionUID =584392193824931979L;
596
        static final long serialVersionUID =584392193824931979L;
583
597
584
        ToggleCaseIdentifierBeginAction() {
598
        public ToggleCaseIdentifierBeginAction() {
585
            super(toggleCaseIdentifierBeginAction, ABBREV_RESET
599
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
586
                  | MAGIC_POSITION_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
587
        }
600
        }
588
601
589
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
602
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 997-1002 Link Here
997
1010
998
1011
999
    // Completion customized actions
1012
    // Completion customized actions
1013
    @EditorActionRegistration(
1014
            name = defaultKeyTypedAction,
1015
            shortDescription = editorBundleHash + defaultKeyTypedAction
1016
    )
1000
    public static class ExtDefaultKeyTypedAction extends DefaultKeyTypedAction {
1017
    public static class ExtDefaultKeyTypedAction extends DefaultKeyTypedAction {
1001
1018
1002
        static final long serialVersionUID =5273032708909044812L;
1019
        static final long serialVersionUID =5273032708909044812L;
Lines 1104-1115 Link Here
1104
     * @deprecated Please use Editor Code Completion API instead, for details see
1121
     * @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>.
1122
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1106
     */
1123
     */
1124
    @EditorActionRegistration(
1125
            name = completionShowAction,
1126
            shortDescription = editorBundleHash + completionShowAction
1127
    )
1107
    public static class CompletionShowAction extends BaseKitLocalizedAction {
1128
    public static class CompletionShowAction extends BaseKitLocalizedAction {
1108
1129
1109
        static final long serialVersionUID =1050644925893851146L;
1130
        static final long serialVersionUID =1050644925893851146L;
1110
1131
1111
        public CompletionShowAction() {
1132
        public CompletionShowAction() {
1112
            super(completionShowAction);
1113
        }
1133
        }
1114
1134
1115
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1135
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1121-1130 Link Here
1121
     * @deprecated Please use Editor Code Completion API instead, for details see
1141
     * @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>.
1142
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1123
     */
1143
     */
1144
    @EditorActionRegistration(
1145
            name = allCompletionShowAction,
1146
            shortDescription = editorBundleHash + allCompletionShowAction
1147
    )
1124
    public static class AllCompletionShowAction extends BaseKitLocalizedAction {
1148
    public static class AllCompletionShowAction extends BaseKitLocalizedAction {
1125
1149
1126
        public AllCompletionShowAction() {
1150
        public AllCompletionShowAction() {
1127
            super(allCompletionShowAction);
1128
        }
1151
        }
1129
1152
1130
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1153
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1136-1145 Link Here
1136
     * @deprecated Please use Editor Code Completion API instead, for details see
1159
     * @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>.
1160
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1138
     */
1161
     */
1162
    @EditorActionRegistration(
1163
            name = documentationShowAction,
1164
            shortDescription = editorBundleHash + documentationShowAction
1165
    )
1139
    public static class DocumentationShowAction extends BaseKitLocalizedAction {
1166
    public static class DocumentationShowAction extends BaseKitLocalizedAction {
1140
1167
1141
        public DocumentationShowAction() {
1168
        public DocumentationShowAction() {
1142
            super(documentationShowAction);
1143
        }
1169
        }
1144
1170
1145
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1171
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 1151-1160 Link Here
1151
     * @deprecated Please use Editor Code Completion API instead, for details see
1177
     * @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>.
1178
     *   <a href="@org-netbeans-modules-editor-completion@/overview-summary.html">Editor Code Completion</a>.
1153
     */
1179
     */
1180
    @EditorActionRegistration(
1181
            name = completionTooltipShowAction,
1182
            shortDescription = editorBundleHash + completionTooltipShowAction
1183
    )
1154
    public static class CompletionTooltipShowAction extends BaseKitLocalizedAction {
1184
    public static class CompletionTooltipShowAction extends BaseKitLocalizedAction {
1155
1185
1156
        public CompletionTooltipShowAction() {
1186
        public CompletionTooltipShowAction() {
1157
            super(completionTooltipShowAction);
1158
        }
1187
        }
1159
1188
1160
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
1189
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
(-)a/editor.lib2/apichanges.xml (-1 / +16 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="7" month="4" year="2009"/>
112
            <author login="mmetelka"/>
113
            <compatibility binary="compatible" source="compatible" semantic="compatible" addition="yes"/>
114
            <description>
115
                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
            <class package="org.netbeans.api.editor" name="EditorActionRegistration"/>
120
            <issue number="150875"/>
121
        </change>
122
108
        <change id="added-codegen-spi">
123
        <change id="added-codegen-spi">
109
            <summary>Code Generation SPI added</summary>
124
            <summary>Code Generation SPI added</summary>
110
            <version major="1" minor="8"/>
125
            <version major="1" minor="8"/>
Lines 118-124 Link Here
118
                them into documents on the Insert Code editor action invocation.
133
                them into documents on the Insert Code editor action invocation.
119
                The <code>CodeGeneratorContextProvider</code> implementations
134
                The <code>CodeGeneratorContextProvider</code> implementations
120
                registered for the mime types could provide the respective
135
                registered for the mime types could provide the respective
121
                CodeGenerators with an additional context information. 
136
                CodeGenerators with an additional context information.
122
            </description>
137
            </description>
123
            <issue number="134239"/>
138
            <issue number="134239"/>
124
        </change>
139
        </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 / +9 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.7</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>
150
                    <test-dependency>
151
                        <code-name-base>org.openide.util</code-name-base>
152
                        <compile-dependency/>
153
                        <test/>
154
                    </test-dependency>
147
                </test-type>
155
                </test-type>
148
                <test-type>
156
                <test-type>
149
                    <name>qa-functional</name>
157
                    <name>qa-functional</name>
(-)a/editor.lib2/src/org/netbeans/api/editor/EditorActionRegistration.java (+137 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
import java.lang.annotation.ElementType;
45
import java.lang.annotation.Retention;
46
import java.lang.annotation.RetentionPolicy;
47
import java.lang.annotation.Target;
48
49
/**
50
 * Registration of an editor action so that it's automatically added into the list
51
 * of editor actions even without being explicitly created by <code>BaseKit.createActions()</code>.
52
 * <br/>
53
 * The corresponding annotation processor will build a xml-layer entry file
54
 * in the corresponding <i>/Editors/&lt;mime-type&gt;/Actions</code> folder.
55
 *
56
 * @since 1.10
57
 * @author Miloslav Metelka
58
 */
59
@Retention(RetentionPolicy.RUNTIME)
60
@Target({ ElementType.TYPE, ElementType.METHOD })
61
public @interface EditorActionRegistration {
62
63
    /**
64
     * Name of the action that will appear as <code>Action.NAME</code> attribute's value.
65
     * <br/>
66
     * The Swing's text package actions use convention of lowercase letters with hyphens
67
     * e.g. "caret-end-word" - see String constants in {@link javax.swing.text.DefaultEditorKit}.
68
     *
69
     * @return value of Action.NAME attribute.
70
     */
71
    String name();
72
73
    /**
74
     * Mime type for which the action will be registered.
75
     * <br/>
76
     * It implies the target folder of the registration <i>/Editors/&lt;mime-type&gt;/Actions</code>.
77
     *
78
     * @return mime-type of the action registration (for example "text/x-java"
79
     *  or empty string which means that the action will be registered as global (for all mime-types).
80
     */
81
    String mimeType() default "";
82
83
    /**
84
     * Resource specification for small icon.
85
     *
86
     * @return icon resource specification or default (empty string which means no icon).
87
     */
88
    String iconResource() default "";
89
90
    /**
91
     * Short description bundle key of the action being registered.
92
     * Several constructions are allowed:<ul>
93
     *   <li>
94
     *      Leave the annotation's default value which means that the short description
95
     *      will be searched in a bundle located in the same package as the action's class
96
     *      by a key equal to action's name (value of Action.NAME property).
97
     *   </li>
98
     *   <li>
99
     *      Value starting with a hash "#key" searches in a bundle in the same package
100
     *      as the action's class.
101
     *   </li>
102
     *   <li>
103
     *      "bundle#key" allows specification of both bundle and a corresponding key.
104
     *   </li>
105
     *   <li>
106
     *      Empty string "" means that nothing will be generated and
107
     *      the value of Action.SHORT_DESCRIPTION property will be null.
108
     *   </li>
109
     * </ul>
110
     */
111
    String shortDescription() default "BY_ACTION_NAME";
112
113
    /**
114
     * Menu text bundle key of the registered action.
115
     * If an empty string is used (the default) it will be set to the same value
116
     * like action's short description.
117
     * <br/>
118
     * Value starting with a hash "#key" searches in a bundle in the same package
119
     * as the action's class.
120
     * <br/>
121
     * "bundle#key" allows specification of both bundle and a corresponding key.
122
     */
123
    String menuText() default "";
124
125
    /**
126
     * Popup menu text bundle key of the registered action.
127
     * If an empty string is used (the default) it will be set to the same value
128
     * like menu text.
129
     * <br/>
130
     * Value starting with a hash "#key" searches in a bundle in the same package
131
     * as the action's class.
132
     * <br/>
133
     * "bundle#key" allows specification of both bundle and a corresponding key.
134
     */
135
    String popupText() default "";
136
137
}
(-)a/editor.lib2/src/org/netbeans/modules/editor/lib2/EditorActionRegistrationProcessor.java (+325 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.ProcessingEnvironment;
49
import javax.annotation.processing.Processor;
50
import javax.annotation.processing.RoundEnvironment;
51
import javax.annotation.processing.SupportedAnnotationTypes;
52
import javax.annotation.processing.SupportedSourceVersion;
53
import javax.lang.model.SourceVersion;
54
import javax.lang.model.element.Element;
55
import javax.lang.model.element.ExecutableElement;
56
import javax.lang.model.element.Modifier;
57
import javax.lang.model.element.TypeElement;
58
import javax.lang.model.type.TypeMirror;
59
import javax.lang.model.util.ElementFilter;
60
import javax.swing.Action;
61
import javax.tools.StandardLocation;
62
import org.netbeans.api.editor.EditorActionRegistration;
63
import org.netbeans.api.editor.EditorActionRegistrations;
64
import org.openide.filesystems.annotations.LayerBuilder;
65
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
66
import org.openide.filesystems.annotations.LayerGenerationException;
67
import org.openide.util.lookup.ServiceProvider;
68
69
/**
70
 * Annotation processor for
71
 */
72
@ServiceProvider(service=Processor.class)
73
@SupportedSourceVersion(SourceVersion.RELEASE_6)
74
@SupportedAnnotationTypes({ "org.netbeans.api.editor.EditorActionRegistration", // NOI18N
75
                            "org.netbeans.api.editor.EditorActionRegistrations" // NOI18N
76
                          })
77
public final class EditorActionRegistrationProcessor extends LayerGeneratingProcessor {
78
79
    @Override
80
    protected boolean handleProcess(Set<? extends TypeElement> annotations,
81
            RoundEnvironment roundEnv) throws LayerGenerationException
82
    {
83
        if (roundEnv.processingOver()) {
84
            return false;
85
        }
86
        for (Element e : roundEnv.getElementsAnnotatedWith(EditorActionRegistration.class)) {
87
            EditorActionRegistration annotation = e.getAnnotation(EditorActionRegistration.class);
88
            register(e, annotation);
89
        }
90
        for (Element e : roundEnv.getElementsAnnotatedWith(EditorActionRegistrations.class)) {
91
            EditorActionRegistrations annotationArray = e.getAnnotation(EditorActionRegistrations.class);
92
            for (EditorActionRegistration annotation : annotationArray.value()) {
93
                register(e, annotation);
94
            }
95
        }
96
        return true;
97
    }
98
99
    private void register(Element e, EditorActionRegistration annotation) throws LayerGenerationException {
100
        String className;
101
        String methodName;
102
        TypeMirror swingActionType = processingEnv.getTypeUtils().getDeclaredType(
103
                processingEnv.getElementUtils().getTypeElement("javax.swing.Action"));
104
105
        switch (e.getKind()) {
106
            case CLASS:
107
                className = processingEnv.getElementUtils().getBinaryName((TypeElement)e).toString();
108
                if (e.getModifiers().contains(Modifier.ABSTRACT)) {
109
                    throw new LayerGenerationException(className + " must not be abstract", e);
110
                }
111
                if (!e.getModifiers().contains(Modifier.PUBLIC)) {
112
                    throw new LayerGenerationException(className + " is not public", e);
113
                }
114
                boolean hasDefaultCtor = false;
115
                for (ExecutableElement constructor : ElementFilter.constructorsIn(e.getEnclosedElements())) {
116
                    if (constructor.getParameters().isEmpty()) {
117
                        if (!constructor.getModifiers().contains(Modifier.PUBLIC)) {
118
                            throw new LayerGenerationException("Default constructor of " + className + " is not public", e);
119
                        }
120
                        hasDefaultCtor = true;
121
                        break;
122
                    }
123
                }
124
                if (!hasDefaultCtor) {
125
                    throw new LayerGenerationException(className + " must have a no-argument constructor", e);
126
                }
127
128
                if (!processingEnv.getTypeUtils().isAssignable(e.asType(), swingActionType)) {
129
                    throw new LayerGenerationException(className + " is not assignable to javax.swing.Action", e);
130
                }
131
132
                methodName = null;
133
                break;
134
135
            case METHOD:
136
                className = processingEnv.getElementUtils().getBinaryName((TypeElement) e.getEnclosingElement()).toString();
137
                methodName = e.getSimpleName().toString();
138
                if (!e.getModifiers().contains(Modifier.STATIC)) {
139
                    throw new LayerGenerationException(className + "." + methodName + " must be static", e);
140
                }
141
                // It appears that actually even non-public method registration works - so commented following
142
//                    if (!e.getModifiers().contains(Modifier.PUBLIC)) {
143
//                        throw new LayerGenerationException(className + "." + methodName + " must be public", e);
144
//                    }
145
                if (!((ExecutableElement) e).getParameters().isEmpty()) {
146
                    throw new LayerGenerationException(className + "." + methodName + " must not take arguments", e);
147
                }
148
                if (swingActionType != null && !processingEnv.getTypeUtils().isAssignable(((ExecutableElement)e).getReturnType(), swingActionType)) {
149
                    throw new LayerGenerationException(className + "." + methodName + " is not assignable to javax.swing.Action", e);
150
                }
151
                break;
152
153
            default:
154
                throw new IllegalArgumentException("Annotated element is not loadable as an instance: " + e);
155
156
        }
157
158
        String actionName = annotation.name();
159
        StringBuilder filePath = new StringBuilder(50);
160
        filePath.append("Editors");
161
        if (annotation.mimeType().length() > 0) {
162
            filePath.append("/").append(annotation.mimeType());
163
        }
164
        filePath.append("/Actions/").append(actionName).append(".instance");
165
        LayerBuilder.File file = layer(e).file(filePath.toString());
166
167
        file.stringvalue("displayName", actionName);
168
169
        // Resolve icon resource
170
        String iconResource = annotation.iconResource();
171
        if (iconResource.length() > 0) {
172
            file.stringvalue("iconBase", iconResource);
173
        }
174
175
        // Resolve short description bundle key
176
        String shortDescription = annotation.shortDescription();
177
        if (shortDescription.length() > 0) {
178
            BundleHandler bundleHandler = new BundleHandler(actionName, className);
179
            String key;
180
            if ("BY_ACTION_NAME".equals(shortDescription)) {
181
                // Leave bundlePkg and bundleName null
182
                key = actionName;
183
            } else {
184
                key = bundleHandler.parseKey(shortDescription);
185
            }
186
            bundleHandler.initBundle(processingEnv);
187
            bundleHandler.verifyBundleKey(key);
188
            shortDescription = bundleHandler.completeKey(key);
189
            file.bundlevalue(Action.SHORT_DESCRIPTION, shortDescription);
190
        }
191
192
        // Resolve menu text bundle key
193
        String menuText = annotation.menuText();
194
        if (menuText.length() > 0) {
195
            BundleHandler bundleHandler = new BundleHandler(actionName, className);
196
            String key = bundleHandler.parseKey(menuText);
197
            bundleHandler.initBundle(processingEnv);
198
            bundleHandler.verifyBundleKey(key);
199
            menuText = bundleHandler.completeKey(key);
200
            file.bundlevalue("menuText", menuText);
201
        } else if (shortDescription.length() > 0) { // Use shortDesc (already verified)
202
            menuText = shortDescription;
203
            file.bundlevalue("menuText", menuText);
204
        }
205
206
        // Resolve popup menu text bundle key
207
        String popupText = annotation.popupText();
208
        if (popupText.length() > 0) {
209
            BundleHandler bundleHandler = new BundleHandler(actionName, className);
210
            String key = bundleHandler.parseKey(popupText);
211
            bundleHandler.initBundle(processingEnv);
212
            bundleHandler.verifyBundleKey(key);
213
            popupText = bundleHandler.completeKey(key);
214
            file.bundlevalue("popupText", popupText);
215
        } else if (menuText.length() > 0) { // Use shortDesc (already verified)
216
            popupText = menuText;
217
            file.bundlevalue("popupText", popupText);
218
        }
219
220
        file.methodvalue("instanceCreate", "org.openide.awt.Actions", "alwaysEnabled");
221
        if (methodName != null) {
222
            file.methodvalue("delegate", className, methodName);
223
        } else {
224
            file.newvalue("delegate", className);
225
        }
226
        file.write();
227
    }
228
229
    private static final class BundleHandler {
230
231
        private static BundleHandler lastHandler;
232
233
        String bundlePkg;
234
235
        String bundleName;
236
237
        ResourceBundle bundle;
238
239
        final String actionName;
240
241
        final String actionClassName;
242
243
        BundleHandler(String actionName, String actionClassName) {
244
            this.actionName = actionName;
245
            this.actionClassName = actionClassName;
246
        }
247
248
        String parseKey(String keyDescription) throws LayerGenerationException {
249
            String key;
250
            if (keyDescription.startsWith("#")) {
251
                // Leave bundlePkg and bundleName null
252
                key = keyDescription.substring(1);
253
            } else { // Full spec "bundle#key"
254
                int hashIndex = keyDescription.indexOf('#');
255
                if (hashIndex == -1) {
256
                    throw new LayerGenerationException("Annotation \"" + actionName + // NOI18N
257
                            ", class=" + actionClassName + // NOI18N
258
                            ": bundle key description does not contain '#': " + keyDescription);
259
                }
260
                // Bundle-pkg.bundle-name format
261
                bundlePkg = keyDescription.substring(0, hashIndex);
262
                int lastDotIndex = bundlePkg.lastIndexOf('.');
263
                if (lastDotIndex == -1) {
264
                    lastDotIndex = 0;
265
                }
266
                bundleName = bundlePkg.substring(lastDotIndex + 1);
267
                bundlePkg = bundlePkg.substring(0, lastDotIndex);
268
                key = keyDescription.substring(hashIndex + 1);
269
            }
270
            return key;
271
        }
272
273
        void initBundle(ProcessingEnvironment processingEnv) throws LayerGenerationException {
274
            if (bundlePkg == null) { // Use common bundle in action's package
275
                assert (bundleName == null);
276
                int lastDotIndex = actionClassName.lastIndexOf('.');
277
                if (lastDotIndex == -1) // no dots
278
                    lastDotIndex = 0;
279
                bundlePkg = actionClassName.substring(0, lastDotIndex);
280
                bundleName = "Bundle";
281
            }
282
            if (lastHandler != null &&
283
                bundlePkg.equals(lastHandler.bundlePkg) &&
284
                bundleName.equals(lastHandler.bundleName))
285
            {
286
                bundle = lastHandler.bundle;
287
                bundlePkg = lastHandler.bundlePkg;
288
                bundleName = lastHandler.bundleName;
289
290
            }
291
            assert (bundlePkg != null && bundleName != null);
292
            try {
293
                String bundleNameSuffix = bundleName + ".properties";
294
                javax.tools.FileObject bundleFileObject = processingEnv.getFiler().getResource(
295
                        StandardLocation.SOURCE_PATH, bundlePkg, bundleNameSuffix);
296
                bundle = new PropertyResourceBundle(bundleFileObject.openInputStream());
297
            } catch (IOException ex) {
298
//            ex.printStackTrace(); // Print the queried file
299
                throw new LayerGenerationException("Action annotation \"" + actionName + // NOI18N
300
                        "\", class=" + actionClassName + // NOI18N
301
                        ": Bundle \"" + bundlePkg + '.' + bundleName + // NOI18N
302
                        "\" not found."); // NOI18N
303
            }
304
305
            lastHandler = this;
306
        }
307
308
        void verifyBundleKey(String key) throws LayerGenerationException {
309
            try {
310
                bundle.getString(key); // would throw MissingResourceException
311
            } catch (MissingResourceException ex) {
312
                throw new LayerGenerationException("Action annotation \"" + actionName + // NOI18N
313
                        "\", class=" + actionClassName + // NOI18N
314
                        ": Bundle \"" + bundlePkg + '.' + bundleName + // NOI18N
315
                        "\" does not contain key \"" + key + '"'); // NOI18N
316
            }
317
        }
318
319
        String completeKey(String key) {
320
            return bundlePkg + '.' + bundleName + '#' + key;
321
        }
322
323
    }
324
325
}
(-)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 (+185 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 java.io.ByteArrayOutputStream;
46
import javax.swing.AbstractAction;
47
import javax.swing.Action;
48
import org.netbeans.junit.NbTestCase;
49
import org.netbeans.api.editor.EditorActionRegistration;
50
import org.openide.filesystems.FileObject;
51
import org.openide.filesystems.FileUtil;
52
import org.openide.util.test.AnnotationProcessorTestUtils;
53
54
/**
55
 * Test registration of editor actions through an annotation.
56
 *
57
 * @author Miloslav Metelka
58
 */
59
public class EditorActionRegistrationTest extends NbTestCase {
60
    
61
    private static final String NAME1 = "editor-test-action1";
62
    private static final String NAME2 = "editor-test-action2";
63
    private static final String NAME3 = "editor-test-action3";
64
    private static final String NAME4 = "editor-test-action4";
65
66
    private static final String bundleHash = "org.netbeans.modules.editor.lib2.testactionsregistration.Bundle#";
67
68
    public EditorActionRegistrationTest(String name) {
69
        super(name);
70
    }
71
72
    public void testRegistration() throws Exception {
73
        FileObject fo = FileUtil.getConfigFile("/Editors/Actions/" + NAME1 + ".instance");
74
        assertNotNull(fo);
75
        assertEquals(NAME1, fo.getAttribute("displayName"));
76
        assertEquals("Short Desc1", fo.getAttribute(Action.SHORT_DESCRIPTION));
77
        assertEquals("Short Desc1", fo.getAttribute("menuText"));
78
        assertEquals("Short Desc1", fo.getAttribute("popupText"));
79
80
        fo = FileUtil.getConfigFile("/Editors/Actions/" + NAME2 + ".instance");
81
        assertNotNull(fo);
82
        assertEquals(NAME2, fo.getAttribute("displayName"));
83
        assertEquals("Short Desc2", fo.getAttribute(Action.SHORT_DESCRIPTION));
84
        assertEquals("Menu Text2", fo.getAttribute("menuText"));
85
        assertEquals("Menu Text2", fo.getAttribute("popupText"));
86
87
        fo = FileUtil.getConfigFile("/Editors/Actions/" + NAME3 + ".instance");
88
        assertNotNull(fo);
89
        assertEquals(NAME3, fo.getAttribute("displayName"));
90
        assertEquals("Short Desc3", fo.getAttribute(Action.SHORT_DESCRIPTION));
91
        assertEquals("Menu Text3", fo.getAttribute("menuText"));
92
        assertEquals("Popup Text3", fo.getAttribute("popupText"));
93
    }
94
95
    public void testNonPublicClass() throws Exception {
96
        String nonPublicClassSource =
97
                "import org.netbeans.api.editor.EditorActionRegistration;\n" +
98
                "import javax.swing.AbstractAction;\n" +
99
                "import javax.swing.event.ActionEvent;\n" +
100
                "@EditorActionRegistration(name = \"NonPublicClass\", shortDescription = \"\")\n" +
101
                "static final class EditorTestActionNonPublic extends AbstractAction {\n" +
102
                "        public EditorTestActionNonPublic() {}\n" +
103
                "        @Override\n" +
104
                "        public void actionPerformed(ActionEvent evt) {}\n"+
105
                "}\n";
106
        checkCompilationFails(nonPublicClassSource);
107
    }
108
109
    public void testNonPublicConstructor() throws Exception {
110
        String nonPublicConstructorSource =
111
                "import org.netbeans.api.editor.EditorActionRegistration;\n" +
112
                "import javax.swing.AbstractAction;\n" +
113
                "import javax.swing.event.ActionEvent;\n" +
114
                "@EditorActionRegistration(name = \"NonPublicClass\", shortDescription = \"\")\n" +
115
                "public static final class EditorTestActionNonPublic extends AbstractAction {\n" +
116
                "        EditorTestActionNonPublic() {}\n" +
117
                "        @Override\n" +
118
                "        public void actionPerformed(ActionEvent evt) {}\n"+
119
                "}\n";
120
        checkCompilationFails(nonPublicConstructorSource);
121
122
    }
123
124
    public void checkCompilationFails(String classSource) throws Exception {
125
        AnnotationProcessorTestUtils.makeSource(getWorkDir(), "x.EditorTestActionNonPublic", classSource);
126
        ByteArrayOutputStream out = new ByteArrayOutputStream();
127
        boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, out);
128
        assertFalse("Compilation failed", res);
129
        if (!out.toString().contains("is not public")) {
130
            fail(out.toString());
131
        }
132
    }
133
134
    @EditorActionRegistration(name = NAME1)
135
    public static final class EditorTestAction extends AbstractAction {
136
137
        public EditorTestAction() {
138
        }
139
140
        @Override
141
        public void actionPerformed(ActionEvent evt) {
142
        }
143
144
    }
145
146
    @EditorActionRegistration(
147
            name = NAME2,
148
            shortDescription="#editor-test-action-explicit",
149
            menuText = bundleHash + NAME2 + "_menu_text"
150
            // popupText same like menuText
151
    )
152
    public static EditorTestAction createAction2() {
153
        return new EditorTestAction();
154
    }
155
156
    @EditorActionRegistration(
157
            name = NAME3,
158
            menuText = "#" + NAME3 + "_menu_text",
159
            popupText = "#" + NAME3 + "_popup_text"
160
    )
161
    public static EditorTestAction createAction3() {
162
        return new EditorTestAction();
163
    }
164
165
    @EditorActionRegistration(
166
            name = NAME4,
167
            shortDescription = ""
168
    )
169
    public static EditorTestAction createAction4() {
170
        return new EditorTestAction();
171
    }
172
173
    @EditorActionRegistration(name = "NonPublicClass", shortDescription = "")
174
    public static final class EditorTestActionNonPublic extends AbstractAction {
175
176
        public EditorTestActionNonPublic() {
177
        }
178
179
        @Override
180
        public void actionPerformed(ActionEvent evt) {
181
        }
182
183
    }
184
185
}
(-)a/editor/nbproject/project.xml (-1 / +1 lines)
Lines 129-135 Link Here
129
                    <build-prerequisite/>
129
                    <build-prerequisite/>
130
                    <compile-dependency/>
130
                    <compile-dependency/>
131
                    <run-dependency>
131
                    <run-dependency>
132
                        <specification-version>6.5</specification-version>
132
                        <specification-version>7.7</specification-version>
133
                    </run-dependency>
133
                    </run-dependency>
134
                </dependency>
134
                </dependency>
135
                <dependency>
135
                <dependency>
(-)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 / +13 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
                                       nbUndoActionDef,
189
                                       nbUndoActionDef,
190
                                       nbRedoActionDef,
190
                                       nbRedoActionDef,
191
                                       new NbBuildToolTipAction(),
192
                                       new NbToggleLineNumbersAction(),
193
                                       new ToggleToolbarAction(),
194
                                       new NbGenerateGoToPopupAction(),
195
                                       new GenerateFoldPopupAction(),
191
                                       new GenerateFoldPopupAction(),
196
                                       new NbGenerateCodeAction(),
197
                                       new NavigationHistoryLastEditAction(),
198
                                       new NavigationHistoryBackAction(),
192
                                       new NavigationHistoryBackAction(),
199
                                       new NavigationHistoryForwardAction(),
193
                                       new NavigationHistoryForwardAction(),
200
                                       new SearchBar.IncrementalSearchForwardAction(),
194
                                       new SearchBar.IncrementalSearchForwardAction(),
Lines 242-248 Link Here
242
        addSystemActionMapping(deleteNextCharAction, org.openide.actions.DeleteAction.class);
236
        addSystemActionMapping(deleteNextCharAction, org.openide.actions.DeleteAction.class);
243
        addSystemActionMapping(showPopupMenuAction, org.openide.actions.PopupAction.class);
237
        addSystemActionMapping(showPopupMenuAction, org.openide.actions.PopupAction.class);
244
238
245
        addSystemActionMapping(SearchBar.IncrementalSearchForwardAction.ACTION_NAME, org.openide.actions.FindAction.class);
239
        addSystemActionMapping(SearchBar.INCREMENTAL_SEARCH_FORWARD, org.openide.actions.FindAction.class);
246
        addSystemActionMapping(replaceAction, org.openide.actions.ReplaceAction.class);
240
        addSystemActionMapping(replaceAction, org.openide.actions.ReplaceAction.class);
247
        addSystemActionMapping(gotoAction, org.openide.actions.GotoAction.class);
241
        addSystemActionMapping(gotoAction, org.openide.actions.GotoAction.class);
248
242
Lines 280-290 Link Here
280
        return bundle;
274
        return bundle;
281
    }
275
    }
282
    
276
    
283
    
277
    @EditorActionRegistration(name = toggleToolbarAction)
284
    public static class ToggleToolbarAction extends BaseAction {
278
    public static class ToggleToolbarAction extends BaseAction {
285
279
286
        public ToggleToolbarAction() {
280
        public ToggleToolbarAction() {
287
            super(ExtKit.toggleToolbarAction);
281
            super(toggleToolbarAction); // Due to creation from MainMenuAction
288
            putValue ("helpID", ToggleToolbarAction.class.getName ()); // NOI18N
282
            putValue ("helpID", ToggleToolbarAction.class.getName ()); // NOI18N
289
        }
283
        }
290
284
Lines 366-371 Link Here
366
        }
360
        }
367
    }
361
    }
368
362
363
    @EditorActionRegistration(name = buildPopupMenuAction)
369
    public class NbBuildPopupMenuAction extends BuildPopupMenuAction {
364
    public class NbBuildPopupMenuAction extends BuildPopupMenuAction {
370
365
371
        static final long serialVersionUID =-8623762627678464181L;
366
        static final long serialVersionUID =-8623762627678464181L;
Lines 567-572 Link Here
567
    }
562
    }
568
563
569
    /** Switch visibility of line numbers in editor */
564
    /** Switch visibility of line numbers in editor */
565
    @EditorActionRegistration(name = BaseKit.toggleLineNumbersAction)
570
    public static class NbToggleLineNumbersAction extends ActionFactory.ToggleLineNumbersAction {
566
    public static class NbToggleLineNumbersAction extends ActionFactory.ToggleLineNumbersAction {
571
567
572
        public NbToggleLineNumbersAction() {
568
        public NbToggleLineNumbersAction() {
Lines 584-593 Link Here
584
        }
580
        }
585
    }
581
    }
586
582
583
    @EditorActionRegistration(name = generateGoToPopupAction)
587
    public static class NbGenerateGoToPopupAction extends BaseAction {
584
    public static class NbGenerateGoToPopupAction extends BaseAction {
588
585
589
        public NbGenerateGoToPopupAction() {
586
        public NbGenerateGoToPopupAction() {
590
            super(generateGoToPopupAction);
587
            super(generateGoToPopupAction); // Because of action in Gsf
591
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
588
            putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
592
        }
589
        }
593
590
Lines 601-606 Link Here
601
    }
598
    }
602
599
603
600
601
    @EditorActionRegistration(name = buildToolTipAction)
604
    public static class NbBuildToolTipAction extends BuildToolTipAction {
602
    public static class NbBuildToolTipAction extends BuildToolTipAction {
605
603
606
        public @Override void actionPerformed(ActionEvent evt, JTextComponent target) {
604
        public @Override void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 610-616 Link Here
610
        }
608
        }
611
609
612
    }
610
    }
613
    
611
612
// No registration - NO_KEYBINDING property in constructor
613
//    @EditorActionRegistration(name = generateFoldPopupAction)
614
    public static class GenerateFoldPopupAction extends BaseAction {
614
    public static class GenerateFoldPopupAction extends BaseAction {
615
615
616
        private boolean addSeparatorBeforeNextAction;
616
        private boolean addSeparatorBeforeNextAction;
Lines 749-755 Link Here
749
        }
749
        }
750
        
750
        
751
        public LayerSubFolderMenu(JTextComponent target, FileObject folder) {
751
        public LayerSubFolderMenu(JTextComponent target, FileObject folder) {
752
            this(target, getLocalizedName(folder), ActionsList.convert(sort(folder.getChildren())));
752
            this(target, getLocalizedName(folder), ActionsList.convert(sort(folder.getChildren()), false));
753
        }
753
        }
754
        
754
        
755
        private static List<FileObject> sort( FileObject[] children ) {
755
        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/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 (+120 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 - issue #150875
285
org.netbeans.editor.DefaultKeyTypedAction
286
org.netbeans.editor.InsertContentAction
287
org.netbeans.editor.SplitLineAction
288
org.netbeans.editor.ReadOnlyAction
289
org.netbeans.editor.WritableAction
290
org.netbeans.editor.BeepAction
291
org.netbeans.editor.UpAction
292
org.netbeans.editor.UpAction
293
org.netbeans.editor.PageUpAction
294
org.netbeans.editor.PageUpAction
295
org.netbeans.editor.DownAction
296
org.netbeans.editor.DownAction
297
org.netbeans.editor.PageDownAction
298
org.netbeans.editor.PageDownAction
299
org.netbeans.editor.ForwardAction
300
org.netbeans.editor.ForwardAction
301
org.netbeans.editor.BackwardAction
302
org.netbeans.editor.BackwardAction
303
org.netbeans.editor.BeginLineAction
304
org.netbeans.editor.BeginLineAction
305
org.netbeans.editor.BeginLineAction
306
org.netbeans.editor.BeginLineAction
307
org.netbeans.editor.EndLineAction
308
org.netbeans.editor.EndLineAction
309
org.netbeans.editor.BeginAction
310
org.netbeans.editor.BeginAction
311
org.netbeans.editor.EndAction
312
org.netbeans.editor.EndAction
313
org.netbeans.editor.NextWordAction
314
org.netbeans.editor.NextWordAction
315
org.netbeans.editor.PreviousWordAction
316
org.netbeans.editor.PreviousWordAction
317
org.netbeans.editor.BeginWordAction
318
org.netbeans.editor.BeginWordAction
319
org.netbeans.editor.EndWordAction
320
org.netbeans.editor.EndWordAction
321
org.netbeans.editor.SelectWordAction
322
org.netbeans.editor.SelectLineAction
323
org.netbeans.editor.SelectAllAction
324
org.netbeans.editor.RemoveTrailingSpacesAction
325
326
org.netbeans.editor.ActionFactory.RemoveWordPreviousAction
327
org.netbeans.editor.ActionFactory.RemoveWordNextAction
328
org.netbeans.editor.ActionFactory.RemoveLineBeginAction
329
org.netbeans.editor.ActionFactory.RemoveLineAction
330
org.netbeans.editor.ActionFactory.MoveSelectionElseLineUpAction
331
org.netbeans.editor.ActionFactory.MoveSelectionElseLineDownAction
332
org.netbeans.editor.ActionFactory.CopySelectionElseLineUpAction
333
org.netbeans.editor.ActionFactory.CopySelectionElseLineDownAction
334
org.netbeans.editor.ActionFactory.ToggleTypingModeAction
335
org.netbeans.editor.ActionFactory.ChangeCaseAction
336
org.netbeans.editor.ActionFactory.ChangeCaseAction
337
org.netbeans.editor.ActionFactory.ChangeCaseAction
338
org.netbeans.editor.ActionFactory.FindNextAction
339
org.netbeans.editor.ActionFactory.FindPreviousAction
340
org.netbeans.editor.ActionFactory.FindSelectionAction
341
org.netbeans.editor.ActionFactory.ToggleHighlightSearchAction
342
org.netbeans.editor.ActionFactory.WordMatchAction
343
org.netbeans.editor.ActionFactory.WordMatchAction
344
org.netbeans.editor.ActionFactory.ReindentLineAction
345
org.netbeans.editor.ActionFactory.ShiftLineAction
346
org.netbeans.editor.ActionFactory.ShiftLineAction
347
org.netbeans.editor.ActionFactory.AdjustWindowAction
348
org.netbeans.editor.ActionFactory.AdjustWindowAction
349
org.netbeans.editor.ActionFactory.AdjustWindowAction
350
org.netbeans.editor.ActionFactory.AdjustCaretAction
351
org.netbeans.editor.ActionFactory.AdjustCaretAction
352
org.netbeans.editor.ActionFactory.AdjustCaretAction
353
org.netbeans.editor.ActionFactory.FormatAction
354
org.netbeans.editor.ActionFactory.FirstNonWhiteAction
355
org.netbeans.editor.ActionFactory.FirstNonWhiteAction
356
org.netbeans.editor.ActionFactory.LastNonWhiteAction
357
org.netbeans.editor.ActionFactory.LastNonWhiteAction
358
org.netbeans.editor.ActionFactory.SelectIdentifierAction
359
org.netbeans.editor.ActionFactory.SelectNextParameterAction
360
org.netbeans.editor.ActionFactory.ScrollUpAction
361
org.netbeans.editor.ActionFactory.ScrollDownAction
362
org.netbeans.editor.ActionFactory.InsertDateTimeAction
363
org.netbeans.editor.ActionFactory.GenerateGutterPopupAction
364
org.netbeans.editor.ActionFactory.ToggleLineNumbersAction
365
org.netbeans.editor.ActionFactory.AnnotationsCyclingAction
366
org.netbeans.editor.ActionFactory.CollapseFold
367
org.netbeans.editor.ActionFactory.ExpandFold
368
org.netbeans.editor.ActionFactory.CollapseAllFolds
369
org.netbeans.editor.ActionFactory.ExpandAllFolds
370
org.netbeans.editor.ActionFactory.DumpViewHierarchyAction
371
org.netbeans.editor.ActionFactory.StartNewLine
372
org.netbeans.editor.ActionFactory.CutToLineBeginOrEndAction
373
org.netbeans.editor.ActionFactory.CutToLineBeginOrEndAction
374
375
org.netbeans.editor.ext.ExtKit.BuildPopupMenuAction
376
org.netbeans.editor.ext.ExtKit.ShowPopupMenuAction
377
org.netbeans.editor.ext.ExtKit.BuildToolTipAction
378
org.netbeans.editor.ext.ExtKit.ToggleCaseIdentifierBeginAction
379
org.netbeans.editor.ext.ExtKit.ExtDefaultKeyTypedAction
380
org.netbeans.editor.ext.ExtKit.CompletionShowAction
381
org.netbeans.editor.ext.ExtKit.AllCompletionShowAction
382
org.netbeans.editor.ext.ExtKit.DocumentationShowAction
383
org.netbeans.editor.ext.ExtKit.CompletionTooltipShowAction
384
385
org.netbeans.modules.editor.NbEditorKit.NbBuildPopupMenuAction
386
org.netbeans.modules.editor.NbEditorKit.NbBuildToolTipAction
387
org.netbeans.modules.editor.NbEditorKit.NbToggleLineNumbersAction
388
org.netbeans.modules.editor.NbEditorKit.ToggleToolbarAction
389
org.netbeans.modules.editor.NbEditorKit.NbGenerateGoToPopupAction
390
org.netbeans.modules.editor.NbEditorKit.NbGenerateCodeAction
391
org.netbeans.modules.editor.NbEditorKit.NavigationHistoryLastEditAction
392
393
org.netbeans.modules.editor.java.JavaKit.AbbrevDebugLineAction
394
org.netbeans.modules.editor.java.JavaKit.JavaGenerateGoToPopupAction
395
org.netbeans.modules.editor.java.JavaKit.ExpandAllJavadocFolds
396
org.netbeans.modules.editor.java.JavaKit.CollapseAllJavadocFolds
397
org.netbeans.modules.editor.java.JavaKit.ExpandAllCodeBlockFolds
398
org.netbeans.modules.editor.java.JavaKit.CollapseAllCodeBlockFolds
399
org.netbeans.modules.editor.java.JavaKit.JavaGoToSourceAction
400
org.netbeans.modules.editor.java.JavaKit.JavaGotoHelpAction
401
org.netbeans.modules.editor.java.JavaKit.JavaFixImports
402
403
284
# Mobility
404
# Mobility
285
org.netbeans.modules.mobility.project.security.KeyStoreRepository
405
org.netbeans.modules.mobility.project.security.KeyStoreRepository
286
org.netbeans.modules.mobility.project.security.KeyStoreRepositoryWarmUp
406
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 / +93 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(),
248
            new ToggleCommentAction("//"), // NOI18N
250
            new ToggleCommentAction("//"), // NOI18N
249
            new JavaGenerateGoToPopupAction(),
250
            new JavaInsertBreakAction(),
251
            new JavaInsertBreakAction(),
251
            new JavaDeleteCharAction(deletePrevCharAction, false),
252
            new JavaDeleteCharAction(deletePrevCharAction, false),
252
            new JavaDeleteCharAction(deleteNextCharAction, true),
253
            new JavaDeleteCharAction(deleteNextCharAction, true),
253
            new ExpandAllJavadocFolds(),
254
            new JavaGenerateFoldPopupAction(), // NO_KEYBINDING in super
254
            new CollapseAllJavadocFolds(),
255
            new ExpandAllCodeBlockFolds(),
256
            new CollapseAllCodeBlockFolds(),
257
            new JavaGenerateFoldPopupAction(),
258
            new JavaGoToDeclarationAction(),
255
            new JavaGoToDeclarationAction(),
259
            new JavaGoToSourceAction(),
260
            new JavaGotoHelpAction(),
261
            new InstantRenameAction(),
256
            new InstantRenameAction(),
262
            new JavaFixImports(),
263
            new InsertSemicolonAction(true),
257
            new InsertSemicolonAction(true),
264
            new InsertSemicolonAction(false),
258
            new InsertSemicolonAction(false),
265
            new SelectCodeElementAction(selectNextElementAction, true),
259
            new SelectCodeElementAction(selectNextElementAction, true),
Lines 278-283 Link Here
278
            new GoToMarkOccurrencesAction(false),
272
            new GoToMarkOccurrencesAction(false),
279
            new GoToMarkOccurrencesAction(true),
273
            new GoToMarkOccurrencesAction(true),
280
        };
274
        };
275
276
        return TextAction.augmentList(superActions, actions);
281
    }
277
    }
282
278
283
    private static Action findAction(Action [] actions, String name) {
279
    private static Action findAction(Action [] actions, String name) {
Lines 354-360 Link Here
354
        }
350
        }
355
    }
351
    }
356
352
357
353
    @EditorActionRegistration(name = generateGoToPopupAction, mimeType = JAVA_MIME_TYPE)
358
    public static class JavaGenerateGoToPopupAction extends NbGenerateGoToPopupAction {
354
    public static class JavaGenerateGoToPopupAction extends NbGenerateGoToPopupAction {
359
355
360
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
356
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 449-459 Link Here
449
445
450
    }
446
    }
451
447
452
448
    @EditorActionRegistration(
449
            name = abbrevDebugLineAction,
450
            mimeType = JAVA_MIME_TYPE,
451
            shortDescription = ""
452
    )
453
    public static class AbbrevDebugLineAction extends BaseAction {
453
    public static class AbbrevDebugLineAction extends BaseAction {
454
454
455
        public AbbrevDebugLineAction() {
455
        public AbbrevDebugLineAction() {
456
            super(abbrevDebugLineAction);
457
        }
456
        }
458
457
459
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
458
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 670-680 Link Here
670
        }
669
        }
671
    }
670
    }
672
671
673
    public static class ExpandAllJavadocFolds extends BaseAction{
672
    @EditorActionRegistration(
673
            name = expandAllJavadocFolds,
674
            mimeType = JAVA_MIME_TYPE,
675
            popupText = "#popup-expand-all-javadoc-folds"
676
    )
677
    public static class ExpandAllJavadocFolds extends BaseAction {
678
674
        public ExpandAllJavadocFolds(){
679
        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
        }
680
        }
679
681
680
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
682
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 684-694 Link Here
684
        }
686
        }
685
    }
687
    }
686
688
689
    @EditorActionRegistration(
690
            name = collapseAllJavadocFolds,
691
            mimeType = JAVA_MIME_TYPE,
692
            shortDescription = "#popup-collapse-all-javadoc-folds"
693
    )
687
    public static class CollapseAllJavadocFolds extends BaseAction{
694
    public static class CollapseAllJavadocFolds extends BaseAction{
695
688
        public CollapseAllJavadocFolds(){
696
        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
        }
697
        }
693
698
694
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
699
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 698-708 Link Here
698
        }
703
        }
699
    }
704
    }
700
705
706
    @EditorActionRegistration(
707
            name = expandAllCodeBlockFolds,
708
            mimeType = JAVA_MIME_TYPE,
709
            popupText = "#popup-expand-all-code-block-folds"
710
711
    )
701
    public static class ExpandAllCodeBlockFolds extends BaseAction{
712
    public static class ExpandAllCodeBlockFolds extends BaseAction{
713
702
        public ExpandAllCodeBlockFolds(){
714
        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
        }
715
        }
707
716
708
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
717
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 715-725 Link Here
715
        }
724
        }
716
    }
725
    }
717
726
718
    public static class CollapseAllCodeBlockFolds extends BaseAction{
727
    @EditorActionRegistration(
728
            name = collapseAllCodeBlockFolds,
729
            mimeType = JAVA_MIME_TYPE,
730
            shortDescription = "#popup-collapse-all-code-block-folds"
731
    )
732
    public static class CollapseAllCodeBlockFolds extends BaseAction {
733
719
        public CollapseAllCodeBlockFolds(){
734
        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
        }
735
        }
724
736
725
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
737
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 732-738 Link Here
732
        }
744
        }
733
    }
745
    }
734
746
735
    public static class JavaGenerateFoldPopupAction extends GenerateFoldPopupAction{
747
// extends from NbEditorKit
748
//    @EditorActionRegistration(name = generateFoldPopupAction, mimeType = JAVA_MIME_TYPE)
749
    public static class JavaGenerateFoldPopupAction extends GenerateFoldPopupAction {
736
750
737
        protected void addAdditionalItems(JTextComponent target, JMenu menu){
751
        protected void addAdditionalItems(JTextComponent target, JMenu menu){
738
            addAction(target, menu, collapseAllJavadocFolds);
752
            addAction(target, menu, collapseAllJavadocFolds);
Lines 744-750 Link Here
744
758
745
    }
759
    }
746
760
747
    private static class JavaGoToDeclarationAction extends GotoDeclarationAction {
761
// extends from NbEditorKit
762
//    @EditorActionRegistration(name = gotoDeclarationAction, mimeType = JAVA_MIME_TYPE)
763
    public static class JavaGoToDeclarationAction extends GotoDeclarationAction {
764
765
        public JavaGoToDeclarationAction() {
766
        }
767
748
        public @Override boolean gotoDeclaration(JTextComponent target) {
768
        public @Override boolean gotoDeclaration(JTextComponent target) {
749
            if (!(target.getDocument() instanceof BaseDocument)) // Fixed #113062
769
            if (!(target.getDocument() instanceof BaseDocument)) // Fixed #113062
750
                return false;
770
                return false;
Lines 753-768 Link Here
753
        }
773
        }
754
    }
774
    }
755
775
756
    private static class JavaGoToSourceAction extends BaseAction {
776
    @EditorActionRegistration(
777
            name = gotoSourceAction,
778
            mimeType = JAVA_MIME_TYPE
779
    )
780
    public static class JavaGoToSourceAction extends BaseAction {
757
781
758
        static final long serialVersionUID =-6440495023918097760L;
782
        static final long serialVersionUID =-6440495023918097760L;
759
783
760
        public JavaGoToSourceAction() {
784
        public JavaGoToSourceAction() {
761
            super(gotoSourceAction,
785
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET
762
                  ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET
763
                  | SAVE_POSITION
786
                  | SAVE_POSITION
764
                 );
787
                 );
765
            putValue(TRIMMED_TEXT, LocaleSupport.getString("goto-source-trimmed"));  //NOI18N
766
        }
788
        }
767
789
768
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
790
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
Lines 780-791 Link Here
780
        }
802
        }
781
    }
803
    }
782
804
783
    private static class JavaFixImports extends BaseAction {
805
    @EditorActionRegistration(
806
            name = fixImportsAction,
807
            mimeType = JAVA_MIME_TYPE
808
    )
809
    public static class JavaFixImports extends BaseAction {
784
810
785
        public JavaFixImports() {
811
        public JavaFixImports() {
786
            super(fixImportsAction,
812
            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"));
813
            putValue(TRIMMED_TEXT, NbBundle.getBundle(JavaKit.class).getString("fix-imports-trimmed"));
790
            putValue(SHORT_DESCRIPTION, NbBundle.getBundle(JavaKit.class).getString("desc-fix-imports")); // NOI18N
814
            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
815
            putValue(POPUP_MENU_TEXT, NbBundle.getBundle(JavaKit.class).getString("popup-fix-imports")); // NOI18N
Lines 827-840 Link Here
827
        }
851
        }
828
    } // End of JavaFixImports action
852
    } // End of JavaFixImports action
829
853
830
    private static class JavaGotoHelpAction extends BaseAction {
854
    @EditorActionRegistration(
855
            name = gotoHelpAction,
856
            mimeType = JAVA_MIME_TYPE,
857
            shortDescription = "#java-desc-goto-help"
858
    )
859
    public static class JavaGotoHelpAction extends BaseAction {
831
860
832
        public JavaGotoHelpAction() {
861
        public JavaGotoHelpAction() {
833
            super(gotoHelpAction, ABBREV_RESET | MAGIC_POSITION_RESET
862
            super(ABBREV_RESET | MAGIC_POSITION_RESET | UNDO_MERGE_RESET |SAVE_POSITION);
834
                    | UNDO_MERGE_RESET |SAVE_POSITION);
835
            putValue ("helpID", JavaGotoHelpAction.class.getName ()); // NOI18N
863
            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
        }
864
        }
839
865
840
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
866
        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/apichanges.xml (+17 lines)
Lines 47-52 Link Here
47
<apidef name="awt">AWT API</apidef>
47
<apidef name="awt">AWT API</apidef>
48
</apidefs>
48
</apidefs>
49
<changes>
49
<changes>
50
    <change id="AlwaysEnabledAction-extra-properties-and-name-sync">
51
        <api name="awt"/>
52
        <summary>AlwaysEnabledAction extra properties and Action.NAME synchronization</summary>
53
        <version major="7" minor="7"/>
54
        <date day="7" month="4" year="2009"/>
55
        <author login="mmetelka"/>
56
        <compatibility addition="no" binary="compatible" semantic="compatible" deprecation="no" deletion="no" modification="yes"/>
57
        <description>
58
            Actions.alwaysEnabled() now checks whether Action.NAME property value
59
            of the delegate action (if defined) matches to the one in the declared
60
            for the action in the xml-layer.
61
            The AlwaysEnabledAction.getValue() now resolves all the keys
62
            in Acxtion.getValue() against the defined attributes in the xml-layer.
63
        </description>
64
        <class package="org.openide.awt" name="AlwaysEnabledAction"/>
65
        <issue number="150875"/>
66
    </change>
50
    <change id="Notifications">
67
    <change id="Notifications">
51
        <api name="awt"/>
68
        <api name="awt"/>
52
        <summary>Support for showing of notification-like messages in the main status line.</summary>
69
        <summary>Support for showing of notification-like messages in the main status line.</summary>
(-)a/openide.awt/nbproject/project.properties (-1 / +1 lines)
Lines 44-47 Link Here
44
javadoc.arch=${basedir}/arch.xml
44
javadoc.arch=${basedir}/arch.xml
45
javadoc.apichanges=${basedir}/apichanges.xml
45
javadoc.apichanges=${basedir}/apichanges.xml
46
46
47
spec.version.base=7.6.0
47
spec.version.base=7.7.0
(-)a/openide.awt/src/org/openide/awt/AlwaysEnabledAction.java (-2 / +35 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);
65
            }
74
            }
66
        }
75
        }
67
        return delegate;
76
        return delegate;
68
    }
77
    }
69
78
79
    private void syncActionDelegateProperty(String propertyName, Action actionDelegate) {
80
        Object value = extractCommonAttribute(map, this, propertyName);
81
        Object delegateValue = actionDelegate.getValue(propertyName);
82
        if (value != null) {
83
            if (delegateValue == null) {
84
                actionDelegate.putValue(propertyName, value);
85
            } else {
86
                if (!delegateValue.equals(value)) { // Values differ
87
                    if (LOG.isLoggable(Level.FINE)) {
88
                        LOG.warning("Value of property \"" + propertyName +
89
                                "\" of AlwaysEnabledAction is \"" +
90
                                value + "\" but delegate has \"" + delegateValue +
91
                                "\"\ndelegate:" + delegate + '\n');
92
                    }
93
                }
94
            }
95
        } // else either both values are null or
96
        // this has null and delegate has non-null which is probably fine (declarer does not care)
97
    }
98
70
    @Override
99
    @Override
71
    public boolean isEnabled() {
100
    public boolean isEnabled() {
72
        assert EventQueue.isDispatchThread();
101
//        assert EventQueue.isDispatchThread();
73
        if (delegate instanceof Action) {
102
        if (delegate instanceof Action) {
74
            return ((Action)delegate).isEnabled();
103
            return ((Action)delegate).isEnabled();
75
        }
104
        }
Lines 143-148 Link Here
143
                return arr.length > 0 ? arr[0] : null;
172
                return arr.length > 0 ? arr[0] : null;
144
            }
173
            }
145
        }
174
        }
175
        // Delegate query to other properties to "fo" ignoring special properties
176
        if (!"delegate".equals(name) && !"instanceCreate".equals(name)) {
177
            return fo.get(name);
178
        }
146
179
147
        return null;
180
        return null;
148
    }
181
    }
(-)a/openide.awt/test/unit/src/org/openide/awt/ActionsTest.java (-6 / +8 lines)
Lines 63-68 Link Here
63
import org.netbeans.junit.NbTestCase;
63
import org.netbeans.junit.NbTestCase;
64
import org.openide.util.HelpCtx;
64
import org.openide.util.HelpCtx;
65
import org.openide.util.Lookup;
65
import org.openide.util.Lookup;
66
import org.openide.util.Utilities;
66
import org.openide.util.actions.SystemAction;
67
import org.openide.util.actions.SystemAction;
67
68
68
/**
69
/**
Lines 345-356 Link Here
345
        assertTrue(button.getToolTipText().equals(TestActionWithTooltip.TOOLTIP));
346
        assertTrue(button.getToolTipText().equals(TestActionWithTooltip.TOOLTIP));
346
        
347
        
347
        action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK));
348
        action.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK));
348
        
349
349
        assertTrue(button.getToolTipText().indexOf("Ctrl+C") != (-1));
350
        String ctrlMod = Utilities.isMac() ? "\u2303" : "Ctrl";
351
        assertTrue(button.getToolTipText().indexOf(ctrlMod + "+C") != (-1));
350
        
352
        
351
        action.putValue(Action.SHORT_DESCRIPTION, null);
353
        action.putValue(Action.SHORT_DESCRIPTION, null);
352
        
354
        
353
        assertTrue(button.getToolTipText().indexOf("Ctrl+C") != (-1));
355
        assertTrue(button.getToolTipText().indexOf(ctrlMod + "+C") != (-1));
354
        
356
        
355
        f.setVisible(false);
357
        f.setVisible(false);
356
    }
358
    }
Lines 394-400 Link Here
394
        
396
        
395
        Actions.connect(item, action, true);
397
        Actions.connect(item, action, true);
396
        
398
        
397
        assertEquals('A', item.getMnemonic());
399
        assertEquals(Utilities.isMac() ? 0 : 'A', item.getMnemonic());
398
        assertEquals("Ahoj", item.getText());
400
        assertEquals("Ahoj", item.getText());
399
    }
401
    }
400
402
Lines 413-419 Link Here
413
        
415
        
414
        Actions.connect(item, action, true);
416
        Actions.connect(item, action, true);
415
        
417
        
416
        assertEquals('B', item.getMnemonic());
418
        assertEquals(Utilities.isMac() ? 0 : 'B', item.getMnemonic());
417
        assertEquals("Ble", item.getText());
419
        assertEquals("Ble", item.getText());
418
    }
420
    }
419
    
421
    
Lines 432-438 Link Here
432
        
434
        
433
        Actions.connect(item, action, true);
435
        Actions.connect(item, action, true);
434
        
436
        
435
        assertEquals('M', item.getMnemonic());
437
        assertEquals(Utilities.isMac() ? 0 : 'M', item.getMnemonic());
436
        assertEquals("Mle", item.getText());
438
        assertEquals("Mle", item.getText());
437
    }
439
    }
438
    
440
    
(-)a/openide.awt/test/unit/src/org/openide/awt/AlwaysEnabledActionTest.java (+33 lines)
Lines 47-52 Link Here
47
import java.beans.PropertyChangeListener;
47
import java.beans.PropertyChangeListener;
48
import java.net.URL;
48
import java.net.URL;
49
import java.util.logging.Level;
49
import java.util.logging.Level;
50
import java.util.logging.Logger;
50
import javax.swing.AbstractAction;
51
import javax.swing.AbstractAction;
51
import javax.swing.Action;
52
import javax.swing.Action;
52
import javax.swing.Icon;
53
import javax.swing.Icon;
Lines 287-292 Link Here
287
        assertTrue("Actions expected to be equal", a1.equals(a11));
288
        assertTrue("Actions expected to be equal", a1.equals(a11));
288
    }
289
    }
289
    
290
    
291
    public void testExtraPropertiesAndNamePropagation() throws Exception {
292
        Action a = readAction("testExtraProperties.instance");
293
        assertNull(MyAction.last);
294
        assertNotNull("Action created", a);
295
        a.actionPerformed(new ActionEvent(this, 0, ""));
296
        assertNotNull(MyAction.last);
297
        assertPropertyPropagated(Action.NAME, "Name1", a, MyAction.last);
298
        assertEquals("Short Desc1", a.getValue(Action.SHORT_DESCRIPTION));
299
        assertEquals("Menu Text1", a.getValue("menuText"));
300
        assertEquals("Popup Text1", a.getValue("popupText"));
301
    }
302
303
    public void testDisplayNameDiffer() throws Exception {
304
        Action a = readAction("testDisplayNameDiffer.instance");
305
        assertNull(MyAction.last);
306
        assertNotNull("Action created", a);
307
        a.actionPerformed(new ActionEvent(this, 0, ""));
308
        // Check LOG for warning
309
        assertEquals("MyNamedAction", a.getValue(Action.NAME)); // Queries the delegate
310
        assertEquals("MyNamedAction", MyAction.last.getValue(Action.NAME));
311
    }
312
313
    private static void assertPropertyPropagated(String propertyName, Object value, Action a, Action delegate) {
314
        assertEquals("Action's property \"" + propertyName + "\"", value, a.getValue(propertyName));
315
        assertEquals("Delegate's property \"" + propertyName + "\"", value, delegate.getValue(propertyName));
316
    }
317
290
    private static int myListenerCounter;
318
    private static int myListenerCounter;
291
    private static int myListenerCalled;
319
    private static int myListenerCalled;
292
    private static ActionListener myListener() {
320
    private static ActionListener myListener() {
Lines 297-302 Link Here
297
        myListenerCounter++;
325
        myListenerCounter++;
298
        return new MyAction();
326
        return new MyAction();
299
    }
327
    }
328
    private static Action myNamedAction() {
329
        MyAction a = new MyAction();
330
        a.putValue(Action.NAME, "MyNamedAction");
331
        return a;
332
    }
300
    private static ActionListener myContextAction() {
333
    private static ActionListener myContextAction() {
301
        myListenerCounter++;
334
        myListenerCounter++;
302
        return new MyContextAction();
335
        return new MyContextAction();
(-)a/openide.awt/test/unit/src/org/openide/awt/MnemonicsTest.java (-3 / +5 lines)
Lines 79-86 Link Here
79
        assertEquals("<html><b>R&amp;D</b> department", b.getText());
79
        assertEquals("<html><b>R&amp;D</b> department", b.getText());
80
        assertEquals(0, b.getMnemonic());
80
        assertEquals(0, b.getMnemonic());
81
        assertEquals(-1, b.getDisplayedMnemonicIndex());
81
        assertEquals(-1, b.getDisplayedMnemonicIndex());
82
        String underStart = Utilities.isMac() ? "" : "<u>";
83
        String underEnd = Utilities.isMac() ? "" : "</u>";
82
        Mnemonics.setLocalizedText(b, "<html><b>R&amp;D</b> departmen&t");
84
        Mnemonics.setLocalizedText(b, "<html><b>R&amp;D</b> departmen&t");
83
        assertEquals("<html><b>R&amp;D</b> departmen<u>t</u>", b.getText());
85
        assertEquals("<html><b>R&amp;D</b> departmen" + underStart + "t" + underEnd, b.getText());
84
        if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
86
        if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
85
            assertEquals(0, b.getMnemonic());
87
            assertEquals(0, b.getMnemonic());
86
            assertEquals(-1, b.getDisplayedMnemonicIndex());
88
            assertEquals(-1, b.getDisplayedMnemonicIndex());
Lines 89-95 Link Here
89
        }
91
        }
90
        
92
        
91
        Mnemonics.setLocalizedText(b, "<html>Smith &amp; &Wesson");
93
        Mnemonics.setLocalizedText(b, "<html>Smith &amp; &Wesson");
92
        assertEquals("<html>Smith &amp; <u>W</u>esson", b.getText());
94
        assertEquals("<html>Smith &amp; " + underStart + "W" + underEnd + "esson", b.getText());
93
        if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
95
        if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
94
            assertEquals(0, b.getMnemonic());
96
            assertEquals(0, b.getMnemonic());
95
            assertEquals(-1, b.getDisplayedMnemonicIndex());
97
            assertEquals(-1, b.getDisplayedMnemonicIndex());
Lines 97-103 Link Here
97
            assertEquals(KeyEvent.VK_W, b.getMnemonic());
99
            assertEquals(KeyEvent.VK_W, b.getMnemonic());
98
        }
100
        }
99
        Mnemonics.setLocalizedText(b, "<html>&Advanced Mode <em>(experimental)</em></html>");
101
        Mnemonics.setLocalizedText(b, "<html>&Advanced Mode <em>(experimental)</em></html>");
100
        assertEquals("<html><u>A</u>dvanced Mode <em>(experimental)</em></html>", b.getText());
102
        assertEquals("<html>" + underStart + "A" + underEnd + "dvanced Mode <em>(experimental)</em></html>", b.getText());
101
        if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
103
        if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
102
            assertEquals(0, b.getMnemonic());
104
            assertEquals(0, b.getMnemonic());
103
            assertEquals(-1, b.getDisplayedMnemonicIndex());
105
            assertEquals(-1, b.getDisplayedMnemonicIndex());
(-)a/openide.awt/test/unit/src/org/openide/awt/test-layer.xml (+13 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='instanceCreate' methodvalue='org.openide.awt.Actions.alwaysEnabled'/>
84
                    <attr name='delegate' methodvalue='org.openide.awt.AlwaysEnabledActionTest.myAction'/>
85
                    <attr name='displayName' stringvalue='Name1'/>
86
                    <attr name='ShortDescription' stringvalue='Short Desc1'/>
87
                    <attr name='menuText' stringvalue='Menu Text1'/>
88
                    <attr name='popupText' stringvalue='Popup Text1'/>
89
                </file>
90
                <file name="testDisplayNameDiffer.instance">
91
                    <attr name='instanceCreate' methodvalue='org.openide.awt.Actions.alwaysEnabled'/>
92
                    <attr name='delegate' methodvalue='org.openide.awt.AlwaysEnabledActionTest.myNamedAction'/>
93
                    <attr name='displayName' stringvalue='Name1'/>
94
                </file>
82
            </folder>
95
            </folder>
83
        </folder>
96
        </folder>
84
    </folder> 
97
    </folder> 

Return to bug 150875