--- a/editor.actions/build.xml
+++ a/editor.actions/build.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
--- a/editor.actions/manifest.mf
+++ a/editor.actions/manifest.mf
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+OpenIDE-Module: org.netbeans.modules.editor.actions/1
+OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/actions/Bundle.properties
+AutoUpdate-Show-In-Client: false
+OpenIDE-Module-Provides: org.netbeans.modules.editor.actions
--- a/editor.actions/nbproject/project.properties
+++ a/editor.actions/nbproject/project.properties
@@ -0,0 +1,46 @@
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+#
+# 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. Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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.
+
+javac.compilerargs=-Xlint:unchecked
+javac.source=1.5
+javadoc.title=Editor Actions
+spec.version.base=1.0.0
+
+#javadoc.arch=${basedir}/arch.xml
+#javadoc.apichanges=${basedir}/apichanges.xml
--- a/editor.actions/nbproject/project.xml
+++ a/editor.actions/nbproject/project.xml
@@ -0,0 +1,98 @@
+
+
+
+ org.netbeans.modules.apisupport.project
+
+
+ org.netbeans.modules.editor.actions
+
+
+ org.netbeans.modules.editor.lib
+
+
+
+ 1
+ 1.40
+
+
+
+ org.netbeans.modules.editor.lib2
+
+
+
+ 1
+
+
+
+
+ org.netbeans.modules.editor.mimelookup
+
+
+
+ 1
+ 1.12
+
+
+
+ org.netbeans.modules.editor.settings
+
+
+
+ 1
+ 1.25
+
+
+
+ org.openide.util
+
+
+
+ 7.24
+
+
+
+
+
+
+
+
--- a/editor.actions/src/org/netbeans/modules/editor/actions/Bundle.properties
+++ a/editor.actions/src/org/netbeans/modules/editor/actions/Bundle.properties
@@ -0,0 +1,51 @@
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+#
+# 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. Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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.
+
+OpenIDE-Module-Name=Editor Actions
+OpenIDE-Module-Display-Category=Editing
+OpenIDE-Module-Short-Description=Contains editor actions implementations
+OpenIDE-Module-Long-Description=Editor Actions module contains default editor actions implementations.
+
+# Actions
+toggle-toolbar=Toggle Toolbar
+toggle-toolbar_menu_text=S&how Editor Toolbar
+toggle-line-numbers=Toggle Line Numbers
+toggle-line-numbers_menu_text=&Show Line Numbers
+goto-declaration=Go to Declaration
+goto-declaration_menu_text=Go to &Declaration
--- a/editor.actions/src/org/netbeans/modules/editor/actions/GotoAction.java
+++ a/editor.actions/src/org/netbeans/modules/editor/actions/GotoAction.java
@@ -0,0 +1,99 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 2008 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.editor.actions;
+
+import org.netbeans.spi.editor.AbstractEditorAction;
+import java.awt.event.ActionEvent;
+import java.util.logging.Logger;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Caret;
+import javax.swing.text.JTextComponent;
+import org.netbeans.api.editor.EditorActionRegistration;
+import org.netbeans.api.editor.EditorActionRegistrations;
+import org.netbeans.editor.BaseDocument;
+import org.netbeans.editor.Utilities;
+import org.netbeans.editor.ext.ExtSyntaxSupport;
+import org.netbeans.api.editor.EditorActionNames;
+
+/**
+ * Toggle toolbar/lines visibility.
+ *
+ * @author Miloslav Metelka
+ * @since 1.13
+ */
+
+@EditorActionRegistrations({
+ @EditorActionRegistration(
+ name = EditorActionNames.gotoDeclaration,
+ menuPath = "GoTo",
+ menuPosition = 900,
+ menuText = "#" + EditorActionNames.gotoDeclaration + "_menu_text"
+ )
+})
+public final class GotoAction extends AbstractEditorAction {
+
+ // -J-Dorg.netbeans.modules.editor.actions.GotoAction.level=FINEST
+ private static final Logger LOG = Logger.getLogger(GotoAction.class.getName());
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent evt, JTextComponent target) {
+ String actionName = actionName();
+ if (EditorActionNames.gotoDeclaration.equals(actionName)) {
+ resetCaretMagicPosition(target);
+ BaseDocument doc = Utilities.getDocument(target);
+ if (doc != null) {
+ try {
+ Caret caret = target.getCaret();
+ int dotPos = caret.getDot();
+ int[] idBlk = Utilities.getIdentifierBlock(doc, dotPos);
+ ExtSyntaxSupport extSup = (ExtSyntaxSupport)doc.getSyntaxSupport();
+ if (idBlk != null) {
+ int decPos = extSup.findDeclarationPosition(doc.getText(idBlk), idBlk[1]);
+ if (decPos >= 0) {
+ caret.setDot(decPos);
+ }
+ }
+ } catch (BadLocationException e) {
+ }
+ }
+ }
+ }
+
+}
--- a/editor.actions/src/org/netbeans/modules/editor/actions/ToggleAction.java
+++ a/editor.actions/src/org/netbeans/modules/editor/actions/ToggleAction.java
@@ -0,0 +1,87 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 2008 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.editor.actions;
+
+import java.awt.event.ActionEvent;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.text.JTextComponent;
+import org.netbeans.spi.editor.AbstractEditorAction;
+import org.netbeans.api.editor.EditorActionRegistration;
+import org.netbeans.api.editor.EditorActionRegistrations;
+import org.netbeans.api.editor.settings.SimpleValueNames;
+import org.netbeans.api.editor.EditorActionNames;
+
+/**
+ * Toggle toolbar/lines visibility.
+ *
+ * @author Miloslav Metelka
+ */
+@EditorActionRegistrations({
+ @EditorActionRegistration(
+ name = EditorActionNames.toggleToolbar,
+ menuPath = "View",
+ menuPosition = 800,
+ menuText = "#" + EditorActionNames.toggleToolbar + "_menu_text",
+ preferencesKey = SimpleValueNames.TOOLBAR_VISIBLE_PROP
+ ),
+ @EditorActionRegistration(
+ name = EditorActionNames.toggleLineNumbers,
+ menuPath = "View",
+ menuPosition = 850,
+ menuText = "#" + EditorActionNames.toggleLineNumbers + "_menu_text",
+ preferencesKey = SimpleValueNames.LINE_NUMBER_VISIBLE
+ )
+})
+public final class ToggleAction extends AbstractEditorAction {
+
+ private static final Logger LOG = Logger.getLogger(ToggleAction.class.getName());
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void actionPerformed(ActionEvent evt, JTextComponent component) {
+ // Leave empty - AlwaysEnabledAction toggles state in preferences by default
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("actionPerformed: actionName=" + actionName());
+ }
+ }
+
+}
--- a/editor.deprecated.pre61settings/nbproject/project.xml
+++ a/editor.deprecated.pre61settings/nbproject/project.xml
@@ -65,6 +65,15 @@
+ org.netbeans.modules.editor.lib2
+
+
+
+ 1
+
+
+
+ org.netbeans.modules.editor.mimelookup
--- a/editor.deprecated.pre61settings/src/org/netbeans/editor/SettingsDefaults.java
+++ a/editor.deprecated.pre61settings/src/org/netbeans/editor/SettingsDefaults.java
@@ -48,7 +48,7 @@
import javax.swing.UIManager;
import java.util.Map;
import java.util.HashMap;
-import org.netbeans.modules.editor.lib.EditorPreferencesDefaults;
+import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
/**
* Default values for the settings. They are used
@@ -156,8 +156,8 @@
public static final Color defaultTextLimitLineColor = new Color(255, 235, 235);
public static final Integer defaultTextLimitWidth = EditorPreferencesDefaults.defaultTextLimitWidth;
- public static final Acceptor defaultIdentifierAcceptor = EditorPreferencesDefaults.defaultIdentifierAcceptor;
- public static final Acceptor defaultWhitespaceAcceptor = EditorPreferencesDefaults.defaultWhitespaceAcceptor;
+// public static final Acceptor defaultIdentifierAcceptor = EditorPreferencesDefaults.defaultIdentifierAcceptor;
+// public static final Acceptor defaultWhitespaceAcceptor = EditorPreferencesDefaults.defaultWhitespaceAcceptor;
public static final Float defaultLineHeightCorrection = EditorPreferencesDefaults.defaultLineHeightCorrection;
--- a/editor.deprecated.pre61settings/src/org/netbeans/editor/SettingsNames.java
+++ a/editor.deprecated.pre61settings/src/org/netbeans/editor/SettingsNames.java
@@ -41,7 +41,7 @@
package org.netbeans.editor;
-import org.netbeans.modules.editor.lib.EditorPreferencesKeys;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
/**
* Names of the base settings defined in the editor. The other packages
--- a/editor.deprecated.pre61settings/src/org/netbeans/editor/ext/ExtSettingsNames.java
+++ a/editor.deprecated.pre61settings/src/org/netbeans/editor/ext/ExtSettingsNames.java
@@ -42,7 +42,7 @@
package org.netbeans.editor.ext;
import org.netbeans.editor.SettingsNames;
-import org.netbeans.modules.editor.lib.EditorPreferencesKeys;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
/**
* Names of the extended editor settings.
--- a/editor.lib/nbproject/project.xml
+++ a/editor.lib/nbproject/project.xml
@@ -87,7 +87,7 @@
1
- 1.25
+ 1.30
--- a/editor.lib/src/org/netbeans/editor/ActionFactory.java
+++ a/editor.lib/src/org/netbeans/editor/ActionFactory.java
@@ -2031,7 +2031,10 @@
}
- /** Switch visibility of line numbers in editor */
+ /**
+ * Switch visibility of line numbers in editor
+ * @deprecated this action is no longer used. It is reimplemented in editor.actions module.
+ */
//@EditorActionRegistration(name = BaseKit.toggleLineNumbersAction)
// Registration in createActions() due to getPopupMenuItem()
public static class ToggleLineNumbersAction extends LocalBaseAction {
--- a/editor.lib/src/org/netbeans/editor/Analyzer.java
+++ a/editor.lib/src/org/netbeans/editor/Analyzer.java
@@ -51,7 +51,7 @@
import javax.swing.text.Document;
import javax.swing.text.Segment;
import org.netbeans.api.lexer.TokenHierarchy;
-import org.netbeans.modules.editor.lib.EditorPreferencesKeys;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import org.netbeans.spi.lexer.MutableTextInput;
/**
--- a/editor.lib/src/org/netbeans/editor/BaseAction.java
+++ a/editor.lib/src/org/netbeans/editor/BaseAction.java
@@ -56,14 +56,17 @@
import javax.swing.text.Caret;
/**
-* This is the parent of majority of the actions. It implements
-* the necessary resetting depending of what is required
-* by constructor of target action.
-* The other thing implemented here is macro recording.
-*
-* @author Miloslav Metelka
-* @version 1.00
-*/
+ * This is the parent of majority of the actions. It implements
+ * the necessary resetting depending of what is required
+ * by constructor of target action.
+ * The other thing implemented here is macro recording.
+ *
+ * Property "noIconInMenu" can be set to inform menu items not to use action's icon.
+ *
+ *
+ * @author Miloslav Metelka
+ * @version 1.00
+ */
public abstract class BaseAction extends TextAction {
@@ -120,7 +123,7 @@
* the action's real task is invoked.
*/
protected int updateMask;
-
+
private static boolean recording;
private static StringBuffer macroBuffer = new StringBuffer();
private static StringBuffer textBuffer = new StringBuffer();
--- a/editor.lib/src/org/netbeans/editor/BaseCaret.java
+++ a/editor.lib/src/org/netbeans/editor/BaseCaret.java
@@ -105,7 +105,7 @@
import org.netbeans.api.editor.settings.FontColorSettings;
import org.netbeans.api.editor.settings.SimpleValueNames;
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority;
-import org.netbeans.modules.editor.lib.EditorPreferencesDefaults;
+import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
import org.netbeans.modules.editor.lib.SettingsConversions;
import org.openide.util.WeakListeners;
@@ -122,10 +122,10 @@
AtomicLockListener, FoldHierarchyListener {
/** Caret type representing block covering current character */
- public static final String BLOCK_CARET = "block-caret"; // NOI18N
+ public static final String BLOCK_CARET = EditorPreferencesDefaults.BLOCK_CARET; // NOI18N
/** Default caret type */
- public static final String LINE_CARET = "line-caret"; // NOI18N
+ public static final String LINE_CARET = EditorPreferencesDefaults.LINE_CARET; // NOI18N
/** One dot thin line compatible with Swing default caret */
public static final String THIN_LINE_CARET = "thin-line-caret"; // NOI18N
--- a/editor.lib/src/org/netbeans/editor/BaseDocument.java
+++ a/editor.lib/src/org/netbeans/editor/BaseDocument.java
@@ -92,8 +92,8 @@
import org.netbeans.lib.editor.util.ListenerList;
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority;
import org.netbeans.modules.editor.lib.EditorPackageAccessor;
-import org.netbeans.modules.editor.lib.EditorPreferencesDefaults;
-import org.netbeans.modules.editor.lib.EditorPreferencesKeys;
+import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import org.netbeans.modules.editor.lib.FormatterOverride;
import org.netbeans.modules.editor.lib.TrailingWhitespaceRemove;
import org.netbeans.modules.editor.lib.SettingsConversions;
--- a/editor.lib/src/org/netbeans/editor/BaseKit.java
+++ a/editor.lib/src/org/netbeans/editor/BaseKit.java
@@ -74,6 +74,8 @@
import java.util.prefs.PreferenceChangeListener;
import java.util.prefs.Preferences;
import javax.swing.KeyStroke;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import javax.swing.text.AbstractDocument;
import javax.swing.text.EditorKit;
import javax.swing.text.Position;
@@ -82,9 +84,10 @@
import org.netbeans.api.editor.mimelookup.MimeLookup;
import org.netbeans.api.editor.mimelookup.MimePath;
import org.netbeans.api.editor.settings.KeyBindingSettings;
+import org.netbeans.lib.editor.util.ListenerList;
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
-import org.netbeans.modules.editor.lib.EditorPreferencesDefaults;
-import org.netbeans.modules.editor.lib.EditorPreferencesKeys;
+import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import org.netbeans.modules.editor.lib.KitsTracker;
import org.netbeans.modules.editor.lib.NavigationHistory;
import org.netbeans.modules.editor.lib.SettingsConversions;
@@ -113,6 +116,7 @@
*/
static ThreadLocal IN_PASTE = new ThreadLocal();
+ // -J-Dorg.netbeans.editor.BaseKit.level=FINEST
private static final Logger LOG = Logger.getLogger(BaseKit.class.getName());
/** split the current line at cursor position */
@@ -352,6 +356,8 @@
public static final int MAGIC_POSITION_MAX = Integer.MAX_VALUE - 1;
+ private final SearchableKit searchableKit;
+
// static SettingsChangeListener settingsListener = new SettingsChangeListener() {
// public void settingsChange(SettingsChangeEvent evt) {
// String settingName = (evt != null) ? evt.getSettingName() : null;
@@ -534,6 +540,10 @@
kits.put(this.getClass(), this); // register itself
}
}
+ // Directly implementing searchable editor kit would require module dependency changes
+ // of any modules using BaseKit reference so make a wrapper instead
+ org.netbeans.modules.editor.lib2.actions.EditorActionUtilities.registerSearchableKit(this,
+ searchableKit = new SearchableKit(this));
}
/** Clone this editor kit */
@@ -691,21 +701,34 @@
/** Creates map with [name, action] pairs from the given
* array of actions.
*/
- public static Map actionsToMap(Action[] actions) {
- Map map = new HashMap();
+ public static void addActionsToMap(Map map, Action[] actions, String logActionsType) {
+ boolean fineLoggable = LOG.isLoggable(Level.FINE);
+ if (fineLoggable) {
+ LOG.fine(logActionsType + " start --------------------\n");
+ }
for (int i = 0; i < actions.length; i++) {
Action a = actions[i];
if (a == null) {
- throw new IllegalStateException("actions[] contains null at index " + i +
- ((i > 0) ? ". Preceding action is " + actions[i - 1] : ""));
+ LOG.info("actions[] contains null at index " + i +
+ ((i > 0) ? ". Preceding action is " + actions[i - 1] : "."));
+ continue;
}
String name = (String) a.getValue(Action.NAME);
if (name == null) {
- throw new IllegalStateException("Null Action.NAME property of action " + a);
+ LOG.info("Null Action.NAME property of action " + a);
+ continue;
}
+
+ if (fineLoggable) {
+ String overriding = map.containsKey(name) ? " OVERRIDING\n" : "\n"; // NOI18N
+ LOG.fine(" " + name + ": " + a + overriding); // NOI18N
+ }
+
map.put(name, a); // NOI18N
}
- return map;
+ if (fineLoggable) {
+ LOG.fine(logActionsType + " end ----------------------\n");
+ }
}
/** Converts map with [name, action] back
@@ -848,7 +871,7 @@
removeSelectionActionDef,
undoActionDef,
redoActionDef,
- new ActionFactory.ToggleLineNumbersAction(),
+ //new ActionFactory.ToggleLineNumbersAction(),
new NextWordAction(nextWordAction),
new NextWordAction(selectionNextWordAction),
new PreviousWordAction(previousWordAction),
@@ -895,31 +918,43 @@
* to get basic list and then customActions are added.
*/
public @Override final Action[] getActions() {
- return (Action []) getActionsAndMap()[0];
+ return (Action []) addActionsToMap()[0];
}
/* package */ Map getActionMap() {
- return (Map) getActionsAndMap()[1];
+ return (Map) addActionsToMap()[1];
}
- private Object[] getActionsAndMap() {
+ private Object[] addActionsToMap() {
synchronized (KEYMAPS_AND_ACTIONS_LOCK) {
MimePath mimePath = MimePath.parse(getContentType());
Action[] actions = kitActions.get(mimePath);
Map actionMap = kitActionMaps.get(mimePath);
if (actions == null || actionMap == null) {
- // create map of actions
- actions = createActions();
- actionMap = actionsToMap(actions);
+ // Initialize actions - use the following actions:
+ // 1. Declared "global" actions (declared in the xml layer under "Editors/Actions")
+ // 2. Declared "mime-type actions (declared in the xml layer under "Editors/content-type/Actions")
+ // 3. Result of createActions()
+ // 4. Custom actions (EditorPreferencesKeys.CUSTOM_ACTION_LIST)
+ // Higher levels override actions with same Action.NAME
+ actions = getDeclaredActions(); // non-null
+ actionMap = new HashMap(actions.length << 1);
+ addActionsToMap(actionMap, actions, "Declared actions"); // NOI18N
+
+ Action[] createActionsMethodResult = createActions();
+ if (createActionsMethodResult != null) {
+ addActionsToMap(actionMap, createActionsMethodResult, "Actions from createActions()"); // NOI18N
+ }
// add custom actions
Action[] customActions = getCustomActions();
if (customActions != null) {
- actionMap.putAll(actionsToMap(customActions));
- actions = actionMap.values().toArray(new Action[actionMap.values().size()]);
+ addActionsToMap(actionMap, customActions, "Custom actions"); // NOI18N
}
+ actions = actionMap.values().toArray(new Action[actionMap.values().size()]);
+
kitActions.put(mimePath, actions);
kitActionMaps.put(mimePath, actionMap);
@@ -932,6 +967,16 @@
return new Object [] { actions, actionMap };
}
}
+
+ /**
+ * Get actions declared in the xml layer. They may be overriden by result
+ * of createActions() and finally by result of getCustomActions().
+ *
+ * @return non-null list of declared actions.
+ */
+ protected Action[] getDeclaredActions() {
+ return new Action[0];
+ }
/** Update the actions right after their creation was finished.
* The getActions() and getActionByName()
@@ -1309,7 +1354,11 @@
}
}
- /** Compound action that encapsulates several actions */
+ /**
+ * Compound action that encapsulates several actions
+ * @deprecated this action is no longer used.
+ */
+ @Deprecated
public static class CompoundAction extends LocalBaseAction {
Action[] actions;
@@ -1339,11 +1388,14 @@
}
}
- /** Compound action that gets and executes its actions
- * depending on the kit of the component.
- * The other advantage is that it doesn't create additional
- * instances of compound actions.
- */
+ /**
+ * Compound action that gets and executes its actions
+ * depending on the kit of the component.
+ * The other advantage is that it doesn't create additional
+ * instances of compound actions.
+ * @deprecated this action is no longer used. It is reimplemented in editor.actions module.
+ */
+ @Deprecated
public static class KitCompoundAction extends LocalBaseAction {
private String[] actionNames;
@@ -1387,7 +1439,11 @@
}
}
- @EditorActionRegistration(name = insertContentAction)
+ /**
+ * @deprecated this action is no longer used. It is reimplemented in editor.actions module.
+ */
+// @EditorActionRegistration(name = insertContentAction)
+ @Deprecated
public static class InsertContentAction extends LocalBaseAction {
static final long serialVersionUID =5647751370952797218L;
@@ -1501,7 +1557,11 @@
}
}
- @EditorActionRegistration(name = readOnlyAction)
+ /**
+ * @deprecated this action is no longer used. It is reimplemented in editor.actions module.
+ */
+ @Deprecated
+// @EditorActionRegistration(name = readOnlyAction)
public static class ReadOnlyAction extends LocalBaseAction {
static final long serialVersionUID =9204335480208463193L;
@@ -1517,7 +1577,11 @@
}
}
- @EditorActionRegistration(name = writableAction)
+ /**
+ * @deprecated this action is no longer used. It is reimplemented in editor.actions module.
+ */
+ @Deprecated
+// @EditorActionRegistration(name = writableAction)
public static class WritableAction extends LocalBaseAction {
static final long serialVersionUID =-5982547952800937954L;
@@ -2725,7 +2789,41 @@
for(JTextComponent c : arr) {
c.setKeymap(keymap);
}
+
+ searchableKit.fireActionsChange();
}
} // End of KeymapTracker class
+
+ private static final class SearchableKit implements org.netbeans.modules.editor.lib2.actions.SearchableEditorKit {
+
+ private final BaseKit baseKit;
+
+ private final ListenerList actionsListenerList = new ListenerList();
+
+ SearchableKit(BaseKit baseKit) {
+ this.baseKit = baseKit;
+ }
+
+ public Action getAction(String actionName) {
+ return baseKit.getActionByName(actionName);
+ }
+
+ public void addActionsChangeListener(ChangeListener listener) {
+ actionsListenerList.add(listener);
+ }
+
+ public void removeActionsChangeListener(ChangeListener listener) {
+ actionsListenerList.remove(listener);
+ }
+
+ void fireActionsChange() {
+ ChangeEvent evt = new ChangeEvent(this);
+ for (ChangeListener listener : actionsListenerList.getListeners()) {
+ listener.stateChanged(evt);
+ }
+ }
+
+ }
+
}
--- a/editor.lib/src/org/netbeans/editor/BaseTextUI.java
+++ a/editor.lib/src/org/netbeans/editor/BaseTextUI.java
@@ -66,8 +66,8 @@
import org.netbeans.api.editor.settings.SimpleValueNames;
import org.netbeans.modules.editor.lib2.EditorApiPackageAccessor;
import org.netbeans.editor.view.spi.LockView;
-import org.netbeans.modules.editor.lib.EditorPreferencesDefaults;
-import org.netbeans.modules.editor.lib.EditorPreferencesKeys;
+import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import org.netbeans.modules.editor.lib.SettingsConversions;
import org.openide.util.WeakListeners;
--- a/editor.lib/src/org/netbeans/editor/CodeFoldingSideBar.java
+++ a/editor.lib/src/org/netbeans/editor/CodeFoldingSideBar.java
@@ -84,7 +84,7 @@
import org.netbeans.api.editor.settings.FontColorSettings;
import org.netbeans.api.editor.settings.SimpleValueNames;
import org.netbeans.editor.CodeFoldingSideBar.PaintInfo;
-import org.netbeans.modules.editor.lib.EditorPreferencesDefaults;
+import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
import org.netbeans.modules.editor.lib.SettingsConversions;
import org.openide.util.Lookup;
import org.openide.util.LookupEvent;
--- a/editor.lib/src/org/netbeans/editor/EditorUI.java
+++ a/editor.lib/src/org/netbeans/editor/EditorUI.java
@@ -86,8 +86,8 @@
import org.netbeans.editor.ext.ExtKit;
import org.netbeans.editor.ext.ToolTipSupport;
import org.netbeans.modules.editor.lib.ColoringMap;
-import org.netbeans.modules.editor.lib.EditorPreferencesDefaults;
-import org.netbeans.modules.editor.lib.EditorPreferencesKeys;
+import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import org.netbeans.modules.editor.lib.KitsTracker;
import org.netbeans.modules.editor.lib.SettingsConversions;
import org.openide.util.WeakListeners;
--- a/editor.lib/src/org/netbeans/editor/Formatter.java
+++ a/editor.lib/src/org/netbeans/editor/Formatter.java
@@ -61,7 +61,7 @@
import org.netbeans.api.editor.settings.SimpleValueNames;
import org.netbeans.lib.editor.util.CharSequenceUtilities;
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
-import org.netbeans.modules.editor.lib.EditorPreferencesDefaults;
+import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
import org.netbeans.modules.editor.lib.KitsTracker;
import org.netbeans.modules.editor.lib.SettingsConversions;
import org.openide.util.Lookup;
--- a/editor.lib/src/org/netbeans/editor/StatusBar.java
+++ a/editor.lib/src/org/netbeans/editor/StatusBar.java
@@ -86,7 +86,7 @@
import org.netbeans.api.editor.settings.FontColorNames;
import org.netbeans.api.editor.settings.FontColorSettings;
import org.netbeans.api.editor.settings.SimpleValueNames;
-import org.netbeans.modules.editor.lib.EditorPreferencesDefaults;
+import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
import org.openide.util.NbBundle;
import org.openide.util.WeakListeners;
--- a/editor.lib/src/org/netbeans/editor/Utilities.java
+++ a/editor.lib/src/org/netbeans/editor/Utilities.java
@@ -61,7 +61,7 @@
import javax.swing.text.View;
import org.netbeans.lib.editor.util.CharSequenceUtilities;
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
-import org.netbeans.modules.editor.lib.EditorPreferencesKeys;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import org.openide.util.NbBundle;
/**
--- a/editor.lib/src/org/netbeans/editor/WordMatch.java
+++ a/editor.lib/src/org/netbeans/editor/WordMatch.java
@@ -52,8 +52,8 @@
import javax.swing.text.BadLocationException;
import javax.swing.text.JTextComponent;
import org.netbeans.api.editor.mimelookup.MimeLookup;
-import org.netbeans.modules.editor.lib.EditorPreferencesDefaults;
-import org.netbeans.modules.editor.lib.EditorPreferencesKeys;
+import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import org.openide.util.WeakListeners;
/** Word matching support enables to fill in the rest of the word
--- a/editor.lib/src/org/netbeans/editor/ext/ExtFormatter.java
+++ a/editor.lib/src/org/netbeans/editor/ext/ExtFormatter.java
@@ -65,7 +65,7 @@
import org.netbeans.editor.AcceptorFactory;
import org.netbeans.editor.BaseKit;
import org.netbeans.editor.Syntax;
-import org.netbeans.modules.editor.lib.EditorPreferencesKeys;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import org.netbeans.modules.editor.lib.SettingsConversions;
import org.openide.util.Lookup;
import org.openide.util.WeakListeners;
--- a/editor.lib/src/org/netbeans/editor/ext/ExtKit.java
+++ a/editor.lib/src/org/netbeans/editor/ext/ExtKit.java
@@ -68,6 +68,7 @@
import org.netbeans.lib.editor.util.CharSequenceUtilities;
import org.netbeans.lib.editor.util.swing.DocumentUtilities;
import org.netbeans.modules.editor.lib.NavigationHistory;
+import org.netbeans.api.editor.EditorActionNames;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
@@ -111,7 +112,7 @@
public static final String gotoAction = "goto"; // NOI18N
/** Goto declaration depending on the context under the caret */
- public static final String gotoDeclarationAction = "goto-declaration"; // NOI18N
+ public static final String gotoDeclarationAction = EditorActionNames.gotoDeclaration; // NOI18N
/** Goto source depending on the context under the caret */
public static final String gotoSourceAction = "goto-source"; // NOI18N
@@ -160,7 +161,7 @@
public static final String toggleCommentAction = "toggle-comment"; // NOI18N
/** Toggle the toolbar */
- public static final String toggleToolbarAction = "toggle-toolbar"; // NOI18N
+ public static final String toggleToolbarAction = EditorActionNames.toggleToolbar;
/** Trimmed text for go to submenu*/
public static final String TRIMMED_TEXT = "trimmed-text"; //NOI18N
@@ -553,8 +554,10 @@
}
- /** Action to go to the declaration of the variable under the caret.
- */
+ /**
+ * Action to go to the declaration of the variable under the caret.
+ * @deprecated this action is no longer used. It is reimplemented in editor.actions module.
+ */
public static class GotoDeclarationAction extends BaseKitLocalizedAction {
static final long serialVersionUID =-6440495023918097760L;
--- a/editor.lib/src/org/netbeans/modules/editor/lib/ColoringMap.java
+++ a/editor.lib/src/org/netbeans/modules/editor/lib/ColoringMap.java
@@ -40,6 +40,7 @@
*/
package org.netbeans.modules.editor.lib;
+import org.netbeans.modules.editor.lib2.EditorPreferencesKeys;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.lang.reflect.Field;
--- a/editor.lib/src/org/netbeans/modules/editor/lib/SettingsConversions.java
+++ a/editor.lib/src/org/netbeans/modules/editor/lib/SettingsConversions.java
@@ -52,6 +52,7 @@
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.editor.Acceptor;
import org.openide.util.Lookup;
/**
@@ -259,7 +260,7 @@
}
}
}
-
+
private SettingsConversions() {
}
--- a/editor.lib2/manifest.mf
+++ a/editor.lib2/manifest.mf
@@ -3,3 +3,4 @@
OpenIDE-Module-Implementation-Version: 2
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/lib2/Bundle.properties
OpenIDE-Module-Layer: org/netbeans/modules/editor/lib2/resources/layer.xml
+OpenIDE-Module-Needs: org.netbeans.modules.editor.actions
--- a/editor.lib2/nbproject/project.properties
+++ a/editor.lib2/nbproject/project.properties
@@ -40,7 +40,7 @@
is.autoload=true
javac.source=1.5
javac.compilerargs=-Xlint:unchecked
-spec.version.base=1.13.0
+spec.version.base=1.14.0
cp.extra=${nb_all}/apisupport.harness/external/openjdk-javac-6-b12.jar
javadoc.arch=${basedir}/arch.xml
--- a/editor.lib2/nbproject/project.xml
+++ a/editor.lib2/nbproject/project.xml
@@ -87,7 +87,7 @@
- 7.7
+ 7.25
--- a/editor.lib2/src/org/netbeans/api/editor/EditorActionNames.java
+++ a/editor.lib2/src/org/netbeans/api/editor/EditorActionNames.java
@@ -0,0 +1,69 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 2008 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.api.editor;
+
+/**
+ * Names of common editor actions.
+ * Clients can use the names constants e.g. for
+ *
+ * Retrieving (and possibly running) action's impl for a particular kit by
+ * {@link EditorUtilities#getAction(javax.swing.text.EditorKit, java.lang.String)}.
+ *
+ *
+ * When overriding action's impl for a target mime-type (rather than using a string literal).
+ *
+ *
+ * Ideally all editor actions' names should be declared here.
+ *
+ * @author Miloslav Metelka
+ * @since 1.13
+ */
+public final class EditorActionNames {
+
+ /** Toggle the visibility of the editor toolbar */
+ public static final String toggleToolbar = "toggle-toolbar"; // NOI18N
+
+ /** Toggle visibility of line numbers*/
+ public static final String toggleLineNumbers = "toggle-line-numbers"; // NOI18N
+
+ /** Goto declaration depending on the context under the caret */
+ public static final String gotoDeclaration = "goto-declaration"; // NOI18N
+
+}
--- a/editor.lib2/src/org/netbeans/api/editor/EditorActionRegistration.java
+++ a/editor.lib2/src/org/netbeans/api/editor/EditorActionRegistration.java
@@ -134,4 +134,45 @@
*/
String popupText() default "";
+ /**
+ * Path of this action in main menu e.g. "Edit".
+ */
+ String menuPath() default "";
+
+ /**
+ * Integer position of the main menu item among the other menu items.
+ *
+ * The default Integer.MAX_VALUE value means no menu representation.
+ */
+ int menuPosition() default Integer.MAX_VALUE;
+
+ /**
+ * Path of this action in popup menu e.g. "" for appearance right in the context menu
+ * or a corresponding path for nested submenu appearance.
+ */
+ String popupPath() default "";
+
+ /**
+ * Integer position of the popup menu item among the other popup menu (or submenu) items.
+ *
+ * The default Integer.MAX_VALUE value means no popup menu representation.
+ */
+ int popupPosition() default Integer.MAX_VALUE;
+
+ /**
+ * Integer position of this action in editor toolbar.
+ *
+ * The default Integer.MAX_VALUE value means no toolbar representation.
+ */
+ int toolBarPosition() default Integer.MAX_VALUE;
+
+ /**
+ * Boolean key in preferences that corresponds to action's selected state.
+ *
+ * If set to non-empty string the action will be represented by a check-box
+ * in menu and popup menu and the corresponding key will be set in
+ * global mime-lookup MimeLookup.getLookup(MimePath.EMPTY).
+ */
+ String preferencesKey() default "";
+
}
--- a/editor.lib2/src/org/netbeans/api/editor/EditorUtilities.java
+++ a/editor.lib2/src/org/netbeans/api/editor/EditorUtilities.java
@@ -0,0 +1,73 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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.api.editor;
+
+import javax.swing.Action;
+import javax.swing.text.EditorKit;
+import org.netbeans.modules.editor.lib2.actions.EditorActionUtilities;
+
+
+/**
+ * Various utility methods related to editor.
+ *
+ * @author Miloslav Metelka
+ * @since 1.13
+ */
+
+public final class EditorUtilities {
+
+ private EditorUtilities() {
+ // No instances
+ }
+
+ /**
+ * Find an action with the given name in the editor kit.
+ *
+ * @param editorKit non-null editor kit in which search is performed.
+ * @param actionName non-null action name to search for.
+ * @return action instance with the given name or null if action not found.
+ */
+ public static Action getAction(EditorKit editorKit, String actionName) {
+ return EditorActionUtilities.getAction(editorKit, actionName);
+ }
+
+}
--- a/editor.lib2/src/org/netbeans/modules/editor/lib2/EditorActionRegistrationProcessor.java
+++ a/editor.lib2/src/org/netbeans/modules/editor/lib2/EditorActionRegistrationProcessor.java
@@ -39,13 +39,10 @@
package org.netbeans.modules.editor.lib2;
-import java.io.IOException;
-import java.util.MissingResourceException;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
+import java.util.List;
+import org.netbeans.modules.editor.lib2.actions.EditorActionUtilities;
+import org.netbeans.modules.editor.lib2.actions.PresenterEditorAction;
import java.util.Set;
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
@@ -55,10 +52,10 @@
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter;
import javax.swing.Action;
-import javax.tools.StandardLocation;
import org.netbeans.api.editor.EditorActionRegistration;
import org.netbeans.api.editor.EditorActionRegistrations;
import org.openide.filesystems.annotations.LayerBuilder;
@@ -67,7 +64,8 @@
import org.openide.util.lookup.ServiceProvider;
/**
- * Annotation processor for
+ * Annotation processor for {@link EditorActionRegistration}
+ * and {@link EditorActionRegistrations}.
*/
@ServiceProvider(service=Processor.class)
@SupportedSourceVersion(SourceVersion.RELEASE_6)
@@ -101,7 +99,9 @@
String methodName;
TypeMirror swingActionType = processingEnv.getTypeUtils().getDeclaredType(
processingEnv.getElementUtils().getTypeElement("javax.swing.Action"));
-
+ TypeMirror utilMapType = processingEnv.getTypeUtils().getDeclaredType(
+ processingEnv.getElementUtils().getTypeElement("java.util.Map"));
+ boolean directActionCreation = false; // Whether construct AlwaysEnabledAction or annotated action directly
switch (e.getKind()) {
case CLASS:
className = processingEnv.getElementUtils().getBinaryName((TypeElement)e).toString();
@@ -111,24 +111,35 @@
if (!e.getModifiers().contains(Modifier.PUBLIC)) {
throw new LayerGenerationException(className + " is not public", e);
}
- boolean hasDefaultCtor = false;
+ ExecutableElement defaultCtor = null;
+ ExecutableElement mapCtor = null;
for (ExecutableElement constructor : ElementFilter.constructorsIn(e.getEnclosedElements())) {
- if (constructor.getParameters().isEmpty()) {
- if (!constructor.getModifiers().contains(Modifier.PUBLIC)) {
- throw new LayerGenerationException("Default constructor of " + className + " is not public", e);
- }
- hasDefaultCtor = true;
- break;
+ List extends VariableElement> params = constructor.getParameters();
+ if (params.isEmpty()) {
+ defaultCtor = constructor;
+
+ } else if (params.size() == 1 &&
+ processingEnv.getTypeUtils().isAssignable(params.get(0).asType(), utilMapType))
+ {
+ mapCtor = constructor;
}
}
- if (!hasDefaultCtor) {
- throw new LayerGenerationException(className + " must have a no-argument constructor", e);
+ String msgBase = "No-argument (or single-argument \"Map attrs\") constructor";
+ if (defaultCtor == null && mapCtor == null) {
+ throw new LayerGenerationException(msgBase + " not present in " + className, e);
+ }
+ boolean defaultCtorPublic = (defaultCtor != null && defaultCtor.getModifiers().contains(Modifier.PUBLIC));
+ boolean mapCtorPublic = (mapCtor != null && mapCtor.getModifiers().contains(Modifier.PUBLIC));
+ if (!defaultCtorPublic && !mapCtorPublic) {
+ throw new LayerGenerationException(msgBase + " not public in " + className, e);
}
if (!processingEnv.getTypeUtils().isAssignable(e.asType(), swingActionType)) {
throw new LayerGenerationException(className + " is not assignable to javax.swing.Action", e);
}
-
+ if (mapCtorPublic) {
+ directActionCreation = true;
+ }
methodName = null;
break;
@@ -136,18 +147,28 @@
className = processingEnv.getElementUtils().getBinaryName((TypeElement) e.getEnclosingElement()).toString();
methodName = e.getSimpleName().toString();
if (!e.getModifiers().contains(Modifier.STATIC)) {
- throw new LayerGenerationException(className + "." + methodName + " must be static", e);
+ throw new LayerGenerationException(className + "." + methodName + " must be static", e); // NOI18N
}
// It appears that actually even non-public method registration works - so commented following
// if (!e.getModifiers().contains(Modifier.PUBLIC)) {
// throw new LayerGenerationException(className + "." + methodName + " must be public", e);
// }
- if (!((ExecutableElement) e).getParameters().isEmpty()) {
- throw new LayerGenerationException(className + "." + methodName + " must not take arguments", e);
+ List extends VariableElement> params = ((ExecutableElement)e).getParameters();
+ boolean emptyParams = params.isEmpty();
+ boolean mapParam = (params.size() == 1 && processingEnv.getTypeUtils().isAssignable(
+ params.get(0).asType(), utilMapType));
+ if (!emptyParams && !mapParam)
+ {
+ throw new LayerGenerationException(className + "." + methodName +
+ " must not take arguments (or have a single-argument \"Map attrs\")", e); // NOI18N
}
- if (swingActionType != null && !processingEnv.getTypeUtils().isAssignable(((ExecutableElement)e).getReturnType(), swingActionType)) {
+ TypeMirror returnType = ((ExecutableElement)e).getReturnType();
+ if (swingActionType != null && !processingEnv.getTypeUtils().isAssignable(returnType, swingActionType)) {
throw new LayerGenerationException(className + "." + methodName + " is not assignable to javax.swing.Action", e);
}
+ if (mapParam) {
+ directActionCreation = true;
+ }
break;
default:
@@ -157,14 +178,16 @@
String actionName = annotation.name();
StringBuilder filePath = new StringBuilder(50);
+ String mimeType = annotation.mimeType();
filePath.append("Editors");
- if (annotation.mimeType().length() > 0) {
- filePath.append("/").append(annotation.mimeType());
+ if (mimeType.length() > 0) {
+ filePath.append("/").append(mimeType);
}
filePath.append("/Actions/").append(actionName).append(".instance");
- LayerBuilder.File file = layer(e).file(filePath.toString());
-
- file.stringvalue("displayName", actionName);
+ LayerBuilder layer = layer(e);
+ LayerBuilder.File file = layer.file(filePath.toString());
+ String preferencesKey = annotation.preferencesKey();
+ boolean checkBoxPresenter = (preferencesKey.length() > 0);
// Resolve icon resource
String iconResource = annotation.iconResource();
@@ -199,13 +222,117 @@
file.bundlevalue("popupText", popupText);
}
- file.methodvalue("instanceCreate", "org.openide.awt.Actions", "alwaysEnabled");
- if (methodName != null) {
- file.methodvalue("delegate", className, methodName);
- } else {
- file.newvalue("delegate", className);
+ // Check presenters
+ String presenterActionName = null;
+
+ // Check menu path
+ String menuPath = annotation.menuPath();
+ int menuPosition = annotation.menuPosition();
+ if (menuPosition != Integer.MAX_VALUE) {
+ StringBuilder presenterFilePath = new StringBuilder(50);
+ presenterFilePath.append("Menu/");
+ if (menuPath.length() > 0) {
+ presenterFilePath.append(menuPath).append('/');
+ }
+ presenterFilePath.append(actionName).append(".shadow");
+ LayerBuilder.File presenterShadowFile = layer.file(presenterFilePath.toString());
+ if (presenterActionName == null) {
+ if (checkBoxPresenter) { // Point directly to AlwaysEnabledAction
+ presenterActionName = "Editors/Actions/" + actionName + ".instance";
+ } else {
+ presenterActionName = generatePresenterAction(layer, actionName);
+ }
+ }
+ presenterShadowFile.stringvalue("originalFile", presenterActionName);
+ presenterShadowFile.intvalue("position", menuPosition);
+ presenterShadowFile.write();
+ }
+
+ // Check popup path
+ String popupPath = annotation.popupPath();
+ int popupPosition = annotation.popupPosition();
+ if (popupPosition != Integer.MAX_VALUE) {
+ StringBuilder presenterFilePath = new StringBuilder(50);
+ presenterFilePath.append("Editors/Popup/");
+ if (mimeType.length() > 0) {
+ presenterFilePath.append(mimeType).append("/");
+ }
+ if (popupPath.length() > 0) {
+ presenterFilePath.append(popupPath).append('/');
+ }
+ presenterFilePath.append(actionName).append(".shadow");
+ LayerBuilder.File presenterShadowFile = layer.file(presenterFilePath.toString());
+ if (presenterActionName == null) {
+ if (checkBoxPresenter) { // Point directly to AlwaysEnabledAction
+ presenterActionName = "Editors/Actions/" + actionName + ".instance";
+ } else {
+ presenterActionName = generatePresenterAction(layer, actionName);
+ }
+ }
+ presenterShadowFile.stringvalue("originalFile", presenterActionName);
+ presenterShadowFile.intvalue("position", popupPosition);
+ presenterShadowFile.write();
+ }
+
+ int toolBarPosition = annotation.toolBarPosition();
+ if (toolBarPosition != Integer.MAX_VALUE) {
+ StringBuilder presenterFilePath = new StringBuilder(50);
+ presenterFilePath.append("Editors/Toolbar/");
+ if (mimeType.length() > 0) {
+ presenterFilePath.append(mimeType).append("/");
+ }
+ presenterFilePath.append(actionName).append(".shadow");
+ LayerBuilder.File presenterShadowFile = layer.file(presenterFilePath.toString());
+ if (presenterActionName == null) {
+ presenterActionName = generatePresenterAction(layer, actionName);
+ }
+ presenterShadowFile.stringvalue("originalFile", presenterActionName);
+ presenterShadowFile.intvalue("position", toolBarPosition);
+ presenterShadowFile.write();
+ }
+
+ if (preferencesKey.length() > 0) {
+ file.stringvalue("PreferencesKey", preferencesKey);
+ file.methodvalue("PreferencesNode", EditorActionUtilities.class.getName(), "getGlobalPreferences");
+ }
+
+ // Deafult helpID is action's name
+ file.stringvalue("helpID", actionName);
+
+ // Resolve accelerator through method
+ file.methodvalue(Action.ACCELERATOR_KEY, EditorActionUtilities.class.getName(), "getAccelerator");
+
+ // Always generate Action.NAME since although AlwaysEnabledAction tweaks its retrieval to "displayName"
+ // some tools may query FO's properties and expect it there.
+ file.stringvalue(Action.NAME, actionName);
+
+ if (directActionCreation) {
+ if (methodName != null) {
+ file.methodvalue("instanceCreate", className, methodName);
+ } else {
+ file.newvalue("instanceCreate", className);
+ }
+
+ } else { // Create always enabled action
+ file.methodvalue("instanceCreate", "org.openide.awt.Actions", "alwaysEnabled");
+ file.stringvalue("displayName", actionName);
+
+ if (methodName != null) {
+ file.methodvalue("delegate", className, methodName);
+ } else {
+ file.newvalue("delegate", className);
+ }
}
file.write();
}
+ private String generatePresenterAction(LayerBuilder layer, String actionName) {
+ String presenterActionName = "Editors/ActionPresenters/" + actionName + ".instance";
+ LayerBuilder.File presenterActionFile = layer.file(presenterActionName);
+ presenterActionFile.methodvalue("instanceCreate", PresenterEditorAction.class.getName(), "create");
+ presenterActionFile.stringvalue(Action.NAME, actionName);
+ presenterActionFile.write();
+ return presenterActionName;
+ }
+
}
--- a/editor.lib/src/org/netbeans/modules/editor/lib/EditorPreferencesDefaults.java
+++ a/editor.lib/src/org/netbeans/modules/editor/lib/EditorPreferencesDefaults.java
@@ -39,13 +39,10 @@
* made subject to such option by the copyright holder.
*/
-package org.netbeans.modules.editor.lib;
+package org.netbeans.modules.editor.lib2;
import java.awt.Insets;
import java.awt.Dimension;
-import org.netbeans.editor.Acceptor;
-import org.netbeans.editor.AcceptorFactory;
-import org.netbeans.editor.BaseCaret;
/**
* This class contains settings default values copied over from SettingsDefaults and ExtSettingsDefaults.
@@ -57,9 +54,13 @@
private EditorPreferencesDefaults() {
// no-op
}
+
+ public static final String LINE_CARET = "line-caret";
+ public static final String BLOCK_CARET = "block-caret";
- // not in SettingsDefaults not ExtSettingsDefaults
- public static final boolean defaultToolbarVisible = true;
+ public static final boolean defaultToolbarVisible = true; // Currently unused - see ToggleAction in editor.actions
+ public static final boolean defaultLineNumberVisible = false; // Currently unused - see ToggleAction in editor.actions
+
public static final boolean defaultPopupMenuEnabled = true;
// -----------------------------------------------------------------------
@@ -98,8 +99,8 @@
public static final boolean defaultExpandTabs = true;
- public static final String defaultCaretTypeInsertMode = BaseCaret.LINE_CARET;
- public static final String defaultCaretTypeOverwriteMode = BaseCaret.BLOCK_CARET;
+ public static final String defaultCaretTypeInsertMode = LINE_CARET;
+ public static final String defaultCaretTypeOverwriteMode = BLOCK_CARET;
public static final boolean defaultCaretItalicInsertMode = false;
public static final boolean defaultCaretItalicOverwriteMode = false;
/** @since 1.23 */
@@ -110,7 +111,6 @@
public static final boolean defaultStatusBarVisible = true;
- public static final boolean defaultLineNumberVisible = false;
public static final boolean defaultPrintLineNumberVisible = true;
public static final boolean defaultTextLimitLineVisible = true;
public static final boolean defaultHomeKeyColumnOne = false;
--- a/editor.lib/src/org/netbeans/modules/editor/lib/EditorPreferencesKeys.java
+++ a/editor.lib/src/org/netbeans/modules/editor/lib/EditorPreferencesKeys.java
@@ -39,7 +39,7 @@
* made subject to such option by the copyright holder.
*/
-package org.netbeans.modules.editor.lib;
+package org.netbeans.modules.editor.lib2;
import org.netbeans.api.editor.settings.SimpleValueNames;
--- a/editor.lib2/src/org/netbeans/modules/editor/lib2/actions/EditorActionUtilities.java
+++ a/editor.lib2/src/org/netbeans/modules/editor/lib2/actions/EditorActionUtilities.java
@@ -0,0 +1,308 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 2008 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.editor.lib2.actions;
+
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.prefs.Preferences;
+import javax.swing.Action;
+import javax.swing.KeyStroke;
+import javax.swing.event.ChangeListener;
+import javax.swing.text.EditorKit;
+import org.netbeans.api.editor.mimelookup.MimeLookup;
+import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.api.editor.settings.KeyBindingSettings;
+import org.netbeans.api.editor.settings.MultiKeyBinding;
+import org.openide.filesystems.FileObject;
+import org.openide.util.Lookup;
+import org.openide.util.LookupEvent;
+import org.openide.util.LookupListener;
+import org.openide.util.lookup.Lookups;
+
+
+/**
+ * Various utility methods for declarative editor action registrations.
+ */
+public final class EditorActionUtilities {
+
+ // -J-Dorg.netbeans.modules.editor.lib2.actions.EditorActionUtilities.level=FINEST
+ private static final Logger LOG = Logger.getLogger(EditorActionUtilities.class.getName());
+
+ private static Map> mimeType2actionName2KeyStroke;
+
+ private static Map mimeType2ListenerPresent = new HashMap();
+
+ private static Reference globalKitRef;
+
+ private static LookupListener globalKitListener;
+
+ private static final Map kit2searchable = new WeakHashMap();
+
+ private EditorActionUtilities() {
+ // No instances
+ }
+
+ public static EditorKit getGlobalKit() {
+ synchronized (kit2searchable) {
+ EditorKit globalKit = (globalKitRef != null) ? globalKitRef.get() : null;
+ if (globalKit == null) {
+ Lookup.Result result = MimeLookup.getLookup("").lookupResult(EditorKit.class);
+ Iterator extends EditorKit> instancesIterator = result.allInstances().iterator();
+ globalKit = instancesIterator.hasNext() ? instancesIterator.next() : null;
+ if (globalKit != null) {
+ globalKitRef = new WeakReference(globalKit);
+ }
+ if (globalKitListener == null) {
+ globalKitListener = new LookupListener() {
+ public void resultChanged(LookupEvent evt) {
+ synchronized (kit2searchable) {
+ globalKitRef = null;
+ }
+ }
+ };
+ result.addLookupListener(globalKitListener);
+ }
+ }
+ return globalKit;
+ }
+ }
+
+ public static EditorKit getKit(String mimeType) {
+ Lookup.Result result = MimeLookup.getLookup(mimeType).lookupResult(EditorKit.class);
+ Iterator extends EditorKit> instancesIterator = result.allInstances().iterator();
+ EditorKit kit = instancesIterator.hasNext() ? instancesIterator.next() : null;
+ return kit;
+ }
+
+ public static void registerSearchableKit(EditorKit kit, SearchableEditorKit searchableKit) {
+ synchronized (kit2searchable) {
+ kit2searchable.put(kit, searchableKit);
+ }
+ }
+
+ /**
+ * Get an editor action in a constant time (wrap a kit with a SearchableEditorKit if necessary).
+ *
+ * @param kit non-null kit.
+ * @param actionName non-null action name.
+ * @return action's instance or null.
+ */
+ public static Action getAction(EditorKit kit, String actionName) {
+ return getSearchableKit(kit).getAction(actionName);
+ }
+
+ /**
+ * Get searchable editor kit for the given kit.
+ * @param kit non-null kit.
+ * @return non-null searchable kit.
+ */
+ public static SearchableEditorKit getSearchableKit(EditorKit kit) {
+ SearchableEditorKit searchableKit;
+ if (kit instanceof SearchableEditorKit) {
+ searchableKit = ((SearchableEditorKit)kit);
+ } else {
+ synchronized (kit2searchable) {
+ searchableKit = kit2searchable.get(kit);
+ if (searchableKit == null) {
+ searchableKit = new DefaultSearchableKit(kit);
+ registerSearchableKit(kit, searchableKit);
+ }
+ }
+ }
+ return searchableKit;
+ }
+
+ public static Lookup.Result createActionsLookupResult(String mimeType) {
+ if (!MimePath.validate(mimeType)) {
+ throw new IllegalArgumentException("Ïnvalid mimeType=\"" + mimeType + "\"");
+ }
+ Lookup lookup = Lookups.forPath(getPath(mimeType, "Actions"));
+ return lookup.lookupResult(Action.class);
+ }
+
+ private static String getPath(String mimeType, String subFolder) {
+ StringBuilder path = new StringBuilder(50);
+ path.append("Editors/");
+ if (mimeType.length() > 0) {
+ path.append('/').append(mimeType);
+ }
+ if (subFolder.length() > 0) {
+ path.append('/').append(subFolder);
+ }
+ return path.toString();
+ }
+
+ public static Preferences getGlobalPreferences() {
+ Lookup globalMimeLookup = MimeLookup.getLookup(MimePath.EMPTY);
+ return (globalMimeLookup != null) ? globalMimeLookup.lookup(Preferences.class) : null;
+ }
+
+ /**
+ * Get single-key accelerator for a given declared action.
+ * Only a single-key accelerators are supported.
+ */
+ public static KeyStroke getAccelerator(FileObject fo) {
+ if (fo == null) {
+ throw new IllegalArgumentException("Must be called with non-null fileObject"); // NOI18N
+ }
+ boolean fineLoggable = LOG.isLoggable(Level.FINE);
+ String path = fo.getParent().getPath();
+ String actionName = (String) fo.getAttribute(Action.NAME);
+ KeyStroke ks = null;
+ if (path.startsWith("Editors/")) {
+ path = path.substring(7); // Leave ending '/' to support "Editors/Actions"
+ if (path.endsWith("/Actions")) {
+ path = path.substring(0, path.length() - 8);
+ if (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+ String mimeType = path;
+ if (!MimePath.validate(mimeType)) {
+ LOG.info("Invalid mime-type='" + mimeType + "' of action's fileObject=" + fo); // NOI18N
+ }
+ ks = getAccelerator(mimeType, actionName);
+ } else if (fineLoggable) {
+ LOG.fine("No \"/Actions\" at end of mime-type='" + path +
+ "' of action's fileObject=" + fo); // NOI18N
+ }
+ } else if (fineLoggable) {
+ LOG.fine("No \"Editors/\" at begining of mime-type='" + path + // NOI18N
+ "' of action's fileObject=" + fo); // NOI18N
+ }
+
+ if (LOG.isLoggable(Level.FINER)) {
+ LOG.finer("Accelerator for action \"" + actionName + "\" is " + ks);
+ }
+ return ks;
+ }
+
+ /**
+ * Get single-key accelerator for a given declared action.
+ *
+ * Unfortunately currently there's no easy way to display multi-keybinding in menu-item
+ * (there's just JMenuItem.setAccelerator() and its impl is L&F-based)
+ * so just display single-keystroke accelerators.
+ */
+ public static KeyStroke getAccelerator(String mimeType, String actionName) {
+ KeyStroke ks = null;
+ if (actionName != null) {
+ synchronized (EditorActionUtilities.class) {
+ if (mimeType2actionName2KeyStroke == null) {
+ mimeType2actionName2KeyStroke = new HashMap>();
+ }
+ Map actionName2KeyStrokeList = mimeType2actionName2KeyStroke.get(mimeType);
+ if (actionName2KeyStrokeList == null) {
+ actionName2KeyStrokeList = new HashMap();
+ Lookup.Result result = MimeLookup.getLookup(mimeType).lookupResult(
+ KeyBindingSettings.class);
+ Collection extends KeyBindingSettings> instances = result.allInstances();
+ if (!instances.isEmpty()) {
+ KeyBindingSettings kbs = instances.iterator().next();
+ for (MultiKeyBinding kb : kbs.getKeyBindings()) {
+ if (!actionName2KeyStrokeList.containsKey(kb.getActionName())
+ && kb.getKeyStrokeCount() == 1)
+ {
+ actionName2KeyStrokeList.put(kb.getActionName(), kb.getKeyStroke(0));
+ }
+ }
+ }
+ mimeType2actionName2KeyStroke.put(mimeType, actionName2KeyStrokeList);
+ // Ensure listening on changes in keybinding settings
+ if (!Boolean.TRUE.equals(mimeType2ListenerPresent.get(mimeType))) {
+ mimeType2ListenerPresent.put(mimeType, true);
+ result.addLookupListener(KeyBindingSettingsListener.INSTANCE);
+ }
+ }
+ ks = actionName2KeyStrokeList.get(actionName);
+ }
+ }
+ return ks;
+ }
+
+ private static final class KeyBindingSettingsListener implements LookupListener {
+
+ static final KeyBindingSettingsListener INSTANCE = new KeyBindingSettingsListener();
+
+ private KeyBindingSettingsListener() {
+ }
+
+ public void resultChanged(LookupEvent ev) {
+ synchronized (EditorActionUtilities.class) {
+ mimeType2actionName2KeyStroke = null;
+ LOG.fine("mimeType2actionName2KeyStroke cleared."); // NOI18N
+ }
+ }
+
+ }
+
+ private static final class DefaultSearchableKit implements SearchableEditorKit {
+
+ private final Map> name2actionRef = new WeakHashMap>();
+
+ DefaultSearchableKit(EditorKit kit) {
+ for (Action action : kit.getActions()) {
+ if (action != null) {
+ name2actionRef.put((String)action.getValue(Action.NAME), new WeakReference(action));
+ }
+ }
+ }
+
+ public Action getAction(String actionName) {
+ Reference actionRef = name2actionRef.get(actionName);
+ return (actionRef != null) ? actionRef.get() : null;
+ }
+
+ public void addActionsChangeListener(ChangeListener listener) {
+ }
+
+ public void removeActionsChangeListener(ChangeListener listener) {
+ }
+
+
+ }
+
+}
--- a/editor.lib2/src/org/netbeans/modules/editor/lib2/actions/EditorActionsProvider.java
+++ a/editor.lib2/src/org/netbeans/modules/editor/lib2/actions/EditorActionsProvider.java
@@ -0,0 +1,59 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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.lib2.actions;
+
+import java.util.List;
+import javax.swing.Action;
+
+/**
+ * Abstract class implemented by editor module providing editor actions.
+ *
+ * @author Vita Stejskal
+ * @since 1.39
+ */
+public interface EditorActionsProvider {
+
+ List getActionsOnly();
+
+ List