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 217163
Collapse All | Expand All

(-)a/csl.api/nbproject/project.properties (-1 / +1 lines)
Lines 40-46 Link Here
40
# Version 2 license, then the option applies only if the new code is
40
# Version 2 license, then the option applies only if the new code is
41
# made subject to such option by the copyright holder.
41
# made subject to such option by the copyright holder.
42
42
43
spec.version.base=2.37.0
43
spec.version.base=2.38.0
44
is.autoload=true
44
is.autoload=true
45
javac.source=1.6
45
javac.source=1.6
46
46
(-)a/csl.api/nbproject/project.xml (-1 / +8 lines)
Lines 69-74 Link Here
69
                    </run-dependency>
69
                    </run-dependency>
70
                </dependency>
70
                </dependency>
71
                <dependency>
71
                <dependency>
72
                    <code-name-base>org.netbeans.modules.editor.actions</code-name-base>
73
                    <run-dependency>
74
                        <release-version>1</release-version>
75
                        <specification-version>1.21</specification-version>
76
                    </run-dependency>
77
                </dependency>
78
                <dependency>
72
                    <code-name-base>org.netbeans.modules.editor.breadcrumbs</code-name-base>
79
                    <code-name-base>org.netbeans.modules.editor.breadcrumbs</code-name-base>
73
                    <build-prerequisite/>
80
                    <build-prerequisite/>
74
                    <compile-dependency/>
81
                    <compile-dependency/>
Lines 146-152 Link Here
146
                    <compile-dependency/>
153
                    <compile-dependency/>
147
                    <run-dependency>
154
                    <run-dependency>
148
                        <release-version>1</release-version>
155
                        <release-version>1</release-version>
149
                        <specification-version>1.4</specification-version>
156
                        <specification-version>1.79</specification-version>
150
                    </run-dependency>
157
                    </run-dependency>
151
                </dependency>
158
                </dependency>
152
                <dependency>
159
                <dependency>
(-)a/csl.api/src/org/netbeans/modules/csl/api/CslActions.java (+4 lines)
Lines 43-48 Link Here
43
package org.netbeans.modules.csl.api;
43
package org.netbeans.modules.csl.api;
44
44
45
import javax.swing.Action;
45
import javax.swing.Action;
46
import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
46
47
47
/**
48
/**
48
 * A factory class for creating actions provided by CSL.
49
 * A factory class for creating actions provided by CSL.
Lines 119-124 Link Here
119
     * @param originalAction - the action to wrap around; may be {@code null}.
120
     * @param originalAction - the action to wrap around; may be {@code null}.
120
     * @param next - {@code true} for navigating to next; {@code false} for previous.
121
     * @param next - {@code true} for navigating to next; {@code false} for previous.
121
     * 
122
     * 
123
     * @deprecated use {@link CamelCaseInterceptor} instead
122
     * @return the action; never {@code null}.
124
     * @return the action; never {@code null}.
123
     */
125
     */
124
    public static Action createCamelCasePositionAction(Action originalAction, boolean next) {
126
    public static Action createCamelCasePositionAction(Action originalAction, boolean next) {
Lines 132-137 Link Here
132
     * @param originalAction - the action to wrap around; may be {@code null}.
134
     * @param originalAction - the action to wrap around; may be {@code null}.
133
     * @param next - {@code true} for navigating to next; {@code false} for previous.
135
     * @param next - {@code true} for navigating to next; {@code false} for previous.
134
     *
136
     *
137
     * @deprecated use {@link CamelCaseInterceptor} instead
135
     * @return the action; never {@code null}.
138
     * @return the action; never {@code null}.
136
     */
139
     */
137
    public static Action createDeleteToCamelCasePositionAction(Action originalAction, boolean next) {
140
    public static Action createDeleteToCamelCasePositionAction(Action originalAction, boolean next) {
Lines 145-150 Link Here
145
     * @param originalAction - the action to wrap around; may be {@code null}.
148
     * @param originalAction - the action to wrap around; may be {@code null}.
146
     * @param next - {@code true} for navigating to next; {@code false} for previous.
149
     * @param next - {@code true} for navigating to next; {@code false} for previous.
147
     *
150
     *
151
     * @deprecated use {@link CamelCaseInterceptor} instead
148
     * @return the action; never {@code null}.
152
     * @return the action; never {@code null}.
149
     */
153
     */
150
    public static Action createSelectCamelCasePositionAction(Action originalAction, boolean next) {
154
    public static Action createSelectCamelCasePositionAction(Action originalAction, boolean next) {
(-)a/csl.api/src/org/netbeans/modules/csl/api/KeystrokeHandler.java (+5 lines)
Lines 50-55 Link Here
50
import org.netbeans.api.annotations.common.CheckForNull;
50
import org.netbeans.api.annotations.common.CheckForNull;
51
import org.netbeans.api.annotations.common.NonNull;
51
import org.netbeans.api.annotations.common.NonNull;
52
import org.netbeans.modules.csl.spi.ParserResult;
52
import org.netbeans.modules.csl.spi.ParserResult;
53
import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
54
import org.netbeans.spi.editor.typinghooks.DeletedTextInterceptor;
55
import org.netbeans.spi.editor.typinghooks.TypedBreakInterceptor;
56
import org.netbeans.spi.editor.typinghooks.TypedTextInterceptor;
53
57
54
58
55
/**
59
/**
Lines 57-62 Link Here
57
 * editing.
61
 * editing.
58
 *
62
 *
59
 * @author Tor Norbye
63
 * @author Tor Norbye
64
 * @deprecated use interceptors {@link CamelCaseInterceptor} {@link DeletedTextInterceptor} {@link TypedTextInterceptor} {@link TypedBreakInterceptor} instead.
60
 */
65
 */
61
public interface KeystrokeHandler {
66
public interface KeystrokeHandler {
62
    /**
67
    /**
(-)a/csl.api/src/org/netbeans/modules/csl/core/CslCamelCaseInterceptor.java (+90 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.csl.core;
43
44
import javax.swing.text.BadLocationException;
45
import javax.swing.text.Document;
46
import org.netbeans.api.editor.mimelookup.MimePath;
47
import org.netbeans.api.editor.mimelookup.MimeRegistration;
48
import org.netbeans.api.editor.mimelookup.MimeRegistrations;
49
import org.netbeans.modules.csl.api.KeystrokeHandler;
50
import org.netbeans.modules.csl.api.UiUtils;
51
import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
52
import org.netbeans.spi.editor.typinghooks.TypedBreakInterceptor;
53
54
public class CslCamelCaseInterceptor implements CamelCaseInterceptor {
55
56
    @Override
57
    public boolean beforeChange(MutableContext context) throws BadLocationException {
58
        return false;
59
    }
60
61
    @Override
62
    public void change(MutableContext context) throws BadLocationException {
63
        int offset = context.getOffset();
64
        Document doc = context.getDocument();
65
66
        KeystrokeHandler bc = UiUtils.getBracketCompletion(doc, offset);
67
        if (bc != null) {
68
            int nextOffset = bc.getNextWordOffset(doc, offset, context.isBackward());
69
            context.setNextWordOffset(nextOffset);
70
        }
71
    }
72
73
    @Override
74
    public void afterChange(MutableContext context) throws BadLocationException {
75
    }
76
77
    @Override
78
    public void cancelled(MutableContext context) {
79
    }
80
81
    @MimeRegistrations(value = {
82
        @MimeRegistration(mimeType = "", service = CamelCaseInterceptor.Factory.class)})
83
    public static class Factory implements CamelCaseInterceptor.Factory {
84
85
        @Override
86
        public CamelCaseInterceptor createCamelCaseInterceptor(MimePath mimePath) {
87
            return new CslCamelCaseInterceptor();
88
        }
89
    }
90
}
(-)a/csl.api/src/org/netbeans/modules/csl/core/CslEditorKit.java (-15 / +12 lines)
Lines 67-87 Link Here
67
import org.netbeans.editor.ext.ExtSyntaxSupport;
67
import org.netbeans.editor.ext.ExtSyntaxSupport;
68
import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager;
68
import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager;
69
import org.netbeans.modules.csl.api.CslActions;
69
import org.netbeans.modules.csl.api.CslActions;
70
import org.netbeans.modules.csl.api.DeleteToNextCamelCasePosition;
71
import org.netbeans.modules.csl.api.DeleteToPreviousCamelCasePosition;
72
import org.netbeans.modules.csl.api.GoToDeclarationAction;
73
import org.netbeans.modules.csl.api.InstantRenameAction;
70
import org.netbeans.modules.csl.api.InstantRenameAction;
74
import org.netbeans.modules.csl.api.KeystrokeHandler;
71
import org.netbeans.modules.csl.api.KeystrokeHandler;
75
import org.netbeans.modules.csl.api.NextCamelCasePosition;
76
import org.netbeans.modules.csl.api.OffsetRange;
72
import org.netbeans.modules.csl.api.OffsetRange;
77
import org.netbeans.modules.csl.api.PreviousCamelCasePosition;
78
import org.netbeans.modules.csl.api.SelectCodeElementAction;
73
import org.netbeans.modules.csl.api.SelectCodeElementAction;
79
import org.netbeans.modules.csl.api.SelectNextCamelCasePosition;
80
import org.netbeans.modules.csl.api.SelectPreviousCamelCasePosition;
81
import org.netbeans.modules.csl.api.ToggleBlockCommentAction;
74
import org.netbeans.modules.csl.api.ToggleBlockCommentAction;
82
import org.netbeans.modules.csl.api.UiUtils;
75
import org.netbeans.modules.csl.api.UiUtils;
83
import org.netbeans.modules.csl.api.GoToMarkOccurrencesAction;
76
import org.netbeans.modules.csl.api.GoToMarkOccurrencesAction;
84
import org.netbeans.modules.editor.NbEditorKit;
77
import org.netbeans.modules.editor.NbEditorKit;
78
import org.netbeans.spi.editor.typinghooks.DeletedTextInterceptor;
79
import org.netbeans.spi.editor.typinghooks.TypedBreakInterceptor;
80
import org.netbeans.spi.editor.typinghooks.TypedTextInterceptor;
85
import org.openide.awt.Mnemonics;
81
import org.openide.awt.Mnemonics;
86
import org.openide.filesystems.FileObject;
82
import org.openide.filesystems.FileObject;
87
import org.openide.util.Exceptions;
83
import org.openide.util.Exceptions;
Lines 182-195 Link Here
182
        actions.add(new GenericGenerateGoToPopupAction());
178
        actions.add(new GenericGenerateGoToPopupAction());
183
        actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true));
179
        actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true));
184
        actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false));
180
        actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false));
185
        //actions.add(new ExpandAllCodeBlockFolds());
186
        //actions.add(new CollapseAllCodeBlockFolds());
187
        actions.add(new NextCamelCasePosition(findAction(superActions, nextWordAction)));
188
        actions.add(new PreviousCamelCasePosition(findAction(superActions, previousWordAction)));
189
        actions.add(new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction)));
190
        actions.add(new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction)));
191
        actions.add(new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)));
192
        actions.add(new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)));
193
181
194
        if (language == null) {
182
        if (language == null) {
195
            LOG.log(Level.WARNING, "Language missing for MIME type {0}", mimeType);
183
            LOG.log(Level.WARNING, "Language missing for MIME type {0}", mimeType);
Lines 231-236 Link Here
231
        return true;
219
        return true;
232
    }
220
    }
233
221
222
    /**
223
     * @deprecated use {@link TypedTextInterceptor} instead
224
     */
234
    private final class GsfDefaultKeyTypedAction extends ExtDefaultKeyTypedAction {
225
    private final class GsfDefaultKeyTypedAction extends ExtDefaultKeyTypedAction {
235
        private JTextComponent currentTarget;
226
        private JTextComponent currentTarget;
236
        private String replacedText = null;
227
        private String replacedText = null;
Lines 318-323 Link Here
318
        }
309
        }
319
    }
310
    }
320
311
312
    /**
313
     * @deprecated use {@link TypedBreakInterceptor} instead
314
     */
321
    private final class GsfInsertBreakAction extends InsertBreakAction {
315
    private final class GsfInsertBreakAction extends InsertBreakAction {
322
        static final long serialVersionUID = -1506173310438326380L;
316
        static final long serialVersionUID = -1506173310438326380L;
323
317
Lines 363-368 Link Here
363
        }
357
        }
364
    }
358
    }
365
359
360
    /**
361
     * @deprecated use {@link DeletedTextInterceptor} instead
362
     */
366
    private final class GsfDeleteCharAction extends ExtDeleteCharAction {
363
    private final class GsfDeleteCharAction extends ExtDeleteCharAction {
367
        private JTextComponent currentTarget;
364
        private JTextComponent currentTarget;
368
365
(-)a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java (-2 / +36 lines)
Lines 123-129 Link Here
123
import java.util.ArrayList;
123
import java.util.ArrayList;
124
import java.util.Collections;
124
import java.util.Collections;
125
import java.util.Comparator;
125
import java.util.Comparator;
126
import java.util.Enumeration;
126
import java.util.HashMap;
127
import java.util.HashMap;
128
import java.util.LinkedList;
127
import java.util.List;
129
import java.util.List;
128
import java.util.Map;
130
import java.util.Map;
129
import java.util.WeakHashMap;
131
import java.util.WeakHashMap;
Lines 139-144 Link Here
139
import javax.swing.text.DefaultEditorKit;
141
import javax.swing.text.DefaultEditorKit;
140
import javax.swing.text.Document;
142
import javax.swing.text.Document;
141
import javax.swing.text.Element;
143
import javax.swing.text.Element;
144
import junit.framework.Assert;
142
import org.netbeans.api.annotations.common.NullAllowed;
145
import org.netbeans.api.annotations.common.NullAllowed;
143
import org.netbeans.api.editor.mimelookup.MimeLookup;
146
import org.netbeans.api.editor.mimelookup.MimeLookup;
144
import org.netbeans.api.editor.mimelookup.MimePath;
147
import org.netbeans.api.editor.mimelookup.MimePath;
Lines 199-204 Link Here
199
import org.netbeans.spi.editor.bracesmatching.BracesMatcherFactory;
202
import org.netbeans.spi.editor.bracesmatching.BracesMatcherFactory;
200
import org.netbeans.spi.editor.bracesmatching.MatcherContext;
203
import org.netbeans.spi.editor.bracesmatching.MatcherContext;
201
import org.netbeans.spi.java.classpath.ClassPathProvider;
204
import org.netbeans.spi.java.classpath.ClassPathProvider;
205
import org.openide.filesystems.MultiFileSystem;
206
import org.openide.filesystems.Repository;
207
import org.openide.filesystems.XMLFileSystem;
202
import org.openide.loaders.DataObject;
208
import org.openide.loaders.DataObject;
203
import org.openide.loaders.DataObjectNotFoundException;
209
import org.openide.loaders.DataObjectNotFoundException;
204
import org.openide.util.test.MockLookup;
210
import org.openide.util.test.MockLookup;
Lines 213-218 Link Here
213
    }
219
    }
214
220
215
    private Map<String, ClassPath> classPathsForTest;
221
    private Map<String, ClassPath> classPathsForTest;
222
    private static Object[] extraLookupContent = null;
216
223
217
    @Override
224
    @Override
218
    protected void setUp() throws Exception {
225
    protected void setUp() throws Exception {
Lines 227-234 Link Here
227
        assert cache != null;
234
        assert cache != null;
228
        CacheFolder.setCacheFolder(cache);
235
        CacheFolder.setCacheFolder(cache);
229
236
230
        // This has to be before touching ClassPath class
237
        List<URL> layers = new LinkedList<URL>();
231
        MockLookup.setInstances(new TestClassPathProvider(), new TestPathRecognizer());
238
        String[] additionalLayers = new String[]{"META-INF/generated-layer.xml"};
239
        Object[] additionalLookupContent = new Object[0];
240
241
        for (int cntr = 0; cntr < additionalLayers.length; cntr++) {
242
            boolean found = false;
243
244
            for (Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources(additionalLayers[cntr]); en.hasMoreElements(); ) {
245
                found = true;
246
                layers.add(en.nextElement());
247
            }
248
249
            Assert.assertTrue(additionalLayers[cntr], found);
250
        }
251
252
        XMLFileSystem xmlFS = new XMLFileSystem();
253
        xmlFS.setXmlUrls(layers.toArray(new URL[0]));
254
255
        FileSystem system = new MultiFileSystem(new FileSystem[] {FileUtil.createMemoryFileSystem(), xmlFS});
256
257
        Repository repository = new Repository(system);
258
        // This has to be before touching ClassPath cla
259
260
        extraLookupContent = new Object[additionalLookupContent.length + 1];
261
262
        System.arraycopy(additionalLookupContent, 0, extraLookupContent, 1, additionalLookupContent.length);
263
264
        extraLookupContent[0] = repository;
265
        MockLookup.setInstances(extraLookupContent, new TestClassPathProvider(), new TestPathRecognizer());
232
266
233
        classPathsForTest = createClassPathsForTest();
267
        classPathsForTest = createClassPathsForTest();
234
        if (classPathsForTest != null) {
268
        if (classPathsForTest != null) {
(-)a/editor.actions/nbproject/project.properties (-1 / +1 lines)
Lines 43-49 Link Here
43
javac.compilerargs=-Xlint:unchecked
43
javac.compilerargs=-Xlint:unchecked
44
javac.source=1.7
44
javac.source=1.7
45
javadoc.title=Editor Actions
45
javadoc.title=Editor Actions
46
spec.version.base=1.21.0
46
spec.version.base=1.22.0
47
47
48
#javadoc.arch=${basedir}/arch.xml
48
#javadoc.arch=${basedir}/arch.xml
49
#javadoc.apichanges=${basedir}/apichanges.xml
49
#javadoc.apichanges=${basedir}/apichanges.xml
(-)a/editor.actions/nbproject/project.xml (+9 lines)
Lines 86-91 Link Here
86
                    </run-dependency>
86
                    </run-dependency>
87
                </dependency>
87
                </dependency>
88
                <dependency>
88
                <dependency>
89
                    <code-name-base>org.netbeans.modules.editor.util</code-name-base>
90
                    <build-prerequisite/>
91
                    <compile-dependency/>
92
                    <run-dependency>
93
                        <release-version>1</release-version>
94
                        <specification-version>1.53</specification-version>
95
                    </run-dependency>
96
                </dependency>
97
                <dependency>
89
                    <code-name-base>org.openide.util</code-name-base>
98
                    <code-name-base>org.openide.util</code-name-base>
90
                    <build-prerequisite/>
99
                    <build-prerequisite/>
91
                    <compile-dependency/>
100
                    <compile-dependency/>
(-)a/editor.actions/src/org/netbeans/modules/editor/actions/Bundle.properties (+7 lines)
Lines 61-63 Link Here
61
move-code-element-up_menu_text=Move Code Element &Up
61
move-code-element-up_menu_text=Move Code Element &Up
62
move-code-element-down=Move Code Element Down
62
move-code-element-down=Move Code Element Down
63
move-code-element-down_menu_text=Move Code Element &Down
63
move-code-element-down_menu_text=Move Code Element &Down
64
65
remove-word-previous=Delete Previous Word
66
remove-word-next=Delete Next Word
67
caret-next-word=Insertion Point to Next Word
68
caret-previous-word=Insertion Point to Previous Word
69
selection-next-word=Extend Selection to Next Word
70
selection-previous-word=Extend Selection to Previous Word
(-)a/editor.actions/src/org/netbeans/modules/editor/actions/CamelCaseActions.java (+232 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.editor.actions;
43
44
import java.awt.event.ActionEvent;
45
import java.util.Map;
46
import javax.swing.text.BadLocationException;
47
import javax.swing.text.Caret;
48
import javax.swing.text.DefaultEditorKit;
49
import javax.swing.text.JTextComponent;
50
import org.netbeans.api.editor.EditorActionRegistration;
51
import org.netbeans.editor.BaseCaret;
52
import org.netbeans.editor.BaseDocument;
53
import org.netbeans.editor.BaseKit;
54
import org.netbeans.editor.Utilities;
55
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
56
import org.netbeans.modules.editor.lib2.RectangularSelectionUtils;
57
import org.netbeans.modules.editor.lib2.typinghooks.CamelCaseInterceptorsManager;
58
import org.netbeans.spi.editor.AbstractEditorAction;
59
60
61
public class CamelCaseActions {
62
63
    /* package */ static final String deleteNextCamelCasePosition = "delete-next-camel-case-position"; //NOI18N
64
    static final String SYSTEM_ACTION_CLASS_NAME_PROPERTY = "systemActionClassName";
65
66
    public static abstract class CamelCaseAction extends AbstractEditorAction {
67
68
        public CamelCaseAction(Map<String, ?> attrs) {
69
            super(attrs);
70
        }
71
72
        public CamelCaseAction() {
73
        }
74
75
        @Override
76
        public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
77
            if (target != null) {
78
                if (!target.isEditable() || !target.isEnabled()) {
79
                    target.getToolkit().beep();
80
                    return;
81
                }
82
83
                final Caret caret = target.getCaret();
84
                final BaseDocument doc = (BaseDocument)target.getDocument();
85
                final CamelCaseInterceptorsManager.Transaction t = CamelCaseInterceptorsManager.getInstance().openTransaction(target, caret.getDot(), !isForward());
86
                try {
87
                    if (!t.beforeChange()) {
88
                        final Boolean [] result = new Boolean [] { Boolean.FALSE };
89
                        doc.runAtomicAsUser(new Runnable() {
90
                            @Override
91
                            public void run() {
92
                                DocumentUtilities.setTypingModification(doc, true);
93
                                Object[] r = t.change();
94
                                try {
95
                                    int dotPos = caret.getDot();
96
                                    int wsPos;
97
                                    if (r == null) {
98
                                        if (isForward()) {
99
                                            int eolPos = Utilities.getRowEnd(doc, dotPos);
100
                                            wsPos = Utilities.getNextWord(target, dotPos);
101
                                            wsPos = (dotPos == eolPos) ? wsPos : Math.min(eolPos, wsPos);
102
                                        } else {
103
                                            int bolPos = Utilities.getRowStart(doc, dotPos);
104
                                            wsPos = Utilities.getPreviousWord(target, dotPos);
105
                                            wsPos = (dotPos == bolPos) ? wsPos : Math.max(bolPos, wsPos);
106
                                        }
107
                                    } else  {
108
                                        wsPos = (Integer) r[0];
109
                                    }
110
111
                                    if (isForward()) {
112
                                        moveToNewOffset(target, dotPos, wsPos - dotPos);
113
                                    } else {
114
                                        moveToNewOffset(target, wsPos, dotPos - wsPos);
115
                                    }
116
                                    result[0] = Boolean.TRUE;
117
                                } catch (BadLocationException e) {
118
                                    target.getToolkit().beep();
119
                                } finally {
120
                                    DocumentUtilities.setTypingModification(doc, false);
121
                                }
122
                            }
123
                        });
124
125
                        if(result[0].booleanValue()) {
126
                            t.afterChange();
127
                        }
128
                    }
129
                } finally {
130
                    t.close();
131
                }
132
133
            }
134
        }
135
136
        protected abstract boolean isForward();
137
        protected abstract void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException;
138
    }
139
140
    @EditorActionRegistration(name = BaseKit.removeNextWordAction)
141
    public static class RemoveWordNextAction extends CamelCaseAction {
142
143
        @Override
144
        protected boolean isForward() {
145
            return true;
146
        }
147
148
        @Override
149
        protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
150
            target.getDocument().remove(offset, length);
151
        }
152
    }
153
154
    @EditorActionRegistration(name = BaseKit.removePreviousWordAction)
155
    public static class RemoveWordPreviousAction extends CamelCaseAction {
156
157
        @Override
158
        protected boolean isForward() {
159
            return false;
160
        }
161
162
        @Override
163
        protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
164
            target.getDocument().remove(offset, length);
165
        }
166
    }
167
168
    @EditorActionRegistration(name = DefaultEditorKit.nextWordAction)
169
    public static class NextCamelCasePosition extends CamelCaseAction {
170
171
        @Override
172
        protected boolean isForward() {
173
            return true;
174
        }
175
176
        @Override
177
        protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
178
            target.setCaretPosition(offset+length);
179
        }
180
    }
181
182
183
    @EditorActionRegistration(name = DefaultEditorKit.previousWordAction)
184
    public static class PreviousCamelCasePosition extends CamelCaseAction {
185
186
        @Override
187
        protected boolean isForward() {
188
            return false;
189
        }
190
191
        @Override
192
        protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
193
            target.setCaretPosition(offset);
194
        }
195
    }
196
197
    @EditorActionRegistration(name = DefaultEditorKit.selectionNextWordAction)
198
    public static class SelectNextCamelCasePosition extends CamelCaseAction {
199
200
        @Override
201
        protected boolean isForward() {
202
            return true;
203
        }
204
205
        protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
206
            Caret caret = target.getCaret();
207
            if (caret instanceof BaseCaret && RectangularSelectionUtils.isRectangularSelection(target)) {
208
                ((BaseCaret) caret).extendRectangularSelection(true, true);
209
            } else {
210
                target.getCaret().moveDot(offset + length);
211
            }
212
        }
213
    }
214
215
    @EditorActionRegistration(name = DefaultEditorKit.selectionPreviousWordAction)
216
    public static class SelectPreviousCamelCasePosition extends CamelCaseAction {
217
        @Override
218
        protected boolean isForward() {
219
            return false;
220
        }
221
222
        protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
223
            Caret caret = target.getCaret();
224
            if (caret instanceof BaseCaret && RectangularSelectionUtils.isRectangularSelection(target)) {
225
                ((BaseCaret) caret).extendRectangularSelection(false, true);
226
            } else {
227
                target.getCaret().moveDot(offset);
228
            }
229
        }
230
    }
231
232
}
(-)a/editor.lib/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
javac.compilerargs=-Xlint:unchecked
43
javac.compilerargs=-Xlint:unchecked
44
javac.source=1.7
44
javac.source=1.7
45
spec.version.base=3.40.0
45
spec.version.base=3.41.0
46
is.autoload=true
46
is.autoload=true
47
47
48
javadoc.arch=${basedir}/arch.xml
48
javadoc.arch=${basedir}/arch.xml
(-)a/editor.lib/src/org/netbeans/editor/ActionFactory.java (-36 / +6 lines)
Lines 94-99 Link Here
94
import org.netbeans.api.editor.NavigationHistory;
94
import org.netbeans.api.editor.NavigationHistory;
95
import org.netbeans.modules.editor.lib2.RectangularSelectionUtils;
95
import org.netbeans.modules.editor.lib2.RectangularSelectionUtils;
96
import org.netbeans.modules.editor.lib2.view.DocumentView;
96
import org.netbeans.modules.editor.lib2.view.DocumentView;
97
import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
97
import org.openide.util.ContextAwareAction;
98
import org.openide.util.ContextAwareAction;
98
import org.openide.util.ImageUtilities;
99
import org.openide.util.ImageUtilities;
99
import org.openide.util.Lookup;
100
import org.openide.util.Lookup;
Lines 207-247 Link Here
207
208
208
    }
209
    }
209
210
210
    /* #47709
211
    /**
211
    public static class RemoveWordAction extends LocalBaseAction {
212
     * @deprecated use {@link CamelCaseInterceptor} instead
212
213
        static final long serialVersionUID =9193117196412195554L;
214
215
        public RemoveWordAction() {
216
            super(BaseKit.removeWordAction, MAGIC_POSITION_RESET
217
                  | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
218
        }
219
220
        public void actionPerformed(ActionEvent evt, JTextComponent target) {
221
            if (target != null) {
222
                if (!target.isEditable() || !target.isEnabled()) {
223
                    target.getToolkit().beep();
224
                    return;
225
                }
226
227
                Caret caret = target.getCaret();
228
                try {
229
                    BaseDocument doc = (BaseDocument)target.getDocument();
230
                    int dotPos = caret.getDot();
231
                    int [] identBlock = Utilities.getIdentifierBlock(doc,dotPos);
232
                    if (identBlock != null){
233
                        doc.remove(identBlock[0], identBlock[1] - identBlock[0]);
234
                    }
235
                } catch (BadLocationException e) {
236
                    target.getToolkit().beep();
237
                }
238
            }
239
        }
240
    }
241
     */
213
     */
242
243
    // Disabled annotations due to overriding by camel-case actions in GSF (no concrete mimetype)
244
//    @EditorActionRegistration(name = BaseKit.removePreviousWordAction)
245
    public static class RemoveWordPreviousAction extends LocalBaseAction {
214
    public static class RemoveWordPreviousAction extends LocalBaseAction {
246
215
247
        public RemoveWordPreviousAction() {
216
        public RemoveWordPreviousAction() {
Lines 278-285 Link Here
278
        }
247
        }
279
    }
248
    }
280
249
281
    // Disabled annotations due to overriding by camel-case actions in GSF (no concrete mimetype)
250
    /**
282
//    @EditorActionRegistration(name = BaseKit.removeNextWordAction)
251
     * @deprecated use {@link CamelCaseInterceptor} instead
252
     */
283
    public static class RemoveWordNextAction extends LocalBaseAction {
253
    public static class RemoveWordNextAction extends LocalBaseAction {
284
254
285
        public RemoveWordNextAction() {
255
        public RemoveWordNextAction() {
(-)a/editor.lib/src/org/netbeans/editor/BaseKit.java (-19 / +7 lines)
Lines 109-114 Link Here
109
import org.netbeans.modules.editor.lib2.typinghooks.DeletedTextInterceptorsManager;
109
import org.netbeans.modules.editor.lib2.typinghooks.DeletedTextInterceptorsManager;
110
import org.netbeans.modules.editor.lib2.typinghooks.TypedBreakInterceptorsManager;
110
import org.netbeans.modules.editor.lib2.typinghooks.TypedBreakInterceptorsManager;
111
import org.netbeans.modules.editor.lib2.typinghooks.TypedTextInterceptorsManager;
111
import org.netbeans.modules.editor.lib2.typinghooks.TypedTextInterceptorsManager;
112
import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
112
import org.openide.awt.StatusDisplayer;
113
import org.openide.awt.StatusDisplayer;
113
import org.openide.util.HelpCtx;
114
import org.openide.util.HelpCtx;
114
import org.openide.util.Lookup;
115
import org.openide.util.Lookup;
Lines 173-181 Link Here
173
    /** Reset the abbreviation accounting string */
174
    /** Reset the abbreviation accounting string */
174
    public static final String abbrevResetAction = "abbrev-reset"; // NOI18N
175
    public static final String abbrevResetAction = "abbrev-reset"; // NOI18N
175
176
176
    /** Remove the word */ 
177
    //public static final String removeWordAction = "remove-word"; #47709
178
179
    /** Remove characters to the begining of the word or 
177
    /** Remove characters to the begining of the word or 
180
     *  the previous word if caret is not directly at word */
178
     *  the previous word if caret is not directly at word */
181
    public static final String removePreviousWordAction = "remove-word-previous"; // NOI18N
179
    public static final String removePreviousWordAction = "remove-word-previous"; // NOI18N
Lines 873-884 Link Here
873
                   undoActionDef,
871
                   undoActionDef,
874
                   redoActionDef,
872
                   redoActionDef,
875
                   //new ActionFactory.ToggleLineNumbersAction(),
873
                   //new ActionFactory.ToggleLineNumbersAction(),
876
                   new NextWordAction(nextWordAction),
877
                   new NextWordAction(selectionNextWordAction),
878
                   new PreviousWordAction(previousWordAction),
879
                   new PreviousWordAction(selectionPreviousWordAction),
880
                   new ActionFactory.RemoveWordNextAction(),
881
                   new ActionFactory.RemoveWordPreviousAction(),
882
                   new ActionFactory.ToggleRectangularSelectionAction(),
874
                   new ActionFactory.ToggleRectangularSelectionAction(),
883
875
884
                   // Self test actions
876
                   // Self test actions
Lines 2761-2771 Link Here
2761
        }
2753
        }
2762
    }
2754
    }
2763
2755
2764
    // Disabled annotations due to overriding by camel-case actions in GSF (no concrete mimetype)
2756
    /**
2765
//    @EditorActionRegistrations({
2757
     * @deprecated use {@link CamelCaseInterceptor} instead
2766
//        @EditorActionRegistration(name = nextWordAction),
2758
     */
2767
//        @EditorActionRegistration(name = selectionNextWordAction)
2768
//    })
2769
    public static class NextWordAction extends LocalBaseAction {
2759
    public static class NextWordAction extends LocalBaseAction {
2770
2760
2771
        static final long serialVersionUID =-5909906947175434032L;
2761
        static final long serialVersionUID =-5909906947175434032L;
Lines 2809-2819 Link Here
2809
        }
2799
        }
2810
    }
2800
    }
2811
2801
2812
    // Disabled annotations due to overriding by camel-case actions in GSF (no concrete mimetype)
2802
    /**
2813
//    @EditorActionRegistrations({
2803
     * @deprecated use {@link CamelCaseInterceptor} instead
2814
//        @EditorActionRegistration(name = previousWordAction),
2804
     */
2815
//        @EditorActionRegistration(name = selectionPreviousWordAction)
2816
//    })
2817
    public static class PreviousWordAction extends LocalBaseAction {
2805
    public static class PreviousWordAction extends LocalBaseAction {
2818
2806
2819
        static final long serialVersionUID =-5465143382669785799L;
2807
        static final long serialVersionUID =-5465143382669785799L;
(-)a/editor.lib/src/org/netbeans/editor/Bundle.properties (-4 lines)
Lines 78-85 Link Here
78
caret-end-word=Insertion Point to End of Word
78
caret-end-word=Insertion Point to End of Word
79
caret-end=Insertion Point to End of Document
79
caret-end=Insertion Point to End of Document
80
caret-forward=Insertion Point Forward
80
caret-forward=Insertion Point Forward
81
caret-next-word=Insertion Point to Next Word
82
caret-previous-word=Insertion Point to Previous Word
83
caret-up=Insertion Point Up
81
caret-up=Insertion Point Up
84
comment=Comment
82
comment=Comment
85
copy-to-clipboard=Copy
83
copy-to-clipboard=Copy
Lines 161-170 Link Here
161
selection-forward=Extend Selection Forward
159
selection-forward=Extend Selection Forward
162
selection-last-non-white=Extend Selection to Last Non-whitespace Char
160
selection-last-non-white=Extend Selection to Last Non-whitespace Char
163
selection-match-brace=Extend Selection to Matching Brace
161
selection-match-brace=Extend Selection to Matching Brace
164
selection-next-word=Extend Selection to Next Word
165
selection-page-down=Extend Selection to Next Page
162
selection-page-down=Extend Selection to Next Page
166
selection-page-up=Extend Selection to Previous Page
163
selection-page-up=Extend Selection to Previous Page
167
selection-previous-word=Extend Selection to Previous Word
168
selection-up=Extend Selection Up
164
selection-up=Extend Selection Up
169
set-dot=Set Dot
165
set-dot=Set Dot
170
set-read-only=Set Read Only
166
set-read-only=Set Read Only
(-)a/editor.lib2/apichanges.xml (+14 lines)
Lines 107-112 Link Here
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
108
109
    <changes>
109
    <changes>
110
111
        <change id="typinghooks-CamelCase-spi-added">
112
            <summary>Typing Hooks Camel Case SPI added</summary>
113
            <version major="1" minor="79"/>
114
            <date day="16" month="4" year="2013"/>
115
            <author login="mkristofic"/>
116
            <compatibility binary="compatible" source="compatible" semantic="compatible" addition="yes"/>
117
            <description>
118
                Typing Hooks Camel Case SPI is addition to Typing Hooks. it allows interception of various key events
119
                that are processed in the editor. The SPI is a replacement for
120
                subclassing editor actions such as <code>RemoveWordNextAction</code>, <code>PreviousCamelCasePosition</code>, etc.
121
            </description>
122
            <issue number="217163"/>
123
        </change>
110
        <change id="EditorLibDeprecation.SidebarFactory">
124
        <change id="EditorLibDeprecation.SidebarFactory">
111
            <summary>SidebarFactory interface adopted</summary>
125
            <summary>SidebarFactory interface adopted</summary>
112
            <version major="1" minor="77"/>
126
            <version major="1" minor="77"/>
(-)a/editor.lib2/nbproject/org-netbeans-modules-editor-lib2.sig (-2 / +153 lines)
Lines 1-8 Link Here
1
#Signature file v4.1
1
#Signature file v4.1
2
#Version 1.71.1
2
#Version 1.78.0
3
4
CLSS public abstract interface java.awt.event.ActionListener
5
intf java.util.EventListener
6
meth public abstract void actionPerformed(java.awt.event.ActionEvent)
3
7
4
CLSS public abstract interface java.io.Serializable
8
CLSS public abstract interface java.io.Serializable
5
9
10
CLSS public abstract interface java.lang.Cloneable
11
6
CLSS public java.lang.Object
12
CLSS public java.lang.Object
7
cons public init()
13
cons public init()
8
meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
14
meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
Lines 54-59 Link Here
54
supr java.lang.Object
60
supr java.lang.Object
55
hfds serialVersionUID
61
hfds serialVersionUID
56
62
63
CLSS public abstract javax.swing.AbstractAction
64
cons public init()
65
cons public init(java.lang.String)
66
cons public init(java.lang.String,javax.swing.Icon)
67
fld protected boolean enabled
68
fld protected javax.swing.event.SwingPropertyChangeSupport changeSupport
69
intf java.io.Serializable
70
intf java.lang.Cloneable
71
intf javax.swing.Action
72
meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
73
meth protected void firePropertyChange(java.lang.String,java.lang.Object,java.lang.Object)
74
meth public boolean isEnabled()
75
meth public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
76
meth public java.lang.Object getValue(java.lang.String)
77
meth public java.lang.Object[] getKeys()
78
meth public void addPropertyChangeListener(java.beans.PropertyChangeListener)
79
meth public void putValue(java.lang.String,java.lang.Object)
80
meth public void removePropertyChangeListener(java.beans.PropertyChangeListener)
81
meth public void setEnabled(boolean)
82
supr java.lang.Object
83
hfds RECONFIGURE_ON_NULL,arrayTable
84
85
CLSS public abstract interface javax.swing.Action
86
fld public final static java.lang.String ACCELERATOR_KEY = "AcceleratorKey"
87
fld public final static java.lang.String ACTION_COMMAND_KEY = "ActionCommandKey"
88
fld public final static java.lang.String DEFAULT = "Default"
89
fld public final static java.lang.String DISPLAYED_MNEMONIC_INDEX_KEY = "SwingDisplayedMnemonicIndexKey"
90
fld public final static java.lang.String LARGE_ICON_KEY = "SwingLargeIconKey"
91
fld public final static java.lang.String LONG_DESCRIPTION = "LongDescription"
92
fld public final static java.lang.String MNEMONIC_KEY = "MnemonicKey"
93
fld public final static java.lang.String NAME = "Name"
94
fld public final static java.lang.String SELECTED_KEY = "SwingSelectedKey"
95
fld public final static java.lang.String SHORT_DESCRIPTION = "ShortDescription"
96
fld public final static java.lang.String SMALL_ICON = "SmallIcon"
97
intf java.awt.event.ActionListener
98
meth public abstract boolean isEnabled()
99
meth public abstract java.lang.Object getValue(java.lang.String)
100
meth public abstract void addPropertyChangeListener(java.beans.PropertyChangeListener)
101
meth public abstract void putValue(java.lang.String,java.lang.Object)
102
meth public abstract void removePropertyChangeListener(java.beans.PropertyChangeListener)
103
meth public abstract void setEnabled(boolean)
104
105
CLSS public abstract javax.swing.text.TextAction
106
cons public init(java.lang.String)
107
meth protected final javax.swing.text.JTextComponent getFocusedComponent()
108
meth protected final javax.swing.text.JTextComponent getTextComponent(java.awt.event.ActionEvent)
109
meth public final static javax.swing.Action[] augmentList(javax.swing.Action[],javax.swing.Action[])
110
supr javax.swing.AbstractAction
111
57
CLSS public final org.netbeans.api.editor.DialogBinding
112
CLSS public final org.netbeans.api.editor.DialogBinding
58
cons public init()
113
cons public init()
59
meth public static void bindComponentToDocument(javax.swing.text.Document,int,int,int,javax.swing.text.JTextComponent)
114
meth public static void bindComponentToDocument(javax.swing.text.Document,int,int,int,javax.swing.text.JTextComponent)
Lines 83-88 Link Here
83
 anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=SOURCE)
138
 anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=SOURCE)
84
 anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE, METHOD])
139
 anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[TYPE, METHOD])
85
intf java.lang.annotation.Annotation
140
intf java.lang.annotation.Annotation
141
meth public abstract !hasdefault boolean noIconInMenu()
142
meth public abstract !hasdefault boolean noKeyBinding()
86
meth public abstract !hasdefault boolean preferencesDefault()
143
meth public abstract !hasdefault boolean preferencesDefault()
87
meth public abstract !hasdefault int menuPosition()
144
meth public abstract !hasdefault int menuPosition()
88
meth public abstract !hasdefault int popupPosition()
145
meth public abstract !hasdefault int popupPosition()
Lines 123-128 Link Here
123
meth public static javax.swing.Action getAction(javax.swing.text.EditorKit,java.lang.String)
180
meth public static javax.swing.Action getAction(javax.swing.text.EditorKit,java.lang.String)
124
supr java.lang.Object
181
supr java.lang.Object
125
182
183
CLSS public final org.netbeans.api.editor.NavigationHistory
184
fld public final static java.lang.String PROP_WAYPOINTS = "NavigationHHistory.PROP_WAYPOINTS"
185
innr public final static Waypoint
186
meth public boolean hasNextWaypoints()
187
meth public boolean hasPreviousWaypoints()
188
meth public java.util.List<org.netbeans.api.editor.NavigationHistory$Waypoint> getNextWaypoints()
189
meth public java.util.List<org.netbeans.api.editor.NavigationHistory$Waypoint> getPreviousWaypoints()
190
meth public org.netbeans.api.editor.NavigationHistory$Waypoint getCurrentWaypoint()
191
meth public org.netbeans.api.editor.NavigationHistory$Waypoint markWaypoint(javax.swing.text.JTextComponent,int,boolean,boolean) throws javax.swing.text.BadLocationException
192
meth public org.netbeans.api.editor.NavigationHistory$Waypoint navigateBack()
193
meth public org.netbeans.api.editor.NavigationHistory$Waypoint navigateFirst()
194
meth public org.netbeans.api.editor.NavigationHistory$Waypoint navigateForward()
195
meth public org.netbeans.api.editor.NavigationHistory$Waypoint navigateLast()
196
meth public org.netbeans.api.editor.NavigationHistory$Waypoint navigateTo(org.netbeans.api.editor.NavigationHistory$Waypoint)
197
meth public static org.netbeans.api.editor.NavigationHistory getEdits()
198
meth public static org.netbeans.api.editor.NavigationHistory getNavigations()
199
meth public void addPropertyChangeListener(java.beans.PropertyChangeListener)
200
meth public void removePropertyChangeListener(java.beans.PropertyChangeListener)
201
supr java.lang.Object
202
hfds LOCK,LOG,PCS,id,instances,pointer,sublistsCache,waypoints
203
hcls RingBuffer
204
205
CLSS public final static org.netbeans.api.editor.NavigationHistory$Waypoint
206
 outer org.netbeans.api.editor.NavigationHistory
207
meth public int getOffset()
208
meth public java.net.URL getUrl()
209
meth public javax.swing.text.JTextComponent getComponent()
210
supr java.lang.Object
211
hfds compRef,navigationHistory,pos,rawIndex,url
212
126
CLSS public final org.netbeans.api.editor.document.EditorDocumentUtils
213
CLSS public final org.netbeans.api.editor.document.EditorDocumentUtils
127
meth public static void runExclusive(javax.swing.text.Document,java.lang.Runnable)
214
meth public static void runExclusive(javax.swing.text.Document,java.lang.Runnable)
128
supr java.lang.Object
215
supr java.lang.Object
Lines 137-142 Link Here
137
supr java.lang.Object
224
supr java.lang.Object
138
hfds INSTANCE
225
hfds INSTANCE
139
226
227
CLSS public abstract org.netbeans.spi.editor.AbstractEditorAction
228
cons protected init()
229
cons protected init(java.util.Map<java.lang.String,?>)
230
fld public final static java.lang.String ASYNCHRONOUS_KEY = "asynchronous"
231
fld public final static java.lang.String DISPLAY_NAME_KEY = "displayName"
232
fld public final static java.lang.String ICON_RESOURCE_KEY = "iconBase"
233
fld public final static java.lang.String MENU_TEXT_KEY = "menuText"
234
fld public final static java.lang.String MIME_TYPE_KEY = "mimeType"
235
fld public final static java.lang.String MULTI_ACCELERATOR_LIST_KEY = "MultiAcceleratorListKey"
236
fld public final static java.lang.String NO_ICON_IN_MENU = "noIconInMenu"
237
fld public final static java.lang.String NO_KEY_BINDING = "no-keybinding"
238
fld public final static java.lang.String POPUP_TEXT_KEY = "popupText"
239
fld public final static java.lang.String PREFERENCES_DEFAULT_KEY = "preferencesDefault"
240
fld public final static java.lang.String PREFERENCES_KEY_KEY = "preferencesKey"
241
fld public final static java.lang.String PREFERENCES_NODE_KEY = "preferencesNode"
242
fld public final static java.lang.String WRAPPER_ACTION_KEY = "WrapperActionKey"
243
intf org.openide.util.actions.Presenter$Menu
244
intf org.openide.util.actions.Presenter$Popup
245
intf org.openide.util.actions.Presenter$Toolbar
246
meth protected abstract void actionPerformed(java.awt.event.ActionEvent,javax.swing.text.JTextComponent)
247
meth protected boolean asynchronous()
248
meth protected final java.lang.String actionName()
249
meth protected final void resetCaretMagicPosition(javax.swing.text.JTextComponent)
250
meth protected java.lang.Object createValue(java.lang.String)
251
meth protected void valuesUpdated()
252
meth public boolean isEnabled()
253
meth public final java.lang.Object getValue(java.lang.String)
254
meth public final void actionPerformed(java.awt.event.ActionEvent)
255
meth public final void putValue(java.lang.String,java.lang.Object)
256
meth public java.awt.Component getToolbarPresenter()
257
meth public java.lang.Object[] getKeys()
258
meth public java.lang.String toString()
259
meth public javax.swing.JMenuItem getMenuPresenter()
260
meth public javax.swing.JMenuItem getPopupPresenter()
261
meth public void setEnabled(boolean)
262
supr javax.swing.text.TextAction
263
hfds LOG,LOGGED_ACTION_NAMES,MASK_NULL_VALUE,UILOG,UNITIALIZED_ACTION,attrs,delegateAction,preferencesNodeAndListener,properties,serialVersionUID
264
hcls DelegateActionPropertyChangeListener,PreferencesNodeAndListener
265
266
CLSS public abstract interface org.netbeans.spi.editor.SideBarFactory
267
 anno 0 org.netbeans.spi.editor.mimelookup.MimeLocation(java.lang.Class<? extends org.netbeans.spi.editor.mimelookup.InstanceProvider> instanceProviderClass=class org.netbeans.spi.editor.mimelookup.InstanceProvider, java.lang.String subfolderName="SideBar")
268
meth public abstract javax.swing.JComponent createSideBar(javax.swing.text.JTextComponent)
269
140
CLSS public abstract interface org.netbeans.spi.editor.codegen.CodeGenerator
270
CLSS public abstract interface org.netbeans.spi.editor.codegen.CodeGenerator
141
innr public abstract interface static Factory
271
innr public abstract interface static Factory
142
meth public abstract java.lang.String getDisplayName()
272
meth public abstract java.lang.String getDisplayName()
Lines 373-384 Link Here
373
503
374
CLSS public final static org.netbeans.spi.editor.typinghooks.TypedTextInterceptor$MutableContext
504
CLSS public final static org.netbeans.spi.editor.typinghooks.TypedTextInterceptor$MutableContext
375
 outer org.netbeans.spi.editor.typinghooks.TypedTextInterceptor
505
 outer org.netbeans.spi.editor.typinghooks.TypedTextInterceptor
506
meth public java.lang.String getReplacedText()
376
meth public java.lang.String getText()
507
meth public java.lang.String getText()
377
meth public void setText(java.lang.String,int)
508
meth public void setText(java.lang.String,int)
378
supr org.netbeans.spi.editor.typinghooks.TypedTextInterceptor$Context
509
supr org.netbeans.spi.editor.typinghooks.TypedTextInterceptor$Context
379
hfds caretPosition,insertionText
510
hfds caretPosition,insertionText,replacedText
380
hcls Accessor
511
hcls Accessor
381
512
382
CLSS public abstract interface org.openide.util.Cancellable
513
CLSS public abstract interface org.openide.util.Cancellable
383
meth public abstract boolean cancel()
514
meth public abstract boolean cancel()
384
515
516
CLSS public abstract interface org.openide.util.actions.Presenter
517
innr public abstract interface static Menu
518
innr public abstract interface static Popup
519
innr public abstract interface static Toolbar
520
521
CLSS public abstract interface static org.openide.util.actions.Presenter$Menu
522
 outer org.openide.util.actions.Presenter
523
intf org.openide.util.actions.Presenter
524
meth public abstract javax.swing.JMenuItem getMenuPresenter()
525
526
CLSS public abstract interface static org.openide.util.actions.Presenter$Popup
527
 outer org.openide.util.actions.Presenter
528
intf org.openide.util.actions.Presenter
529
meth public abstract javax.swing.JMenuItem getPopupPresenter()
530
531
CLSS public abstract interface static org.openide.util.actions.Presenter$Toolbar
532
 outer org.openide.util.actions.Presenter
533
intf org.openide.util.actions.Presenter
534
meth public abstract java.awt.Component getToolbarPresenter()
535
(-)a/editor.lib2/nbproject/project.properties (-1 / +1 lines)
Lines 43-49 Link Here
43
is.autoload=true
43
is.autoload=true
44
javac.source=1.7
44
javac.source=1.7
45
javac.compilerargs=-Xlint:unchecked
45
javac.compilerargs=-Xlint:unchecked
46
spec.version.base=1.78.0
46
spec.version.base=1.79.0
47
47
48
javadoc.arch=${basedir}/arch.xml
48
javadoc.arch=${basedir}/arch.xml
49
javadoc.apichanges=${basedir}/apichanges.xml
49
javadoc.apichanges=${basedir}/apichanges.xml
(-)a/editor.lib2/src/org/netbeans/modules/editor/lib2/typinghooks/DeletedTextInterceptorsManager.java (-45 / +48 lines)
Lines 51-56 Link Here
51
import java.util.WeakHashMap;
51
import java.util.WeakHashMap;
52
import java.util.logging.Level;
52
import java.util.logging.Level;
53
import java.util.logging.Logger;
53
import java.util.logging.Logger;
54
import javax.swing.text.BadLocationException;
54
import javax.swing.text.Document;
55
import javax.swing.text.Document;
55
import javax.swing.text.JTextComponent;
56
import javax.swing.text.JTextComponent;
56
import org.netbeans.api.editor.mimelookup.MimeLookup;
57
import org.netbeans.api.editor.mimelookup.MimeLookup;
Lines 58-70 Link Here
58
import org.netbeans.api.lexer.TokenHierarchy;
59
import org.netbeans.api.lexer.TokenHierarchy;
59
import org.netbeans.api.lexer.TokenSequence;
60
import org.netbeans.api.lexer.TokenSequence;
60
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
61
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
61
import org.netbeans.spi.editor.typinghooks.DeletedTextInterceptor;
62
import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
62
63
63
/**
64
public final class CamelCaseInterceptorsManager {
64
 *
65
 * @author vita
66
 */
67
public final class DeletedTextInterceptorsManager {
68
    
65
    
69
    static MimePath getMimePath(final Document doc, final int offset) {
66
    static MimePath getMimePath(final Document doc, final int offset) {
70
        final MimePath[] mimePathR = new MimePath[1];
67
        final MimePath[] mimePathR = new MimePath[1];
Lines 80-96 Link Here
80
        return mimePathR[0];
77
        return mimePathR[0];
81
    }
78
    }
82
79
83
    public static DeletedTextInterceptorsManager getInstance() {
80
    public static CamelCaseInterceptorsManager getInstance() {
84
        if (instance == null) {
81
        if (instance == null) {
85
            instance = new DeletedTextInterceptorsManager();
82
            instance = new CamelCaseInterceptorsManager();
86
        }
83
        }
87
        return instance;
84
        return instance;
88
    }
85
    }
89
86
90
    public Transaction openTransaction(JTextComponent c, int offset, String removedText, boolean backwardDelete) {
87
    public Transaction openTransaction(JTextComponent c, int offset, boolean backward) {
91
        synchronized (this) {
88
        synchronized (this) {
92
            if (transaction == null) {
89
            if (transaction == null) {
93
                transaction = new Transaction(c, offset, removedText, backwardDelete);
90
                transaction = new Transaction(c, offset, backward);
94
                return transaction;
91
                return transaction;
95
            } else {
92
            } else {
96
                throw new IllegalStateException("Too many transactions; only one at a time is allowed!"); //NOI18N
93
                throw new IllegalStateException("Too many transactions; only one at a time is allowed!"); //NOI18N
Lines 100-113 Link Here
100
97
101
    public final class Transaction {
98
    public final class Transaction {
102
99
103
        public boolean beforeRemove() {
100
        public boolean beforeChange() {
104
            for(DeletedTextInterceptor i : interceptors) {
101
            for(CamelCaseInterceptor i : interceptors) {
105
                try {
102
                try {
106
                    if (i.beforeRemove(context)) {
103
                    if (i.beforeChange(context)) {
107
                        return true;
104
                        return true;
108
                    }
105
                    }
109
                } catch (Exception e) {
106
                } catch (BadLocationException e) {
110
                    LOG.log(Level.INFO, "DeletedTextInterceptor crashed in beforeRemove(): " + i, e); //NOI18N
107
                    LOG.log(Level.INFO, "DeleteWordInterceptor crashed in beforeRemove(): " + i, e); //NOI18N
111
                }
108
                }
112
            }
109
            }
113
110
Lines 115-141 Link Here
115
            return false;
112
            return false;
116
        }
113
        }
117
114
118
        public void textDeleted() {
115
        public Object[] change() {
119
            Object [] data = null;
116
            Object [] data = null;
120
117
121
            for(DeletedTextInterceptor i : interceptors) {
118
            for(CamelCaseInterceptor i : interceptors) {
122
                try {
119
                try {
123
                    i.remove(context);
120
                    i.change(context);
124
                } catch (Exception e) {
121
                } catch (BadLocationException e) {
125
                    LOG.log(Level.INFO, "DeletedTextInterceptor crashed in remove(): " + i, e); //NOI18N
122
                    LOG.log(Level.INFO, "DeleteWordInterceptor crashed in remove(): " + i, e); //NOI18N
126
                    continue;
123
                    continue;
127
                }
124
                }
125
126
                data = TypingHooksSpiAccessor.get().getDwiContextData(context);
127
                if (data != null) {
128
                    break;
129
                }
128
            }
130
            }
129
131
130
            phase++;
132
            phase++;
133
            return data;
131
        }
134
        }
132
135
133
        public void afterRemove() {
136
        public void afterChange() {
134
            for(DeletedTextInterceptor i : interceptors) {
137
            for(CamelCaseInterceptor i : interceptors) {
135
                try {
138
                try {
136
                    i.afterRemove(context);
139
                    i.afterChange(context);
137
                } catch (Exception e) {
140
                } catch (BadLocationException e) {
138
                    LOG.log(Level.INFO, "DeletedTextInterceptor crashed in afterRemove(): " + i, e); //NOI18N
141
                    LOG.log(Level.INFO, "DeleteWordInterceptor crashed in afterRemove(): " + i, e); //NOI18N
139
                }
142
                }
140
            }
143
            }
141
144
Lines 144-159 Link Here
144
147
145
        public void close() {
148
        public void close() {
146
            if (phase < 3) {
149
            if (phase < 3) {
147
                for(DeletedTextInterceptor i : interceptors) {
150
                for(CamelCaseInterceptor i : interceptors) {
148
                    try {
151
                    try {
149
                        i.cancelled(context);
152
                        i.cancelled(context);
150
                    } catch (Exception e) {
153
                    } catch (Exception e) {
151
                        LOG.log(Level.INFO, "DeletedTextInterceptor crashed in cancelled(): " + i, e); //NOI18N
154
                        LOG.log(Level.INFO, "DeleteWordInterceptor crashed in cancelled(): " + i, e); //NOI18N
152
                    }
155
                    }
153
                }
156
                }
154
            }
157
            }
155
158
156
            synchronized (DeletedTextInterceptorsManager.this) {
159
            synchronized (CamelCaseInterceptorsManager.this) {
157
                transaction = null;
160
                transaction = null;
158
            }
161
            }
159
        }
162
        }
Lines 162-173 Link Here
162
        // Private implementation
165
        // Private implementation
163
        // ------------------------------------------------------------------------
166
        // ------------------------------------------------------------------------
164
167
165
        private final DeletedTextInterceptor.Context context;
168
        private final CamelCaseInterceptor.MutableContext context;
166
        private final Collection<? extends DeletedTextInterceptor> interceptors;
169
        private final Collection<? extends CamelCaseInterceptor> interceptors;
167
        private int phase = 0;
170
        private int phase = 0;
168
171
169
        private Transaction(JTextComponent c, int offset, String removedText, boolean backwardDelete) {
172
        private Transaction(JTextComponent c, int offset, boolean backwardDelete) {
170
            this.context = TypingHooksSpiAccessor.get().createDtiContext(c, offset, removedText, backwardDelete);
173
            this.context = TypingHooksSpiAccessor.get().createDwiContext(c, offset, backwardDelete);
171
            this.interceptors = getInterceptors(c.getDocument(), offset);
174
            this.interceptors = getInterceptors(c.getDocument(), offset);
172
        }
175
        }
173
    } // End of Transaction class
176
    } // End of Transaction class
Lines 176-209 Link Here
176
    // Private implementation
179
    // Private implementation
177
    // ------------------------------------------------------------------------
180
    // ------------------------------------------------------------------------
178
181
179
    private static final Logger LOG = Logger.getLogger(DeletedTextInterceptorsManager.class.getName());
182
    private static final Logger LOG = Logger.getLogger(CamelCaseInterceptorsManager.class.getName());
180
    
183
    
181
    private static DeletedTextInterceptorsManager instance;
184
    private static CamelCaseInterceptorsManager instance;
182
185
183
    private Transaction transaction = null;
186
    private Transaction transaction = null;
184
    private final Map<MimePath, Reference<Collection<DeletedTextInterceptor>>> cache = new WeakHashMap<MimePath, Reference<Collection<DeletedTextInterceptor>>>();
187
    private final Map<MimePath, Reference<Collection<CamelCaseInterceptor>>> cache = new WeakHashMap<>();
185
    
188
    
186
    private DeletedTextInterceptorsManager() {
189
    private CamelCaseInterceptorsManager() {
187
190
188
    }
191
    }
189
192
190
    // XXX: listne on changes in MimeLookup
193
    // XXX: listne on changes in MimeLookup
191
    private Collection<? extends DeletedTextInterceptor> getInterceptors(Document doc, int offset) {
194
    private Collection<? extends CamelCaseInterceptor> getInterceptors(Document doc, int offset) {
192
        MimePath mimePath = getMimePath(doc, offset);
195
        MimePath mimePath = getMimePath(doc, offset);
193
        synchronized (cache) {
196
        synchronized (cache) {
194
            Reference<Collection<DeletedTextInterceptor>> ref = cache.get(mimePath);
197
            Reference<Collection<CamelCaseInterceptor>> ref = cache.get(mimePath);
195
            Collection<DeletedTextInterceptor> interceptors = ref == null ? null : ref.get();
198
            Collection<CamelCaseInterceptor> interceptors = ref == null ? null : ref.get();
196
199
197
            if (interceptors == null) {
200
            if (interceptors == null) {
198
                Collection<? extends DeletedTextInterceptor.Factory> factories = MimeLookup.getLookup(mimePath).lookupAll(DeletedTextInterceptor.Factory.class);
201
                Collection<? extends CamelCaseInterceptor.Factory> factories = MimeLookup.getLookup(mimePath).lookupAll(CamelCaseInterceptor.Factory.class);
199
                interceptors = new HashSet<DeletedTextInterceptor>(factories.size());
202
                interceptors = new HashSet<>(factories.size());
200
203
201
                if (LOG.isLoggable(Level.FINE)) {
204
                if (LOG.isLoggable(Level.FINE)) {
202
                    LOG.log(Level.FINE, "DeletedTextInterceptor.Factory instances for {0}:" , mimePath.getPath()); //NOI18N
205
                    LOG.log(Level.FINE, "CamelCaseInterceptor.Factory instances for {0}:" , mimePath.getPath()); //NOI18N
203
                }
206
                }
204
207
205
                for(DeletedTextInterceptor.Factory f : factories) {
208
                for(CamelCaseInterceptor.Factory f : factories) {
206
                    DeletedTextInterceptor interceptor = f.createDeletedTextInterceptor(mimePath);
209
                    CamelCaseInterceptor interceptor = f.createCamelCaseInterceptor(mimePath);
207
                    if (interceptor != null) {
210
                    if (interceptor != null) {
208
                        interceptors.add(interceptor);
211
                        interceptors.add(interceptor);
209
                    }
212
                    }
Lines 217-223 Link Here
217
                }
220
                }
218
221
219
                // XXX: this should really be a timed WeakReference
222
                // XXX: this should really be a timed WeakReference
220
                cache.put(mimePath, new SoftReference<Collection<DeletedTextInterceptor>>(interceptors));
223
                cache.put(mimePath, new SoftReference<>(interceptors));
221
            }
224
            }
222
225
223
            return interceptors;
226
            return interceptors;
(-)a/editor.lib2/src/org/netbeans/modules/editor/lib2/typinghooks/TypingHooksSpiAccessor.java (+3 lines)
Lines 41-46 Link Here
41
41
42
import javax.swing.text.JTextComponent;
42
import javax.swing.text.JTextComponent;
43
import javax.swing.text.Position;
43
import javax.swing.text.Position;
44
import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
44
import org.netbeans.spi.editor.typinghooks.DeletedTextInterceptor;
45
import org.netbeans.spi.editor.typinghooks.DeletedTextInterceptor;
45
import org.netbeans.spi.editor.typinghooks.TypedBreakInterceptor;
46
import org.netbeans.spi.editor.typinghooks.TypedBreakInterceptor;
46
import org.netbeans.spi.editor.typinghooks.TypedTextInterceptor;
47
import org.netbeans.spi.editor.typinghooks.TypedTextInterceptor;
Lines 79-84 Link Here
79
    public abstract void resetTtiContextData(TypedTextInterceptor.MutableContext context);
80
    public abstract void resetTtiContextData(TypedTextInterceptor.MutableContext context);
80
    
81
    
81
    public abstract DeletedTextInterceptor.Context createDtiContext(JTextComponent c, int offset, String removedText, boolean backwardDelete);
82
    public abstract DeletedTextInterceptor.Context createDtiContext(JTextComponent c, int offset, String removedText, boolean backwardDelete);
83
    public abstract Object [] getDwiContextData(CamelCaseInterceptor.MutableContext context);
84
    public abstract CamelCaseInterceptor.MutableContext createDwiContext(JTextComponent c, int offset, boolean backwardDelete);
82
    
85
    
83
    public abstract TypedBreakInterceptor.MutableContext createTbiContext(JTextComponent c, int caretOffset, int insertBreakOffset);
86
    public abstract TypedBreakInterceptor.MutableContext createTbiContext(JTextComponent c, int caretOffset, int insertBreakOffset);
84
    public abstract Object [] getTbiContextData(TypedBreakInterceptor.MutableContext context);
87
    public abstract Object [] getTbiContextData(TypedBreakInterceptor.MutableContext context);
(-)a/editor.lib2/src/org/netbeans/spi/editor/typinghooks/DeletedTextInterceptor.java (-87 / +53 lines)
Lines 48-61 Link Here
48
import org.netbeans.api.editor.mimelookup.MimePath;
48
import org.netbeans.api.editor.mimelookup.MimePath;
49
49
50
/**
50
/**
51
 * An interceptor which is called when user deletes text from a document. You should
51
 * An interceptor which is called when user use camel case action. You should
52
 * implement this interface if you want to hook in the keyboard input
52
 * implement this interface if you want to hook in the keyboard input
53
 * processing done in the editor infrastructure that would normally result in removing text
53
 * processing done in the editor infrastructure that would normally result in removing word
54
 * from a document. Typically, implementations of this interface will be called
54
 * from a document, selecting word or moving to next word. Typically, implementations of this interface will be called
55
 * when processing <code>KeyEvent</code>s that reach the default editor actions bound to
55
 * when processing <code>KeyEvent</code>s that reach the default editor actions bound to
56
 * <code>VK_DELETE</code> and <code>VK_BACK_SPACE</code> events.
56
 * CTRL+DEL, CTRL+BACKSPACE, CTRL+RIGHT_ARROW, CTRL+LEFT_ARROW, CTRL+SHIFT+RIGHT_ARROW, CTRL+SHIFT+LEFT_ARROW events.
57
 *
57
 *
58
 * <p><b>Registration</b>: <code>DeletedTextInterceptor</code>s can be plugged in the editor infrastructure
58
 * <p>When you set nextWordOffset, the implementation deletes/jumps according to this value. If value is not set or set to -1,
59
 * the default implementation of camel case action is performed.
60
 *
61
 * <p><b>Registration</b>: <code>CamelCaseInterceptor</code>s can be plugged in the editor infrastructure
59
 * by implementing the {@link Factory} interface and registering it in <code>MimeLookup</code>
62
 * by implementing the {@link Factory} interface and registering it in <code>MimeLookup</code>
60
 * under the appropriate mimetype (ie. <code>MimePath</code>).
63
 * under the appropriate mimetype (ie. <code>MimePath</code>).
61
 *
64
 *
Lines 66-72 Link Here
66
 * the interceptors are guaranteed to be called in AWT thread only, which means that
69
 * the interceptors are guaranteed to be called in AWT thread only, which means that
67
 * they should not need any internal synchronization model.
70
 * they should not need any internal synchronization model.
68
 *
71
 *
69
 * <p><b>Processing rules</b>: If there are multiple instances of <code>DeletedTextInterceptor</code> registered
72
 * <p><b>Processing rules</b>: If there are multiple instances of <code>CamelCaseInterceptor</code> registered
70
 * for the same mime type the infrastructure will queue them up in their registration
73
 * for the same mime type the infrastructure will queue them up in their registration
71
 * order and when processing an event it will call them all until the processing is done
74
 * order and when processing an event it will call them all until the processing is done
72
 * or terminated. 
75
 * or terminated. 
Lines 78-122 Link Here
78
 * all the queued interceptors before moving on to the next stage and calling next
81
 * all the queued interceptors before moving on to the next stage and calling next
79
 * method.
82
 * method.
80
 *
83
 *
81
 * <ul>
82
 * <li>{@link #beforeRemove(Context)} - It's called before any text is removed
83
 *   from a document. No document lock is held when this method is called. The method
84
 *   is not allowed to modify the document (and it's not supposed to do any tricks to
85
 *   break this rule). An interceptor can stop further processing of the event by returning
86
 *   <code>true</code> from this method. If it does so, no other interceptors'
87
 *   <code>beforeRemove</code> method will be called and the processing will be terminated
88
 *   without removing any text.
89
 *
90
 * <li>{@link #remove(Context)} - This method is called during the text
91
 *   removal stage immediately after the text was removed from a document. At this
92
 *   time the document is already write locked and the interceptors can modify it
93
 *   if they need to.
94
 *
95
 * <li>{@link #afterRemove(Context)} - This is the last method in the processing
96
 *   chain and it will be called when the text has already been removed from the document.
97
 *   Similarly as in <code>beforeRemove</code> the document is not locked when
98
 *   this method is called.
99
 * 
100
 * <li>{@link #cancelled(Context)} - This is an additional method that will be called
101
 *   when the processing is terminated in the before-removal stage (ie. by an interceptor
102
 *   returning <code>true</code> from its <code>beforeRemove</code> method).
103
 *   The infrastructure will only call this method on interceptors that have already
104
 *   had their <code>beforeRemove</code> method called, but not on those that
105
 *   have not yet been called at all.
106
 * </ul>
107
 *
108
 * <p><b>Errors recovery</b>: If an exception is thrown from any of the methods
84
 * <p><b>Errors recovery</b>: If an exception is thrown from any of the methods
109
 * when calling an interceptor the infrastructure will catch it and log it,
85
 * when calling an interceptor the infrastructure will catch it and log it,
110
 * but it will not stop further processing. The infrastructure may blacklist the offending
86
 * but it will not stop further processing. The infrastructure may blacklist the offending
111
 * interceptor and exclude it from processing future events.
87
 * interceptor and exclude it from processing future events.
112
 *
88
 *
113
 * @author Vita Stejskal
89
 * @since 1.79
114
 * @since 1.31
115
 */
90
 */
116
public interface DeletedTextInterceptor {
91
public interface CamelCaseInterceptor {
117
92
118
    /**
93
    /**
119
     * This method is called before any text is removed from a document. The context object
94
     * This method is called before any text is removed from a document or before caret move. The context object
120
     * passed to the method provides access to the document and its editor pane. The interceptors
95
     * passed to the method provides access to the document and its editor pane. The interceptors
121
     * are not allowed to modify the document in this method.
96
     * are not allowed to modify the document in this method.
122
     *
97
     *
Lines 138-147 Link Here
138
     * @throws BadLocationException Since the document is not locked prior calling this
113
     * @throws BadLocationException Since the document is not locked prior calling this
139
     *   method the processing may fail when working with stale context data.
114
     *   method the processing may fail when working with stale context data.
140
     */
115
     */
141
    boolean beforeRemove(Context context) throws BadLocationException;
116
    boolean beforeChange(MutableContext context) throws BadLocationException;
142
    
117
    
143
    /**
118
    /**
144
     * This method is called immediately after the text is removed from a document.
119
     * This method is called immediately after the text is removed from a document or caret is moved.
145
     * Implementors can modify the document as they need. The document and all
120
     * Implementors can modify the document as they need. The document and all
146
     * the other useful information is accessible from the <code>Context</code> object
121
     * the other useful information is accessible from the <code>Context</code> object
147
     * passed in this method. The document is write-locked.
122
     * passed in this method. The document is write-locked.
Lines 154-163 Link Here
154
     *
129
     *
155
     * @throws BadLocationException If the processing fails.
130
     * @throws BadLocationException If the processing fails.
156
     */
131
     */
157
    void remove(Context context) throws BadLocationException;
132
    void change(MutableContext context) throws BadLocationException;
158
133
159
    /**
134
    /**
160
     * This method is called after text is removed from a document and its editor's
135
     * This method is called after text is removed from a document and/or its editor's
161
     * caret is adjusted.
136
     * caret is adjusted.
162
     *
137
     *
163
     * <p><b>Locking</b>: When this method is called the document is not locked
138
     * <p><b>Locking</b>: When this method is called the document is not locked
Lines 170-193 Link Here
170
     * @throws BadLocationException Since the document is not locked prior calling this
145
     * @throws BadLocationException Since the document is not locked prior calling this
171
     *   method the processing may fail when working with stale context data.
146
     *   method the processing may fail when working with stale context data.
172
     */
147
     */
173
    void afterRemove(Context context) throws BadLocationException;
148
    void afterChange(MutableContext context) throws BadLocationException;
174
149
175
    /**
150
    /**
176
     * This method is called when the normal processing is terminated by some
151
     * This method is called when the normal processing is terminated by some
177
     * interceptor's <code>beforeRemove</code> method. Please note that this
152
     * interceptor's <code>beforeChange</code> method. Please note that this
178
     * method will not be called if the <code>beforeRemove</code> method was not
153
     * method will not be called if the <code>beforeChange</code> method was not
179
     * called.
154
     * called.
180
     * 
155
     * 
181
     * @param context The context object used for calling the <code>beforeRemove</code>
156
     * @param context The context object used for calling the <code>beforeChange</code>
182
     *   method.
157
     *   method.
183
     */
158
     */
184
    void cancelled(Context context);
159
    void cancelled(MutableContext context);
185
    
160
    
186
    /**
161
    /**
187
     * The context class providing information about the edited document, its
162
     * The context class providing information about the edited document, its
188
     * editor pane and the offset where the delete key event occurred.
163
     * editor pane and the offset where the key event occurred.
189
     */
164
     */
190
    public static final class Context {
165
    public static final class MutableContext {
191
166
192
        /**
167
        /**
193
         * Gets the editor component where the currently processed key typed event
168
         * Gets the editor component where the currently processed key typed event
Lines 210-236 Link Here
210
        }
185
        }
211
        
186
        
212
        /**
187
        /**
213
         * Gets the removal offset. This is the offset in the document where
188
         * Gets the offset. This is the offset in the document where
214
         * a user performed the delete action (ie. where the currently processed <code>KeyEvent</code>
189
         * a user performed the camel case action (ie. where the currently processed <code>KeyEvent</code>
215
         * happened). This is also the offset with text, which will be removed.
190
         * happened). This is also the offset with text, which will be removed or jumped.
216
         *
191
         *
217
         * @return The offset in the edited document.
192
         * @return The offset in the edited document.
218
         */
193
         */
219
        public int getOffset() {
194
        public int getOffset() {
220
            return offset;
195
            return offset;
221
        }
196
        }
222
223
// XXX: since this is always one (character) it make no sense to have it
224
//        public int getLength() {
225
//            return lenght;
226
//        }
227
        
197
        
228
        /**
198
        /**
229
         * Determines the type of the character removal action performed by a user. The two
199
         * Determines the type of the direction performed by a user. The two
230
         * possible actions are called differently on different platforms,
200
         * possible actions are called differently on different platforms,
231
         * but they are always defined by the position of a character, which they are
201
         * but they are always defined by the position of a character, which they are
232
         * applied to. The <i>backspace</i> action deletes a character on the left hand
202
         * applied to. The <i>backspace/left arrow</i> action deletes/jumps a character on the left hand
233
         * side of a caret, while the <i>delete</i> action deletes a character on
203
         * side of a caret, while the <i>delete/right arrow</i> action deletes/jumps a character on
234
         * the right hand side of the caret.
204
         * the right hand side of the caret.
235
         * 
205
         * 
236
         * <p>In other words one delete action removes characters backwards moving
206
         * <p>In other words one delete action removes characters backwards moving
Lines 242-261 Link Here
242
         *   backspace action. <code>false</code> if the handled action is the
212
         *   backspace action. <code>false</code> if the handled action is the
243
         *   delete action.
213
         *   delete action.
244
         */
214
         */
245
        public boolean isBackwardDelete() {
215
        public boolean isBackward() {
246
            return backwardDelete;
216
            return backward;
247
        }
217
        }
248
        
218
249
        /**
219
        /**
250
         * Gets the text being removed. In <code>beforeRemove</code> method this
220
         * Sets the new offset after remove or jump.
251
         * text is still present in the document, while in the other methods this
221
         *
252
         * text has already been removed from the document. Nevertheless this method
222
         * @param nextWordOffset == -1 if default implementation should process otherwise nextWordOffset is used to jump/delete
253
         * always returns a copy of the text.
254
         * 
255
         * @return The text being removed by the currently processed key typed event.
256
         */
223
         */
257
        public String getText() {
224
        public void setNextWordOffset(int nextWordOffset) {
258
            return removedText;
225
            this.nextWordOffset = nextWordOffset;
259
        }
226
        }
260
        
227
        
261
        // -------------------------------------------------------------------
228
        // -------------------------------------------------------------------
Lines 265-297 Link Here
265
        private final JTextComponent component;
232
        private final JTextComponent component;
266
        private final Document document;
233
        private final Document document;
267
        private final int offset;
234
        private final int offset;
268
        private final boolean backwardDelete;
235
        private final boolean backward;
269
        private final String removedText;
236
        private int nextWordOffset = -1;
270
237
271
        /* package */ Context(JTextComponent component, int offset, String removedText, boolean backwardDelete) {
238
        /* package */ MutableContext(JTextComponent component, int offset, boolean backwardDelete) {
272
            this.component = component;
239
            this.component = component;
273
            this.document = component.getDocument();
240
            this.document = component.getDocument();
274
            this.offset = offset;
241
            this.offset = offset;
275
            this.backwardDelete = backwardDelete;
242
            this.backward = backwardDelete;
276
            this.removedText = removedText;
277
        }
243
        }
244
245
        Object[] getData() {
246
            return nextWordOffset != -1 ? new Object[] {nextWordOffset} : null;
247
        }
248
249
278
        
250
        
279
    } // End of Context class
251
    } // End of Context class
280
252
281
    /**
253
    /**
282
     * The factory interface for registering <code>DeletedTextInterceptor</code>s
254
     * The factory interface for registering <code>CamelCaseInterceptor</code>s
283
     * in <code>MimeLookup</code>. An example registration in an XML layer shown
255
     * in <code>MimeLookup</code>. An example registration with java annotations.
284
     * below registers <code>Factory</code> implementation under <code>text/x-something</code>
256
     *
285
     * mime type in <code>MimeLookup</code>.
286
     *
257
     *
287
     * <pre>
258
     * <pre>
288
     * &lt;folder name="Editors"&gt;
259
     * @MimeRegistrations({
289
     *  &lt;folder name="text"&gt;
260
     *  @MimeRegistration(mimeType = "x-something", service = CamelCaseInterceptor.Factory.class)})
290
     *   &lt;folder name="x-something"&gt;
291
     *    &lt;file name="org-some-module-DTIFactory.instance" /&gt;
292
     *   &lt;/folder&gt;
293
     *  &lt;/folder&gt;
294
     * &lt;/folder&gt;
295
     * </pre>
261
     * </pre>
296
     */
262
     */
297
    public interface Factory {
263
    public interface Factory {
Lines 306-311 Link Here
306
         *
272
         *
307
         * @return The new interceptor.
273
         * @return The new interceptor.
308
         */
274
         */
309
        DeletedTextInterceptor createDeletedTextInterceptor(MimePath mimePath);
275
        CamelCaseInterceptor createCamelCaseInterceptor(MimePath mimePath);
310
    } // End of Factory interface
276
    } // End of Factory interface
311
}
277
}
(-)a/editor.lib2/src/org/netbeans/spi/editor/typinghooks/TypedTextInterceptor.java (+10 lines)
Lines 354-359 Link Here
354
            }
354
            }
355
            
355
            
356
            @Override
356
            @Override
357
            public CamelCaseInterceptor.MutableContext createDwiContext(JTextComponent c, int offset, boolean backwardDelete) {
358
                return new CamelCaseInterceptor.MutableContext(c, offset, backwardDelete);
359
            }
360
            
361
            @Override
357
            public TypedBreakInterceptor.MutableContext createTbiContext(JTextComponent c, int caretOffset, int insertBreakOffset) {
362
            public TypedBreakInterceptor.MutableContext createTbiContext(JTextComponent c, int caretOffset, int insertBreakOffset) {
358
                return new TypedBreakInterceptor.MutableContext(c, caretOffset, insertBreakOffset);
363
                return new TypedBreakInterceptor.MutableContext(c, caretOffset, insertBreakOffset);
359
            }
364
            }
Lines 367-372 Link Here
367
            public void resetTbiContextData(TypedBreakInterceptor.MutableContext context) {
372
            public void resetTbiContextData(TypedBreakInterceptor.MutableContext context) {
368
                context.resetData();
373
                context.resetData();
369
            }
374
            }
375
376
            @Override
377
            public Object[] getDwiContextData(CamelCaseInterceptor.MutableContext context) {
378
                return context.getData();
379
            }
370
        } // End of Accessor class
380
        } // End of Accessor class
371
381
372
        static {
382
        static {
(-)a/java.editor/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
javadoc.title=Java Editor
43
javadoc.title=Java Editor
44
44
45
spec.version.base=2.54.0
45
spec.version.base=2.55.0
46
test.qa-functional.cp.extra=${editor.dir}/modules/org-netbeans-modules-editor-fold.jar
46
test.qa-functional.cp.extra=${editor.dir}/modules/org-netbeans-modules-editor-fold.jar
47
javac.source=1.7
47
javac.source=1.7
48
#test.unit.cp.extra=
48
#test.unit.cp.extra=
(-)a/java.editor/nbproject/project.xml (-1 / +1 lines)
Lines 170-176 Link Here
170
                    <compile-dependency/>
170
                    <compile-dependency/>
171
                    <run-dependency>
171
                    <run-dependency>
172
                        <release-version>1</release-version>
172
                        <release-version>1</release-version>
173
                        <specification-version>1.35</specification-version>
173
                        <specification-version>1.79</specification-version>
174
                    </run-dependency>
174
                    </run-dependency>
175
                </dependency>
175
                </dependency>
176
                <dependency>
176
                <dependency>
(-)a/java.editor/src/org/netbeans/modules/editor/java/AbstractCamelCasePosition.java (-139 lines)
Lines 1-139 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.editor.java;
46
47
import java.awt.event.ActionEvent;
48
import java.util.MissingResourceException;
49
import java.util.prefs.Preferences;
50
import javax.swing.Action;
51
import javax.swing.text.BadLocationException;
52
import javax.swing.text.JTextComponent;
53
import org.netbeans.editor.BaseAction;
54
import org.netbeans.editor.BaseDocument;
55
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
56
import org.openide.util.NbBundle;
57
import org.openide.util.NbPreferences;
58
59
/**
60
 *
61
 * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
62
 */
63
/* package */ abstract class AbstractCamelCasePosition extends BaseAction {
64
65
    private Action originalAction;
66
    
67
    public AbstractCamelCasePosition(String name, Action originalAction) {
68
        super(name, MAGIC_POSITION_RESET);
69
        
70
        if (originalAction != null) {
71
            Object nameObj = originalAction.getValue(Action.NAME);
72
            if (nameObj instanceof String) {
73
                // We will be wrapping around the original action, use its name
74
                putValue(NAME, nameObj);
75
                this.originalAction = originalAction;
76
            }
77
        }
78
        
79
        String desc = getShortDescription();
80
        if (desc != null) {
81
            putValue(SHORT_DESCRIPTION, desc);
82
        }
83
    }
84
85
    public final void actionPerformed(ActionEvent evt, final JTextComponent target) {
86
        if (target != null) {
87
            if (originalAction != null && !isUsingCamelCase()) {
88
                if (originalAction instanceof BaseAction) {
89
                    ((BaseAction) originalAction).actionPerformed(evt, target);
90
                } else {
91
                    originalAction.actionPerformed(evt);
92
                }
93
            } else {
94
                final BaseDocument bdoc = org.netbeans.editor.Utilities.getDocument(target);
95
                if (bdoc != null) {
96
                    bdoc.runAtomicAsUser(new Runnable () {
97
                        public void run () {
98
                            DocumentUtilities.setTypingModification(bdoc, true);
99
                            try {
100
                                int offset = newOffset(target);
101
                                if (offset != -1) {
102
                                    moveToNewOffset(target, offset);
103
                                }
104
                            } catch (BadLocationException ble) {
105
                                target.getToolkit().beep();
106
                            } finally {
107
                                DocumentUtilities.setTypingModification(bdoc, false);
108
                            }
109
                        }
110
                    });
111
                } else {
112
                    target.getToolkit().beep();
113
                }
114
            }
115
        }
116
    }
117
118
    protected abstract int newOffset(JTextComponent textComponent) throws BadLocationException;
119
    protected abstract void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException;
120
121
    public String getShortDescription(){
122
        String name = (String)getValue(Action.NAME);
123
        if (name == null) return null;
124
        String shortDesc;
125
        try {
126
            shortDesc = NbBundle.getBundle(JavaKit.class).getString(name); // NOI18N
127
        }catch (MissingResourceException mre){
128
            shortDesc = name;
129
        }
130
        return shortDesc;
131
    }
132
    
133
    
134
    
135
    private boolean isUsingCamelCase() {
136
        Preferences p = NbPreferences.forModule(AbstractCamelCasePosition.class);
137
        return NbPreferences.root ().getBoolean("useCamelCaseStyleNavigation", true); // NOI18N
138
    }
139
}
(-)a/java.editor/src/org/netbeans/modules/editor/java/Bundle.properties (-6 lines)
Lines 74-85 Link Here
74
select-element-next=Select Next Element
74
select-element-next=Select Next Element
75
select-element-previous=Select Previous Element
75
select-element-previous=Select Previous Element
76
76
77
previous-camel-case-position=Insertion Point to Previous Camel Case Position
78
next-camel-case-position=Insertion Point to Next Camel Case Position
79
select-previous-camel-case-position=Extend Selection to Previous Camel Case Position
80
select-next-camel-case-position=Extend Selection to Next Camel Case Position
81
delete-previous-camel-case-position=Delete to Previous Camel Case Position
82
delete-next-camel-case-position=Delete to Next Camel Case Position
83
abbrev-debug-line=Debug Filename and Line Number
77
abbrev-debug-line=Debug Filename and Line Number
84
78
85
opening-element=Opening {0}...
79
opening-element=Opening {0}...
(-)a/java.editor/src/org/netbeans/modules/editor/java/CamelCaseOperations.java (-1 / +51 lines)
Lines 48-60 Link Here
48
import javax.swing.text.BadLocationException;
48
import javax.swing.text.BadLocationException;
49
import javax.swing.text.Document;
49
import javax.swing.text.Document;
50
import javax.swing.text.JTextComponent;
50
import javax.swing.text.JTextComponent;
51
import org.netbeans.api.editor.mimelookup.MimePath;
52
import org.netbeans.api.editor.mimelookup.MimeRegistration;
53
import org.netbeans.api.editor.mimelookup.MimeRegistrations;
51
import org.netbeans.api.java.lexer.JavaTokenId;
54
import org.netbeans.api.java.lexer.JavaTokenId;
52
import org.netbeans.api.lexer.Token;
55
import org.netbeans.api.lexer.Token;
53
import org.netbeans.api.lexer.TokenHierarchy;
56
import org.netbeans.api.lexer.TokenHierarchy;
54
import org.netbeans.api.lexer.TokenSequence;
57
import org.netbeans.api.lexer.TokenSequence;
55
import org.netbeans.editor.BaseDocument;
58
import org.netbeans.editor.BaseDocument;
56
import org.netbeans.editor.Utilities;
59
import org.netbeans.editor.Utilities;
57
import org.openide.util.Exceptions;
60
import static org.netbeans.modules.editor.java.JavaKit.JAVA_MIME_TYPE;
61
import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
62
import org.openide.util.NbPreferences;
58
63
59
/**
64
/**
60
 *
65
 *
Lines 216-219 Link Here
216
        return Utilities.getPreviousWord((BaseDocument)doc, offset);
221
        return Utilities.getPreviousWord((BaseDocument)doc, offset);
217
    }
222
    }
218
223
224
    public static class JavaCamelCaseInterceptor implements CamelCaseInterceptor {
225
226
        private boolean isUsingCamelCase() {
227
            return NbPreferences.root().getBoolean("useCamelCaseStyleNavigation", true); // NOI18N
228
        }
229
230
        @Override
231
        public boolean beforeChange(MutableContext context) throws BadLocationException {
232
            return false;
233
        }
234
235
        @Override
236
        public void change(MutableContext context) throws BadLocationException {
237
            if (isUsingCamelCase()) {
238
                if (context.isBackward()) {
239
                    context.setNextWordOffset(CamelCaseOperations.previousCamelCasePosition(context.getComponent()));
240
                } else {
241
                    context.setNextWordOffset(CamelCaseOperations.nextCamelCasePosition(context.getComponent()));
242
                }
243
            }
244
        }
245
246
        @Override
247
        public void afterChange(MutableContext context) throws BadLocationException {
248
        }
249
250
        @Override
251
        public void cancelled(MutableContext context) {
252
        }
253
254
        @MimeRegistrations({
255
            @MimeRegistration(mimeType = JAVA_MIME_TYPE, service = CamelCaseInterceptor.Factory.class),
256
            @MimeRegistration(mimeType = "text/x-javadoc", service = CamelCaseInterceptor.Factory.class), //NOI18N
257
            @MimeRegistration(mimeType = "text/x-java-string", service = CamelCaseInterceptor.Factory.class), //NOI18N
258
            @MimeRegistration(mimeType = "text/x-java-character", service = CamelCaseInterceptor.Factory.class) //NOI18N
259
        })
260
        @MimeRegistration(mimeType = JAVA_MIME_TYPE, service = CamelCaseInterceptor.Factory.class)
261
        public static class JavaFactory implements CamelCaseInterceptor.Factory {
262
263
            @Override
264
            public CamelCaseInterceptor createCamelCaseInterceptor(MimePath mimePath) {
265
                return new JavaCamelCaseInterceptor();
266
            }
267
        }
268
    }
219
}
269
}
(-)a/java.editor/src/org/netbeans/modules/editor/java/DeleteToNextCamelCasePosition.java (-65 lines)
Lines 1-65 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.editor.java;
46
47
import javax.swing.Action;
48
import javax.swing.text.BadLocationException;
49
import javax.swing.text.JTextComponent;
50
51
/**
52
 *
53
 * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
54
 */
55
/* package */ final class DeleteToNextCamelCasePosition extends SelectNextCamelCasePosition {
56
57
    public DeleteToNextCamelCasePosition(Action originalAction) {
58
        super(JavaKit.deleteNextCamelCasePosition, originalAction);
59
    }
60
61
    protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
62
        textComponent.getDocument().remove(textComponent.getCaretPosition(), offset - textComponent.getCaretPosition());
63
    }
64
}
65
(-)a/java.editor/src/org/netbeans/modules/editor/java/DeleteToPreviousCamelCasePosition.java (-65 lines)
Lines 1-65 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.editor.java;
46
47
import javax.swing.Action;
48
import javax.swing.text.BadLocationException;
49
import javax.swing.text.JTextComponent;
50
51
/**
52
 *
53
 * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
54
 */
55
/* package */ final class DeleteToPreviousCamelCasePosition extends PreviousCamelCasePosition {
56
57
    public DeleteToPreviousCamelCasePosition(Action originalAction) {
58
        super(JavaKit.deletePreviousCamelCasePosition, originalAction);
59
    }
60
61
    protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
62
        textComponent.getDocument().remove(offset, textComponent.getCaretPosition() - offset);
63
    }
64
}
65
(-)a/java.editor/src/org/netbeans/modules/editor/java/JavaKit.java (-63 lines)
Lines 218-235 Link Here
218
218
219
    public static final String selectPreviousElementAction = "select-element-previous"; //NOI18N
219
    public static final String selectPreviousElementAction = "select-element-previous"; //NOI18N
220
220
221
    /* package */ static final String previousCamelCasePosition = "previous-camel-case-position"; //NOI18N
222
223
    /* package */ static final String nextCamelCasePosition = "next-camel-case-position"; //NOI18N
224
225
    /* package */ static final String selectPreviousCamelCasePosition = "select-previous-camel-case-position"; //NOI18N
226
227
    /* package */ static final String selectNextCamelCasePosition = "select-next-camel-case-position"; //NOI18N
228
229
    /* package */ static final String deletePreviousCamelCasePosition = "delete-previous-camel-case-position"; //NOI18N
230
231
    /* package */ static final String deleteNextCamelCasePosition = "delete-next-camel-case-position"; //NOI18N
232
233
//    public static Action create(FileObject file) {
221
//    public static Action create(FileObject file) {
234
//        initialize();
222
//        initialize();
235
//
223
//
Lines 273-285 Link Here
273
            new JavaMoveCodeElementAction(EditorActionNames.moveCodeElementUp, false),
261
            new JavaMoveCodeElementAction(EditorActionNames.moveCodeElementUp, false),
274
            new JavaMoveCodeElementAction(EditorActionNames.moveCodeElementDown, true),
262
            new JavaMoveCodeElementAction(EditorActionNames.moveCodeElementDown, true),
275
263
276
            new JavaNextWordAction(nextWordAction),
277
            new JavaPreviousWordAction(previousWordAction),
278
            new JavaNextWordAction(selectionNextWordAction),
279
            new JavaPreviousWordAction(selectionPreviousWordAction),
280
            new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)),
281
            new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)),
282
283
            new FastImportAction(),
264
            new FastImportAction(),
284
            new GoToSuperTypeAction(),
265
            new GoToSuperTypeAction(),
285
266
Lines 291-306 Link Here
291
        return TextAction.augmentList(superActions, actions);
272
        return TextAction.augmentList(superActions, actions);
292
    }
273
    }
293
274
294
    private static Action findAction(Action [] actions, String name) {
295
        for(Action a : actions) {
296
            Object nameObj = a.getValue(Action.NAME);
297
            if (nameObj instanceof String && name.equals(nameObj)) {
298
                return a;
299
            }
300
        }
301
        return null;
302
    }
303
304
    @Override
275
    @Override
305
    public void install(JEditorPane c) {
276
    public void install(JEditorPane c) {
306
        super.install(c);
277
        super.install(c);
Lines 837-874 Link Here
837
        }
808
        }
838
809
839
    }
810
    }
840
841
    private static boolean isUsingCamelCase() {
842
        return NbPreferences.root().getBoolean("useCamelCaseStyleNavigation", true); // NOI18N
843
    }
844
845
    public static class JavaNextWordAction extends NextWordAction {
846
847
        JavaNextWordAction(String name) {
848
            super(name);
849
        }
850
        
851
        @Override
852
        protected int getNextWordOffset(JTextComponent target) throws BadLocationException {
853
            return isUsingCamelCase()
854
                    ? CamelCaseOperations.nextCamelCasePosition(target)
855
                    : super.getNextWordOffset(target);
856
        }
857
858
    }
859
860
    public static class JavaPreviousWordAction extends PreviousWordAction {
861
862
        JavaPreviousWordAction(String name) {
863
            super(name);
864
        }
865
866
        protected int getPreviousWordOffset(JTextComponent target) throws BadLocationException {
867
            return isUsingCamelCase()
868
                    ? CamelCaseOperations.previousCamelCasePosition(target)
869
                    : super.getPreviousWordOffset(target);
870
        }
871
872
    }
873
874
}
811
}
(-)a/java.editor/src/org/netbeans/modules/editor/java/NextCamelCasePosition.java (-72 lines)
Lines 1-72 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.editor.java;
46
47
import javax.swing.Action;
48
import javax.swing.text.BadLocationException;
49
import javax.swing.text.JTextComponent;
50
51
/**
52
 *
53
 * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
54
 */
55
/* package */ class NextCamelCasePosition extends AbstractCamelCasePosition {
56
57
    public NextCamelCasePosition(Action originalAction) {
58
        this(JavaKit.nextCamelCasePosition, originalAction);
59
    }
60
61
    protected NextCamelCasePosition(String name, Action originalAction) {
62
        super(name, originalAction);
63
    }
64
65
    protected int newOffset(JTextComponent textComponent) throws BadLocationException {
66
        return CamelCaseOperations.nextCamelCasePosition(textComponent);
67
    }
68
69
    protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
70
        textComponent.setCaretPosition(offset);
71
    }
72
}
(-)a/java.editor/src/org/netbeans/modules/editor/java/PreviousCamelCasePosition.java (-73 lines)
Lines 1-73 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.editor.java;
46
47
import javax.swing.Action;
48
import javax.swing.text.BadLocationException;
49
import javax.swing.text.JTextComponent;
50
51
/**
52
 *
53
 * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
54
 */
55
/* package */ class PreviousCamelCasePosition extends AbstractCamelCasePosition {
56
57
    public PreviousCamelCasePosition(Action originalAction) {
58
        this(JavaKit.previousCamelCasePosition, originalAction);
59
    }
60
61
    protected PreviousCamelCasePosition(String name, Action originalAction) {
62
        super(name, originalAction);
63
    }
64
65
    protected int newOffset(JTextComponent textComponent) throws BadLocationException {
66
        return CamelCaseOperations.previousCamelCasePosition(textComponent);
67
    }
68
69
    protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
70
        textComponent.setCaretPosition(offset);
71
    }
72
}
73
(-)a/java.editor/src/org/netbeans/modules/editor/java/SelectNextCamelCasePosition.java (-69 lines)
Lines 1-69 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.editor.java;
46
47
import javax.swing.Action;
48
import javax.swing.text.BadLocationException;
49
import javax.swing.text.JTextComponent;
50
51
/**
52
 *
53
 * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
54
 */
55
/* package */ class SelectNextCamelCasePosition extends NextCamelCasePosition {
56
57
    public SelectNextCamelCasePosition(Action originalAction) {
58
        this(JavaKit.selectNextCamelCasePosition, originalAction);
59
    }
60
61
    protected SelectNextCamelCasePosition(String name, Action originalAction) {
62
        super(name, originalAction);
63
    }
64
65
    protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
66
        textComponent.getCaret().moveDot(offset);
67
    }
68
}
69
(-)a/java.editor/src/org/netbeans/modules/editor/java/SelectPreviousCamelCasePosition.java (-68 lines)
Lines 1-68 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
45
package org.netbeans.modules.editor.java;
46
47
import javax.swing.Action;
48
import javax.swing.text.JTextComponent;
49
50
/**
51
 *
52
 * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
53
 */
54
/* package */ class SelectPreviousCamelCasePosition extends PreviousCamelCasePosition {
55
56
    public SelectPreviousCamelCasePosition(Action originalAction) {
57
        this(JavaKit.selectPreviousCamelCasePosition, originalAction);
58
    }
59
    
60
    protected SelectPreviousCamelCasePosition(String name, Action originalAction) {
61
        super(name, originalAction);
62
    }
63
    
64
    protected void moveToNewOffset(JTextComponent textComponent, int offset) {
65
        textComponent.getCaret().moveDot(offset);
66
    }
67
}
68

Return to bug 217163