Index: nbbuild/cluster.properties
===================================================================
RCS file: nbbuild/cluster.properties
diff -N nbbuild/cluster.properties
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ nbbuild/cluster.properties 8 Mar 2007 22:50:14 -0000 1.136.18.3
@@ -0,0 +1,345 @@
+# The contents of this file are subject to the terms of the Common Development
+# and Distribution License (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.html
+# or http://www.netbeans.org/cddl.txt.
+#
+# When distributing Covered Code, include this CDDL Header Notice in each file
+# and include the License file at http://www.netbeans.org/cddl.txt.
+# If applicable, add the following below the CDDL Header, with the fields
+# enclosed by brackets [] replaced by your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+# 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.
+
+clusters.prefix=libnb
+
+clusters.extra.list=\
+ nb.pkg.testtools
+
+#List of clusters in standard build
+nb.clusters.list=\
+ nb.cluster.profiler,\
+ nb.cluster.harness,\
+ nb.cluster.ide,\
+ nb.cluster.j2ee,\
+ nb.cluster.nb,\
+ nb.cluster.platform
+
+clusters.list=\
+ ${nb.clusters.list},\
+ ${clusters.extra.list}
+
+# === NOTICE ===
+# When updating any of the following lists, please also run:
+# ant -f nbbuild/build.xml check-module-configs
+# Check for warnings (should not be any), and commit any modifications to
+# ide/golden/moduleconfigs.txt and/or nbbuild/nbproject/project.xml
+
+nb.cluster.platform.dir=platform7
+nb.cluster.platform.depends=
+nb.cluster.platform=\
+ autoupdate,\
+ core,\
+ core/bootstrap,\
+ core/execution,\
+ core/favorites,\
+ core/javahelp,\
+ core/multiview,\
+ core/options,\
+ core/options/keymap,\
+ core/output2,\
+ core/progress,\
+ core/progressui,\
+ core/sendopts,\
+ core/settings,\
+ core/startup,\
+ core/swing/plaf,\
+ core/swing/tabcontrol,\
+ core/ui,\
+ core/windows,\
+ editor/mimelookup,\
+ editor/mimelookup/impl,\
+ libs/swing-layout,\
+ libs/jsr223,\
+ openide/actions,\
+ openide/awt,\
+ openide/compat,\
+ openide/dialogs,\
+ openide/execution,\
+ openide/explorer,\
+ openide/fs,\
+ openide/io,\
+ openide/loaders,\
+ openide/masterfs,\
+ openide/modules,\
+ openide/nodes,\
+ openide/options,\
+ openide/templates,\
+ openide/text,\
+ openide/util,\
+ openide/util/enum,\
+ openide/windows,\
+ projects/queries
+
+nb.pkg.idesupport=\
+ ant/debugger,\
+ apisupport/timers,\
+ core/ide,\
+ core/navigator,\
+ core/palette,\
+ debuggercore,\
+ debuggercore/api,\
+ debuggercore/viewmodel,\
+ diff,\
+ editor,\
+ editor/bookmarks,\
+ editor/codetemplates,\
+ editor/completion,\
+ editor/errorstripe,\
+ editor/errorstripe/api,\
+ editor/fold,\
+ editor/guards,\
+ editor/hints,\
+ editor/hints/highlights,\
+ editor/lib,\
+ editor/lib2,\
+ editor/options,\
+ editor/plain,\
+ editor/plain/lib,\
+ editor/settings,\
+ editor/settings/storage,\
+ editor/util,\
+ form,\
+ html/editor,\
+ html/editor/lib,\
+ html/lexer,\
+ ide/defaults,\
+ java/editor,\
+ java/editor/lib,\
+ java/guards,\
+ java/lexer,\
+ java/navigation, \
+ java/source, \
+ java/source/debug, \
+ java/source/javacapi, \
+ java/source/javacimpl, \
+ java/source/preprocessorbridge, \
+ javacvs/cvsmodule,\
+ javacvs/libmodule,\
+ lexer,\
+ lexer/nbbridge,\
+ libs/commons_logging,\
+ libs/freemarker,\
+ libs/jsch,\
+ libs/xerces,\
+ projects/libraries,\
+ projects/projectapi,\
+ projects/projectui,\
+ projects/projectuiapi,\
+ subversion/client,\
+ subversion/ini4j,\
+ subversion/main,\
+ versioncontrol,\
+ versioncontrol/localhistory,\
+ xml/tageditorsupport
+
+nb.pkg.ideextensions=\
+ html,\
+ i18n,\
+ i18n/form,\
+ image,\
+ libs/resolver,\
+ openidex,\
+ properties,\
+ properties/syntax,\
+ tasklist/api,\
+ tasklist/core,\
+ tasklist/docscan,\
+ tasklist/suggestions,\
+ usersguide,\
+ usersguide/j2seexamples,\
+ utilities,\
+ utilities/project,\
+ xml/api,\
+ xml/catalog,\
+ xml/core,\
+ xml/css,\
+ xml/lexer, \
+ xml/retriever,\
+ xml/schema,\
+ xml/schema/api,\
+ xml/tax,\
+ xml/text-edit,\
+ xml/tools,\
+ xml/wsdl/api,\
+ xml/xam,\
+ xml/xdm,\
+ xml/xsl
+
+nb.pkg.javarefactoring=\
+ ant,\
+ ant/browsetask,\
+ ant/freeform,\
+ ant/grammar,\
+ ant/project,\
+ apisupport/ant,\
+ apisupport/project,\
+ apisupport/samples/PaintApp-sample-ui,\
+ apisupport/samples/feedreader-sample-ui,\
+ classfile,\
+ debuggerjpda,\
+ debuggerjpda/ant,\
+ debuggerjpda/api,\
+ debuggerjpda/projects,\
+ debuggerjpda/ui,\
+ websvc/serviceapi,\
+ java/api,\
+ java/freeform,\
+ java/hints,\
+ java/j2seplatform,\
+ java/j2seproject,\
+ java/platform,\
+ java/project,\
+ javadoc,\
+ junit,\
+ refactoring/api,\
+ refactoring/java,\
+ javawebstart
+
+nb.pkg.webapp=\
+ db,\
+ db/core,\
+ db/dbapi,\
+ db/model,\
+ db/sqleditor,\
+ extbrowser,\
+ httpserver,\
+ httpserver/servletapi,\
+ j2ee/metadata,\
+ j2ee/persistence,\
+ j2ee/persistenceapi,\
+ j2ee/persistence/verification,\
+ j2ee/toplinklib,\
+ schema2beans/rt,\
+ websvc/clientapi,\
+ websvc/jaxrpc16,\
+ websvc/jaxws20,\
+ websvc/jaxwsapi,\
+ websvc/jaxwsmodel,\
+ xml/multiview
+
+nb.pkg.ide=
+
+# special cluster for NetBeans IDE only extensions
+nb.pkg.nb=\
+ ide/applemenu,\
+ ide/branding,\
+ ide/launcher/upgrade,\
+ ide/updatecenters,\
+ ide/welcome,\
+ logger/uihandler,\
+ logger/uihandlerforprojects,\
+ logger/uihandlerlib
+
+nb.pkg.testtools.dir=testtools
+nb.pkg.testtools.depends=\
+ nb.cluster.platform,\
+ nb.cluster.ide
+nb.pkg.testtools=\
+ jellytools,\
+ jemmy/idemodule,\
+ jemmysupport,\
+ xtest,\
+ xtest/examples,\
+ xtest/module,\
+ xtest/nbjunit,\
+ xtest/nbjunit/ide
+
+nb.cluster.ide.dir=ide8
+nb.cluster.ide.depends=\
+ nb.cluster.platform
+nb.cluster.ide=\
+ ${nb.pkg.ideextensions},\
+ ${nb.pkg.idesupport},\
+ ${nb.pkg.javarefactoring},\
+ ${nb.pkg.webapp}
+
+nb.cluster.j2ee.dir=enterprise4
+nb.cluster.j2ee.depends=\
+ nb.cluster.ide,\
+ nb.cluster.platform
+nb.cluster.j2ee=\
+ db/derby,\
+ j2ee/blueprints,\
+ j2ee/archiveproject,\
+ j2ee/clientproject,\
+ j2ee/ddapi,\
+ j2ee/ddloaders,\
+ j2ee/debug,\
+ j2ee/earproject,\
+ j2ee/ejbapi,\
+ j2ee/ejbcore,\
+ j2ee/ejbfreeform,\
+ j2ee/ejbjarproject,\
+ j2ee/genericserver,\
+ j2ee/platform,\
+ j2ee/samples,\
+ j2ee/utilities,\
+ j2eeserver,\
+ j2eeserver/ant,\
+ j2eeserver/j2eeapis,\
+ monitor,\
+ serverplugins/jboss4,\
+ serverplugins/sun/appsrv,\
+ serverplugins/sun/appsrv81,\
+ serverplugins/sun/sunddapi,\
+ serverplugins/sun/sunddui,\
+ serverplugins/weblogic9,\
+ tomcatint/tomcat5,\
+ tomcatint/tomcat5/bundled,\
+ web/core,\
+ web/el/lexer,\
+ web/examples,\
+ web/freeform,\
+ web/jsf,\
+ web/jspdebug,\
+ web/jspparser,\
+ web/jspsyntax,\
+ web/jspsyntax/lexer,\
+ web/jstl11,\
+ web/libs/glassfish_logging,\
+ web/project,\
+ web/servletjspapi,\
+ web/struts,\
+ web/webapi,\
+ websvc/core,\
+ websvc/customization,\
+ websvc/registry,\
+ websvc/websvcapi,\
+ websvc/websvcddapi,\
+ websvc/jaxrpcsupport
+# j2ee/refactoring,\
+# j2ee/verification,\
+# websvc/dev,\
+
+nb.cluster.nb.dir=nb6.0
+nb.cluster.nb.depends=\
+ nb.cluster.ide
+nb.cluster.nb=\
+ ${nb.pkg.ide},\
+ ${nb.pkg.nb}
+
+nb.cluster.harness.dir=harness
+nb.cluster.harness=\
+ apisupport/harness
+nb.cluster.harness.depends=nb.cluster.platform
+
+nb.cluster.profiler.dir=profiler2
+nb.cluster.profiler=\
+ profiler
+nb.cluster.profiler.depends=nb.cluster.j2ee
+
Index: editor/options/arch.xml
===================================================================
RCS file: /cvs/editor/options/arch.xml,v
retrieving revision 1.6
retrieving revision 1.4.16.1
diff -u -r1.6 -r1.4.16.1
Index: editor/options/build.xml
===================================================================
RCS file: /cvs/editor/options/build.xml,v
retrieving revision 1.3
retrieving revision 1.2.40.1
diff -u -r1.3 -r1.2.40.1
Index: editor/options/nbproject/project.properties
===================================================================
RCS file: /cvs/editor/options/nbproject/project.properties,v
retrieving revision 1.8
retrieving revision 1.7.18.1
diff -u -r1.8 -r1.7.18.1
--- editor/options/nbproject/project.properties 30 Jun 2006 19:18:11 -0000 1.8
+++ editor/options/nbproject/project.properties 4 Mar 2007 21:41:10 -0000 1.7.18.1
@@ -16,6 +16,8 @@
# Microsystems, Inc. All Rights Reserved.
+javac.compilerargs=-Xlint:unchecked
+javac.source=1.5
javadoc.arch=${basedir}/arch.xml
test.unit.run.cp.extra=${ide/defaults.dir}/modules/org-netbeans-modules-defaults.jar:\
${editor/settings/storage.dir}/modules/org-netbeans-modules-editor-settings-storage.jar:\
Index: editor/options/nbproject/project.xml
===================================================================
RCS file: /cvs/editor/options/nbproject/project.xml,v
retrieving revision 1.18
retrieving revision 1.12.12.4
diff -u -r1.18 -r1.12.12.4
--- editor/options/nbproject/project.xml 5 Feb 2007 09:43:32 -0000 1.18
+++ editor/options/nbproject/project.xml 9 Mar 2007 10:18:09 -0000 1.12.12.4
@@ -95,6 +95,12 @@
+ org.netbeans.modules.options.keymap
+
+
+
+
+
org.openide.awt
Index: editor/options/src/META-INF/services/org.netbeans.spi.shortcuts.KeymapManager
===================================================================
RCS file: editor/options/src/META-INF/services/org.netbeans.spi.shortcuts.KeymapManager
diff -N editor/options/src/META-INF/services/org.netbeans.spi.shortcuts.KeymapManager
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ editor/options/src/META-INF/services/org.netbeans.spi.shortcuts.KeymapManager 9 Mar 2007 10:17:32 -0000 1.1.2.1
@@ -0,0 +1 @@
+org.netbeans.modules.options.editor.keymap.EditorBridge
Index: editor/options/src/org/netbeans/modules/options/codetemplates/Bundle.properties
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/codetemplates/Bundle.properties,v
retrieving revision 1.12
retrieving revision 1.10.16.1
diff -u -r1.12 -r1.10.16.1
Index: editor/options/src/org/netbeans/modules/options/codetemplates/CodeTemplatesModel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/codetemplates/CodeTemplatesModel.java,v
retrieving revision 1.11
retrieving revision 1.8.22.2
diff -u -r1.11 -r1.8.22.2
--- editor/options/src/org/netbeans/modules/options/codetemplates/CodeTemplatesModel.java 5 Feb 2007 09:26:19 -0000 1.11
+++ editor/options/src/org/netbeans/modules/options/codetemplates/CodeTemplatesModel.java 4 Mar 2007 21:41:03 -0000 1.8.22.2
@@ -37,6 +37,7 @@
import org.netbeans.api.editor.mimelookup.MimePath;
import org.netbeans.modules.editor.options.BaseOptions;
import org.netbeans.modules.editor.settings.storage.api.EditorSettings;
+import org.openide.util.Lookup;
import org.openide.util.NbBundle;
Index: editor/options/src/org/netbeans/modules/options/codetemplates/CodeTemplatesPanel.form
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/codetemplates/CodeTemplatesPanel.form,v
retrieving revision 1.2
retrieving revision 1.1.12.1
diff -u -r1.2 -r1.1.12.1
Index: editor/options/src/org/netbeans/modules/options/codetemplates/CodeTemplatesPanel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/codetemplates/CodeTemplatesPanel.java,v
retrieving revision 1.25
retrieving revision 1.22.16.1
diff -u -r1.25 -r1.22.16.1
Index: editor/options/src/org/netbeans/modules/options/codetemplates/CodeTemplatesPanelController.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/codetemplates/CodeTemplatesPanelController.java,v
retrieving revision 1.6
retrieving revision 1.5.16.1
diff -u -r1.6 -r1.5.16.1
Index: editor/options/src/org/netbeans/modules/options/colors/AnnotationsPanel.form
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/AnnotationsPanel.form,v
retrieving revision 1.2
retrieving revision 1.1.12.1
diff -u -r1.2 -r1.1.12.1
Index: editor/options/src/org/netbeans/modules/options/colors/AnnotationsPanel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/AnnotationsPanel.java,v
retrieving revision 1.21
retrieving revision 1.19.8.1
diff -u -r1.21 -r1.19.8.1
Index: editor/options/src/org/netbeans/modules/options/colors/Bundle.properties
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/Bundle.properties,v
retrieving revision 1.18
retrieving revision 1.16.8.1
diff -u -r1.18 -r1.16.8.1
Index: editor/options/src/org/netbeans/modules/options/colors/CategoryComparator.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/CategoryComparator.java,v
retrieving revision 1.6
retrieving revision 1.5.8.1
diff -u -r1.6 -r1.5.8.1
Index: editor/options/src/org/netbeans/modules/options/colors/CategoryRenderer.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/CategoryRenderer.java,v
retrieving revision 1.4
retrieving revision 1.3.30.1
diff -u -r1.4 -r1.3.30.1
Index: editor/options/src/org/netbeans/modules/options/colors/ColorComboBox.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/ColorComboBox.java,v
retrieving revision 1.12
retrieving revision 1.11.8.1
diff -u -r1.12 -r1.11.8.1
Index: editor/options/src/org/netbeans/modules/options/colors/ColorComboBoxRenderer.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/ColorComboBoxRenderer.java,v
retrieving revision 1.3
retrieving revision 1.2.8.1
diff -u -r1.3 -r1.2.8.1
Index: editor/options/src/org/netbeans/modules/options/colors/ColorModel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/ColorModel.java,v
retrieving revision 1.30
retrieving revision 1.25.8.1
diff -u -r1.30 -r1.25.8.1
Index: editor/options/src/org/netbeans/modules/options/colors/ColorValue.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/ColorValue.java,v
retrieving revision 1.2
retrieving revision 1.1.12.1
diff -u -r1.2 -r1.1.12.1
Index: editor/options/src/org/netbeans/modules/options/colors/FontAndColors.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/FontAndColors.java,v
retrieving revision 1.6
retrieving revision 1.5.16.1
diff -u -r1.6 -r1.5.16.1
Index: editor/options/src/org/netbeans/modules/options/colors/FontAndColorsPanelController.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/FontAndColorsPanelController.java,v
retrieving revision 1.8
retrieving revision 1.7.12.1
diff -u -r1.8 -r1.7.12.1
Index: editor/options/src/org/netbeans/modules/options/colors/HighlightingPanel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/HighlightingPanel.java,v
retrieving revision 1.14
retrieving revision 1.12.8.1
diff -u -r1.14 -r1.12.8.1
Index: editor/options/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.form
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.form,v
retrieving revision 1.3
retrieving revision 1.2.8.1
diff -u -r1.3 -r1.2.8.1
Index: editor/options/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java,v
retrieving revision 1.42
retrieving revision 1.38.8.1
diff -u -r1.42 -r1.38.8.1
Index: editor/options/src/org/netbeans/modules/options/editor/Bundle.properties
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/editor/Bundle.properties,v
retrieving revision 1.14
retrieving revision 1.11.8.1
diff -u -r1.14 -r1.11.8.1
Index: editor/options/src/org/netbeans/modules/options/editor/Editor.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/editor/Editor.java,v
retrieving revision 1.6
retrieving revision 1.5.16.1
diff -u -r1.6 -r1.5.16.1
Index: editor/options/src/org/netbeans/modules/options/editor/EditorPanel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/editor/EditorPanel.java,v
retrieving revision 1.10
retrieving revision 1.9.12.1
diff -u -r1.10 -r1.9.12.1
Index: editor/options/src/org/netbeans/modules/options/editor/EditorPanelController.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/editor/EditorPanelController.java,v
retrieving revision 1.10
retrieving revision 1.9.12.1
diff -u -r1.10 -r1.9.12.1
Index: editor/options/src/org/netbeans/modules/options/editor/mf-layer.xml
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/editor/mf-layer.xml,v
retrieving revision 1.26
retrieving revision 1.22.8.3
diff -u -r1.26 -r1.22.8.3
--- editor/options/src/org/netbeans/modules/options/editor/mf-layer.xml 16 Jan 2007 08:06:25 -0000 1.26
+++ editor/options/src/org/netbeans/modules/options/editor/mf-layer.xml 14 Mar 2007 09:42:16 -0000 1.22.8.3
@@ -20,44 +20,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -71,11 +33,7 @@
-
-
-
-
-
+
Index: editor/options/src/org/netbeans/modules/options/editor/keymap/Bundle.properties
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/editor/keymap/Bundle.properties
diff -N editor/options/src/org/netbeans/modules/options/editor/keymap/Bundle.properties
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ editor/options/src/org/netbeans/modules/options/editor/keymap/Bundle.properties 14 Mar 2007 10:48:30 -0000 1.1.2.1
@@ -0,0 +1,72 @@
+# The contents of this file are subject to the terms of the Common Development
+# and Distribution License (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.html
+# or http://www.netbeans.org/cddl.txt.
+#
+# When distributing Covered Code, include this CDDL Header Notice in each file
+# and include the License file at http://www.netbeans.org/cddl.txt.
+# If applicable, add the following below the CDDL Header, with the fields
+# enclosed by brackets [] replaced by your own identifying information:
+# "Portions Copyrighted [year] [name of copyright owner]"
+#
+# 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.
+
+OpenIDE-Module-Name=Keymap Options
+
+CTL_Keymap_Options=&Keymap
+CTL_Keymap_Options_Title=Keymap
+CTL_Keymap_Options_Description=Keymap
+
+CTL_Duplicate=D&uplicate ...
+AN_Duplicate=Duplicate
+AD_Duplicate=Duplicate
+CTL_Delete=Dele&te
+AN_Delete=Delete
+AD_Delete=Delete
+CTL_Restore=&Restore
+AN_Restore=Restore
+AD_Restore=Restore
+CTL_Show_Actions=Actio&ns
+AN_Show_Actions=Actions
+AD_Show_Actions=Actions
+CTL_Show_Shortcuts=&Shortcuts
+AN_Show_Shortcuts=Shortcuts
+AD_Show_Shortcuts=Shortcuts
+CTL_Add_Shortcut=A&dd ...
+AN_Add_Shortcut=Add
+AD_Add_Shortcut=Add
+CTL_Remove_Shortcut=Remo&ve
+AN_Remove_Shortcut=Remove
+AD_Remove_Shortcut=Remove
+CTL_Actions=Actio&ns:
+AN_Actions=Actions
+AD_Actions=Actions
+CTL_Shortcuts=&Shortcuts:
+AN_Shortcuts=Shortcuts
+AD_Shortcuts=Shortcuts
+AN_Profiles=Profiles
+AD_Profiles=Profiles
+Show_Actions=Actio&ns
+Show_Shortcuts=&Shortcuts
+Keymaps=&Keymaps
+Keymap_Name=&Profile:
+View_By=&View By
+Shortcut=&Shortcut:
+Add_Shortcut_Dialog=Add Shortcut Dialog
+CTL_Create_New_Profile_Message=Profile Name:
+CTL_Create_New_Profile_Title=Create New Profile Dialog
+Shortcut_Conflict=Shortcut already assigned to {0} Action.
+CTL_Clear=&Clear
+CTL_Tab=&Tab
+CTL_Duplicate_Profile_Name=Profile with such name already exists.\n Choose different name, please.
+
+CTL_Export_IDE_Actions_Action=Export IDE Actions to XML
+CTL_Export_IDE_Shortcuts_Action=Export IDE Shortcuts to XML
+CTL_Export_Editor_Shortcuts_Action=Export Editor Shortcuts to XML
+CTL_Export_Shortcuts_to_HTML_Action=Export Shortcuts to HTML
+
+CTL_Other=Other
Index: editor/options/src/org/netbeans/modules/options/editor/keymap/EditorBridge.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/editor/keymap/EditorBridge.java
diff -N editor/options/src/org/netbeans/modules/options/editor/keymap/EditorBridge.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ editor/options/src/org/netbeans/modules/options/editor/keymap/EditorBridge.java 19 Mar 2007 14:51:47 -0000 1.1.2.2
@@ -0,0 +1,496 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License (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.html
+ * or http://www.netbeans.org/cddl.txt.
+ *
+ * When distributing Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at http://www.netbeans.org/cddl.txt.
+ * If applicable, add the following below the CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * 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.
+ */
+
+package org.netbeans.modules.options.editor.keymap;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Set;
+import java.util.StringTokenizer;
+import javax.swing.Action;
+import javax.swing.KeyStroke;
+import javax.swing.text.EditorKit;
+import javax.swing.text.TextAction;
+import org.netbeans.api.editor.mimelookup.MimeLookup;
+import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.api.editor.settings.MultiKeyBinding;
+import org.netbeans.spi.shortcuts.KeymapManager;
+import org.netbeans.api.shortcuts.ShortcutAction;
+import org.netbeans.editor.BaseAction;
+import org.netbeans.editor.BaseKit;
+import org.netbeans.modules.editor.NbEditorKit;
+import org.netbeans.modules.editor.settings.storage.api.EditorSettings;
+import org.netbeans.modules.editor.settings.storage.api.KeyBindingSettingsFactory;
+import org.openide.ErrorManager;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.Repository;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+import org.openide.util.Utilities;
+
+
+/**
+ * @author Jan Jancura
+ */
+public final class EditorBridge extends KeymapManager {
+
+ private static final String EDITOR_BRIDGE = "EditorBridge";
+
+ public EditorBridge() {
+ super(EDITOR_BRIDGE);
+ }
+
+ private Map actions;
+
+ public Map getActions () {
+ if (actions == null) {
+ Map categories = readCategories ();
+ actions = new HashMap ();
+ Iterator it = getEditorActionsMap ().values ().iterator ();
+ while (it.hasNext ()) {
+ ShortcutAction action = (ShortcutAction) it.next ();
+ String category = (String) categories.get (action.getId ());
+ if (category == null)
+ category = NbBundle.getMessage
+ (EditorBridge.class, "CTL_Other"); // NOI18N
+ Set a = (Set) actions.get (category);
+ if (a == null) {
+ a = new HashSet ();
+ actions.put (category, a);
+ }
+ a.add (action);
+ }
+ actions.remove ("Hidden"); // NOI18N
+ }
+ return actions;
+ }
+
+ public void refreshActions () {
+ editorActionsMap = null;
+ actions = null;
+ actionNameToMimeTypes = new HashMap ();
+ }
+
+ public String getCurrentProfile () {
+ return getEditorSettings ().getCurrentKeyMapProfile ();
+ }
+
+ public void setCurrentProfile (String profile) {
+ getEditorSettings ().setCurrentKeyMapProfile (profile);
+ }
+
+ public boolean isCustomProfile (String profile) {
+ return getEditorSettings ().isCustomKeymapProfile (profile);
+ }
+
+ public Map getKeymap (String profile) {
+ Map result = new HashMap ();
+ readKeymap (profile, "text/base", false, result);
+ Iterator it = getEditorSettings ().getMimeTypes ().iterator ();
+ while (it.hasNext ())
+ readKeymap (profile, (String) it.next (), false, result);
+ return Collections.unmodifiableMap (result);
+ }
+
+ Map readKeymapDefaults (String profile) {
+ Map result = new HashMap ();
+ readKeymap (profile, "text/base", true, result);
+ Iterator it = getEditorSettings ().getMimeTypes ().iterator ();
+ while (it.hasNext ())
+ readKeymap (profile, (String) it.next (), true, result);
+ return Collections.unmodifiableMap (result);
+ }
+
+ public void deleteProfile (String profile) {
+ KeyBindingSettingsFactory kbs = getKeyBindingSettings ("text/base");
+ kbs.setKeyBindings (profile, null);
+ }
+
+ /**
+ * Saves actionToShortcuts Map (GlobalAction > Set (String (shortcut)).
+ * Ignores all non EditorAction actions.
+ */
+ public void saveKeymap (String profile, Map actionToShortcuts) {
+
+ // 1)
+ // convert actionToShortcuts: Map (ShortcutAction > Set (String (shortcut AS-M)))
+ // to mimeTypeToKeyBinding: Map (String (mimetype) > List (MultiKeyBinding)).
+ Map mimeTypeToKeyBinding = new HashMap (); // editor shortcuts
+ Iterator it = actionToShortcuts.keySet ().iterator ();
+ while (it.hasNext ()) {
+ ShortcutAction action = (ShortcutAction) it.next ();
+ Set shortcuts = (Set) actionToShortcuts.get (action);
+
+ action = action.getKeymapManagerInstance(EDITOR_BRIDGE);
+ if (!(action instanceof EditorAction)) continue;
+ EditorAction editorAction = (EditorAction) action;
+ Set mimeTypes = getMimeTypes (editorAction);
+
+ Iterator it2 = shortcuts.iterator ();
+ while (it2.hasNext ()) {
+ String shortcut = (String) it2.next ();
+ MultiKeyBinding mkb = new MultiKeyBinding (
+ stringToKeyStrokes2 (shortcut),
+ editorAction.getId ()
+ );
+ Iterator it3 = mimeTypes.iterator ();
+ while (it3.hasNext ()) {
+ String mimeType = (String) it3.next ();
+ List l = (List) mimeTypeToKeyBinding.get (mimeType);
+ if (l == null) {
+ l = new ArrayList ();
+ mimeTypeToKeyBinding.put (mimeType, l);
+ }
+ l.add (mkb);
+ }
+ }
+ }
+
+ // 2) save all shortcuts
+ it = keyBindingSettings.keySet ().iterator ();
+ while (it.hasNext ()) {
+ String mimeType = (String) it.next ();
+ KeyBindingSettingsFactory kbs = (KeyBindingSettingsFactory) keyBindingSettings.
+ get (mimeType);
+ //log ("changeKeymap.editorShortcuts " + mimeType, (List) mimeTypeToKeyBinding.get (mimeType));
+ kbs.setKeyBindings (profile, (List) mimeTypeToKeyBinding.get (mimeType));
+ }
+ }
+
+
+ // private methods .........................................................
+
+ /** Map (String (mimeType) > Set (String (action name))). */
+ private Map editorActionsMap;
+ /** Map (ShortcutAction > Set (String (mimeType))). */
+ private Map actionNameToMimeTypes = new HashMap ();
+
+ /**
+ * Returns map of all editor actions.
+ * Map (String (mimeType) > Set (String (action name)))
+ */
+ private Map getEditorActionsMap () {
+ if (editorActionsMap == null) {
+ editorActionsMap = new HashMap ();
+ Iterator it = getEditorSettings ().getMimeTypes ().iterator ();
+ while (it.hasNext ())
+ initActionMap ((String) it.next ());
+ initActionMap ("text/base");
+ }
+ return editorActionsMap;
+ }
+
+ private Set getMimeTypes (EditorAction a) {
+ getEditorActionsMap (); // initialization
+ return (Set) actionNameToMimeTypes.get (a.getId ());
+ }
+
+ /**
+ * Loads editor actions for given mimeType to editorActionsMap.
+ */
+ private void initActionMap (String mimeType) {
+
+ // 1) get EditorKit
+ EditorKit editorKit = null;
+ if (mimeType.equals ("text/base")) {
+ editorKit = BaseKit.getKit (NbEditorKit.class);
+ } else {
+ Lookup mimeLookup = MimeLookup.getLookup (MimePath.parse(mimeType));
+ editorKit = (EditorKit) mimeLookup.lookup (EditorKit.class);
+ }
+ if (editorKit == null) {
+ if (System.getProperty ("org.netbeans.optionsDialog") != null)
+ System.out.println
+ ("KeymapModel EditorKit not found for: " + mimeType);
+ return;
+ }
+
+ // 2) copy actions from EditorKit to actionMap
+ Action[] as = editorKit.getActions ();
+ int i, k = as.length;
+ for (i = 0; i < k; i++) {
+ Object isHidden = as [i].getValue (BaseAction.NO_KEYBINDING);
+ if (isHidden instanceof Boolean &&
+ ((Boolean) isHidden).booleanValue ()
+ )
+ continue; // ignore hidden actions
+
+ EditorAction action = new EditorAction ((TextAction) as [i]);
+ String id = action.getId ();
+ editorActionsMap.put (id, action);
+ if (mimeType.equals ("text/base")) {
+ actionNameToMimeTypes.put (id, Collections.singleton ("text/base"));
+ continue;
+ }
+ Set s = (Set) actionNameToMimeTypes.get (id);
+ if (s == null) {
+ s = new HashSet ();
+ actionNameToMimeTypes.put (id, s);
+ }
+ s.add (mimeType);
+ }
+ }
+
+ private EditorSettings editorSettings;
+
+ private EditorSettings getEditorSettings () {
+ if (editorSettings == null)
+ editorSettings = EditorSettings.getDefault ();
+ return editorSettings;
+ }
+
+ private Map keyBindingSettings = new HashMap ();
+ private KeyBindingSettingsFactory getKeyBindingSettings (String mimeType) {
+ if (keyBindingSettings.containsKey (mimeType))
+ return (KeyBindingSettingsFactory) keyBindingSettings.get (mimeType);
+ KeyBindingSettingsFactory kbs = EditorSettings.getDefault ().
+ getKeyBindingSettings (new String[] {mimeType});
+ keyBindingSettings.put (mimeType, kbs);
+ getListener ().add (kbs);
+ return kbs;
+ }
+
+ private Listener listener;
+ private Listener getListener () {
+ if (listener == null)
+ listener = new Listener (this);
+ return listener;
+ }
+
+ private static class Listener implements PropertyChangeListener {
+
+ private WeakReference model;
+ private Set settings = new HashSet ();
+
+ Listener (EditorBridge model) {
+ this.model = new WeakReference (model);
+ }
+
+ void add (KeyBindingSettingsFactory settings) {
+ this.settings.add (settings);
+ settings.addPropertyChangeListener (this);
+ }
+
+ private EditorBridge getModel () {
+ EditorBridge m = (EditorBridge) model.get ();
+ if (m != null) return m;
+ Iterator it = settings.iterator ();
+ while (it.hasNext ())
+ ((KeyBindingSettingsFactory) it.next ()).
+ removePropertyChangeListener (this);
+ settings = new HashSet ();
+ return null;
+ }
+
+ public void propertyChange (PropertyChangeEvent evt) {
+ EditorBridge model = getModel ();
+ if (model == null) return;
+ //model.keyMaps = new HashMap ();
+ }
+ }
+
+ /**
+ * Reads keymap for given mimetype and profile to given map
+ * Map (ShortcutAction > Set (String (shortcut)))
+ */
+ private void readKeymap (
+ String profile,
+ String mimeType,
+ boolean defaults,
+ Map map
+ ) {
+ // 1) get list of MultiKeyBindings
+ KeyBindingSettingsFactory kbs = getKeyBindingSettings (mimeType);
+ if (kbs == null) return;
+ List keyBindings = defaults ?
+ kbs.getKeyBindingDefaults (profile) :
+ kbs.getKeyBindings (profile);
+ if (keyBindings == null) return;
+
+ // 2) create Map (String (action name) > Set (String (shortcut)))
+ Map actionNameToShortcuts = convertKeymap (keyBindings);
+
+ // 3) create Map (EditorAction > Set (String (shortcut)))
+ Iterator it = actionNameToShortcuts.keySet ().iterator ();
+ while (it.hasNext ()) {
+ String actionName = (String) it.next ();
+ Set keyStrokes = (Set) actionNameToShortcuts.get
+ (actionName);
+ ShortcutAction action = (ShortcutAction) getEditorActionsMap ().get (actionName);
+ if (action == null) {
+ if (System.getProperty ("org.netbeans.optionsDialog") != null)
+ System.out.println ("action not found " + actionName);
+ continue;
+ }
+ Set s = (Set) map.get (action);
+ if (s == null)
+ map.put (action, keyStrokes);
+ else
+ s.addAll (keyStrokes);
+ }
+ }
+
+ /**
+ * create Map (String (action name) > Set (String (shortcut AS-M)))
+ *
+ * @param keyBindings list of MultiKeyBindings
+ */
+ private static Map convertKeymap (List keyBindings) {
+ Map actionNameToShortcuts = new HashMap ();
+ int i, k = keyBindings.size ();
+ for (i = 0; i < k; i++) {
+ MultiKeyBinding mkb = (MultiKeyBinding) keyBindings.get (i);
+ String keyStroke = "";
+ Iterator it = mkb.getKeyStrokeList ().iterator ();
+ if (it.hasNext ()) {
+ StringBuffer sb = new StringBuffer
+ (Utilities.keyToString ((KeyStroke) it.next ()));
+ while (it.hasNext ())
+ sb.append (' ').append
+ (Utilities.keyToString ((KeyStroke) it.next ()));
+ keyStroke = sb.toString ();
+ }
+
+ Set keyStrokes = (Set) actionNameToShortcuts.get
+ (mkb.getActionName ());
+ if (keyStrokes == null) {
+ keyStrokes = new HashSet ();
+ actionNameToShortcuts.put (mkb.getActionName (), keyStrokes);
+ }
+ keyStrokes.add (keyStroke);
+ //S ystem.out.println(" " + mkb.actionName + " : " + keyStroke);
+ }
+ return actionNameToShortcuts;
+ }
+
+ private static Map readCategories () {
+ Map result = new HashMap ();
+ FileSystem fs = Repository.getDefault ().getDefaultFileSystem ();
+ FileObject fo = fs.findResource ("OptionsDialog/Actions");
+ if (fo == null) return result;
+ FileObject[] categories = fo.getChildren ();
+ int i, k = categories.length;
+ for (i = 0; i < k; i++) {
+ String categoryName = categories [i].getName ();
+ String bundleName = (String) categories [i].getAttribute
+ ("SystemFileSystem.localizingBundle");
+ if (bundleName != null)
+ try {
+ categoryName = NbBundle.getBundle (bundleName).getString (
+ categories [i].getPath ()
+ );
+ } catch (MissingResourceException ex) {
+ ErrorManager.getDefault ().notify (ex);
+ }
+ FileObject[] actions = categories [i].getChildren ();
+ int j, jj = actions.length;
+ for (j = 0; j < jj; j++) {
+ if (actions [j].getExt ().length () > 0) continue;
+ String actionName = actions [j].getName ();
+ result.put (actionName, categoryName);
+ }
+ }
+ return result;
+ }
+
+ public List getProfiles() {
+ return null;
+ }
+
+ static KeyStroke[] stringToKeyStrokes2 (String key) {
+ StringTokenizer st = new StringTokenizer (key, " ");
+ List result = new ArrayList ();
+ key = null;
+ while (st.hasMoreTokens ()) {
+ String ks = st.nextToken ().trim ();
+ KeyStroke keyStroke = Utilities.stringToKey (ks);
+ //S ystem.out.println("1 " + ks + ">" + keyStroke);
+ if (keyStroke == null) {
+ if (System.getProperty ("org.netbeans.optionsDialog") != null)
+ System.out.println("no key stroke for:" + key);
+ return null;
+ }
+ result.add (keyStroke);
+ }
+ return (KeyStroke[]) result.toArray
+ (new KeyStroke [result.size ()]);
+ }
+
+ public static class EditorAction implements ShortcutAction {
+ private TextAction action;
+ private String name;
+ private String id;
+ private String delegaitngActionId;
+
+ public EditorAction (TextAction a) {
+ action = a;
+ }
+
+ public String getDisplayName () {
+ if (name == null) {
+ name = (String) action.getValue (Action.SHORT_DESCRIPTION);
+ name = name.replaceAll ("&", "").trim ();
+ }
+ return name;
+ }
+
+ public String getId () {
+ if (id == null)
+ id = (String) action.getValue (Action.NAME);
+ return id;
+ }
+
+ public String getDelegatingActionId () {
+ if (delegaitngActionId == null)
+ delegaitngActionId = (String) action.getValue
+ (NbEditorKit.SYSTEM_ACTION_CLASS_NAME_PROPERTY);
+ return delegaitngActionId;
+ }
+
+ public boolean equals (Object o) {
+ if (!(o instanceof EditorAction)) return false;
+ return ((EditorAction) o).getId ().equals (getId ());
+ }
+
+ public int hashCode () {
+ return getId ().hashCode ();
+ }
+
+ public String toString () {
+ return "EditorAction[" + getDisplayName() + ":" + getId() + "]";
+ }
+
+ public ShortcutAction getKeymapManagerInstance(String keymapManagerName) {
+ if (EDITOR_BRIDGE.equals(keymapManagerName)) {
+ return this;
+ }
+ return null;
+ }
+}
+}
Index: editor/options/src/org/netbeans/modules/options/general/AdvancedProxyPanel.form
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/general/AdvancedProxyPanel.form,v
retrieving revision 1.2
retrieving revision 1.2.8.1
diff -u -r1.2 -r1.2.8.1
Index: editor/options/src/org/netbeans/modules/options/general/AdvancedProxyPanel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/general/AdvancedProxyPanel.java,v
retrieving revision 1.2
retrieving revision 1.2.8.1
diff -u -r1.2 -r1.2.8.1
Index: editor/options/src/org/netbeans/modules/options/general/Bundle.properties
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/general/Bundle.properties,v
retrieving revision 1.14
retrieving revision 1.10.4.1
diff -u -r1.14 -r1.10.4.1
Index: editor/options/src/org/netbeans/modules/options/general/GeneralOptions.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/general/GeneralOptions.java,v
retrieving revision 1.6
retrieving revision 1.5.16.1
diff -u -r1.6 -r1.5.16.1
Index: editor/options/src/org/netbeans/modules/options/general/GeneralOptionsModel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/general/GeneralOptionsModel.java,v
retrieving revision 1.13
retrieving revision 1.4.4.1
diff -u -r1.13 -r1.4.4.1
Index: editor/options/src/org/netbeans/modules/options/general/GeneralOptionsPanel.form
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/general/GeneralOptionsPanel.form,v
retrieving revision 1.7
retrieving revision 1.5.4.1
diff -u -r1.7 -r1.5.4.1
Index: editor/options/src/org/netbeans/modules/options/general/GeneralOptionsPanel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/general/GeneralOptionsPanel.java,v
retrieving revision 1.31
retrieving revision 1.25.4.1
diff -u -r1.31 -r1.25.4.1
Index: editor/options/src/org/netbeans/modules/options/general/GeneralOptionsPanelController.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/general/GeneralOptionsPanelController.java,v
retrieving revision 1.8
retrieving revision 1.7.12.1
diff -u -r1.8 -r1.7.12.1
Index: editor/options/src/org/netbeans/modules/options/generaleditor/Bundle.properties
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/generaleditor/Bundle.properties,v
retrieving revision 1.5
retrieving revision 1.4.16.1
diff -u -r1.5 -r1.4.16.1
Index: editor/options/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanel.java,v
retrieving revision 1.8
retrieving revision 1.7.16.1
diff -u -r1.8 -r1.7.16.1
Index: editor/options/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanelController.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/generaleditor/GeneralEditorPanelController.java,v
retrieving revision 1.5
retrieving revision 1.4.16.1
diff -u -r1.5 -r1.4.16.1
Index: editor/options/src/org/netbeans/modules/options/generaleditor/Model.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/generaleditor/Model.java,v
retrieving revision 1.7
retrieving revision 1.3.20.1
diff -u -r1.7 -r1.3.20.1
Index: editor/options/src/org/netbeans/modules/options/indentation/Bundle.properties
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/indentation/Bundle.properties,v
retrieving revision 1.6
retrieving revision 1.5.12.1
diff -u -r1.6 -r1.5.12.1
Index: editor/options/src/org/netbeans/modules/options/indentation/Indentation.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/indentation/Indentation.java,v
retrieving revision 1.7
retrieving revision 1.6.16.1
diff -u -r1.7 -r1.6.16.1
Index: editor/options/src/org/netbeans/modules/options/indentation/IndentationModel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/indentation/IndentationModel.java,v
retrieving revision 1.9
retrieving revision 1.3.26.1
diff -u -r1.9 -r1.3.26.1
Index: editor/options/src/org/netbeans/modules/options/indentation/IndentationPanel.form
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/indentation/IndentationPanel.form,v
retrieving revision 1.2
retrieving revision 1.1.12.1
diff -u -r1.2 -r1.1.12.1
Index: editor/options/src/org/netbeans/modules/options/indentation/IndentationPanel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/indentation/IndentationPanel.java,v
retrieving revision 1.24
retrieving revision 1.21.12.1
diff -u -r1.24 -r1.21.12.1
Index: editor/options/src/org/netbeans/modules/options/indentation/IndentationPanelController.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/indentation/IndentationPanelController.java,v
retrieving revision 1.9
retrieving revision 1.8.12.1
diff -u -r1.9 -r1.8.12.1
Index: editor/options/src/org/netbeans/modules/options/keymap/ActionImpl.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/ActionImpl.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/ActionImpl.java
--- editor/options/src/org/netbeans/modules/options/keymap/ActionImpl.java 30 Jun 2006 19:18:15 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-
-package org.netbeans.modules.options.keymap;
-
-
-public interface ActionImpl {
-
- public String getDisplayName ();
- public String getId ();
- public String getDelegatingActionId ();
-}
-
Index: editor/options/src/org/netbeans/modules/options/keymap/Bundle.properties
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/Bundle.properties
diff -N editor/options/src/org/netbeans/modules/options/keymap/Bundle.properties
--- editor/options/src/org/netbeans/modules/options/keymap/Bundle.properties 30 Jun 2006 19:18:15 -0000 1.15
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-# The contents of this file are subject to the terms of the Common Development
-# and Distribution License (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.html
-# or http://www.netbeans.org/cddl.txt.
-#
-# When distributing Covered Code, include this CDDL Header Notice in each file
-# and include the License file at http://www.netbeans.org/cddl.txt.
-# If applicable, add the following below the CDDL Header, with the fields
-# enclosed by brackets [] replaced by your own identifying information:
-# "Portions Copyrighted [year] [name of copyright owner]"
-#
-# 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.
-
-
-CTL_Keymap_Options=&Keymap
-CTL_Keymap_Options_Title=Keymap
-CTL_Keymap_Options_Description=Keymap
-
-CTL_Duplicate=D&uplicate ...
-AN_Duplicate=Duplicate
-AD_Duplicate=Duplicate
-CTL_Delete=Dele&te
-AN_Delete=Delete
-AD_Delete=Delete
-CTL_Restore=&Restore
-AN_Restore=Restore
-AD_Restore=Restore
-CTL_Show_Actions=Actio&ns
-AN_Show_Actions=Actions
-AD_Show_Actions=Actions
-CTL_Show_Shortcuts=&Shortcuts
-AN_Show_Shortcuts=Shortcuts
-AD_Show_Shortcuts=Shortcuts
-CTL_Add_Shortcut=A&dd ...
-AN_Add_Shortcut=Add
-AD_Add_Shortcut=Add
-CTL_Remove_Shortcut=Remo&ve
-AN_Remove_Shortcut=Remove
-AD_Remove_Shortcut=Remove
-CTL_Actions=Actio&ns:
-AN_Actions=Actions
-AD_Actions=Actions
-CTL_Shortcuts=&Shortcuts:
-AN_Shortcuts=Shortcuts
-AD_Shortcuts=Shortcuts
-AN_Profiles=Profiles
-AD_Profiles=Profiles
-Show_Actions=Actio&ns
-Show_Shortcuts=&Shortcuts
-Keymaps=&Keymaps
-Keymap_Name=&Profile:
-View_By=&View By
-Shortcut=&Shortcut:
-Add_Shortcut_Dialog=Add Shortcut Dialog
-CTL_Create_New_Profile_Message=Profile Name:
-CTL_Create_New_Profile_Title=Create New Profile Dialog
-Shortcut_Conflict=Shortcut already assigned to {0} Action.
-CTL_Clear=&Clear
-CTL_Tab=&Tab
-CTL_Duplicate_Profile_Name=Profile with such name already exists.\n Choose different name, please.
-
-CTL_Export_IDE_Actions_Action=Export IDE Actions to XML
-CTL_Export_IDE_Shortcuts_Action=Export IDE Shortcuts to XML
-CTL_Export_Editor_Shortcuts_Action=Export Editor Shortcuts to XML
-CTL_Export_Shortcuts_to_HTML_Action=Export Shortcuts to HTML
-
-CTL_Other=Other
Index: editor/options/src/org/netbeans/modules/options/keymap/CompoundAction.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/CompoundAction.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/CompoundAction.java
--- editor/options/src/org/netbeans/modules/options/keymap/CompoundAction.java 30 Jun 2006 19:18:15 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,69 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-
-
-/**
- *
- * @author Jan Jancura
- */
-class CompoundAction implements ActionImpl {
- private ActionImpl editorAction;
- private ActionImpl layersAction;
-
- CompoundAction (
- ActionImpl editorAction,
- ActionImpl layersAction
- ) {
- this.editorAction = editorAction;
- this.layersAction = layersAction;
- }
-
- public String getDisplayName () {
- return editorAction.getDisplayName ();
- }
-
- public String getId () {
- return editorAction.getId ();
- }
-
- public String getDelegatingActionId () {
- return editorAction.getDelegatingActionId ();
- }
-
- ActionImpl getEditorAction () {
- return editorAction;
- }
-
- ActionImpl getLayersAction () {
- return layersAction;
- }
-
- public boolean equals (Object o) {
- return o instanceof CompoundAction &&
- ((CompoundAction) o).getEditorAction ().equals (
- getEditorAction ()
- );
- }
-
- public int hashCode () {
- return getEditorAction ().hashCode () * 2;
- }
-}
Index: editor/options/src/org/netbeans/modules/options/keymap/EditorBridge.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/EditorBridge.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/EditorBridge.java
--- editor/options/src/org/netbeans/modules/options/keymap/EditorBridge.java 13 Oct 2006 01:50:52 -0000 1.13
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,458 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.Set;
-import javax.swing.Action;
-import javax.swing.KeyStroke;
-import javax.swing.text.EditorKit;
-import javax.swing.text.TextAction;
-import org.netbeans.api.editor.mimelookup.MimeLookup;
-import org.netbeans.api.editor.mimelookup.MimePath;
-import org.netbeans.api.editor.settings.MultiKeyBinding;
-import org.netbeans.editor.BaseAction;
-import org.netbeans.editor.BaseKit;
-import org.netbeans.modules.editor.NbEditorKit;
-import org.netbeans.modules.editor.settings.storage.api.EditorSettings;
-import org.netbeans.modules.editor.settings.storage.api.KeyBindingSettingsFactory;
-import org.openide.ErrorManager;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileSystem;
-import org.openide.filesystems.Repository;
-import org.openide.util.Lookup;
-import org.openide.util.NbBundle;
-import org.openide.util.Utilities;
-
-
-/**
- * @author Jan Jancura
- */
-public final class EditorBridge {
-
- private Map actions;
-
- Map getActions () {
- if (actions == null) {
- Map categories = readCategories ();
- actions = new HashMap ();
- Iterator it = getEditorActionsMap ().values ().iterator ();
- while (it.hasNext ()) {
- ActionImpl action = (ActionImpl) it.next ();
- String category = (String) categories.get (action.getId ());
- if (category == null)
- category = NbBundle.getMessage
- (EditorBridge.class, "CTL_Other"); // NOI18N
- Set a = (Set) actions.get (category);
- if (a == null) {
- a = new HashSet ();
- actions.put (category, a);
- }
- a.add (action);
- }
- actions.remove ("Hidden"); // NOI18N
- }
- return actions;
- }
-
- void refreshActions () {
- editorActionsMap = null;
- actions = null;
- actionNameToMimeTypes = new HashMap ();
- }
-
- String getCurrentProfile () {
- return getEditorSettings ().getCurrentKeyMapProfile ();
- }
-
- void setCurrentProfile (String profile) {
- getEditorSettings ().setCurrentKeyMapProfile (profile);
- }
-
- boolean isCustomProfile (String profile) {
- return getEditorSettings ().isCustomKeymapProfile (profile);
- }
-
- Map readKeymap (String profile) {
- Map result = new HashMap ();
- readKeymap (profile, "text/base", false, result);
- Iterator it = getEditorSettings ().getMimeTypes ().iterator ();
- while (it.hasNext ())
- readKeymap (profile, (String) it.next (), false, result);
- return Collections.unmodifiableMap (result);
- }
-
- Map readKeymapDefaults (String profile) {
- Map result = new HashMap ();
- readKeymap (profile, "text/base", true, result);
- Iterator it = getEditorSettings ().getMimeTypes ().iterator ();
- while (it.hasNext ())
- readKeymap (profile, (String) it.next (), true, result);
- return Collections.unmodifiableMap (result);
- }
-
- void deleteProfile (String profile) {
- KeyBindingSettingsFactory kbs = getKeyBindingSettings ("text/base");
- kbs.setKeyBindings (profile, null);
- }
-
- /**
- * Saves actionToShortcuts Map (GlobalAction > Set (String (shortcut)).
- * Ignores all non EditorAction actions.
- */
- void saveKeymap (String profile, Map actionToShortcuts) {
-
- // 1)
- // convert actionToShortcuts: Map (ActionImpl > Set (String (shortcut AS-M)))
- // to mimeTypeToKeyBinding: Map (String (mimetype) > List (MultiKeyBinding)).
- Map mimeTypeToKeyBinding = new HashMap (); // editor shortcuts
- Iterator it = actionToShortcuts.keySet ().iterator ();
- while (it.hasNext ()) {
- ActionImpl action = (ActionImpl) it.next ();
- Set shortcuts = (Set) actionToShortcuts.get (action);
-
- if (action instanceof CompoundAction)
- action = ((CompoundAction) action).getEditorAction ();
- if (!(action instanceof EditorAction)) continue;
- EditorAction editorAction = (EditorAction) action;
- Set mimeTypes = getMimeTypes (editorAction);
-
- Iterator it2 = shortcuts.iterator ();
- while (it2.hasNext ()) {
- String shortcut = (String) it2.next ();
- MultiKeyBinding mkb = new MultiKeyBinding (
- Utils.stringToKeyStrokes2 (shortcut),
- editorAction.getId ()
- );
- Iterator it3 = mimeTypes.iterator ();
- while (it3.hasNext ()) {
- String mimeType = (String) it3.next ();
- List l = (List) mimeTypeToKeyBinding.get (mimeType);
- if (l == null) {
- l = new ArrayList ();
- mimeTypeToKeyBinding.put (mimeType, l);
- }
- l.add (mkb);
- }
- }
- }
-
- // 2) save all shortcuts
- it = keyBindingSettings.keySet ().iterator ();
- while (it.hasNext ()) {
- String mimeType = (String) it.next ();
- KeyBindingSettingsFactory kbs = (KeyBindingSettingsFactory) keyBindingSettings.
- get (mimeType);
- //log ("changeKeymap.editorShortcuts " + mimeType, (List) mimeTypeToKeyBinding.get (mimeType));
- kbs.setKeyBindings (profile, (List) mimeTypeToKeyBinding.get (mimeType));
- }
- }
-
-
- // private methods .........................................................
-
- /** Map (String (mimeType) > Set (String (action name))). */
- private Map editorActionsMap;
- /** Map (ActionImpl > Set (String (mimeType))). */
- private Map actionNameToMimeTypes = new HashMap ();
-
- /**
- * Returns map of all editor actions.
- * Map (String (mimeType) > Set (String (action name)))
- */
- private Map getEditorActionsMap () {
- if (editorActionsMap == null) {
- editorActionsMap = new HashMap ();
- Iterator it = getEditorSettings ().getMimeTypes ().iterator ();
- while (it.hasNext ())
- initActionMap ((String) it.next ());
- initActionMap ("text/base");
- }
- return editorActionsMap;
- }
-
- private Set getMimeTypes (EditorAction a) {
- getEditorActionsMap (); // initialization
- return (Set) actionNameToMimeTypes.get (a.getId ());
- }
-
- /**
- * Loads editor actions for given mimeType to editorActionsMap.
- */
- private void initActionMap (String mimeType) {
-
- // 1) get EditorKit
- EditorKit editorKit = null;
- if (mimeType.equals ("text/base")) {
- editorKit = BaseKit.getKit (NbEditorKit.class);
- } else {
- Lookup mimeLookup = MimeLookup.getLookup (MimePath.parse(mimeType));
- editorKit = (EditorKit) mimeLookup.lookup (EditorKit.class);
- }
- if (editorKit == null) {
- if (System.getProperty ("org.netbeans.optionsDialog") != null)
- System.out.println
- ("KeymapModel EditorKit not found for: " + mimeType);
- return;
- }
-
- // 2) copy actions from EditorKit to actionMap
- Action[] as = editorKit.getActions ();
- int i, k = as.length;
- for (i = 0; i < k; i++) {
- Object isHidden = as [i].getValue (BaseAction.NO_KEYBINDING);
- if (isHidden instanceof Boolean &&
- ((Boolean) isHidden).booleanValue ()
- )
- continue; // ignore hidden actions
-
- EditorAction action = new EditorAction ((TextAction) as [i]);
- String id = action.getId ();
- editorActionsMap.put (id, action);
- if (mimeType.equals ("text/base")) {
- actionNameToMimeTypes.put (id, Collections.singleton ("text/base"));
- continue;
- }
- Set s = (Set) actionNameToMimeTypes.get (id);
- if (s == null) {
- s = new HashSet ();
- actionNameToMimeTypes.put (id, s);
- }
- s.add (mimeType);
- }
- }
-
- private EditorSettings editorSettings;
-
- private EditorSettings getEditorSettings () {
- if (editorSettings == null)
- editorSettings = EditorSettings.getDefault ();
- return editorSettings;
- }
-
- private Map keyBindingSettings = new HashMap ();
- private KeyBindingSettingsFactory getKeyBindingSettings (String mimeType) {
- if (keyBindingSettings.containsKey (mimeType))
- return (KeyBindingSettingsFactory) keyBindingSettings.get (mimeType);
- KeyBindingSettingsFactory kbs = EditorSettings.getDefault ().
- getKeyBindingSettings (new String[] {mimeType});
- keyBindingSettings.put (mimeType, kbs);
- getListener ().add (kbs);
- return kbs;
- }
-
- private Listener listener;
- private Listener getListener () {
- if (listener == null)
- listener = new Listener (this);
- return listener;
- }
-
- private static class Listener implements PropertyChangeListener {
-
- private WeakReference model;
- private Set settings = new HashSet ();
-
- Listener (EditorBridge model) {
- this.model = new WeakReference (model);
- }
-
- void add (KeyBindingSettingsFactory settings) {
- this.settings.add (settings);
- settings.addPropertyChangeListener (this);
- }
-
- private EditorBridge getModel () {
- EditorBridge m = (EditorBridge) model.get ();
- if (m != null) return m;
- Iterator it = settings.iterator ();
- while (it.hasNext ())
- ((KeyBindingSettingsFactory) it.next ()).
- removePropertyChangeListener (this);
- settings = new HashSet ();
- return null;
- }
-
- public void propertyChange (PropertyChangeEvent evt) {
- EditorBridge model = getModel ();
- if (model == null) return;
- //model.keyMaps = new HashMap ();
- }
- }
-
- /**
- * Reads keymap for given mimetype and profile to given map
- * Map (ActionImpl > Set (String (shortcut)))
- */
- private void readKeymap (
- String profile,
- String mimeType,
- boolean defaults,
- Map map
- ) {
- // 1) get list of MultiKeyBindings
- KeyBindingSettingsFactory kbs = getKeyBindingSettings (mimeType);
- if (kbs == null) return;
- List keyBindings = defaults ?
- kbs.getKeyBindingDefaults (profile) :
- kbs.getKeyBindings (profile);
- if (keyBindings == null) return;
-
- // 2) create Map (String (action name) > Set (String (shortcut)))
- Map actionNameToShortcuts = convertKeymap (keyBindings);
-
- // 3) create Map (EditorAction > Set (String (shortcut)))
- Iterator it = actionNameToShortcuts.keySet ().iterator ();
- while (it.hasNext ()) {
- String actionName = (String) it.next ();
- Set keyStrokes = (Set) actionNameToShortcuts.get
- (actionName);
- ActionImpl action = (ActionImpl) getEditorActionsMap ().get (actionName);
- if (action == null) {
- if (System.getProperty ("org.netbeans.optionsDialog") != null)
- System.out.println ("action not found " + actionName);
- continue;
- }
- Set s = (Set) map.get (action);
- if (s == null)
- map.put (action, keyStrokes);
- else
- s.addAll (keyStrokes);
- }
- }
-
- /**
- * create Map (String (action name) > Set (String (shortcut AS-M)))
- *
- * @param keyBindings list of MultiKeyBindings
- */
- private static Map convertKeymap (List keyBindings) {
- Map actionNameToShortcuts = new HashMap ();
- int i, k = keyBindings.size ();
- for (i = 0; i < k; i++) {
- MultiKeyBinding mkb = (MultiKeyBinding) keyBindings.get (i);
- String keyStroke = "";
- Iterator it = mkb.getKeyStrokeList ().iterator ();
- if (it.hasNext ()) {
- StringBuffer sb = new StringBuffer
- (Utilities.keyToString ((KeyStroke) it.next ()));
- while (it.hasNext ())
- sb.append (' ').append
- (Utilities.keyToString ((KeyStroke) it.next ()));
- keyStroke = sb.toString ();
- }
-
- Set keyStrokes = (Set) actionNameToShortcuts.get
- (mkb.getActionName ());
- if (keyStrokes == null) {
- keyStrokes = new HashSet ();
- actionNameToShortcuts.put (mkb.getActionName (), keyStrokes);
- }
- keyStrokes.add (keyStroke);
- //S ystem.out.println(" " + mkb.actionName + " : " + keyStroke);
- }
- return actionNameToShortcuts;
- }
-
- private static Map readCategories () {
- Map result = new HashMap ();
- FileSystem fs = Repository.getDefault ().getDefaultFileSystem ();
- FileObject fo = fs.findResource ("OptionsDialog/Actions");
- if (fo == null) return result;
- FileObject[] categories = fo.getChildren ();
- int i, k = categories.length;
- for (i = 0; i < k; i++) {
- String categoryName = categories [i].getName ();
- String bundleName = (String) categories [i].getAttribute
- ("SystemFileSystem.localizingBundle");
- if (bundleName != null)
- try {
- categoryName = NbBundle.getBundle (bundleName).getString (
- categories [i].getPath ()
- );
- } catch (MissingResourceException ex) {
- ErrorManager.getDefault ().notify (ex);
- }
- FileObject[] actions = categories [i].getChildren ();
- int j, jj = actions.length;
- for (j = 0; j < jj; j++) {
- if (actions [j].getExt ().length () > 0) continue;
- String actionName = actions [j].getName ();
- result.put (actionName, categoryName);
- }
- }
- return result;
- }
-
- public static class EditorAction implements ActionImpl {
- private TextAction action;
- private String name;
- private String id;
- private String delegaitngActionId;
-
- public EditorAction (TextAction a) {
- action = a;
- }
-
- public String getDisplayName () {
- if (name == null) {
- name = (String) action.getValue (Action.SHORT_DESCRIPTION);
- name = name.replaceAll ("&", "").trim ();
- }
- return name;
- }
-
- public String getId () {
- if (id == null)
- id = (String) action.getValue (Action.NAME);
- return id;
- }
-
- public String getDelegatingActionId () {
- if (delegaitngActionId == null)
- delegaitngActionId = (String) action.getValue
- (NbEditorKit.SYSTEM_ACTION_CLASS_NAME_PROPERTY);
- return delegaitngActionId;
- }
-
- public boolean equals (Object o) {
- if (!(o instanceof EditorAction)) return false;
- return ((EditorAction) o).getId ().equals (getId ());
- }
-
- public int hashCode () {
- return getId ().hashCode ();
- }
-
- public String toString () {
- return super.toString () + ":" + getId ();
- }
- }
-}
Index: editor/options/src/org/netbeans/modules/options/keymap/ExportShortcutsAction.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/ExportShortcutsAction.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/ExportShortcutsAction.java
--- editor/options/src/org/netbeans/modules/options/keymap/ExportShortcutsAction.java 30 Jun 2006 19:18:15 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,464 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-
-package org.netbeans.modules.options.keymap;
-
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-import javax.swing.AbstractAction;
-import javax.swing.AbstractButton;
-import javax.swing.Action;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
-import org.netbeans.modules.options.keymap.XMLStorage.Attribs;
-import org.openide.ErrorManager;
-import org.openide.awt.Mnemonics;
-import org.openide.filesystems.FileLock;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.filesystems.Repository;
-import org.openide.loaders.DataObject;
-import org.openide.util.NbBundle;
-import org.openide.windows.TopComponent;
-import org.openide.windows.WindowManager;
-
-public class ExportShortcutsAction {
-
- private static Action exportIDEActionsAction = new AbstractAction () {
- {putValue (Action.NAME, loc ("CTL_Export_IDE_Actions_Action"));}
-
- public void actionPerformed (ActionEvent e) {
-
- // 1) load all keymaps to allKeyMaps
- LayersBridge layersBridge = new LayersBridge ();
- Map categoryToActions = layersBridge.getActions ();
- Map m = resolveNames (categoryToActions);
-
- generateLayersXML (layersBridge, m);
- }
- };
-
- public static Action getExportIDEActionsAction () {
- return exportIDEActionsAction;
- }
-
- private static Action exportIDEShortcutsAction = new AbstractAction () {
- {putValue (Action.NAME, loc ("CTL_Export_IDE_Shortcuts_Action"));}
-
- public void actionPerformed (ActionEvent e) {
-
- // 1) load all keymaps to allKeyMaps
- Map allKeyMaps = new HashMap ();
- LayersBridge layersBridge = new LayersBridge ();
- layersBridge.getActions ();
- List keyMaps = layersBridge.getProfiles ();
- Iterator it3 = keyMaps.iterator ();
- while (it3.hasNext ()) {
- String keyMapName = (String) it3.next ();
- Map actionToShortcuts = layersBridge.getKeymap (keyMapName);
- Map shortcutToAction = LayersBridge.shortcutToAction (actionToShortcuts);
- allKeyMaps.put (keyMapName, shortcutToAction);
- }
-
- generateLayersXML (layersBridge, allKeyMaps);
- }
- };
-
- public static Action getExportIDEShortcutsAction () {
- return exportIDEShortcutsAction;
- }
-
- private static Action exportEditorShortcutsAction = new AbstractAction () {
- {putValue (Action.NAME, loc ("CTL_Export_Editor_Shortcuts_Action"));}
-
- public void actionPerformed (ActionEvent e) {
-
- // 1) load all keymaps to allKeyMaps
- Map allKeyMaps = new HashMap ();
- EditorBridge editorBridge = new EditorBridge ();
- editorBridge.getActions ();
- Map actionToShortcuts = editorBridge.readKeymap (editorBridge.getCurrentProfile ());
- generateEditorXML (actionToShortcuts);
- }
- };
-
- public static Action getExportEditorShortcutsAction () {
- return exportEditorShortcutsAction;
- }
-
- private static Action exportShortcutsToHTMLAction = new AbstractAction () {
- {putValue (Action.NAME, loc ("CTL_Export_Shortcuts_to_HTML_Action"));}
-
- public void actionPerformed (ActionEvent e) {
- exportShortcutsToHTML ();
- }
- };
-
- public static Action getExportShortcutsToHTMLAction () {
- return exportShortcutsToHTMLAction;
- }
-
-
- // helper methods ..........................................................
-
- private static void exportShortcutsToHTML () {
- // read all shortcuts to keymaps
- KeymapModel keymapModel = new KeymapModel ();
- Map keymaps = new TreeMap ();
- Iterator it = keymapModel.getProfiles ().iterator ();
- while (it.hasNext ()) {
- String profile = (String) it.next ();
- keymaps.put (
- profile,
- keymapModel.getKeymap (profile)
- );
- }
-
- try {
- StringBuffer sb = new StringBuffer ();
-
- Attribs attribs = new Attribs (true);
- XMLStorage.generateFolderStart (sb, "html", attribs, "");
- XMLStorage.generateFolderStart (sb, "body", attribs, " ");
- attribs.add ("border", "1");
- attribs.add ("cellpadding", "1");
- attribs.add ("cellspacing", "0");
- XMLStorage.generateFolderStart (sb, "table", attribs, " ");
- attribs = new Attribs (true);
-
- // print header of table
- XMLStorage.generateFolderStart (sb, "tr", attribs, " ");
- XMLStorage.generateFolderStart (sb, "td", attribs, " ");
- XMLStorage.generateFolderStart (sb, "h2", attribs, " ");
- sb.append ("Action Name");
- XMLStorage.generateFolderEnd (sb, "h2", " ");
- XMLStorage.generateFolderEnd (sb, "td", " ");
- it = keymaps.keySet ().iterator ();
- while (it.hasNext ()) {
- String profile = (String) it.next ();
- XMLStorage.generateFolderStart (sb, "td", attribs, " ");
- XMLStorage.generateFolderStart (sb, "h2", attribs, " ");
- sb.append (profile);
- XMLStorage.generateFolderEnd (sb, "h2", " ");
- XMLStorage.generateFolderEnd (sb, "td", " ");
- }
-
- // print body of table
- exportShortcutsToHTML2 (keymapModel, sb, keymaps);
-
- XMLStorage.generateFolderEnd (sb, "table", " ");
- XMLStorage.generateFolderEnd (sb, "body", " ");
- XMLStorage.generateFolderEnd (sb, "html", "");
-
- FileObject fo = FileUtil.createData (
- Repository.getDefault ().getDefaultFileSystem ().getRoot (),
- "shortcuts.html"
- );
- FileLock fileLock = fo.lock ();
- try {
- OutputStream outputStream = fo.getOutputStream (fileLock);
- OutputStreamWriter writer = new OutputStreamWriter (outputStream);
- writer.write (sb.toString ());
- writer.close ();
- } catch (IOException ex) {
- ErrorManager.getDefault ().notify (ex);
- } finally {
- fileLock.releaseLock ();
- }
- } catch (IOException ex) {
- ErrorManager.getDefault ().notify (ex);
- }
- }
-
- /**
- * Writes body of shortcuts table to given StringBuffer.
- */
- private static void exportShortcutsToHTML2 (
- KeymapModel keymapModel,
- StringBuffer sb,
- Map keymaps
- ) {
- List categories = new ArrayList (keymapModel.getActionCategories ());
- Collections.sort (categories);
- Attribs attribs = new Attribs (true);
- Iterator it = categories.iterator ();
- while (it.hasNext ()) {
- String category = (String) it.next ();
-
- // print category title
- XMLStorage.generateFolderStart (sb, "tr", attribs, " ");
- attribs.add ("colspan", Integer.toString (keymaps.size () + 1));
- attribs.add ("rowspan", "1");
- XMLStorage.generateFolderStart (sb, "td", attribs, " ");
- attribs = new Attribs (true);
- XMLStorage.generateFolderStart (sb, "h3", attribs, " ");
- sb.append (category);
- XMLStorage.generateFolderEnd (sb, "h3", " ");
- XMLStorage.generateFolderEnd (sb, "td", " ");
- XMLStorage.generateFolderEnd (sb, "tr", " ");
-
- // print body of one category
- exportShortcutsToHTML3 (sb, keymapModel, category, keymaps);
- }
- }
-
- /**
- * Writes body of given category.
- */
- private static void exportShortcutsToHTML3 (
- StringBuffer sb,
- KeymapModel keymapModel,
- String category,
- Map keymaps
- ) {
- Set actions = keymapModel.getActions (category);
-
- // sort actions
- Map sortedActions = new TreeMap ();
- Iterator it = actions.iterator ();
- while (it.hasNext ()) {
- ActionImpl action = (ActionImpl) it.next ();
- sortedActions.put (
- action.getDisplayName (),
- action
- );
- }
-
- // print actions
- Attribs attribs = new Attribs (true);
- it = sortedActions.keySet ().iterator ();
- while (it.hasNext ()) {
- String actionName = (String) it.next ();
- ActionImpl action = (ActionImpl) sortedActions.get (actionName);
-
- // print action name to the first column
- XMLStorage.generateFolderStart (sb, "tr", attribs, " ");
- XMLStorage.generateFolderStart (sb, "td", attribs, " ");
- sb.append (actionName);
- XMLStorage.generateFolderEnd (sb, "td", " ");
-
- Iterator it2 = keymaps.keySet ().iterator ();
- while (it2.hasNext ()) {
- String profile = (String) it2.next ();
- Map keymap = (Map) keymaps.get (profile);
- Set shortcuts = (Set) keymap.get (action);
-
- XMLStorage.generateFolderStart (sb, "td", attribs, " ");
- printShortcuts (shortcuts, sb);
- XMLStorage.generateFolderEnd (sb, "td", " ");
- }
-
- XMLStorage.generateFolderEnd (sb, "tr", " ");
- }
- }
-
- private static void printShortcuts (Set shortcuts, StringBuffer sb) {
- if (shortcuts == null) {
- sb.append ('-');
- return;
- }
- Iterator it = shortcuts.iterator ();
- while (it.hasNext ()) {
- String shortcut = (String) it.next ();
- sb.append (shortcut);
- if (it.hasNext ()) sb.append (", ");
- }
- }
-
- private static void generateLayersXML (
- LayersBridge layersBridge,
- Map categoryToActions
- ) {
- Writer fw = null;
- try {
- fw = openWriter ();
- if (fw == null) return;
-
- StringBuffer sb = XMLStorage.generateHeader ();
- Attribs attribs = new Attribs (true);
- XMLStorage.generateFolderStart (sb, "filesystem", attribs, "");
- attribs.add ("name", "Keymaps");
- XMLStorage.generateFolderStart (sb, "folder", attribs, " ");
- generateShadowsToXML (layersBridge, sb, categoryToActions, " ");
- XMLStorage.generateFolderEnd (sb, "folder", " ");
- XMLStorage.generateFolderEnd (sb, "filesystem", "");
- System.out.println(sb.toString ());
- fw.write (sb.toString ());
- } catch (IOException e) {
- ErrorManager.getDefault ().notify (e);
- } finally {
- try {
- if (fw != null) {
- fw.flush ();
- fw.close ();
- }
- } catch (IOException e) {}
- }
- }
-
- private static void generateEditorXML (
- Map actionToShortcuts
- ) {
- Writer fw = null;
- try {
- fw = openWriter ();
- if (fw == null) return;
-
- StringBuffer sb = XMLStorage.generateHeader ();
- Attribs attribs = new Attribs (true);
- XMLStorage.generateFolderStart (sb, "bindings", attribs, "");
-
- Map sortedMap = new TreeMap ();
- Iterator it = actionToShortcuts.keySet ().iterator ();
- while (it.hasNext ()) {
- ActionImpl action = (ActionImpl) it.next ();
- sortedMap.put (
- action.getDisplayName (),
- actionToShortcuts.get (action)
- );
- }
- it = sortedMap.keySet ().iterator ();
- while (it.hasNext ()) {
- String actionName = (String) it.next ();
- Set shortcuts = (Set) sortedMap.get (actionName);
- Iterator it2 = shortcuts.iterator ();
- while (it2.hasNext ()) {
- String shortcut = (String) it2.next ();
- attribs = new Attribs (true);
- attribs.add ("actionName", actionName);
- attribs.add ("key", shortcut);
- XMLStorage.generateLeaf (sb, "bind", attribs, " ");
- }
- }
-
- XMLStorage.generateFolderEnd (sb, "bindings", "");
- System.out.println(sb.toString ());
- fw.write (sb.toString ());
- } catch (IOException e) {
- ErrorManager.getDefault ().notify (e);
- } finally {
- try {
- if (fw != null) {
- fw.flush ();
- fw.close ();
- }
- } catch (IOException e) {}
- }
- }
-
- private static Map resolveNames (Map categoryToActions) {
- Map result = new HashMap ();
- Iterator it = categoryToActions.keySet ().iterator ();
- while (it.hasNext ()) {
- String category = (String) it.next ();
- Set actions = (Set) categoryToActions.get (category);
- Map actionsMap = new HashMap ();
- Iterator it1 = actions.iterator ();
- while (it1.hasNext ()) {
- ActionImpl action = (ActionImpl) it1.next ();
- actionsMap.put (action.getDisplayName (), action);
- }
- result.put (category, actionsMap);
- }
- return result;
- }
-
- /**
- * Converts:
- * Map (String (profile | category) > Map (String (category)) |
- * ActionImpl)
- * to xml.
- * (String > Map) is represented by folder and
- * (String > DataObject) by ShadowDO
- */
- private static void generateShadowsToXML (
- LayersBridge layersBridge,
- StringBuffer sb,
- Map shortcutToAction,
- String indentation
- ) {
- Iterator it = shortcutToAction.keySet ().iterator ();
- while (it.hasNext ()) {
- String key = (String) it.next ();
- Object value = shortcutToAction.get (key);
- if (value instanceof Map) {
- Attribs attribs = new Attribs (true);
- attribs.add ("name", key);
- XMLStorage.generateFolderStart (sb, "folder", attribs, indentation);
- generateShadowsToXML (
- layersBridge,
- sb,
- (Map) value,
- " " + indentation
- );
- XMLStorage.generateFolderEnd (sb, "folder", indentation);
- } else {
- DataObject dob = layersBridge.getDataObject (value);
- if (dob == null) {
- System.out.println("no Dataobject " + value);
- continue;
- }
- FileObject fo = dob.getPrimaryFile ();
- Attribs attribs = new Attribs (true);
- attribs.add ("name", (String) key + ".shadow");
- XMLStorage.generateFolderStart (sb, "file", attribs, indentation);
- Attribs attribs2 = new Attribs (true);
- attribs2.add ("name", "originalFile");
- attribs2.add ("stringvalue", fo.getPath ());
- XMLStorage.generateLeaf (sb, "attr", attribs2, indentation + " ");
- XMLStorage.generateFolderEnd (sb, "file", indentation);
- }
- }
- }
-
- private static Writer openWriter () throws IOException {
- JFileChooser fileChooser = new JFileChooser ();
- int result = fileChooser.showSaveDialog
- (WindowManager.getDefault ().getMainWindow ());
- if (result != JFileChooser.APPROVE_OPTION) return null;
- File f = fileChooser.getSelectedFile ();
- return new FileWriter (f);
- }
-
- private static String loc (String key) {
- return NbBundle.getMessage (ExportShortcutsAction.class, key);
- }
-}
-
Index: editor/options/src/org/netbeans/modules/options/keymap/Keymap.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/Keymap.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/Keymap.java
--- editor/options/src/org/netbeans/modules/options/keymap/Keymap.java 30 Jun 2006 19:18:15 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import javax.swing.JComponent;
-import org.netbeans.spi.options.OptionsCategory;
-import org.netbeans.spi.options.OptionsPanelController;
-import org.openide.util.NbBundle;
-import org.openide.util.Utilities;
-
-
-/**
- * Contains information about General Options Panel, and creates a new
- * instance of it.
- *
- * @author Jan Jancura
- */
-
-public final class Keymap extends OptionsCategory {
-
- private static String loc (String key) {
- return NbBundle.getMessage (Keymap.class, key);
- }
-
-
- private static Icon icon;
-
- public Icon getIcon () {
- if (icon == null)
- icon = new ImageIcon (
- Utilities.loadImage
- ("org/netbeans/modules/options/resources/keymap.png")
- );
- return icon;
- }
-
- public String getCategoryName () {
- return loc ("CTL_Keymap_Options");
- }
-
- public String getTitle () {
- return loc ("CTL_Keymap_Options_Title");
- }
-
- public String getDescription () {
- return loc ("CTL_Keymap_Options_Description");
- }
-
- public OptionsPanelController create () {
- return new KeymapPanelController ();
- }
-}
Index: editor/options/src/org/netbeans/modules/options/keymap/KeymapListRenderer.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/KeymapListRenderer.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/KeymapListRenderer.java
--- editor/options/src/org/netbeans/modules/options/keymap/KeymapListRenderer.java 30 Jun 2006 19:18:15 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,91 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-
-import java.awt.Component;
-import javax.swing.JTree;
-import javax.swing.tree.DefaultTreeCellRenderer;
-import org.netbeans.modules.options.keymap.Utils;
-import org.openide.ErrorManager;
-
-/**
- *
- * @author Jan Jancura
- */
-public class KeymapListRenderer extends DefaultTreeCellRenderer {
-
- private KeymapViewModel keymapViewModel;
- private static ErrorManager log = ErrorManager.getDefault ().getInstance
- (KeymapListRenderer.class.getName ());
-
-
- public KeymapListRenderer (KeymapViewModel keymapViewModel) {
- if (keymapViewModel == null) throw new NullPointerException ();
- this.keymapViewModel = keymapViewModel;
- //Image i = Utilities.loadImage ("org/openide/resources/actions/empty.gif");
- setLeafIcon (null);
- }
-
- public Component getTreeCellRendererComponent (
- JTree tree,
- Object value,
- boolean sel,
- boolean expanded,
- boolean leaf,
- int row,
- boolean hasFocus
- ) {
- super.getTreeCellRendererComponent (tree, value, sel, expanded, leaf, row, hasFocus);
-
- // There needs to be a way to specify disabled icons.
- if (leaf) {
- String displayName = ((ActionImpl) value).getDisplayName ();
- StringBuffer text = new StringBuffer (displayName);
- if (log.isLoggable (1)) {
- text.append (" <");
- text.append (((ActionImpl) value).getId ());
- text.append ("> ");
- }
- String[] shortcuts = keymapViewModel.getShortcuts ((ActionImpl) value);
- if (shortcuts.length == 1)
- text.append (" [").append (shortcuts [0]).append ("]");
- else
- if (shortcuts.length > 1) {
- int i, k = shortcuts.length;
- text.append (" [").append (shortcuts [0]);
- for (i = 1; i < k; i++)
- text.append (",").append (shortcuts [i]);
- text.append ("]");
- }
-// if (value instanceof Action) {
-// text += " " + ((Action) value).getValue (Action.NAME);
-// }
- setText (text.toString ());
-// Icon icon = getLeafIcon (); //Utils.getIcon (value);
-// if (icon != null) {
-// if (tree.isEnabled ())
-// setIcon (icon);
-// else
-// setDisabledIcon (icon);
-// }
- }
- return this;
- }
-}
\ No newline at end of file
Index: editor/options/src/org/netbeans/modules/options/keymap/KeymapModel.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/KeymapModel.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/KeymapModel.java
--- editor/options/src/org/netbeans/modules/options/keymap/KeymapModel.java 11 Jan 2007 03:01:26 -0000 1.19
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,257 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- *
- * @author Jan Jancura
- */
-public class KeymapModel {
-
- private static final Logger LOG = Logger.getLogger(KeymapModel.class.getName ());
-
- private LayersBridge layersBridge = new LayersBridge ();
- private EditorBridge editorBridge = new EditorBridge ();
-
- // actions .................................................................
-
- public Set /**/ getActionCategories () {
- Set result = new HashSet ();
- result.addAll (layersBridge.getActions ().keySet ());
- result.addAll (editorBridge.getActions ().keySet ());
- return Collections.unmodifiableSet (result);
- }
-
- /** Map (String (category name) > Set (ActionImpl)). */
- private Map categoryToActions = new HashMap ();
-
- /**
- * Returns List (ActionImpl) of all global and editor actions.
- */
- public Set getActions (String category) {
- if (!categoryToActions.containsKey (category)) {
- Set actions = new HashSet ();
- Set s = (Set) layersBridge.getActions ().get (category);
- if (s != null) actions.addAll (s);
- s = (Set) editorBridge.getActions ().get (category);
- if (s != null)
- actions = mergeActions (s, actions);
- categoryToActions.put (category, actions);
- }
- return (Set) categoryToActions.get (category);
- }
-
- /**
- * Clear action caches.
- */
- public void refreshActions () {
- categoryToActions = new HashMap ();
- editorBridge.refreshActions ();
- }
-
- // keymaps .................................................................
-
- public String getCurrentProfile () {
- return editorBridge.getCurrentProfile ();
- }
-
- public void setCurrentProfile (String profile) {
- //layersBridge.setCurrentProfile (profile); !!!!!!!!!!!!!
- editorBridge.setCurrentProfile (profile);
- }
-
- public List getProfiles () {
- return layersBridge.getProfiles ();
- }
-
- public boolean isCustomProfile (String profile) {
- return editorBridge.isCustomProfile (profile);
- }
-
- /** Map (String (profile) > Map (ActionImpl > Set (String (shortcut AS-M)))). */
- private Map keyMaps = new HashMap ();
-
- /**
- * Returns Map (ActionImpl > Set (String (shortcut))).
- */
- public Map getKeymap (String profile) {
- if (!keyMaps.containsKey (profile)) {
- keyMaps.put (
- profile,
- mergeShortcuts (
- (Map) editorBridge.readKeymap (profile),
- (Map) layersBridge.getKeymap (profile)
- )
- );
- }
- return (Map) keyMaps.get (profile);
- }
-
- /** Map (String (keymap name) > Map (ActionImpl > Set (String (shortcut AS-M)))). */
- private Map keyMapDefaults = new HashMap ();
-
- /**
- * Returns Map (ActionImpl > Set (String (shortcut))).
- */
- public Map getKeymapDefaults (String profile) {
- if (!keyMapDefaults.containsKey (profile)) {
- keyMapDefaults.put (
- profile,
- mergeShortcuts (
- (Map) editorBridge.readKeymapDefaults(profile),
- (Map) layersBridge.getKeymapDefaults(profile)
- )
- );
- }
- return (Map) keyMapDefaults.get (profile);
- }
-
- public void deleteProfile (String profile) {
- layersBridge.deleteProfile (profile);
- editorBridge.deleteProfile (profile);
- }
-
- /**
- * Defines new shortcuts for some actions in given keymap.
- * Map (ActionImpl > Set (String (shortcut AS-M P)).
- */
- public void changeKeymap (String profile, Map actionToShortcuts) {
- log ("changeKeymap.actionToShortcuts", actionToShortcuts.entrySet ());
-
- // 1) mix changes with current keymap and put them to cached current shortcuts
- Map m = new HashMap (getKeymap (profile));
- m.putAll (actionToShortcuts);
- keyMaps.put (profile, m);
- log ("changeKeymap.m", m.entrySet ());
-
- layersBridge.saveKeymap (profile, m);
- editorBridge.saveKeymap (profile, m);
- }
-
-
- // private methods .........................................................
-
- private void log(String name, Collection items) {
- if (!LOG.isLoggable(Level.FINE)) return;
-
- LOG.fine(name);
- for(Iterator i = items.iterator(); i.hasNext(); ) {
- Object item = i.next();
- LOG.fine(" " + item);
- }
- }
-
- private Map sharedActions = new HashMap ();
-
- /**
- * Merges editor actions and layers actions. Creates CompoundAction for
- * actions like Copy, registerred to both contexts.
- */
- private Set mergeActions (
- Collection editorActions,
- Collection layersActions
- ) {
- Set result = new HashSet ();
- Map idToAction = new HashMap ();
- if (editorActions != null) {
- Iterator it = editorActions.iterator ();
- while (it.hasNext ()) {
- ActionImpl action = (ActionImpl) it.next ();
- String id = action.getDelegatingActionId ();
- if (id != null)
- idToAction.put (id, action);
- else
- result.add (action);
- }
- }
-
- if (layersActions != null) {
- Iterator it = layersActions.iterator ();
- while (it.hasNext ()) {
- ActionImpl layersAction = (ActionImpl) it.next ();
- String id = layersAction.getId ();
- if (!idToAction.containsKey (id))
- result.add (layersAction);
- else {
- ActionImpl editorAction = (ActionImpl) idToAction.
- remove (id);
- CompoundAction compoundAction = new CompoundAction (
- editorAction, // editor action
- layersAction // layers action
- );
- result.add (compoundAction);
- sharedActions.put (editorAction, compoundAction);
- sharedActions.put (layersAction, compoundAction);
- }
- }
- }
-
- result.addAll (idToAction.values ());
-
- return result;
- }
-
- /**
- * Merges editor actions and layers actions. Creates CompoundAction for
- * actions like Copy, registerred to both contexts.
- */
- private Map mergeShortcuts (
- Map editorActions,
- Map layersActions
- ) {
- Map result = new HashMap ();
- Iterator it = editorActions.keySet ().iterator ();
- while (it.hasNext ()) {
- ActionImpl action = (ActionImpl) it.next ();
- Set shortcuts = (Set) editorActions.get (action);
- if (sharedActions.containsKey (action))
- action = (CompoundAction) sharedActions.get (action);
- result.put (action, shortcuts);
- }
- it = layersActions.keySet ().iterator ();
- while (it.hasNext ()) {
- ActionImpl action = (ActionImpl) it.next ();
- Set shortcuts = (Set) layersActions.get (action);
- if (sharedActions.containsKey (action))
- action = (CompoundAction) sharedActions.get (action);
- result.put (action, shortcuts);
- }
- return result;
- }
-
- {
- // HACK - loads all actions. othervise during second open of Options
- // Dialog (after cancel) map of sharedActions is not initialized.
- Iterator it = getActionCategories ().iterator ();
- while (it.hasNext ())
- getActions ((String) it.next ());
- }
-}
Index: editor/options/src/org/netbeans/modules/options/keymap/KeymapPanel.form
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/KeymapPanel.form
diff -N editor/options/src/org/netbeans/modules/options/keymap/KeymapPanel.form
--- editor/options/src/org/netbeans/modules/options/keymap/KeymapPanel.form 20 Feb 2006 14:39:47 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,145 +0,0 @@
-
-
-
Index: editor/options/src/org/netbeans/modules/options/keymap/KeymapPanel.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/KeymapPanel.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/KeymapPanel.java
--- editor/options/src/org/netbeans/modules/options/keymap/KeymapPanel.java 20 Feb 2006 14:39:47 -0000 1.28
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,388 +0,0 @@
-/*
- * KeymapPanel1.java
- *
- * Created on February 20, 2006, 2:59 PM
- */
-
-package org.netbeans.modules.options.keymap;
-
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Iterator;
-import java.util.List;
-import javax.swing.AbstractButton;
-import javax.swing.AbstractListModel;
-import javax.swing.DefaultListModel;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.SwingUtilities;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import org.openide.DialogDisplayer;
-import org.openide.NotifyDescriptor;
-import org.openide.NotifyDescriptor.InputLine;
-import org.openide.NotifyDescriptor.Message;
-import org.openide.awt.Mnemonics;
-import org.openide.util.NbBundle;
-
-/**
- *
- * @author Jan Jancura
- */
-public class KeymapPanel extends JPanel implements ActionListener,
-TreeSelectionListener, ListSelectionListener {
-
-
- private boolean listen = false;
-
- /** Creates new form KeymapPanel1 */
- public KeymapPanel() {
- initComponents();
- loc (bDuplicate, "Duplicate");
- loc (bDelete, "Delete");
-// loc (rbAction, "Show_Actions");
-// loc (rbShortcut, "Show_Shortcuts");
- liShortcuts.getAccessibleContext ().setAccessibleName (loc ("AN_Shortcuts"));
- liShortcuts.getAccessibleContext ().setAccessibleDescription (loc ("AD_Shortcuts"));
- tActions.getAccessibleContext ().setAccessibleName (loc ("AN_Actions"));
- tActions.getAccessibleContext ().setAccessibleDescription (loc ("AD_Actions"));
- cbProfile.getAccessibleContext ().setAccessibleName (loc ("AN_Profiles"));
- cbProfile.getAccessibleContext ().setAccessibleDescription (loc ("AD_Profiles"));
-// bgViewAs.add (rbAction);
-// bgViewAs.add (rbShortcut);
- bDuplicate.addActionListener (this);
- bDelete.addActionListener (this);
-// rbAction.setSelected (true);
-// rbAction.addActionListener (this);
-// rbShortcut.addActionListener (this);
- tActions.setRootVisible (false);
- tActions.setShowsRootHandles (true);
- tActions.addTreeSelectionListener (this);
- cbProfile.addActionListener (this);
- loc (bAdd, "Add_Shortcut");
- loc (bRemove, "Remove_Shortcut");
- bAdd.addActionListener (this);
- bRemove.addActionListener (this);
- liShortcuts.addListSelectionListener (this);
- bAdd.setEnabled (false);
- bRemove.setEnabled (false);
- loc (lShortcuts, "Shortcuts"); // NOI18N
- lShortcuts.setLabelFor (liShortcuts);
- loc (lActions, "Actions");
- lActions.setLabelFor (tActions);
- }
-
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- // //GEN-BEGIN:initComponents
- private void initComponents() {
- lProfile = new javax.swing.JLabel();
- cbProfile = new javax.swing.JComboBox();
- bDuplicate = new javax.swing.JButton();
- bDelete = new javax.swing.JButton();
- lActions = new javax.swing.JLabel();
- spActions = new javax.swing.JScrollPane();
- tActions = new javax.swing.JTree();
- lShortcuts = new javax.swing.JLabel();
- spShortcuts = new javax.swing.JScrollPane();
- liShortcuts = new javax.swing.JList();
- bAdd = new javax.swing.JButton();
- bRemove = new javax.swing.JButton();
-
- lProfile.setText("Profile:");
-
- bDuplicate.setText("Duplicate...");
-
- bDelete.setText("Delete");
-
- lActions.setText("Actions:");
-
- spActions.setViewportView(tActions);
-
- lShortcuts.setText("Shortcuts:");
-
- spShortcuts.setViewportView(liShortcuts);
-
- bAdd.setText("Add...");
-
- bRemove.setText("Remove");
-
- org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
- this.setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(lProfile)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(cbProfile, 0, 139, Short.MAX_VALUE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(bDuplicate))
- .add(layout.createSequentialGroup()
- .add(spShortcuts, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 175, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(bRemove)
- .add(bAdd))))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(bDelete))
- .add(layout.createSequentialGroup()
- .add(lActions)
- .addContainerGap())
- .add(spActions, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
- .add(layout.createSequentialGroup()
- .add(lShortcuts)
- .addContainerGap())
- );
-
- layout.linkSize(new java.awt.Component[] {bAdd, bRemove}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
-
- layout.linkSize(new java.awt.Component[] {bDelete, bDuplicate}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
-
- layout.setVerticalGroup(
- layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(bDelete)
- .add(bDuplicate)
- .add(lProfile)
- .add(cbProfile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(lActions)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(spActions, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(lShortcuts)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
- .add(layout.createSequentialGroup()
- .add(bAdd)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(bRemove))
- .add(spShortcuts, 0, 52, Short.MAX_VALUE)))
- );
- }// //GEN-END:initComponents
-
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton bAdd;
- private javax.swing.JButton bDelete;
- private javax.swing.JButton bDuplicate;
- private javax.swing.JButton bRemove;
- private javax.swing.JComboBox cbProfile;
- private javax.swing.JLabel lActions;
- private javax.swing.JLabel lProfile;
- private javax.swing.JLabel lShortcuts;
- private javax.swing.JList liShortcuts;
- private javax.swing.JScrollPane spActions;
- private javax.swing.JScrollPane spShortcuts;
- private javax.swing.JTree tActions;
- // End of variables declaration//GEN-END:variables
-
-
- public void actionPerformed (ActionEvent e) {
- if (!listen) return;
- Object source = e.getSource ();
- if (source == bAdd) {
- Object action = tActions.getSelectionPath ().getLastPathComponent ();
- String shortcut = ShortcutsDialog.getShortcut (getModel ());
- if (shortcut == null) return;
- getModel ().addShortcut (
- tActions.getSelectionPath (), shortcut
- );
- selectAction (action);
- if (liShortcuts.getModel ().getSize () > 0)
- liShortcuts.setSelectedIndex (0);
- SwingUtilities.invokeLater (new Runnable () {
- public void run () {
- liShortcuts.requestFocus ();
- }
- });
- } else
- if (source == bRemove) {
- int index = liShortcuts.getSelectedIndex ();
- Object action = tActions.getSelectionPath ().getLastPathComponent ();
- String shortcut = (String) liShortcuts.getSelectedValue ();
- getModel ().removeShortcut (
- tActions.getSelectionPath (), shortcut
- );
- selectAction (action);
- if (liShortcuts.getModel ().getSize () > index)
- liShortcuts.setSelectedIndex (index);
- else
- if (liShortcuts.getModel ().getSize () > 0)
- liShortcuts.setSelectedIndex (0);
- } else
- if (source == bDelete) {
- deleteCurrentProfile ();
- } else
- if (source == cbProfile) {
- String profile = (String) cbProfile.getSelectedItem ();
- getModel ().setCurrentProfile (profile);
- if (getModel ().isCustomProfile (profile))
- loc (bDelete, "Delete"); // NOI18N
- else
- loc (bDelete, "Restore"); // NOI18N
- refreshAction ();
- } else
- if (source == bDuplicate) {
- InputLine il = new InputLine (
- loc ("CTL_Create_New_Profile_Message"), // NOI18N
- loc ("CTL_Create_New_Profile_Title") // NOI18N
- );
- il.setInputText ((String) cbProfile.
- getSelectedItem ());
- DialogDisplayer.getDefault ().notify (il);
- if (il.getValue () == NotifyDescriptor.OK_OPTION) {
- String newProfile = il.getInputText ();
- Iterator it = getModel ().getProfiles ().iterator ();
- while (it.hasNext ())
- if (newProfile.equals (it.next ())) {
- Message md = new Message (
- loc ("CTL_Duplicate_Profile_Name"), // NOI18N
- Message.ERROR_MESSAGE
- );
- DialogDisplayer.getDefault ().notify (md);
- return;
- }
- getModel ().cloneProfile (newProfile);
- cbProfile.addItem (il.getInputText ());
- cbProfile.setSelectedItem (il.getInputText ());
- }
- return;
- }
- }
-
- public void valueChanged (TreeSelectionEvent e) {
- if (!listen) return;
- refreshAction ();
- }
-
- public void valueChanged (ListSelectionEvent e) {
- if (!listen) return;
- // selected shourtcut changed
- int i = liShortcuts.getSelectedIndex ();
- if (i < 0) {
- bRemove.setEnabled (false);
- return;
- }
- bRemove.setEnabled (true);
- }
-
- private boolean initialized = false;
- void update () {
- if (!initialized) {
- initialized = true;
- listen = false;
-
- tActions.setCellRenderer (new KeymapListRenderer (getModel ()));
- tActions.setModel (getModel ());
-
- // cbProfile
- List keymaps = getModel ().getProfiles ();
- cbProfile.removeAllItems ();
- int i, k = keymaps.size ();
- for (i = 0; i < k; i++)
- cbProfile.addItem (keymaps.get (i));
- listen = true;
- }
- cbProfile.setSelectedItem (getModel ().getCurrentProfile ());
- }
-
- private void deleteCurrentProfile () {
- String currentProfile = (String) cbProfile.getSelectedItem ();
- getModel ().deleteProfile (currentProfile);
- if (getModel ().isCustomProfile (currentProfile)) {
- cbProfile.removeItem (currentProfile);
- cbProfile.setSelectedIndex (0);
- }
- }
-
- void applyChanges () {
- if (!initialized) return; // not initialized yet.
- getModel ().apply ();
- }
-
- void cancel () {
- if (model == null) return;
- model.cancel ();
- }
-
- boolean dataValid () {
- return true;
- }
-
- boolean isChanged () {
- return getModel ().isChanged ();
- }
-
- private KeymapViewModel model;
-
- KeymapViewModel getModel () {
- if (model == null)
- model = new KeymapViewModel ();
- return model;
- }
-
-
- // other methods ...........................................................
-
- private static String loc (String key) {
- return NbBundle.getMessage (KeymapPanel.class, key);
- }
-
- private static void loc (Component c, String key) {
- if (!(c instanceof JLabel)) {
- c.getAccessibleContext ().setAccessibleName (loc ("AN_" + key));
- c.getAccessibleContext ().setAccessibleDescription (loc ("AD_" + key));
- }
- if (c instanceof AbstractButton) {
- Mnemonics.setLocalizedText (
- (AbstractButton) c,
- loc ("CTL_" + key)
- );
- } else {
- Mnemonics.setLocalizedText (
- (JLabel) c,
- loc ("CTL_" + key)
- );
- }
- }
-
- void refreshAction () {
- Object action = tActions.getSelectionPath () == null ?
- null : tActions.getSelectionPath ().getLastPathComponent ();
- selectAction (action);
- if (liShortcuts.getModel ().getSize () > 0)
- liShortcuts.setSelectedIndex (0);
- }
-
- void selectAction (Object action) {
- if (action == null || action instanceof String) {
- liShortcuts.setModel (new DefaultListModel ());
- bAdd.setEnabled (false);
- bRemove.setEnabled (false);
- return;
- }
- bAdd.setEnabled (true);
- bRemove.setEnabled (false);
- final String[] shortcuts = getModel ().getShortcuts ((ActionImpl) action);
- liShortcuts.setModel (new AbstractListModel () {
- public int getSize () {
- return shortcuts.length;
- }
- public Object getElementAt (int i) {
- return shortcuts [i];
- }
- });
- }
-}
Index: editor/options/src/org/netbeans/modules/options/keymap/KeymapPanelController.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/KeymapPanelController.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/KeymapPanelController.java
--- editor/options/src/org/netbeans/modules/options/keymap/KeymapPanelController.java 30 Jun 2006 19:18:15 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,86 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-
-import java.beans.PropertyChangeListener;
-import javax.swing.JComponent;
-import org.netbeans.spi.options.OptionsPanelController;
-import org.openide.util.HelpCtx;
-import org.openide.util.Lookup;
-import org.openide.util.lookup.Lookups;
-
-
-/**
- * Implementation of one panel in Options Dialog.
- *
- * @author Jan Jancura
- */
-public final class KeymapPanelController extends OptionsPanelController {
-
-
- public void update () {
- getKeymapPanel ().update ();
- }
-
- public void applyChanges () {
- getKeymapPanel ().applyChanges ();
- }
-
- public void cancel () {
- getKeymapPanel ().cancel ();
- }
-
- public boolean isValid () {
- return getKeymapPanel ().dataValid ();
- }
-
- public boolean isChanged () {
- return getKeymapPanel ().isChanged ();
- }
-
- public HelpCtx getHelpCtx () {
- return new HelpCtx ("netbeans.optionsDialog.keymaps");
- }
-
- public Lookup getLookup () {
- return Lookups.singleton (getKeymapPanel ().getModel ());
- }
-
- public JComponent getComponent (Lookup masterLookup) {
- return getKeymapPanel ();
- }
-
- public void addPropertyChangeListener (PropertyChangeListener l) {
- getKeymapPanel ().addPropertyChangeListener (l);
- }
-
- public void removePropertyChangeListener (PropertyChangeListener l) {
- getKeymapPanel ().removePropertyChangeListener (l);
- }
-
-
- private KeymapPanel keymapPanel;
-
- private KeymapPanel getKeymapPanel () {
- if (keymapPanel == null)
- keymapPanel = new KeymapPanel ();
- return keymapPanel;
- }
-}
Index: editor/options/src/org/netbeans/modules/options/keymap/KeymapViewModel.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/KeymapViewModel.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/KeymapViewModel.java
--- editor/options/src/org/netbeans/modules/options/keymap/KeymapViewModel.java 30 Jun 2006 19:18:15 -0000 1.29
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,540 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-
-
-import java.awt.Component;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-import java.util.Vector;
-import javax.swing.AbstractButton;
-import javax.swing.JLabel;
-import javax.swing.KeyStroke;
-import javax.swing.SwingUtilities;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-import org.netbeans.modules.options.keymap.ShortcutsDialog.ShortcutsFinder;
-import org.openide.ErrorManager;
-import org.openide.awt.Mnemonics;
-import org.openide.util.NbBundle;
-import org.openide.util.RequestProcessor;
-import org.openide.util.Utilities;
-
-
-/**
- *
- * @author Jan Jancura
- */
-public class KeymapViewModel implements TreeModel, ShortcutsFinder {
-
- private Vector listeners = new Vector ();
- private String currentProfile;
- private KeymapModel model = new KeymapModel ();
- // Map (String ("xx/yy") > List (Object (action)))
- // tree of actions in folders
- private Map categoryToActionsCache = new HashMap ();
- // Map (String (keymapName) > Map (ActionImpl > Set (String (shortcut Ctrl+F)))).
- // contains modified shortcuts only
- private Map modifiedProfiles = new HashMap ();
- // Set (String (profileName)).
- private Set deletedProfiles = new HashSet ();
- // Map (String (keymapName) > Map (ActionImpl > Set (String (shortcut Ctrl+F)))).
- private Map shortcutsCache = new HashMap ();
-
- static final ActionsComparator actionsComparator = new ActionsComparator ();
-
-
- /**
- * Creates a new instance of KeymapModel
- */
- public KeymapViewModel () {
- currentProfile = model.getCurrentProfile ();
- }
-
-
- // TreeModel ...............................................................
-
- public Object getRoot () {
- return "";
- }
-
- public Object getChild (Object parent, int index) {
- return getItems ((String) parent).get (index);
- }
-
- public int getChildCount (Object parent) {
- if (parent instanceof String)
- return getItems ((String) parent).size ();
- return 0;
- }
-
- public boolean isLeaf (Object node) {
- return !(node instanceof String);
- }
-
- public void valueForPathChanged (TreePath path, Object newValue) {}
-
- public int getIndexOfChild (Object parent, Object child) {
- return getItems ((String) parent).indexOf (child);
- }
-
- public void addTreeModelListener (TreeModelListener l) {
- listeners.add (l);
- }
-
- public void removeTreeModelListener (TreeModelListener l) {
- listeners.remove (l);
- }
-
- private void treeChanged () {
- final Vector v = (Vector) listeners.clone ();
- SwingUtilities.invokeLater (new Runnable () {
- public void run () {
- TreeModelEvent tme = new TreeModelEvent (this, new Object[] {""});
- int i, k = v.size ();
- for (i = 0; i < k; i++)
- ((TreeModelListener) v.get (i)).treeNodesChanged (tme);
- }
- });
- }
-
- private void nodeChanged (final TreePath path) {
- final Vector v = (Vector) listeners.clone ();
- SwingUtilities.invokeLater (new Runnable () {
- public void run () {
- TreeModelEvent tme = new TreeModelEvent (this, path);
- int i, k = v.size ();
- for (i = 0; i < k; i++)
- ((TreeModelListener) v.get (i)).treeNodesChanged (tme);
- }
- });
- }
-
-
- // ListModel ...............................................................
-
- // Map (String ("xx/yy") > Map ...)
- private Map categories;
-
-
- /**
- * Returns map of categories and subcategories.
- * Root: getCategories ().get ("")
- * Subcategories: getCategories ().get (category)
- *
- * Map (String (category name) > List (String (category name))).
- */
- public Map getCategories () {
- if (categories == null) {
- categories = new TreeMap ();
- List c = new ArrayList (model.getActionCategories ());
- Collections.sort (c);
- Iterator it = c.iterator ();
- while (it.hasNext ()) {
- String cn = (String) it.next ();
- String folderName = "";
- StringTokenizer st = new StringTokenizer (cn, "/");
- while (st.hasMoreTokens ()) {
- String name = st.nextToken ();
- List asd = (List) categories.get (folderName);
- if (asd == null) {
- asd = new ArrayList ();
- categories.put (folderName, asd);
- }
- folderName = folderName.length () == 0 ?
- name : folderName + '/' + name;
- if (asd.isEmpty () ||
- !asd.get (asd.size () - 1).equals (folderName)
- )
- asd.add (folderName);
- }
- }
- }
- return categories;
- }
-
- /**
- * Returns list of subcategories (String) for given category merged
- * together with actions for give category.
- */
- public List getItems (String category) {
- List result = (List) categoryToActionsCache.get (category);
- if (result == null) {
- result = new ArrayList ();
- List ll = (List) getCategories ().get (category);
- if (ll != null)
- result.addAll (ll);
- List l = new ArrayList (model.getActions (category));
- Collections.sort (l, new ActionsComparator ());
- result.addAll (l);
- categoryToActionsCache.put (category, result);
- //S ystem.out.println("getItems " + category + " : " + result);
- }
- return result;
- }
-
-// public ListCellRenderer getListCellRenderer () {
-// return new KeymapListRenderer (this);
-// }
-
-
- // other methods ...........................................................
-
- List getProfiles () {
- Set result = new HashSet (model.getProfiles ());
- result.addAll (modifiedProfiles.keySet ());
- List r = new ArrayList (result);
- Collections.sort (r);
- return r;
- }
-
- boolean isCustomProfile (String profile) {
- return model.isCustomProfile (profile);
- }
-
- void deleteProfile (String profile) {
- if (model.isCustomProfile (profile)) {
- deletedProfiles.add (profile);
- modifiedProfiles.remove (profile);
- } else {
- Map m = model.getKeymapDefaults (profile);
- m = convertFromEmacs (m);
- modifiedProfiles.put (profile, m);
- treeChanged ();
- }
- }
-
- String getCurrentProfile () {
- return currentProfile;
- }
-
- void setCurrentProfile (String currentKeymap) {
- this.currentProfile = currentKeymap;
- treeChanged ();
- }
-
- void cloneProfile (String newProfileName) {
- Map result = new HashMap ();
- cloneProfile ("", result);
- modifiedProfiles.put (newProfileName, result);
- }
-
- private void cloneProfile (
- String category, // name of currently resolved category
- Map result // Map (ActionImpl > Set (String (shortcut)))
- ) {
- Iterator it = getItems (category).iterator ();
- while (it.hasNext ()) {
- Object o = it.next ();
- if (o instanceof String)
- cloneProfile ((String) o, result);
- else {
- String[] shortcuts = getShortcuts ((ActionImpl) o);
- result.put (o, new HashSet (Arrays.asList (shortcuts)));
- }
- }
- }
-
- public ActionImpl findActionForShortcut (String shortcut) {
- return findActionForShortcut (shortcut, "");
- }
-
- private ActionImpl findActionForShortcut (String shortcut, String category) {
- Iterator it = getItems (category).iterator ();
- while (it.hasNext ()) {
- Object o = it.next ();
- if (o instanceof String) {
- ActionImpl result = findActionForShortcut (shortcut, (String) o);
- if (result != null) return result;
- continue;
- }
- ActionImpl action = (ActionImpl) o;
- String[] shortcuts = getShortcuts (action);
- int i, k = shortcuts.length;
- for (i = 0; i < k; i++) {
- if (shortcuts [i].equals (shortcut)) return action;
- if (shortcuts [i].equals (shortcut + " ")) return action;
- }
- }
- return null;
- }
-
- public ActionImpl findActionForId (final String actionId) {
- if (SwingUtilities.isEventDispatchThread ())
- return findActionForId (actionId, "");
-
- final ActionImpl[] result = new ActionImpl [1];
- try {
- SwingUtilities.invokeAndWait (new Runnable () {
- public void run () {
- result [0] = findActionForId (actionId, "");
- }
- });
- } catch (Exception ex) {
- ErrorManager.getDefault ().notify (ex);
- }
- return result [0];
- }
-
- private ActionImpl findActionForId (String actionId, String category) {
- Iterator it = getItems (category).iterator ();
- while (it.hasNext ()) {
- Object o = it.next ();
- if (o instanceof String) {
- ActionImpl result = findActionForId (actionId, (String) o);
- if (result != null) return result;
- continue;
- }
- String id = ((ActionImpl) o).getId ();
- if (actionId.equals (id))
- return (ActionImpl) o;
- }
- return null;
- }
-
- public String[] getShortcuts (ActionImpl action) {
- if (modifiedProfiles.containsKey (currentProfile)) {
- // find it in modified shortcuts
- Map actionToShortcuts = (Map) modifiedProfiles.
- get (currentProfile);
- if (actionToShortcuts.containsKey (action)) {
- Set s = (Set) actionToShortcuts.get (action);
- return (String[]) s.toArray (new String [s.size ()]);
- }
- }
-
- if (!shortcutsCache.containsKey (currentProfile)) {
- // read profile and put it to cache
- Map profileMap = convertFromEmacs (model.getKeymap (currentProfile));
- shortcutsCache.put (
- currentProfile,
- profileMap
- );
- }
- Map profileMap = (Map) shortcutsCache.get (currentProfile);
- Set shortcuts = (Set) profileMap.get (action);
- if (shortcuts == null) return new String [0];
- return (String[]) shortcuts.toArray (new String [shortcuts.size ()]);
- }
-
- void addShortcut (TreePath path, String shortcut) {
- // delete old shortcut
- ActionImpl action = findActionForShortcut (shortcut);
- if (action != null)
- removeShortcut (action, shortcut);
- action = (ActionImpl) path.getLastPathComponent ();
- Set s = new HashSet ();
- s.add (shortcut);
- s.addAll (Arrays.asList (getShortcuts (action)));
- setShortcuts (action, s);
- nodeChanged (path);
- }
-
- public void setShortcuts (ActionImpl action, Set shortcuts) {
- Map actionToShortcuts = (Map) modifiedProfiles.get (currentProfile);
- if (actionToShortcuts == null) {
- actionToShortcuts = new HashMap ();
- modifiedProfiles.put (currentProfile, actionToShortcuts);
- }
- actionToShortcuts.put (action, shortcuts);
- }
-
- void removeShortcut (TreePath path, String shortcut) {
- ActionImpl action = (ActionImpl) path.getLastPathComponent ();
- removeShortcut (action, shortcut);
- nodeChanged (path);
- }
-
- private void removeShortcut (ActionImpl action, String shortcut) {
- Set s = new HashSet (Arrays.asList (getShortcuts (action)));
- s.remove (shortcut);
- Map actionToShortcuts = (Map) modifiedProfiles.get (currentProfile);
- if (actionToShortcuts == null) {
- actionToShortcuts = new HashMap ();
- modifiedProfiles.put (currentProfile, actionToShortcuts);
- }
- actionToShortcuts.put (action, s);
- }
-
- public void refreshActions () {
- categoryToActionsCache = new HashMap ();
- model.refreshActions ();
- }
-
- public void apply () {
- RequestProcessor.getDefault ().post (new Runnable () {
- public void run () {
- Iterator it = modifiedProfiles.keySet ().iterator ();
- while (it.hasNext ()) {
- String profile = (String) it.next ();
- Map actionToShortcuts = (Map) modifiedProfiles.get (profile);
- actionToShortcuts = convertToEmacs (actionToShortcuts);
- model.changeKeymap (
- profile,
- actionToShortcuts
- );
- }
- it = deletedProfiles.iterator ();
- while (it.hasNext ()) {
- String profile = (String) it.next ();
- model.deleteProfile (profile);
- }
- model.setCurrentProfile (currentProfile);
- modifiedProfiles = new HashMap ();
- deletedProfiles = new HashSet ();
- shortcutsCache = new HashMap ();
- model = new KeymapModel ();
- }
- });
- }
-
- public boolean isChanged () {
- return (!modifiedProfiles.isEmpty ()) || !deletedProfiles.isEmpty ();
- }
-
- public void cancel () {
- modifiedProfiles = new HashMap ();
- deletedProfiles = new HashSet ();
- shortcutsCache = new HashMap ();
- setCurrentProfile (model.getCurrentProfile ());
- model = new KeymapModel ();
- }
-
- /**
- * Converts Map (ActionImpl > Set (String (shortcut Alt+Shift+P))) to
- * Map (ActionImpl > Set (String (shortcut AS-P))).
- */
- private static Map convertToEmacs (Map shortcuts) {
- Map result = new HashMap ();
- Iterator it = shortcuts.keySet ().iterator ();
- while (it.hasNext ()) {
- Object action = it.next ();
- Set sh = (Set) shortcuts.get (action);
- Set newSet = new HashSet ();
- Iterator it2 = sh.iterator ();
- while (it2.hasNext ()) {
- String s = (String) it2.next ();
- if (s.length () == 0) continue;
- KeyStroke[] ks = getKeyStrokes (s, " ");
- if (ks == null)
- continue; // unparsable shortcuts ignorred
- StringBuffer sb = new StringBuffer (
- Utilities.keyToString (ks [0])
- );
- int i, k = ks.length;
- for (i = 1; i < k; i++)
- sb.append (' ').append (Utilities.keyToString (ks [i]));
- newSet.add (sb.toString ());
- }
- result.put (action, newSet);
- }
- return result;
- }
-
- /**
- * Converts Map (ActionImpl > Set (String (shortcut AS-P))) to
- * Map (ActionImpl > Set (String (shortcut Alt+Shift+P))).
- */
- private static Map convertFromEmacs (Map emacs) {
- Map result = new HashMap ();
- Iterator it = emacs.keySet ().iterator ();
- while (it.hasNext ()) {
- ActionImpl action = (ActionImpl) it.next ();
- Set emacsShortcuts = (Set) emacs.get (action);
- Iterator it2 = emacsShortcuts.iterator ();
- Set shortcuts = new HashSet ();
- while (it2.hasNext ()) {
- String emacsShortcut = (String) it2.next ();
- KeyStroke[] keyStroke = Utilities.stringToKeys (emacsShortcut);
- shortcuts.add (Utils.getKeyStrokesAsText (keyStroke, " "));
- }
- result.put (action, shortcuts);
- }
- return result;
- }
-
- /**
- * Returns multi keystroke for given text representation of shortcuts
- * (like Alt+A B). Returns null if text is not parsable, and empty array
- * for empty string.
- */
- private static KeyStroke[] getKeyStrokes (String keyStrokes, String delim) {
- if (keyStrokes.length () == 0) return new KeyStroke [0];
- StringTokenizer st = new StringTokenizer (keyStrokes, delim);
- List result = new ArrayList ();
- while (st.hasMoreTokens ()) {
- String ks = st.nextToken ().trim ();
- KeyStroke keyStroke = Utils.getKeyStroke (ks);
- if (keyStroke == null) return null; // text is not parsable
- result.add (keyStroke);
- }
- return (KeyStroke[]) result.toArray (new KeyStroke [result.size ()]);
- }
-
- private static String loc (String key) {
- return NbBundle.getMessage (KeymapPanel.class, key);
- }
-
- private static void loc (Component c, String key) {
- if (c instanceof AbstractButton)
- Mnemonics.setLocalizedText (
- (AbstractButton) c,
- loc (key)
- );
- else
- Mnemonics.setLocalizedText (
- (JLabel) c,
- loc (key)
- );
- }
-
-
- // innerclasses ............................................................
-
- static class ActionsComparator implements Comparator {
-
- public int compare (Object o1, Object o2) {
- if (o1 instanceof String)
- if (o2 instanceof String)
- return ((String) o1).compareTo ((String) o2);
- else
- return 1;
- else
- if (o2 instanceof String)
- return -1;
- else
- return ((ActionImpl) o1).getDisplayName ().compareTo (
- ((ActionImpl) o2).getDisplayName ()
- );
- }
- }
-}
Index: editor/options/src/org/netbeans/modules/options/keymap/LayersBridge.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/LayersBridge.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/LayersBridge.java
--- editor/options/src/org/netbeans/modules/options/keymap/LayersBridge.java 30 Jun 2006 19:18:15 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,424 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.Set;
-import java.util.StringTokenizer;
-import javax.swing.Action;
-import org.openide.ErrorManager;
-
-import org.openide.cookies.InstanceCookie;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileSystem;
-import org.openide.filesystems.Repository;
-import org.openide.loaders.DataFolder;
-import org.openide.loaders.DataObject;
-import org.openide.loaders.DataShadow;
-import org.openide.util.NbBundle;
-import org.openide.util.actions.Presenter;
-
-/**
- * Bridge to old layers based system.
- *
- * @author Jan Jancura
- */
-public class LayersBridge {
-
- static final String KEYMAPS_FOLDER = "Keymaps";
- private static final String SHORTCUTS_FOLDER = "Shortcuts";
- private static final String TOOLBARS_FOLDER = "Toolbars";
-
- /** Map (GlobalAction > DataObject). */
- private Map actionToDataObject = new HashMap ();
- /** Map (String (folderName) > Set (GlobalAction)). */
- private Map categoryToActions;
- /** Set (GlobalAction). */
- private Set actions = new HashSet ();
-
-
- /**
- * Returns Map (String (folderName) > Set (GlobalAction)).
- */
- Map getActions () {
- if (categoryToActions == null) {
- categoryToActions = new HashMap ();
- initActions ("OptionsDialog/Actions", null); // NOI18N
- initActions (
- "Actions",
- NbBundle.getMessage (LayersBridge.class, "CTL_Other")
- );
- categoryToActions.remove ("Hidden"); // NOI18N
- categoryToActions = Collections.unmodifiableMap (categoryToActions);
- }
- return categoryToActions;
- }
-
- private void initActions (String folder, String category) {
- FileSystem fs = Repository.getDefault ().getDefaultFileSystem ();
- FileObject fo = fs.findResource (folder);
- if (fo == null) return;
- DataFolder root = DataFolder.findFolder (fo);
- Enumeration en = root.children ();
- while (en.hasMoreElements ()) {
- DataObject dataObject = (DataObject) en.nextElement ();
- if (dataObject instanceof DataFolder)
- initActions ((DataFolder) dataObject, null, category);
- }
- }
-
- private void initActions (
- DataFolder folder,
- String folderName,
- String category
- ) {
-
- // 1) reslove name
- String name = folder.getName ();
- if (category != null)
- name = category;
- else {
- String bundleName = (String) folder.getPrimaryFile ().getAttribute
- ("SystemFileSystem.localizingBundle");
- if (bundleName != null)
- try {
- name = NbBundle.getBundle (bundleName).getString (
- folder.getPrimaryFile ().getPath ()
- );
- } catch (MissingResourceException ex) {
- ErrorManager.getDefault ().notify (ex);
- }
- if (folderName != null)
- name = folderName + '/' + name;
- }
-
- Enumeration en = folder.children ();
- while (en.hasMoreElements ()) {
- DataObject dataObject = (DataObject) en.nextElement ();
- if (dataObject instanceof DataFolder) {
- initActions ((DataFolder) dataObject, name, category);
- continue;
- }
- GlobalAction action = createAction (dataObject);
- if (actions.contains (action)) continue;
- if (action == null) continue;
- actions.add (action);
-
- // add to actions (Map (String (folderName) > Set (GlobalAction))).
- Set a = (Set) categoryToActions.get (name);
- if (a == null) {
- a = new HashSet ();
- categoryToActions.put (name, a);
- }
- a.add (action);
-
- while (dataObject instanceof DataShadow)
- dataObject = ((DataShadow) dataObject).getOriginal ();
-
- actionToDataObject.put (action, dataObject);
- }
- }
-
- private List keymapNames;
-
- List getProfiles () {
- if (keymapNames == null) {
- DataFolder root = getRootFolder (KEYMAPS_FOLDER, null);
- Enumeration en = root.children (false);
- keymapNames = new ArrayList ();
- while (en.hasMoreElements ()) {
- DataObject dataObject = (DataObject) en.nextElement ();
- if (!(dataObject instanceof DataFolder)) continue;
- keymapNames.add (dataObject.getName ());
- }
- if (!keymapNames.contains ("NetBeans"))
- keymapNames.add ("NetBeans");
- }
- return Collections.unmodifiableList (keymapNames);
- }
-
- /** Map (String (profile) > Map (GlobalAction > Set (String (shortcut)))). */
- private Map keymaps = new HashMap ();
-
- /**
- * Returns Map (GlobalAction > Set (String (shortcut))).
- */
- Map getKeymap (String profile) {
- if (!keymaps.containsKey (profile)) {
- DataFolder root = getRootFolder (SHORTCUTS_FOLDER, null);
- Map m = readKeymap (root);
- root = getRootFolder (KEYMAPS_FOLDER, profile);
- m.putAll (readKeymap (root));
- keymaps.put (profile, m);
- }
- return Collections.unmodifiableMap ((Map) keymaps.get (profile));
- }
-
- /** Map (String (profile) > Map (GlobalAction > Set (String (shortcut)))). */
- private Map keymapDefaults = new HashMap ();
-
- /**
- * Returns Map (GlobalAction > Set (String (shortcut))).
- */
- Map getKeymapDefaults (String profile) {
- if (!keymapDefaults.containsKey (profile)) {
- DataFolder root = getRootFolder (SHORTCUTS_FOLDER, null);
- Map m = readKeymap (root);
- root = getRootFolder (KEYMAPS_FOLDER, profile);
- m.putAll (readKeymap (root));
- keymapDefaults.put (profile, m);
- }
- return Collections.unmodifiableMap ((Map) keymapDefaults.get (profile));
- }
-
- DataObject getDataObject (Object action) {
- return (DataObject) actionToDataObject.get (action);
- }
-
- /**
- * Read keymap from one folder Map (GlobalAction > Set (String (shortcut))).
- */
- private Map readKeymap (DataFolder root) {
- Map keymap = new HashMap ();
- if (root == null) return keymap;
- Enumeration en = root.children (false);
- while (en.hasMoreElements ()) {
- DataObject dataObject = (DataObject) en.nextElement ();
- if (dataObject instanceof DataFolder) continue;
- GlobalAction action = createAction (dataObject);
- if (action == null) continue;
- String shortcut = dataObject.getName ();
- Set s = (Set) keymap.get (action);
- if (s == null) {
- s = new HashSet ();
- keymap.put (action, s);
- }
- s.add (shortcut);
- }
- return keymap;
- }
-
- void deleteProfile (String profile) {
- FileObject root = Repository.getDefault ().
- getDefaultFileSystem ().getRoot ();
- root = root.getFileObject (KEYMAPS_FOLDER);
- if (root == null) return;
- root = root.getFileObject (profile);
- if (root == null) return;
- try {
- root.delete ();
- } catch (IOException ex) {
- ErrorManager.getDefault ().notify (ex);
- }
- }
-
- // actionToShortcuts Map (GlobalAction > Set (String (shortcut))
- void saveKeymap (String profile, Map actionToShortcuts) {
-
- // 1) get / create Keymaps/Profile folder
- DataFolder folder = getRootFolder (KEYMAPS_FOLDER, profile);
- if (folder == null) {
- folder = getRootFolder (KEYMAPS_FOLDER, null);
- try {
- folder = DataFolder.create (folder, profile);
- } catch (IOException ex) {
- ErrorManager.getDefault ().notify (ex);
- return;
- }
- }
- saveKeymap (folder, actionToShortcuts, true);
-
- folder = getRootFolder (SHORTCUTS_FOLDER, null);
- saveKeymap (folder, actionToShortcuts, false);
- }
-
- private void saveKeymap (DataFolder folder, Map actionToShortcuts, boolean add) {
- // 2) convert to: Map (String (shortcut AC-C X) > GlobalAction)
- Map shortcutToAction = shortcutToAction (actionToShortcuts);
-
- // 3) delete obsolete DataObjects
- Enumeration en = folder.children ();
- while (en.hasMoreElements ()) {
- DataObject dataObject = (DataObject) en.nextElement ();
- GlobalAction a1 = (GlobalAction) shortcutToAction.get (dataObject.getName ());
- if (a1 != null) {
- GlobalAction action = createAction (dataObject);
- if (action == null) continue;
- if (action.equals (a1)) {
- // shortcut already saved
- shortcutToAction.remove (dataObject.getName ());
- continue;
- }
- }
- // obsolete shortcut
- try {
- dataObject.delete ();
- } catch (IOException ex) {
- ex.printStackTrace ();
- }
- }
-
- // 4) add new shortcuts
- if (!add) return;
- Iterator it = shortcutToAction.keySet ().iterator ();
- while (it.hasNext ()) {
- String shortcut = (String) it.next ();
- GlobalAction action = (GlobalAction) shortcutToAction.get (shortcut);
- DataObject dataObject = (DataObject) actionToDataObject.get (action);
- if (dataObject == null) {
- if (System.getProperty ("org.netbeans.optionsDialog") != null)
- System.out.println ("No original DataObject specified! Not possible to create shadow1. " + action);
- continue;
- }
- try {
- DataShadow.create (folder, shortcut, dataObject);
- } catch (IOException ex) {
- ex.printStackTrace ();
- continue;
- }
- }
- }
-
- private static DataFolder getRootFolder (String name1, String name2) {
- FileObject root = Repository.getDefault ().
- getDefaultFileSystem ().getRoot ();
- FileObject fo1 = root.getFileObject (name1);
- try {
- if (fo1 == null) root.createFolder (name1);
- if (fo1 == null) return null;
- if (name2 == null) return DataFolder.findFolder (fo1);
- FileObject fo2 = fo1.getFileObject (name2);
- if (fo2 == null) fo1.createFolder (name2);
- if (fo2 == null) return null;
- return DataFolder.findFolder (fo2);
- } catch (IOException ex) {
- ErrorManager.getDefault ().notify (ex);
- return null;
- }
- }
-
- /**
- * Returns instance of GlobalAction encapsulating action, or null.
- */
- private GlobalAction createAction (DataObject dataObject) {
- InstanceCookie ic = (InstanceCookie) dataObject.getCookie
- (InstanceCookie.class);
- if (ic == null) return null;
- try {
- Object action = ic.instanceCreate ();
- if (action == null) return null;
- if (!(action instanceof Action)) return null;
- return new GlobalAction ((Action) action);
- } catch (Exception ex) {
- ex.printStackTrace ();
- return null;
- }
- }
-
- /**
- * converts: actionToShortcuts: Map (ActionImpl > Set (String (shortcut AC-C X)))
- * to: Map (String (shortcut AC-C X) > GlobalAction).
- * removes all non GlobalAction actions.
- */
- static Map shortcutToAction (Map actionToShortcuts) {
- Map shortcutToAction = new HashMap ();
- Iterator it = actionToShortcuts.keySet ().iterator ();
- while (it.hasNext ()) {
- ActionImpl action = (ActionImpl) it.next ();
- Set shortcuts = (Set) actionToShortcuts.get (action);
- if (action instanceof CompoundAction)
- action = ((CompoundAction) action).getLayersAction ();
- if (!(action instanceof GlobalAction)) continue;
- Iterator it2 = shortcuts.iterator ();
- while (it2.hasNext ()) {
- String multiShortcut = (String) it2.next ();
- shortcutToAction.put (multiShortcut, action);
- }
- }
- return shortcutToAction;
- }
-
- private static String[] toArray (String multiShortcut) {
- StringTokenizer st = new StringTokenizer (multiShortcut, " ");
- List result = new ArrayList ();
- while (st.hasMoreTokens ()) {
- String shortcut = st.nextToken ();
- if (shortcut == null) {
- if (System.getProperty ("org.netbeans.optionsDialog") != null)
- System.out.println ("can not parse shortcut: " + multiShortcut);
- continue;
- }
- result.add (shortcut);
- }
- return (String[]) result.toArray (new String [result.size ()]);
- }
-
-
- private static class GlobalAction implements ActionImpl {
- private Action action;
- private String name;
- private String id;
-
- private GlobalAction (Action a) {
- action = a;
- }
-
- public String getDisplayName () {
- if (name == null) {
- name = (String) action.getValue (Action.NAME);
- if (name == null) name = action.toString ();
- name = name.replaceAll ("&", "").trim ();
- }
- return name;
- }
-
- public String getId () {
- if (id == null)
- id = action.getClass ().getName ();
- return id;
- }
-
- public String getDelegatingActionId () {
- return null;
- }
-
- public boolean equals (Object o) {
- if (!(o instanceof GlobalAction)) return false;
- return ((GlobalAction) o).action.equals (action);
- }
-
- public int hashCode () {
- return action.hashCode ();
- }
-
- public String toString () {
- return super.toString () + ":" + getDisplayName ();
- }
- }
-}
Index: editor/options/src/org/netbeans/modules/options/keymap/ShortcutsDialog.form
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/ShortcutsDialog.form
diff -N editor/options/src/org/netbeans/modules/options/keymap/ShortcutsDialog.form
--- editor/options/src/org/netbeans/modules/options/keymap/ShortcutsDialog.form 4 May 2006 12:53:48 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,54 +0,0 @@
-
-
-
Index: editor/options/src/org/netbeans/modules/options/keymap/ShortcutsDialog.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/ShortcutsDialog.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/ShortcutsDialog.java
--- editor/options/src/org/netbeans/modules/options/keymap/ShortcutsDialog.java 4 May 2006 12:53:48 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,236 +0,0 @@
-/*
- * ShortcutsDialog1.java
- *
- * Created on February 20, 2006, 2:51 PM
- */
-
-package org.netbeans.modules.options.keymap;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.KeyboardFocusManager;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.text.MessageFormat;
-import java.util.Collections;
-import javax.swing.AbstractButton;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.KeyStroke;
-import org.openide.DialogDescriptor;
-import org.openide.DialogDisplayer;
-import org.openide.awt.Mnemonics;
-import org.openide.util.NbBundle;
-
-/**
- *
- * @author Jan Jancura
- */
-public class ShortcutsDialog extends javax.swing.JPanel {
-
- public static String getShortcut (final ShortcutsFinder shortcutsFinder) {
- final ShortcutsDialog d = new ShortcutsDialog ();
- loc (d.lShortcut, "Shortcut");
- d.lConflict.setForeground (Color.red);
- final JButton bTab = new JButton ();
- loc (bTab, "CTL_Tab");
- final JButton bClear = new JButton ();
- loc (bClear, "CTL_Clear");
- d.tfShortcut.setFocusTraversalKeys (
- KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
- Collections.EMPTY_SET
- );
- d.tfShortcut.setFocusTraversalKeys (
- KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS,
- Collections.EMPTY_SET
- );
-// tfShortcut.setFocusTraversalKeys (
-// KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
-// Collections.EMPTY_SET
-// );
- d.tfShortcut.setFocusTraversalKeys (
- KeyboardFocusManager.UP_CYCLE_TRAVERSAL_KEYS,
- Collections.EMPTY_SET
- );
- class Listener implements ActionListener, KeyListener {
-
- private KeyStroke backspaceKS = KeyStroke.getKeyStroke
- (KeyEvent.VK_BACK_SPACE, 0);
- private KeyStroke tabKS = KeyStroke.getKeyStroke
- (KeyEvent.VK_TAB, 0);
-
- private String key = "";
-
- public void keyTyped (KeyEvent e) {
- e.consume ();
- }
-
- public void keyPressed (KeyEvent e) {
- KeyStroke keyStroke = KeyStroke.getKeyStroke (
- e.getKeyCode (),
- e.getModifiers ()
- );
-
- boolean add = e.getKeyCode () != e.VK_SHIFT &&
- e.getKeyCode () != e.VK_CONTROL &&
- e.getKeyCode () != e.VK_ALT &&
- e.getKeyCode () != e.VK_META &&
- e.getKeyCode () != e.VK_ALT_GRAPH;
-
- if (keyStroke.equals (backspaceKS) && !key.equals ("")) {
- // delete last key
- int i = key.lastIndexOf (' ');
- if (i < 0)
- key = "";
- else
- key = key.substring (0, i);
- d.tfShortcut.setText (key);
- } else
- // add key
- addKeyStroke (keyStroke, add);
-
- if (add) updateWarning ();
- e.consume ();
- }
-
- public void keyReleased (KeyEvent e) {
- e.consume ();
- }
-
- public void actionPerformed (ActionEvent e) {
- if (e.getSource () == bClear) {
- key = "";
- d.tfShortcut.setText (key);
- } else
- if (e.getSource () == bTab)
- addKeyStroke (tabKS, true);
- }
-
- private void updateWarning () {
- ActionImpl action = shortcutsFinder.findActionForShortcut
- (d.tfShortcut.getText ());
- if (action != null) {
- d.lConflict.setText (MessageFormat.format (
- loc ("Shortcut_Conflict"),
- new Object[] {action.getDisplayName ()}
- ));
- } else
- d.lConflict.setText ("");
- }
-
- private void addKeyStroke (KeyStroke keyStroke, boolean add) {
- String k = Utils.getKeyStrokeAsText (keyStroke);
- if (key.equals ("")) {
- d.tfShortcut.setText (k);
- if (add) key = k;
- } else {
- d.tfShortcut.setText (key + " " + k);
- if (add) key += " " + k;
- }
- }
- }
- Listener listener = new Listener ();
- d.tfShortcut.addKeyListener (listener);
- DialogDescriptor descriptor = new DialogDescriptor (
- d,
- loc ("Add_Shortcut_Dialog"),
- true,
- new Object[] {
- DialogDescriptor.OK_OPTION,
- DialogDescriptor.CANCEL_OPTION
- },
- DialogDescriptor.OK_OPTION,
- DialogDescriptor.DEFAULT_ALIGN,
- null,
- listener
- );
- descriptor.setClosingOptions (new Object[] {
- DialogDescriptor.OK_OPTION,
- DialogDescriptor.CANCEL_OPTION
- });
- descriptor.setAdditionalOptions (new Object [] {
- bClear, bTab
- });
- DialogDisplayer.getDefault ().notify (descriptor);
- if (descriptor.getValue () == DialogDescriptor.OK_OPTION)
- return d.tfShortcut.getText ();
- return null;
- }
-
- private static String loc (String key) {
- return NbBundle.getMessage (ShortcutsDialog.class, key);
- }
-
- private static void loc (Component c, String key) {
- if (c instanceof AbstractButton)
- Mnemonics.setLocalizedText (
- (AbstractButton) c,
- loc (key)
- );
- else
- Mnemonics.setLocalizedText (
- (JLabel) c,
- loc (key)
- );
- }
-
- public interface ShortcutsFinder {
- ActionImpl findActionForShortcut (String shortcuts);
- }
-
-
- /** Creates new form ShortcutsDialog1 */
- public ShortcutsDialog() {
- initComponents();
- }
-
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- // //GEN-BEGIN:initComponents
- private void initComponents() {
- lShortcut = new javax.swing.JLabel();
- tfShortcut = new javax.swing.JTextField();
- lConflict = new javax.swing.JLabel();
-
- lShortcut.setText("Shortcut:");
-
- org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
- this.setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .addContainerGap()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(lConflict, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 449, Short.MAX_VALUE)
- .add(layout.createSequentialGroup()
- .add(lShortcut)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(tfShortcut, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .addContainerGap()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(lShortcut)
- .add(tfShortcut, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(lConflict)
- .addContainerGap(25, Short.MAX_VALUE))
- );
- }// //GEN-END:initComponents
-
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JLabel lConflict;
- private javax.swing.JLabel lShortcut;
- private javax.swing.JTextField tfShortcut;
- // End of variables declaration//GEN-END:variables
-
-}
Index: editor/options/src/org/netbeans/modules/options/keymap/Utils.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/Utils.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/Utils.java
--- editor/options/src/org/netbeans/modules/options/keymap/Utils.java 4 Jan 2007 15:01:30 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,115 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
-import javax.swing.KeyStroke;
-import org.openide.ErrorManager;
-import org.openide.util.Utilities;
-
-
-/**
- *
- * @author Jan Jancura
- */
-class Utils {
-
- static KeyStroke[] stringToKeyStrokes2 (String key) {
- StringTokenizer st = new StringTokenizer (key, " ");
- List result = new ArrayList ();
- key = null;
- while (st.hasMoreTokens ()) {
- String ks = st.nextToken ().trim ();
- KeyStroke keyStroke = Utilities.stringToKey (ks);
- //S ystem.out.println("1 " + ks + ">" + keyStroke);
- if (keyStroke == null) {
- if (System.getProperty ("org.netbeans.optionsDialog") != null)
- System.out.println("no key stroke for:" + key);
- return null;
- }
- result.add (keyStroke);
- }
- return (KeyStroke[]) result.toArray
- (new KeyStroke [result.size ()]);
- }
-
- static String getKeyStrokesAsText (KeyStroke[] keyStrokes, String delim) {
- if (keyStrokes == null) return "";
- if (keyStrokes.length == 0) return "";
- StringBuffer sb = new StringBuffer (getKeyStrokeAsText (keyStrokes [0]));
- int i, k = keyStrokes.length;
- for (i = 1; i < k; i++)
- sb.append (delim).append (getKeyStrokeAsText (keyStrokes [i]));
- return new String (sb);
- }
-
- static KeyStroke getKeyStroke (String keyStroke) {
- int modifiers = 0;
- if (keyStroke.startsWith ("Ctrl+")) {
- modifiers |= InputEvent.CTRL_DOWN_MASK;
- keyStroke = keyStroke.substring (5);
- }
- if (keyStroke.startsWith ("Alt+")) {
- modifiers |= InputEvent.ALT_DOWN_MASK;
- keyStroke = keyStroke.substring (4);
- }
- if (keyStroke.startsWith ("Shift+")) {
- modifiers |= InputEvent.SHIFT_DOWN_MASK;
- keyStroke = keyStroke.substring (6);
- }
- if (keyStroke.startsWith ("Meta+")) {
- modifiers |= InputEvent.META_DOWN_MASK;
- keyStroke = keyStroke.substring (5);
- }
- KeyStroke ks = Utilities.stringToKey (keyStroke);
- if (ks == null)
- ErrorManager.getDefault ().notify (
- new IllegalArgumentException (keyStroke)
- );
- KeyStroke result = KeyStroke.getKeyStroke (ks.getKeyCode (), modifiers);
- return result;
- }
-
- static String getKeyStrokeAsText (KeyStroke keyStroke) {
- int modifiers = keyStroke.getModifiers ();
- StringBuffer sb = new StringBuffer ();
- if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0)
- sb.append ("Ctrl+");
- if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0)
- sb.append ("Alt+");
- if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0)
- sb.append ("Shift+");
- if ((modifiers & InputEvent.META_DOWN_MASK) > 0)
- sb.append ("Meta+");
- if (keyStroke.getKeyCode () != KeyEvent.VK_SHIFT &&
- keyStroke.getKeyCode () != KeyEvent.VK_CONTROL &&
- keyStroke.getKeyCode () != KeyEvent.VK_META &&
- keyStroke.getKeyCode () != KeyEvent.VK_ALT &&
- keyStroke.getKeyCode () != KeyEvent.VK_ALT_GRAPH
- )
- sb.append (Utilities.keyToString (
- KeyStroke.getKeyStroke (keyStroke.getKeyCode (), 0)
- ));
- return sb.toString ();
- }
-}
Index: editor/options/src/org/netbeans/modules/options/keymap/XMLStorage.java
===================================================================
RCS file: editor/options/src/org/netbeans/modules/options/keymap/XMLStorage.java
diff -N editor/options/src/org/netbeans/modules/options/keymap/XMLStorage.java
--- editor/options/src/org/netbeans/modules/options/keymap/XMLStorage.java 30 Jun 2006 19:18:16 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,254 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-
-import java.awt.Color;
-import java.awt.Font;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.openide.ErrorManager;
-import org.openide.filesystems.FileLock;
-
-import org.openide.filesystems.FileObject;
-import org.openide.util.RequestProcessor;
-import org.openide.xml.XMLUtil;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.DefaultHandler;
-
-
-public class XMLStorage {
-
- private static final Map colorToName = new HashMap ();
- private static final Map nameToColor = new HashMap ();
- private static final Map nameToFontStyle = new HashMap ();
- private static final Map fontStyleToName = new HashMap ();
- static {
- colorToName.put (Color.black, "black");
- nameToColor.put ("black", Color.black);
- colorToName.put (Color.blue, "blue");
- nameToColor.put ("blue", Color.blue);
- colorToName.put (Color.cyan, "cyan");
- nameToColor.put ("cyan", Color.cyan);
- colorToName.put (Color.darkGray, "darkGray");
- nameToColor.put ("darkGray", Color.darkGray);
- colorToName.put (Color.gray, "gray");
- nameToColor.put ("gray", Color.gray);
- colorToName.put (Color.green, "green");
- nameToColor.put ("green", Color.green);
- colorToName.put (Color.lightGray, "lightGray");
- nameToColor.put ("lightGray", Color.lightGray);
- colorToName.put (Color.magenta, "magenta");
- nameToColor.put ("magenta", Color.magenta);
- colorToName.put (Color.orange, "orange");
- nameToColor.put ("orange", Color.orange);
- colorToName.put (Color.pink, "pink");
- nameToColor.put ("pink", Color.pink);
- colorToName.put (Color.red, "red");
- nameToColor.put ("red", Color.red);
- colorToName.put (Color.white, "white");
- nameToColor.put ("white", Color.white);
- colorToName.put (Color.yellow, "yellow");
- nameToColor.put ("yellow", Color.yellow);
-
- nameToFontStyle.put ("plain", new Integer (Font.PLAIN));
- fontStyleToName.put (new Integer (Font.PLAIN), "plain");
- nameToFontStyle.put ("bold", new Integer (Font.BOLD));
- fontStyleToName.put (new Integer (Font.BOLD), "bold");
- nameToFontStyle.put ("italic", new Integer (Font.ITALIC));
- fontStyleToName.put (new Integer (Font.ITALIC), "italic");
- nameToFontStyle.put ("bold+italic", new Integer (Font.BOLD + Font.ITALIC));
- fontStyleToName.put (new Integer (Font.BOLD + Font.ITALIC), "bold+italic");
- }
-
- static String colorToString (Color color) {
- if (colorToName.containsKey (color))
- return (String) colorToName.get (color);
- return Integer.toHexString (color.getRGB ());
- }
-
- static Color stringToColor (String color) {
- if (nameToColor.containsKey (color))
- return (Color) nameToColor.get (color);
- return new Color ((int) Long.parseLong (color, 16));
- }
-
-
- // generics support methods ................................................
-
- private static RequestProcessor requestProcessor = new RequestProcessor ("XMLStorage");
-
- static void save (final FileObject fo, final String content) {
- requestProcessor.post (new Runnable () {
- public void run () {
- try {
- FileLock lock = fo.lock ();
- try {
- OutputStream os = fo.getOutputStream (lock);
- Writer writer = new OutputStreamWriter (os, "UTF-8"); // NOI18N
- try {
- writer.write (content);
- } finally {
- writer.close ();
- }
- } finally {
- lock.releaseLock ();
- }
- } catch (IOException ex) {
- ErrorManager.getDefault ().notify (ex);
- }
- }
- });
- }
-
- static Object load (FileObject fo, Handler handler) {
- try {
- XMLReader reader = XMLUtil.createXMLReader ();
- reader.setEntityResolver (handler);
- reader.setContentHandler (handler);
- InputStream is = fo.getInputStream ();
- try {
- reader.parse (new InputSource (is));
- } finally {
- is.close ();
- }
- return handler.getResult ();
- } catch (SAXException ex) {
- System.out.println("File: " + fo);
- ex.printStackTrace ();
- return handler.getResult ();
- } catch (IOException ex) {
- System.out.println("File: " + fo);
- ex.printStackTrace ();
- return handler.getResult ();
- } catch (Exception ex) {
- System.out.println("File: " + fo);
- ex.printStackTrace ();
- return handler.getResult ();
- }
- }
-
- static StringBuffer generateHeader () {
- StringBuffer sb = new StringBuffer ();
- sb.append ("\n\n");
- return sb;
- }
-
- static void generateFolderStart (
- StringBuffer sb,
- String name,
- Attribs attributes,
- String indentation
- ) {
- sb.append (indentation).append ('<').append (name);
- if (attributes != null) {
- if (!attributes.oneLine) sb.append ('\n');
- else sb.append (' ');
- generateAttributes (sb, attributes, indentation + " ");
- if (!attributes.oneLine) sb.append (indentation);
- sb.append (">\n");
- } else
- sb.append (">\n");
- }
-
- static void generateFolderEnd (StringBuffer sb, String name, String indentation) {
- sb.append (indentation).append ("").append (name).append (">\n");
- }
-
- static void generateLeaf (
- StringBuffer sb,
- String name,
- Attribs attributes,
- String indentation
- ) {
- sb.append (indentation).append ('<').append (name);
- if (attributes != null) {
- if (!attributes.oneLine) sb.append ('\n');
- else sb.append (' ');
- generateAttributes (sb, attributes, indentation + " ");
- if (!attributes.oneLine) sb.append (indentation);
- sb.append ("/>\n");
- } else
- sb.append ("/>\n");
- }
-
- private static void generateAttributes (
- StringBuffer sb,
- Attribs attributes,
- String indentation
- ) {
- if (attributes == null) return;
- int i, k = attributes.names.size ();
- for (i = 0; i < k; i++) {
- if (!attributes.oneLine)
- sb.append (indentation);
- sb.append (attributes.names.get (i)).append ("=\"").
- append (attributes.values.get (i)).append ('\"');
- if (!attributes.oneLine)
- sb.append ("\n");
- else
- if (i < (k - 1))
- sb.append (' ');
- }
- }
-
- static class Handler extends DefaultHandler {
- private Object result;
- void setResult (Object result) {
- this.result = result;
- }
- Object getResult () {
- return result;
- }
- }
-
- static class Attribs {
- private List names = new ArrayList ();
- private List values = new ArrayList ();
- private boolean oneLine;
-
- Attribs (boolean oneLine) {
- this.oneLine = oneLine;
- }
-
- void add (String name, String value) {
- int i = names.indexOf (name);
- if (i >= 0) {
- names.remove (i);
- values.remove (i);
- }
- names.add (name);
- values.add (value);
- }
-
- void clear () {
- names.clear ();
- values.clear ();
- }
- }
-}
Index: editor/options/src/org/netbeans/modules/options/macros/Bundle.properties
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/macros/Bundle.properties,v
retrieving revision 1.7
retrieving revision 1.6.24.1
diff -u -r1.7 -r1.6.24.1
Index: editor/options/src/org/netbeans/modules/options/macros/MacrosModel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/macros/MacrosModel.java,v
retrieving revision 1.14
retrieving revision 1.10.20.4
diff -u -r1.14 -r1.10.20.4
--- editor/options/src/org/netbeans/modules/options/macros/MacrosModel.java 12 Jan 2007 05:06:36 -0000 1.14
+++ editor/options/src/org/netbeans/modules/options/macros/MacrosModel.java 4 Mar 2007 21:41:06 -0000 1.10.20.4
@@ -30,18 +30,18 @@
import javax.swing.table.DefaultTableModel;
import org.netbeans.api.editor.mimelookup.MimeLookup;
import org.netbeans.api.editor.mimelookup.MimePath;
+import org.netbeans.api.shortcuts.ShortcutAction;
+import org.netbeans.api.shortcuts.ShortcutsFinder;
import org.netbeans.editor.BaseKit;
import org.netbeans.modules.editor.options.BaseOptions;
import org.netbeans.modules.editor.settings.storage.api.EditorSettings;
-import org.netbeans.modules.options.keymap.ActionImpl;
-import org.netbeans.modules.options.keymap.KeymapViewModel;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
class MacrosModel {
- private KeymapViewModel keymapModel;
+ private ShortcutsFinder keymapModel;
/** Map (String (macro name) > String (macro text)).*/
private Map macroNameToText;
private DefaultTableModel tableModel;
@@ -49,13 +49,11 @@
MacrosModel (Lookup lookup) {
- keymapModel = (KeymapViewModel) lookup.lookup
- (KeymapViewModel.class);
- init ();
+ keymapModel = (ShortcutsFinder)lookup.lookup(ShortcutsFinder.class);
+ init();
}
private void init () {
-
// 1) init macroNameToText
macroNameToText = new HashMap();
Set mimeTypes = EditorSettings.getDefault().getMimeTypes();
@@ -73,7 +71,7 @@
for(Iterator it = macroNameToText.keySet().iterator(); it.hasNext(); ) {
String macroName = (String) it.next ();
String shortcut = "";
- ActionImpl action = keymapModel.findActionForId
+ ShortcutAction action = keymapModel.findActionForId
("macro-" + macroName);
if (action == null)
action = keymapModel.findActionForId (macroName);
@@ -126,7 +124,7 @@
tableModel.removeRow (index);
keymapModel.refreshActions();
- ActionImpl actionImpl = keymapModel.findActionForId(BaseKit.macroActionPrefix + macroName);
+ ShortcutAction actionImpl = keymapModel.findActionForId(BaseKit.macroActionPrefix + macroName);
if (actionImpl != null) {
keymapModel.setShortcuts(actionImpl, Collections.emptySet());
}
@@ -150,13 +148,13 @@
// TextAction textAction = (TextAction) editorKit.getActionByName
// ("macro-" + tableModel.getValueAt (index, 0));
// System.out.println("textAction " + textAction);
-// ActionImpl actionImpl = new EditorBridge.EditorAction (textAction);
+// ShortcutAction ShortcutAction = new EditorBridge.EditorAction (textAction);
saveMacros ();
- keymapModel.refreshActions ();
- ActionImpl actionImpl = keymapModel.findActionForId (
+//// keymapModel.refreshActions ();
+ ShortcutAction ShortcutAction = keymapModel.findActionForId (
BaseKit.macroActionPrefix + tableModel.getValueAt (index, 0)
);
- keymapModel.setShortcuts (actionImpl, Collections.singleton (shortcut));
+ keymapModel.setShortcuts (ShortcutAction, Collections.singleton (shortcut));
changed = true;
}
Index: editor/options/src/org/netbeans/modules/options/macros/MacrosPanel.form
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/macros/MacrosPanel.form,v
retrieving revision 1.2
retrieving revision 1.1.12.1
diff -u -r1.2 -r1.1.12.1
Index: editor/options/src/org/netbeans/modules/options/macros/MacrosPanel.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/macros/MacrosPanel.java,v
retrieving revision 1.32
retrieving revision 1.30.16.3
diff -u -r1.32 -r1.30.16.3
--- editor/options/src/org/netbeans/modules/options/macros/MacrosPanel.java 12 Jan 2007 00:03:17 -0000 1.32
+++ editor/options/src/org/netbeans/modules/options/macros/MacrosPanel.java 4 Mar 2007 21:41:06 -0000 1.30.16.3
@@ -32,8 +32,7 @@
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
-import org.netbeans.modules.options.keymap.KeymapViewModel;
-import org.netbeans.modules.options.keymap.ShortcutsDialog;
+import org.netbeans.api.shortcuts.ShortcutsFinder;
import org.netbeans.spi.options.OptionsPanelController;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
@@ -322,9 +321,8 @@
} else
if (e.getSource () == bSetShortcut) {
int index = tMacros.getSelectedRow ();
- String shortcut = ShortcutsDialog.getShortcut (
- (KeymapViewModel) lookup.lookup (KeymapViewModel.class)
- );
+ ShortcutsFinder f = (ShortcutsFinder)lookup.lookup(ShortcutsFinder.class);
+ String shortcut = f.showShortcutsDialog();
saveCurrentMacro ();
if (shortcut != null)
model.setShortcut (index, shortcut);
Index: editor/options/src/org/netbeans/modules/options/macros/MacrosPanelController.java
===================================================================
RCS file: /cvs/editor/options/src/org/netbeans/modules/options/macros/MacrosPanelController.java,v
retrieving revision 1.6
retrieving revision 1.5.16.1
diff -u -r1.6 -r1.5.16.1
Index: editor/options/test/build-unit.xml
===================================================================
RCS file: /cvs/editor/options/test/build-unit.xml,v
retrieving revision 1.4
retrieving revision 1.3.22.1
diff -u -r1.4 -r1.3.22.1
Index: editor/options/test/build.xml
===================================================================
RCS file: /cvs/editor/options/test/build.xml,v
retrieving revision 1.5
retrieving revision 1.4.20.1
diff -u -r1.5 -r1.4.20.1
Index: editor/options/test/cfg-unit.xml
===================================================================
RCS file: /cvs/editor/options/test/cfg-unit.xml,v
retrieving revision 1.4
retrieving revision 1.3.20.2
diff -u -r1.4 -r1.3.20.2
--- editor/options/test/cfg-unit.xml 30 Jun 2006 19:18:16 -0000 1.4
+++ editor/options/test/cfg-unit.xml 14 Mar 2007 09:21:53 -0000 1.3.20.2
@@ -21,7 +21,7 @@
-
+
@@ -29,7 +29,7 @@
-
+
Index: editor/options/test/unit/src/org/netbeans/modules/options/editor/EditorOptionsTest.java
===================================================================
RCS file: /cvs/editor/options/test/unit/src/org/netbeans/modules/options/editor/EditorOptionsTest.java,v
retrieving revision 1.6
retrieving revision 1.5.20.2
diff -u -r1.6 -r1.5.20.2
--- editor/options/test/unit/src/org/netbeans/modules/options/editor/EditorOptionsTest.java 30 Jun 2006 19:18:17 -0000 1.6
+++ editor/options/test/unit/src/org/netbeans/modules/options/editor/EditorOptionsTest.java 14 Mar 2007 09:21:52 -0000 1.5.20.2
@@ -24,6 +24,7 @@
import java.util.Iterator;
import java.util.List;
import javax.swing.JComponent;
+import org.netbeans.beaninfo.editors.HtmlBrowser;
import org.netbeans.junit.NbTestCase;
import org.netbeans.spi.options.OptionsCategory;
import org.netbeans.spi.options.OptionsPanelController;
@@ -49,9 +50,12 @@
IDEInitializer.setup (
new String[] {
"org/netbeans/modules/options/editor/mf-layer.xml",
- "org/netbeans/modules/defaults/mf-layer.xml"
+ "org/netbeans/modules/defaults/mf-layer.xml",
+ "org/netbeans/modules/options/keymap/mf-layer.xml"
},
- new Object[] {}
+ new Object[] {
+ new HtmlBrowser.FactoryEditor()
+ }
);
}
@@ -68,7 +72,7 @@
while (it.hasNext ()) {
OptionsCategory oc = (OptionsCategory) it.next ();
assertNotNull (oc.getCategoryName ());
- assertNotNull (oc.getIconBase ());
+ assertNotNull (oc.getIcon());
assertNotNull (oc.getTitle ());
}
}
Index: editor/options/test/unit/src/org/netbeans/modules/options/editor/IDEInitializer.java
===================================================================
RCS file: /cvs/editor/options/test/unit/src/org/netbeans/modules/options/editor/IDEInitializer.java,v
retrieving revision 1.3
retrieving revision 1.2.26.1
diff -u -r1.3 -r1.2.26.1
Index: editor/options/test/unit/src/org/netbeans/modules/options/keymap/KeymapViewModelTest.java
===================================================================
RCS file: editor/options/test/unit/src/org/netbeans/modules/options/keymap/KeymapViewModelTest.java
diff -N editor/options/test/unit/src/org/netbeans/modules/options/keymap/KeymapViewModelTest.java
--- editor/options/test/unit/src/org/netbeans/modules/options/keymap/KeymapViewModelTest.java 30 Jun 2006 19:18:17 -0000 1.9
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,275 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License (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.html
- * or http://www.netbeans.org/cddl.txt.
- *
- * When distributing Covered Code, include this CDDL Header Notice in each file
- * and include the License file at http://www.netbeans.org/cddl.txt.
- * If applicable, add the following below the CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * 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.
- */
-
-package org.netbeans.modules.options.keymap;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLStreamHandler;
-import java.net.URLStreamHandlerFactory;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.swing.Action;
-import javax.swing.JComponent;
-import javax.swing.text.TextAction;
-import org.netbeans.junit.Manager;
-import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.options.editor.IDEInitializer;
-import org.netbeans.spi.options.OptionsCategory;
-import org.openide.filesystems.FileObject;
-import org.openide.filesystems.FileUtil;
-import org.openide.filesystems.Repository;
-import org.openide.loaders.DataFolder;
-import org.openide.loaders.FolderLookup;
-import org.openide.util.Lookup;
-
-import org.netbeans.modules.options.macros.MacrosPanelController;
-import org.openide.util.lookup.Lookups;
-import org.openide.util.lookup.ProxyLookup;
-
-
-/**
- *
- * @author Jan Jancura
- */
-public class KeymapViewModelTest extends NbTestCase {
-
- static {
- IDEInitializer.setup (
- new String[] {
- "org/netbeans/modules/options/editor/mf-layer.xml",
- "org/netbeans/modules/defaults/mf-layer.xml",
- "org/netbeans/core/ui/resources/layer.xml"
- },
- new Object[] {}
- );
- }
-
- public KeymapViewModelTest (String testName) {
- super (testName);
- }
-
- public void testCancelCurrentProfile () {
- IDEInitializer.cleanWorkDir ();
- KeymapViewModel model = new KeymapViewModel ();
- String currentProfile = model.getCurrentProfile ();
- model.setCurrentProfile ("XXX");
- assertEquals ("XXX", model.getCurrentProfile ());
- model.cancel ();
- assertEquals (currentProfile, model.getCurrentProfile ());
- assertEquals (currentProfile, new KeymapViewModel ().getCurrentProfile ());
- }
-
- public void testOkCurrentProfile () {
- IDEInitializer.cleanWorkDir ();
- KeymapViewModel model = new KeymapViewModel ();
- String currentProfile = model.getCurrentProfile ();
- model.setCurrentProfile ("XXX");
- assertEquals ("XXX", model.getCurrentProfile ());
- assertEquals (currentProfile, new KeymapViewModel ().getCurrentProfile ());
- model.apply ();
- assertEquals ("XXX", model.getCurrentProfile ());
- assertEquals ("XXX", new KeymapViewModel ().getCurrentProfile ());
- }
-
- public void testChangeShortcuts () {
- IDEInitializer.cleanWorkDir ();
- KeymapViewModel model = new KeymapViewModel ();
- forAllActions (model, new R () {
- public void run (KeymapViewModel model, ActionImpl action) {
- model.setShortcuts (action, Collections.EMPTY_SET);
- }
- });
- forAllActions (model, new R () {
- public void run (KeymapViewModel model, ActionImpl action) {
- assertEquals (0, model.getShortcuts (action).length);
- }
- });
- final Set set = Collections.singleton ("Alt+K");
- forAllActions (model, new R () {
- public void run (KeymapViewModel model, ActionImpl action) {
- model.setShortcuts (action, set);
- }
- });
- forAllActions (model, new R () {
- public void run (KeymapViewModel model, ActionImpl action) {
- String[] s = model.getShortcuts (action);
- assertEquals (1, s.length);
- assertEquals ("Alt+K", s [0]);
- }
- });
- }
-
- public void testChangeShortcutsOk () {
- IDEInitializer.cleanWorkDir ();
- KeymapViewModel model = new KeymapViewModel ();
- Map shortcuts = setRandomShortcuts (model);
- System.out.println ("apply changes");
- model.apply ();
- System.gc ();
- model.apply ();
- System.gc ();
- checkShortcuts (model, shortcuts, true);
- checkShortcuts (new KeymapViewModel (), shortcuts, true);
- }
-
- public void testChangeShortcutsCancel () {
- IDEInitializer.cleanWorkDir ();
- KeymapViewModel model = new KeymapViewModel ();
- Map shortcuts = getShortcuts (model);
- Map shortcuts2 = setRandomShortcuts (model);
- checkShortcuts (model, shortcuts2, false);
- System.out.println ("cancel changes");
- model.cancel ();
- checkShortcuts (model, shortcuts, false);
- checkShortcuts (new KeymapViewModel (), shortcuts, false);
- }
-
- /**
- * Sets random shortcuts and returns them in
- * Map (Set (String (shortcut)) > String (action name)).
- */
- private Map setRandomShortcuts (final KeymapViewModel model) {
- final int[] ii = {1};
- final Map result = new HashMap ();
- System.out.println("set random shortcuts");
- forAllActions (model, new R () {
- public void run (KeymapViewModel model, ActionImpl action) {
- String shortcut = Integer.toString (ii [0], 36).toUpperCase ();
- StringBuffer sb = new StringBuffer ();
- int i, k = shortcut.length ();
- for (i = 0; i < k; i++)
- sb.append (shortcut.charAt (i)).append (' ');
- shortcut = sb.toString ().trim ();
- Set s = Collections.singleton (shortcut);
- model.setShortcuts (action, s);
- result.put (s, action);
- //System.out.println (s + " : " + action);
- ii [0] ++;
- }
- });
- return result;
- }
-
- /**
- * Returns Map (Set (String (shortcut)) > String (action name)) containing
- * all current shortcuts.
- */
- private Map getShortcuts (final KeymapViewModel model) {
- final Map result = new HashMap ();
- System.out.println("get shortcuts");
- forAllActions (model, new R () {
- public void run (KeymapViewModel model, ActionImpl action) {
- String[] sh = model.getShortcuts (action);
- if (sh.length == 0) return;
- Set shortcuts = new HashSet (Arrays.asList (sh));
- //System.out.println("sh: " + shortcuts + " : " + action);
- assertFalse ("Same shortcuts assigned to two actions ", result.containsKey (shortcuts));
- result.put (shortcuts, action);
- }
- });
- return result;
- }
-
- private static String getName (Object action) {
- if (action instanceof TextAction)
- return (String) ((TextAction) action).getValue (Action.SHORT_DESCRIPTION);
- if (action instanceof Action)
- return (String) ((Action) action).getValue (Action.NAME);
- return action.toString ();
- }
-
- private void checkShortcuts (final KeymapViewModel model, final Map shortcuts, final boolean print) {
- System.out.println("check shortcuts");
- final Map localCopy = new HashMap (shortcuts);
- forAllActions (model, new R () {
- public void run (KeymapViewModel model, ActionImpl action) {
- String[] sh = model.getShortcuts (action);
- if (sh.length == 0) return;
- Set s = new HashSet (Arrays.asList (sh));
- if (print)
- System.out.println (s + " : " + action + " : " + localCopy.get (s));
- assertEquals ("Shortcut changed: " + s + " : " + action, localCopy.get (s), action);
- localCopy.remove (s);
- }
- });
- assertTrue ("Some shortcuts found: " + localCopy, localCopy.isEmpty ());
- }
-
-// public void testChangeShortcutsCancel () {
-// KeymapViewModel model = new KeymapViewModel ();
-// final Set set = Collections.singleton ("Alt+K");
-// forAllActions (model, new R () {
-// public void run (KeymapViewModel model, Object action) {
-// model.setShortcuts (action, set);
-// }
-// });
-// model.apply ();
-// final Set set1 = Collections.singleton ("Ctrl+L");
-// forAllActions (model, new R () {
-// public void run (KeymapViewModel model, Object action) {
-// model.setShortcuts (action, set);
-// }
-// });
-// forAllActions (model, new R () {
-// public void run (KeymapViewModel model, Object action) {
-// String[] s = model.getShortcuts (action);
-// assertEquals (1, s.length);
-// assertEquals ("Alt+L", s [0]);
-// }
-// });
-// model.cancel ();
-// forAllActions (model, new R () {
-// public void run (KeymapViewModel model, Object action) {
-// String[] s = model.getShortcuts (action);
-// assertEquals (1, s.length);
-// assertEquals ("Alt+K", s [0]);
-// }
-// });
-// }
-
- private void forAllActions (KeymapViewModel model, R r) {
- forAllActions (model, r, "");
- }
-
- private void forAllActions (KeymapViewModel model, R r, String folder) {
- Iterator it = model.getItems (folder).iterator ();
- while (it.hasNext ()) {
- Object o = it.next ();
- if (o instanceof String)
- forAllActions (model, r, (String) o);
- else
- r.run (model, (ActionImpl) o);
- }
- }
-
- interface R {
- void run (KeymapViewModel model, ActionImpl action);
- }
-}
-
-