diff --git a/csl.api/nbproject/project.properties b/csl.api/nbproject/project.properties
--- a/csl.api/nbproject/project.properties
+++ b/csl.api/nbproject/project.properties
@@ -40,7 +40,7 @@
# Version 2 license, then the option applies only if the new code is
# made subject to such option by the copyright holder.
-spec.version.base=2.37.0
+spec.version.base=2.38.0
is.autoload=true
javac.source=1.6
diff --git a/csl.api/nbproject/project.xml b/csl.api/nbproject/project.xml
--- a/csl.api/nbproject/project.xml
+++ b/csl.api/nbproject/project.xml
@@ -69,6 +69,13 @@
+ org.netbeans.modules.editor.actions
+
+ 1
+ 1.21
+
+
+
org.netbeans.modules.editor.breadcrumbs
@@ -146,7 +153,7 @@
1
- 1.4
+ 1.79
diff --git a/csl.api/src/org/netbeans/modules/csl/api/CslActions.java b/csl.api/src/org/netbeans/modules/csl/api/CslActions.java
--- a/csl.api/src/org/netbeans/modules/csl/api/CslActions.java
+++ b/csl.api/src/org/netbeans/modules/csl/api/CslActions.java
@@ -43,6 +43,7 @@
package org.netbeans.modules.csl.api;
import javax.swing.Action;
+import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
/**
* A factory class for creating actions provided by CSL.
@@ -119,6 +120,7 @@
* @param originalAction - the action to wrap around; may be {@code null}.
* @param next - {@code true} for navigating to next; {@code false} for previous.
*
+ * @deprecated use {@link CamelCaseInterceptor} instead
* @return the action; never {@code null}.
*/
public static Action createCamelCasePositionAction(Action originalAction, boolean next) {
@@ -132,6 +134,7 @@
* @param originalAction - the action to wrap around; may be {@code null}.
* @param next - {@code true} for navigating to next; {@code false} for previous.
*
+ * @deprecated use {@link CamelCaseInterceptor} instead
* @return the action; never {@code null}.
*/
public static Action createDeleteToCamelCasePositionAction(Action originalAction, boolean next) {
@@ -145,6 +148,7 @@
* @param originalAction - the action to wrap around; may be {@code null}.
* @param next - {@code true} for navigating to next; {@code false} for previous.
*
+ * @deprecated use {@link CamelCaseInterceptor} instead
* @return the action; never {@code null}.
*/
public static Action createSelectCamelCasePositionAction(Action originalAction, boolean next) {
diff --git a/csl.api/src/org/netbeans/modules/csl/api/KeystrokeHandler.java b/csl.api/src/org/netbeans/modules/csl/api/KeystrokeHandler.java
--- a/csl.api/src/org/netbeans/modules/csl/api/KeystrokeHandler.java
+++ b/csl.api/src/org/netbeans/modules/csl/api/KeystrokeHandler.java
@@ -50,6 +50,10 @@
import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.modules.csl.spi.ParserResult;
+import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
+import org.netbeans.spi.editor.typinghooks.DeletedTextInterceptor;
+import org.netbeans.spi.editor.typinghooks.TypedBreakInterceptor;
+import org.netbeans.spi.editor.typinghooks.TypedTextInterceptor;
/**
@@ -57,6 +61,7 @@
* editing.
*
* @author Tor Norbye
+ * @deprecated use interceptors {@link CamelCaseInterceptor} {@link DeletedTextInterceptor} {@link TypedTextInterceptor} {@link TypedBreakInterceptor} instead.
*/
public interface KeystrokeHandler {
/**
diff --git a/csl.api/src/org/netbeans/modules/csl/core/CslCamelCaseInterceptor.java b/csl.api/src/org/netbeans/modules/csl/core/CslCamelCaseInterceptor.java
new file mode 100644
--- /dev/null
+++ b/csl.api/src/org/netbeans/modules/csl/core/CslCamelCaseInterceptor.java
@@ -0,0 +1,90 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.csl.core;
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.api.editor.mimelookup.MimeRegistration;
+import org.netbeans.api.editor.mimelookup.MimeRegistrations;
+import org.netbeans.modules.csl.api.KeystrokeHandler;
+import org.netbeans.modules.csl.api.UiUtils;
+import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
+import org.netbeans.spi.editor.typinghooks.TypedBreakInterceptor;
+
+public class CslCamelCaseInterceptor implements CamelCaseInterceptor {
+
+ @Override
+ public boolean beforeChange(MutableContext context) throws BadLocationException {
+ return false;
+ }
+
+ @Override
+ public void change(MutableContext context) throws BadLocationException {
+ int offset = context.getOffset();
+ Document doc = context.getDocument();
+
+ KeystrokeHandler bc = UiUtils.getBracketCompletion(doc, offset);
+ if (bc != null) {
+ int nextOffset = bc.getNextWordOffset(doc, offset, context.isBackward());
+ context.setNextWordOffset(nextOffset);
+ }
+ }
+
+ @Override
+ public void afterChange(MutableContext context) throws BadLocationException {
+ }
+
+ @Override
+ public void cancelled(MutableContext context) {
+ }
+
+ @MimeRegistrations(value = {
+ @MimeRegistration(mimeType = "", service = CamelCaseInterceptor.Factory.class)})
+ public static class Factory implements CamelCaseInterceptor.Factory {
+
+ @Override
+ public CamelCaseInterceptor createCamelCaseInterceptor(MimePath mimePath) {
+ return new CslCamelCaseInterceptor();
+ }
+ }
+}
diff --git a/csl.api/src/org/netbeans/modules/csl/core/CslEditorKit.java b/csl.api/src/org/netbeans/modules/csl/core/CslEditorKit.java
--- a/csl.api/src/org/netbeans/modules/csl/core/CslEditorKit.java
+++ b/csl.api/src/org/netbeans/modules/csl/core/CslEditorKit.java
@@ -67,21 +67,17 @@
import org.netbeans.editor.ext.ExtSyntaxSupport;
import org.netbeans.lib.editor.codetemplates.api.CodeTemplateManager;
import org.netbeans.modules.csl.api.CslActions;
-import org.netbeans.modules.csl.api.DeleteToNextCamelCasePosition;
-import org.netbeans.modules.csl.api.DeleteToPreviousCamelCasePosition;
-import org.netbeans.modules.csl.api.GoToDeclarationAction;
import org.netbeans.modules.csl.api.InstantRenameAction;
import org.netbeans.modules.csl.api.KeystrokeHandler;
-import org.netbeans.modules.csl.api.NextCamelCasePosition;
import org.netbeans.modules.csl.api.OffsetRange;
-import org.netbeans.modules.csl.api.PreviousCamelCasePosition;
import org.netbeans.modules.csl.api.SelectCodeElementAction;
-import org.netbeans.modules.csl.api.SelectNextCamelCasePosition;
-import org.netbeans.modules.csl.api.SelectPreviousCamelCasePosition;
import org.netbeans.modules.csl.api.ToggleBlockCommentAction;
import org.netbeans.modules.csl.api.UiUtils;
import org.netbeans.modules.csl.api.GoToMarkOccurrencesAction;
import org.netbeans.modules.editor.NbEditorKit;
+import org.netbeans.spi.editor.typinghooks.DeletedTextInterceptor;
+import org.netbeans.spi.editor.typinghooks.TypedBreakInterceptor;
+import org.netbeans.spi.editor.typinghooks.TypedTextInterceptor;
import org.openide.awt.Mnemonics;
import org.openide.filesystems.FileObject;
import org.openide.util.Exceptions;
@@ -182,14 +178,6 @@
actions.add(new GenericGenerateGoToPopupAction());
actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true));
actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false));
- //actions.add(new ExpandAllCodeBlockFolds());
- //actions.add(new CollapseAllCodeBlockFolds());
- actions.add(new NextCamelCasePosition(findAction(superActions, nextWordAction)));
- actions.add(new PreviousCamelCasePosition(findAction(superActions, previousWordAction)));
- actions.add(new SelectNextCamelCasePosition(findAction(superActions, selectionNextWordAction)));
- actions.add(new SelectPreviousCamelCasePosition(findAction(superActions, selectionPreviousWordAction)));
- actions.add(new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)));
- actions.add(new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)));
if (language == null) {
LOG.log(Level.WARNING, "Language missing for MIME type {0}", mimeType);
@@ -231,6 +219,9 @@
return true;
}
+ /**
+ * @deprecated use {@link TypedTextInterceptor} instead
+ */
private final class GsfDefaultKeyTypedAction extends ExtDefaultKeyTypedAction {
private JTextComponent currentTarget;
private String replacedText = null;
@@ -318,6 +309,9 @@
}
}
+ /**
+ * @deprecated use {@link TypedBreakInterceptor} instead
+ */
private final class GsfInsertBreakAction extends InsertBreakAction {
static final long serialVersionUID = -1506173310438326380L;
@@ -363,6 +357,9 @@
}
}
+ /**
+ * @deprecated use {@link DeletedTextInterceptor} instead
+ */
private final class GsfDeleteCharAction extends ExtDeleteCharAction {
private JTextComponent currentTarget;
diff --git a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java b/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java
--- a/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java
+++ b/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java
@@ -123,7 +123,9 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Enumeration;
import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
@@ -139,6 +141,7 @@
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document;
import javax.swing.text.Element;
+import junit.framework.Assert;
import org.netbeans.api.annotations.common.NullAllowed;
import org.netbeans.api.editor.mimelookup.MimeLookup;
import org.netbeans.api.editor.mimelookup.MimePath;
@@ -199,6 +202,9 @@
import org.netbeans.spi.editor.bracesmatching.BracesMatcherFactory;
import org.netbeans.spi.editor.bracesmatching.MatcherContext;
import org.netbeans.spi.java.classpath.ClassPathProvider;
+import org.openide.filesystems.MultiFileSystem;
+import org.openide.filesystems.Repository;
+import org.openide.filesystems.XMLFileSystem;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.util.test.MockLookup;
@@ -213,6 +219,7 @@
}
private Map classPathsForTest;
+ private static Object[] extraLookupContent = null;
@Override
protected void setUp() throws Exception {
@@ -227,8 +234,35 @@
assert cache != null;
CacheFolder.setCacheFolder(cache);
- // This has to be before touching ClassPath class
- MockLookup.setInstances(new TestClassPathProvider(), new TestPathRecognizer());
+ List layers = new LinkedList();
+ String[] additionalLayers = new String[]{"META-INF/generated-layer.xml"};
+ Object[] additionalLookupContent = new Object[0];
+
+ for (int cntr = 0; cntr < additionalLayers.length; cntr++) {
+ boolean found = false;
+
+ for (Enumeration en = Thread.currentThread().getContextClassLoader().getResources(additionalLayers[cntr]); en.hasMoreElements(); ) {
+ found = true;
+ layers.add(en.nextElement());
+ }
+
+ Assert.assertTrue(additionalLayers[cntr], found);
+ }
+
+ XMLFileSystem xmlFS = new XMLFileSystem();
+ xmlFS.setXmlUrls(layers.toArray(new URL[0]));
+
+ FileSystem system = new MultiFileSystem(new FileSystem[] {FileUtil.createMemoryFileSystem(), xmlFS});
+
+ Repository repository = new Repository(system);
+ // This has to be before touching ClassPath cla
+
+ extraLookupContent = new Object[additionalLookupContent.length + 1];
+
+ System.arraycopy(additionalLookupContent, 0, extraLookupContent, 1, additionalLookupContent.length);
+
+ extraLookupContent[0] = repository;
+ MockLookup.setInstances(extraLookupContent, new TestClassPathProvider(), new TestPathRecognizer());
classPathsForTest = createClassPathsForTest();
if (classPathsForTest != null) {
diff --git a/csl.api/test/unit/src/org/netbeans/modules/csl/editor/TypingCompletion.java b/csl.api/test/unit/src/org/netbeans/modules/csl/editor/TypingCompletion.java
new file mode 100644
diff --git a/editor.actions/nbproject/project.properties b/editor.actions/nbproject/project.properties
--- a/editor.actions/nbproject/project.properties
+++ b/editor.actions/nbproject/project.properties
@@ -43,7 +43,7 @@
javac.compilerargs=-Xlint:unchecked
javac.source=1.7
javadoc.title=Editor Actions
-spec.version.base=1.21.0
+spec.version.base=1.22.0
#javadoc.arch=${basedir}/arch.xml
#javadoc.apichanges=${basedir}/apichanges.xml
diff --git a/editor.actions/nbproject/project.xml b/editor.actions/nbproject/project.xml
--- a/editor.actions/nbproject/project.xml
+++ b/editor.actions/nbproject/project.xml
@@ -86,6 +86,15 @@
+ org.netbeans.modules.editor.util
+
+
+
+ 1
+ 1.53
+
+
+
org.openide.util
diff --git a/editor.actions/src/org/netbeans/modules/editor/actions/Bundle.properties b/editor.actions/src/org/netbeans/modules/editor/actions/Bundle.properties
--- a/editor.actions/src/org/netbeans/modules/editor/actions/Bundle.properties
+++ b/editor.actions/src/org/netbeans/modules/editor/actions/Bundle.properties
@@ -61,3 +61,10 @@
move-code-element-up_menu_text=Move Code Element &Up
move-code-element-down=Move Code Element Down
move-code-element-down_menu_text=Move Code Element &Down
+
+remove-word-previous=Delete Previous Word
+remove-word-next=Delete Next Word
+caret-next-word=Insertion Point to Next Word
+caret-previous-word=Insertion Point to Previous Word
+selection-next-word=Extend Selection to Next Word
+selection-previous-word=Extend Selection to Previous Word
\ No newline at end of file
diff --git a/editor.actions/src/org/netbeans/modules/editor/actions/CamelCaseActions.java b/editor.actions/src/org/netbeans/modules/editor/actions/CamelCaseActions.java
new file mode 100644
--- /dev/null
+++ b/editor.actions/src/org/netbeans/modules/editor/actions/CamelCaseActions.java
@@ -0,0 +1,232 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.editor.actions;
+
+import java.awt.event.ActionEvent;
+import java.util.Map;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Caret;
+import javax.swing.text.DefaultEditorKit;
+import javax.swing.text.JTextComponent;
+import org.netbeans.api.editor.EditorActionRegistration;
+import org.netbeans.editor.BaseCaret;
+import org.netbeans.editor.BaseDocument;
+import org.netbeans.editor.BaseKit;
+import org.netbeans.editor.Utilities;
+import org.netbeans.lib.editor.util.swing.DocumentUtilities;
+import org.netbeans.modules.editor.lib2.RectangularSelectionUtils;
+import org.netbeans.modules.editor.lib2.typinghooks.CamelCaseInterceptorsManager;
+import org.netbeans.spi.editor.AbstractEditorAction;
+
+
+public class CamelCaseActions {
+
+ /* package */ static final String deleteNextCamelCasePosition = "delete-next-camel-case-position"; //NOI18N
+ static final String SYSTEM_ACTION_CLASS_NAME_PROPERTY = "systemActionClassName";
+
+ public static abstract class CamelCaseAction extends AbstractEditorAction {
+
+ public CamelCaseAction(Map attrs) {
+ super(attrs);
+ }
+
+ public CamelCaseAction() {
+ }
+
+ @Override
+ public void actionPerformed(final ActionEvent evt, final JTextComponent target) {
+ if (target != null) {
+ if (!target.isEditable() || !target.isEnabled()) {
+ target.getToolkit().beep();
+ return;
+ }
+
+ final Caret caret = target.getCaret();
+ final BaseDocument doc = (BaseDocument)target.getDocument();
+ final CamelCaseInterceptorsManager.Transaction t = CamelCaseInterceptorsManager.getInstance().openTransaction(target, caret.getDot(), !isForward());
+ try {
+ if (!t.beforeChange()) {
+ final Boolean [] result = new Boolean [] { Boolean.FALSE };
+ doc.runAtomicAsUser(new Runnable() {
+ @Override
+ public void run() {
+ DocumentUtilities.setTypingModification(doc, true);
+ Object[] r = t.change();
+ try {
+ int dotPos = caret.getDot();
+ int wsPos;
+ if (r == null) {
+ if (isForward()) {
+ int eolPos = Utilities.getRowEnd(doc, dotPos);
+ wsPos = Utilities.getNextWord(target, dotPos);
+ wsPos = (dotPos == eolPos) ? wsPos : Math.min(eolPos, wsPos);
+ } else {
+ int bolPos = Utilities.getRowStart(doc, dotPos);
+ wsPos = Utilities.getPreviousWord(target, dotPos);
+ wsPos = (dotPos == bolPos) ? wsPos : Math.max(bolPos, wsPos);
+ }
+ } else {
+ wsPos = (Integer) r[0];
+ }
+
+ if (isForward()) {
+ moveToNewOffset(target, dotPos, wsPos - dotPos);
+ } else {
+ moveToNewOffset(target, wsPos, dotPos - wsPos);
+ }
+ result[0] = Boolean.TRUE;
+ } catch (BadLocationException e) {
+ target.getToolkit().beep();
+ } finally {
+ DocumentUtilities.setTypingModification(doc, false);
+ }
+ }
+ });
+
+ if(result[0].booleanValue()) {
+ t.afterChange();
+ }
+ }
+ } finally {
+ t.close();
+ }
+
+ }
+ }
+
+ protected abstract boolean isForward();
+ protected abstract void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException;
+ }
+
+ @EditorActionRegistration(name = BaseKit.removeNextWordAction)
+ public static class RemoveWordNextAction extends CamelCaseAction {
+
+ @Override
+ protected boolean isForward() {
+ return true;
+ }
+
+ @Override
+ protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
+ target.getDocument().remove(offset, length);
+ }
+ }
+
+ @EditorActionRegistration(name = BaseKit.removePreviousWordAction)
+ public static class RemoveWordPreviousAction extends CamelCaseAction {
+
+ @Override
+ protected boolean isForward() {
+ return false;
+ }
+
+ @Override
+ protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
+ target.getDocument().remove(offset, length);
+ }
+ }
+
+ @EditorActionRegistration(name = DefaultEditorKit.nextWordAction)
+ public static class NextCamelCasePosition extends CamelCaseAction {
+
+ @Override
+ protected boolean isForward() {
+ return true;
+ }
+
+ @Override
+ protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
+ target.setCaretPosition(offset+length);
+ }
+ }
+
+
+ @EditorActionRegistration(name = DefaultEditorKit.previousWordAction)
+ public static class PreviousCamelCasePosition extends CamelCaseAction {
+
+ @Override
+ protected boolean isForward() {
+ return false;
+ }
+
+ @Override
+ protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
+ target.setCaretPosition(offset);
+ }
+ }
+
+ @EditorActionRegistration(name = DefaultEditorKit.selectionNextWordAction)
+ public static class SelectNextCamelCasePosition extends CamelCaseAction {
+
+ @Override
+ protected boolean isForward() {
+ return true;
+ }
+
+ protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
+ Caret caret = target.getCaret();
+ if (caret instanceof BaseCaret && RectangularSelectionUtils.isRectangularSelection(target)) {
+ ((BaseCaret) caret).extendRectangularSelection(true, true);
+ } else {
+ target.getCaret().moveDot(offset + length);
+ }
+ }
+ }
+
+ @EditorActionRegistration(name = DefaultEditorKit.selectionPreviousWordAction)
+ public static class SelectPreviousCamelCasePosition extends CamelCaseAction {
+ @Override
+ protected boolean isForward() {
+ return false;
+ }
+
+ protected void moveToNewOffset(JTextComponent target, int offset, int length) throws BadLocationException {
+ Caret caret = target.getCaret();
+ if (caret instanceof BaseCaret && RectangularSelectionUtils.isRectangularSelection(target)) {
+ ((BaseCaret) caret).extendRectangularSelection(false, true);
+ } else {
+ target.getCaret().moveDot(offset);
+ }
+ }
+ }
+
+}
diff --git a/editor.lib/nbproject/project.properties b/editor.lib/nbproject/project.properties
--- a/editor.lib/nbproject/project.properties
+++ b/editor.lib/nbproject/project.properties
@@ -42,7 +42,7 @@
javac.compilerargs=-Xlint:unchecked
javac.source=1.7
-spec.version.base=3.40.0
+spec.version.base=3.41.0
is.autoload=true
javadoc.arch=${basedir}/arch.xml
diff --git a/editor.lib/src/org/netbeans/editor/ActionFactory.java b/editor.lib/src/org/netbeans/editor/ActionFactory.java
--- a/editor.lib/src/org/netbeans/editor/ActionFactory.java
+++ b/editor.lib/src/org/netbeans/editor/ActionFactory.java
@@ -94,6 +94,7 @@
import org.netbeans.api.editor.NavigationHistory;
import org.netbeans.modules.editor.lib2.RectangularSelectionUtils;
import org.netbeans.modules.editor.lib2.view.DocumentView;
+import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
import org.openide.util.ContextAwareAction;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
@@ -207,41 +208,9 @@
}
- /* #47709
- public static class RemoveWordAction extends LocalBaseAction {
-
- static final long serialVersionUID =9193117196412195554L;
-
- public RemoveWordAction() {
- super(BaseKit.removeWordAction, MAGIC_POSITION_RESET
- | ABBREV_RESET | UNDO_MERGE_RESET | WORD_MATCH_RESET);
- }
-
- public void actionPerformed(ActionEvent evt, JTextComponent target) {
- if (target != null) {
- if (!target.isEditable() || !target.isEnabled()) {
- target.getToolkit().beep();
- return;
- }
-
- Caret caret = target.getCaret();
- try {
- BaseDocument doc = (BaseDocument)target.getDocument();
- int dotPos = caret.getDot();
- int [] identBlock = Utilities.getIdentifierBlock(doc,dotPos);
- if (identBlock != null){
- doc.remove(identBlock[0], identBlock[1] - identBlock[0]);
- }
- } catch (BadLocationException e) {
- target.getToolkit().beep();
- }
- }
- }
- }
+ /**
+ * @deprecated use {@link CamelCaseInterceptor} instead
*/
-
- // Disabled annotations due to overriding by camel-case actions in GSF (no concrete mimetype)
-// @EditorActionRegistration(name = BaseKit.removePreviousWordAction)
public static class RemoveWordPreviousAction extends LocalBaseAction {
public RemoveWordPreviousAction() {
@@ -278,8 +247,9 @@
}
}
- // Disabled annotations due to overriding by camel-case actions in GSF (no concrete mimetype)
-// @EditorActionRegistration(name = BaseKit.removeNextWordAction)
+ /**
+ * @deprecated use {@link CamelCaseInterceptor} instead
+ */
public static class RemoveWordNextAction extends LocalBaseAction {
public RemoveWordNextAction() {
diff --git a/editor.lib/src/org/netbeans/editor/BaseKit.java b/editor.lib/src/org/netbeans/editor/BaseKit.java
--- a/editor.lib/src/org/netbeans/editor/BaseKit.java
+++ b/editor.lib/src/org/netbeans/editor/BaseKit.java
@@ -109,6 +109,7 @@
import org.netbeans.modules.editor.lib2.typinghooks.DeletedTextInterceptorsManager;
import org.netbeans.modules.editor.lib2.typinghooks.TypedBreakInterceptorsManager;
import org.netbeans.modules.editor.lib2.typinghooks.TypedTextInterceptorsManager;
+import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
import org.openide.awt.StatusDisplayer;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
@@ -173,9 +174,6 @@
/** Reset the abbreviation accounting string */
public static final String abbrevResetAction = "abbrev-reset"; // NOI18N
- /** Remove the word */
- //public static final String removeWordAction = "remove-word"; #47709
-
/** Remove characters to the begining of the word or
* the previous word if caret is not directly at word */
public static final String removePreviousWordAction = "remove-word-previous"; // NOI18N
@@ -873,12 +871,6 @@
undoActionDef,
redoActionDef,
//new ActionFactory.ToggleLineNumbersAction(),
- new NextWordAction(nextWordAction),
- new NextWordAction(selectionNextWordAction),
- new PreviousWordAction(previousWordAction),
- new PreviousWordAction(selectionPreviousWordAction),
- new ActionFactory.RemoveWordNextAction(),
- new ActionFactory.RemoveWordPreviousAction(),
new ActionFactory.ToggleRectangularSelectionAction(),
// Self test actions
@@ -2761,11 +2753,9 @@
}
}
- // Disabled annotations due to overriding by camel-case actions in GSF (no concrete mimetype)
-// @EditorActionRegistrations({
-// @EditorActionRegistration(name = nextWordAction),
-// @EditorActionRegistration(name = selectionNextWordAction)
-// })
+ /**
+ * @deprecated use {@link CamelCaseInterceptor} instead
+ */
public static class NextWordAction extends LocalBaseAction {
static final long serialVersionUID =-5909906947175434032L;
@@ -2809,11 +2799,9 @@
}
}
- // Disabled annotations due to overriding by camel-case actions in GSF (no concrete mimetype)
-// @EditorActionRegistrations({
-// @EditorActionRegistration(name = previousWordAction),
-// @EditorActionRegistration(name = selectionPreviousWordAction)
-// })
+ /**
+ * @deprecated use {@link CamelCaseInterceptor} instead
+ */
public static class PreviousWordAction extends LocalBaseAction {
static final long serialVersionUID =-5465143382669785799L;
diff --git a/editor.lib/src/org/netbeans/editor/Bundle.properties b/editor.lib/src/org/netbeans/editor/Bundle.properties
--- a/editor.lib/src/org/netbeans/editor/Bundle.properties
+++ b/editor.lib/src/org/netbeans/editor/Bundle.properties
@@ -78,8 +78,6 @@
caret-end-word=Insertion Point to End of Word
caret-end=Insertion Point to End of Document
caret-forward=Insertion Point Forward
-caret-next-word=Insertion Point to Next Word
-caret-previous-word=Insertion Point to Previous Word
caret-up=Insertion Point Up
comment=Comment
copy-to-clipboard=Copy
@@ -161,10 +159,8 @@
selection-forward=Extend Selection Forward
selection-last-non-white=Extend Selection to Last Non-whitespace Char
selection-match-brace=Extend Selection to Matching Brace
-selection-next-word=Extend Selection to Next Word
selection-page-down=Extend Selection to Next Page
selection-page-up=Extend Selection to Previous Page
-selection-previous-word=Extend Selection to Previous Word
selection-up=Extend Selection Up
set-dot=Set Dot
set-read-only=Set Read Only
diff --git a/editor.lib2/apichanges.xml b/editor.lib2/apichanges.xml
--- a/editor.lib2/apichanges.xml
+++ b/editor.lib2/apichanges.xml
@@ -107,6 +107,20 @@
+
+
+ Typing Hooks Camel Case SPI added
+
+
+
+
+
+ Typing Hooks Camel Case SPI is addition to Typing Hooks. it allows interception of various key events
+ that are processed in the editor. The SPI is a replacement for
+ subclassing editor actions such as RemoveWordNextAction
, PreviousCamelCasePosition
, etc.
+
+
+
diff --git a/java.editor/src/org/netbeans/modules/editor/java/AbstractCamelCasePosition.java b/java.editor/src/org/netbeans/modules/editor/java/AbstractCamelCasePosition.java
deleted file mode 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/AbstractCamelCasePosition.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.modules.editor.java;
-
-import java.awt.event.ActionEvent;
-import java.util.MissingResourceException;
-import java.util.prefs.Preferences;
-import javax.swing.Action;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.JTextComponent;
-import org.netbeans.editor.BaseAction;
-import org.netbeans.editor.BaseDocument;
-import org.netbeans.lib.editor.util.swing.DocumentUtilities;
-import org.openide.util.NbBundle;
-import org.openide.util.NbPreferences;
-
-/**
- *
- * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
- */
-/* package */ abstract class AbstractCamelCasePosition extends BaseAction {
-
- private Action originalAction;
-
- public AbstractCamelCasePosition(String name, Action originalAction) {
- super(name, MAGIC_POSITION_RESET);
-
- if (originalAction != null) {
- Object nameObj = originalAction.getValue(Action.NAME);
- if (nameObj instanceof String) {
- // We will be wrapping around the original action, use its name
- putValue(NAME, nameObj);
- this.originalAction = originalAction;
- }
- }
-
- String desc = getShortDescription();
- if (desc != null) {
- putValue(SHORT_DESCRIPTION, desc);
- }
- }
-
- public final void actionPerformed(ActionEvent evt, final JTextComponent target) {
- if (target != null) {
- if (originalAction != null && !isUsingCamelCase()) {
- if (originalAction instanceof BaseAction) {
- ((BaseAction) originalAction).actionPerformed(evt, target);
- } else {
- originalAction.actionPerformed(evt);
- }
- } else {
- final BaseDocument bdoc = org.netbeans.editor.Utilities.getDocument(target);
- if (bdoc != null) {
- bdoc.runAtomicAsUser(new Runnable () {
- public void run () {
- DocumentUtilities.setTypingModification(bdoc, true);
- try {
- int offset = newOffset(target);
- if (offset != -1) {
- moveToNewOffset(target, offset);
- }
- } catch (BadLocationException ble) {
- target.getToolkit().beep();
- } finally {
- DocumentUtilities.setTypingModification(bdoc, false);
- }
- }
- });
- } else {
- target.getToolkit().beep();
- }
- }
- }
- }
-
- protected abstract int newOffset(JTextComponent textComponent) throws BadLocationException;
- protected abstract void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException;
-
- public String getShortDescription(){
- String name = (String)getValue(Action.NAME);
- if (name == null) return null;
- String shortDesc;
- try {
- shortDesc = NbBundle.getBundle(JavaKit.class).getString(name); // NOI18N
- }catch (MissingResourceException mre){
- shortDesc = name;
- }
- return shortDesc;
- }
-
-
-
- private boolean isUsingCamelCase() {
- Preferences p = NbPreferences.forModule(AbstractCamelCasePosition.class);
- return NbPreferences.root ().getBoolean("useCamelCaseStyleNavigation", true); // NOI18N
- }
-}
diff --git a/java.editor/src/org/netbeans/modules/editor/java/Bundle.properties b/java.editor/src/org/netbeans/modules/editor/java/Bundle.properties
--- a/java.editor/src/org/netbeans/modules/editor/java/Bundle.properties
+++ b/java.editor/src/org/netbeans/modules/editor/java/Bundle.properties
@@ -74,12 +74,6 @@
select-element-next=Select Next Element
select-element-previous=Select Previous Element
-previous-camel-case-position=Insertion Point to Previous Camel Case Position
-next-camel-case-position=Insertion Point to Next Camel Case Position
-select-previous-camel-case-position=Extend Selection to Previous Camel Case Position
-select-next-camel-case-position=Extend Selection to Next Camel Case Position
-delete-previous-camel-case-position=Delete to Previous Camel Case Position
-delete-next-camel-case-position=Delete to Next Camel Case Position
abbrev-debug-line=Debug Filename and Line Number
opening-element=Opening {0}...
diff --git a/java.editor/src/org/netbeans/modules/editor/java/CamelCaseOperations.java b/java.editor/src/org/netbeans/modules/editor/java/CamelCaseOperations.java
--- a/java.editor/src/org/netbeans/modules/editor/java/CamelCaseOperations.java
+++ b/java.editor/src/org/netbeans/modules/editor/java/CamelCaseOperations.java
@@ -48,13 +48,18 @@
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
+import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.api.editor.mimelookup.MimeRegistration;
+import org.netbeans.api.editor.mimelookup.MimeRegistrations;
import org.netbeans.api.java.lexer.JavaTokenId;
import org.netbeans.api.lexer.Token;
import org.netbeans.api.lexer.TokenHierarchy;
import org.netbeans.api.lexer.TokenSequence;
import org.netbeans.editor.BaseDocument;
import org.netbeans.editor.Utilities;
-import org.openide.util.Exceptions;
+import static org.netbeans.modules.editor.java.JavaKit.JAVA_MIME_TYPE;
+import org.netbeans.spi.editor.typinghooks.CamelCaseInterceptor;
+import org.openide.util.NbPreferences;
/**
*
@@ -216,4 +221,49 @@
return Utilities.getPreviousWord((BaseDocument)doc, offset);
}
+ public static class JavaCamelCaseInterceptor implements CamelCaseInterceptor {
+
+ private boolean isUsingCamelCase() {
+ return NbPreferences.root().getBoolean("useCamelCaseStyleNavigation", true); // NOI18N
+ }
+
+ @Override
+ public boolean beforeChange(MutableContext context) throws BadLocationException {
+ return false;
+ }
+
+ @Override
+ public void change(MutableContext context) throws BadLocationException {
+ if (isUsingCamelCase()) {
+ if (context.isBackward()) {
+ context.setNextWordOffset(CamelCaseOperations.previousCamelCasePosition(context.getComponent()));
+ } else {
+ context.setNextWordOffset(CamelCaseOperations.nextCamelCasePosition(context.getComponent()));
+ }
+ }
+ }
+
+ @Override
+ public void afterChange(MutableContext context) throws BadLocationException {
+ }
+
+ @Override
+ public void cancelled(MutableContext context) {
+ }
+
+ @MimeRegistrations({
+ @MimeRegistration(mimeType = JAVA_MIME_TYPE, service = CamelCaseInterceptor.Factory.class),
+ @MimeRegistration(mimeType = "text/x-javadoc", service = CamelCaseInterceptor.Factory.class), //NOI18N
+ @MimeRegistration(mimeType = "text/x-java-string", service = CamelCaseInterceptor.Factory.class), //NOI18N
+ @MimeRegistration(mimeType = "text/x-java-character", service = CamelCaseInterceptor.Factory.class) //NOI18N
+ })
+ @MimeRegistration(mimeType = JAVA_MIME_TYPE, service = CamelCaseInterceptor.Factory.class)
+ public static class JavaFactory implements CamelCaseInterceptor.Factory {
+
+ @Override
+ public CamelCaseInterceptor createCamelCaseInterceptor(MimePath mimePath) {
+ return new JavaCamelCaseInterceptor();
+ }
+ }
+ }
}
diff --git a/java.editor/src/org/netbeans/modules/editor/java/DeleteToNextCamelCasePosition.java b/java.editor/src/org/netbeans/modules/editor/java/DeleteToNextCamelCasePosition.java
deleted file mode 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/DeleteToNextCamelCasePosition.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.modules.editor.java;
-
-import javax.swing.Action;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.JTextComponent;
-
-/**
- *
- * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
- */
-/* package */ final class DeleteToNextCamelCasePosition extends SelectNextCamelCasePosition {
-
- public DeleteToNextCamelCasePosition(Action originalAction) {
- super(JavaKit.deleteNextCamelCasePosition, originalAction);
- }
-
- protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
- textComponent.getDocument().remove(textComponent.getCaretPosition(), offset - textComponent.getCaretPosition());
- }
-}
-
diff --git a/java.editor/src/org/netbeans/modules/editor/java/DeleteToPreviousCamelCasePosition.java b/java.editor/src/org/netbeans/modules/editor/java/DeleteToPreviousCamelCasePosition.java
deleted file mode 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/DeleteToPreviousCamelCasePosition.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.modules.editor.java;
-
-import javax.swing.Action;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.JTextComponent;
-
-/**
- *
- * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
- */
-/* package */ final class DeleteToPreviousCamelCasePosition extends PreviousCamelCasePosition {
-
- public DeleteToPreviousCamelCasePosition(Action originalAction) {
- super(JavaKit.deletePreviousCamelCasePosition, originalAction);
- }
-
- protected @Override void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
- textComponent.getDocument().remove(offset, textComponent.getCaretPosition() - offset);
- }
-}
-
diff --git a/java.editor/src/org/netbeans/modules/editor/java/JavaKit.java b/java.editor/src/org/netbeans/modules/editor/java/JavaKit.java
--- a/java.editor/src/org/netbeans/modules/editor/java/JavaKit.java
+++ b/java.editor/src/org/netbeans/modules/editor/java/JavaKit.java
@@ -218,18 +218,6 @@
public static final String selectPreviousElementAction = "select-element-previous"; //NOI18N
- /* package */ static final String previousCamelCasePosition = "previous-camel-case-position"; //NOI18N
-
- /* package */ static final String nextCamelCasePosition = "next-camel-case-position"; //NOI18N
-
- /* package */ static final String selectPreviousCamelCasePosition = "select-previous-camel-case-position"; //NOI18N
-
- /* package */ static final String selectNextCamelCasePosition = "select-next-camel-case-position"; //NOI18N
-
- /* package */ static final String deletePreviousCamelCasePosition = "delete-previous-camel-case-position"; //NOI18N
-
- /* package */ static final String deleteNextCamelCasePosition = "delete-next-camel-case-position"; //NOI18N
-
// public static Action create(FileObject file) {
// initialize();
//
@@ -273,13 +261,6 @@
new JavaMoveCodeElementAction(EditorActionNames.moveCodeElementUp, false),
new JavaMoveCodeElementAction(EditorActionNames.moveCodeElementDown, true),
- new JavaNextWordAction(nextWordAction),
- new JavaPreviousWordAction(previousWordAction),
- new JavaNextWordAction(selectionNextWordAction),
- new JavaPreviousWordAction(selectionPreviousWordAction),
- new DeleteToNextCamelCasePosition(findAction(superActions, removeNextWordAction)),
- new DeleteToPreviousCamelCasePosition(findAction(superActions, removePreviousWordAction)),
-
new FastImportAction(),
new GoToSuperTypeAction(),
@@ -291,16 +272,6 @@
return TextAction.augmentList(superActions, actions);
}
- private static Action findAction(Action [] actions, String name) {
- for(Action a : actions) {
- Object nameObj = a.getValue(Action.NAME);
- if (nameObj instanceof String && name.equals(nameObj)) {
- return a;
- }
- }
- return null;
- }
-
@Override
public void install(JEditorPane c) {
super.install(c);
@@ -837,38 +808,4 @@
}
}
-
- private static boolean isUsingCamelCase() {
- return NbPreferences.root().getBoolean("useCamelCaseStyleNavigation", true); // NOI18N
- }
-
- public static class JavaNextWordAction extends NextWordAction {
-
- JavaNextWordAction(String name) {
- super(name);
- }
-
- @Override
- protected int getNextWordOffset(JTextComponent target) throws BadLocationException {
- return isUsingCamelCase()
- ? CamelCaseOperations.nextCamelCasePosition(target)
- : super.getNextWordOffset(target);
- }
-
- }
-
- public static class JavaPreviousWordAction extends PreviousWordAction {
-
- JavaPreviousWordAction(String name) {
- super(name);
- }
-
- protected int getPreviousWordOffset(JTextComponent target) throws BadLocationException {
- return isUsingCamelCase()
- ? CamelCaseOperations.previousCamelCasePosition(target)
- : super.getPreviousWordOffset(target);
- }
-
- }
-
}
diff --git a/java.editor/src/org/netbeans/modules/editor/java/NextCamelCasePosition.java b/java.editor/src/org/netbeans/modules/editor/java/NextCamelCasePosition.java
deleted file mode 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/NextCamelCasePosition.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.modules.editor.java;
-
-import javax.swing.Action;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.JTextComponent;
-
-/**
- *
- * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
- */
-/* package */ class NextCamelCasePosition extends AbstractCamelCasePosition {
-
- public NextCamelCasePosition(Action originalAction) {
- this(JavaKit.nextCamelCasePosition, originalAction);
- }
-
- protected NextCamelCasePosition(String name, Action originalAction) {
- super(name, originalAction);
- }
-
- protected int newOffset(JTextComponent textComponent) throws BadLocationException {
- return CamelCaseOperations.nextCamelCasePosition(textComponent);
- }
-
- protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
- textComponent.setCaretPosition(offset);
- }
-}
diff --git a/java.editor/src/org/netbeans/modules/editor/java/PreviousCamelCasePosition.java b/java.editor/src/org/netbeans/modules/editor/java/PreviousCamelCasePosition.java
deleted file mode 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/PreviousCamelCasePosition.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.modules.editor.java;
-
-import javax.swing.Action;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.JTextComponent;
-
-/**
- *
- * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
- */
-/* package */ class PreviousCamelCasePosition extends AbstractCamelCasePosition {
-
- public PreviousCamelCasePosition(Action originalAction) {
- this(JavaKit.previousCamelCasePosition, originalAction);
- }
-
- protected PreviousCamelCasePosition(String name, Action originalAction) {
- super(name, originalAction);
- }
-
- protected int newOffset(JTextComponent textComponent) throws BadLocationException {
- return CamelCaseOperations.previousCamelCasePosition(textComponent);
- }
-
- protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
- textComponent.setCaretPosition(offset);
- }
-}
-
diff --git a/java.editor/src/org/netbeans/modules/editor/java/SelectNextCamelCasePosition.java b/java.editor/src/org/netbeans/modules/editor/java/SelectNextCamelCasePosition.java
deleted file mode 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/SelectNextCamelCasePosition.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.modules.editor.java;
-
-import javax.swing.Action;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.JTextComponent;
-
-/**
- *
- * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
- */
-/* package */ class SelectNextCamelCasePosition extends NextCamelCasePosition {
-
- public SelectNextCamelCasePosition(Action originalAction) {
- this(JavaKit.selectNextCamelCasePosition, originalAction);
- }
-
- protected SelectNextCamelCasePosition(String name, Action originalAction) {
- super(name, originalAction);
- }
-
- protected void moveToNewOffset(JTextComponent textComponent, int offset) throws BadLocationException {
- textComponent.getCaret().moveDot(offset);
- }
-}
-
diff --git a/java.editor/src/org/netbeans/modules/editor/java/SelectPreviousCamelCasePosition.java b/java.editor/src/org/netbeans/modules/editor/java/SelectPreviousCamelCasePosition.java
deleted file mode 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/SelectPreviousCamelCasePosition.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.modules.editor.java;
-
-import javax.swing.Action;
-import javax.swing.text.JTextComponent;
-
-/**
- *
- * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
- */
-/* package */ class SelectPreviousCamelCasePosition extends PreviousCamelCasePosition {
-
- public SelectPreviousCamelCasePosition(Action originalAction) {
- this(JavaKit.selectPreviousCamelCasePosition, originalAction);
- }
-
- protected SelectPreviousCamelCasePosition(String name, Action originalAction) {
- super(name, originalAction);
- }
-
- protected void moveToNewOffset(JTextComponent textComponent, int offset) {
- textComponent.getCaret().moveDot(offset);
- }
-}
-