Xcos: add preferences management (#2) 69/8569/10
Clément DAVID [Mon, 30 Jul 2012 15:31:23 +0000 (17:31 +0200)]
Change-Id: I5c1f77f6ef6be82fef0d2a148e97efa74208fcf1

16 files changed:
scilab/modules/console/etc/XConfiguration-general.xml
scilab/modules/graph/src/java/org/scilab/modules/graph/actions/base/GraphActionManager.java
scilab/modules/preferences/etc/XConfiguration.xml
scilab/modules/xcos/etc/XConfiguration-xcos.xml
scilab/modules/xcos/etc/XConfiguration-xcos.xsl
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/FitDiagramToViewAction.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/actions/SimulationNotRunningAction.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/configuration/ConfigurationManager.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/configuration/utils/ConfigurationConstants.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/XcosDiagram.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/graph/swing/GraphComponent.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/io/XcosFileType.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/link/BasicLink.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/preferences/XcosConfiguration.java
scilab/modules/xcos/src/java/org/scilab/modules/xcos/preferences/XcosKeyMap.java [new file with mode: 0644]
scilab/modules/xcos/src/java/org/scilab/modules/xcos/preferences/XcosOptions.java

index d531e1e..ad4ef3a 100644 (file)
@@ -1,79 +1,79 @@
 <?xml version="1.0" encoding="utf-8"?>
 <general title="_(General)">
-  <body>
-    <environment fpe="0" printing-format="v" width="10">
-      <fpe code="0" floating-point-exception="_(Produces an error)"/>
-      <fpe code="1" floating-point-exception="_(Produces a warning)"/>
-      <fpe code="2" floating-point-exception="_(Produces Inf or NaN)"/>
-      <printing-format code="v" format="_(Variable format)"/>
-      <printing-format code="e" format="_(Scientific format)"/>
-    </environment>
-    <languages lang="en_US">
-      <language code="en_US" desc="_(English)"/>
-      <language code="fr_FR" desc="_(French)"/>
-      <language code="pt_BR" desc="_(Portugese (Brazil))"/>
-      <language code="ca_ES" desc="_(Catalan)"/>
-      <language code="cs_CZ" desc="_(Czech)"/>
-      <language code="es_ES" desc="_(Spanish)"/>
-      <language code="it_IT" desc="_(Italian)"/>
-      <language code="pl_PL" desc="_(Polish)"/>
-      <language code="ru_RU" desc="_(Russian)"/>
-      <language code="zh_CN" desc="_(Chinese (Simplified))"/>
-      <language code="zh_TW" desc="_(Chinese (Traditional))"/>
-      <language code="de_DE" desc="_(German)"/>
-      <language code="ja_JP" desc="_(Japanese)"/>
-      <language code="uk_UA" desc="_(Ukrainian)"/>
-    </languages>
-    <java-heap-memory heap-size="256"/>
-  </body>
-  <confirmation-dialogs title="_(Confirmation dialogs)"> 
     <body>
-      <tools>
-        <tool state="checked" id="console-exit" name="Console" description="_(Warn before exiting Scilab)"/>
-        <tool state="checked" id="delete-history-item" name="Command History" description="_(Warn before deleting Command History items)"/>
-        <tool state="checked" id="console-clear" name="Console" description="_(Warn before clearing the Console)"/>
-      </tools>
+        <environment fpe="0" printing-format="v" width="10">
+            <fpe code="0" floating-point-exception="_(Produces an error)"/>
+            <fpe code="1" floating-point-exception="_(Produces a warning)"/>
+            <fpe code="2" floating-point-exception="_(Produces Inf or NaN)"/>
+            <printing-format code="v" format="_(Variable format)"/>
+            <printing-format code="e" format="_(Scientific format)"/>
+        </environment>
+        <languages lang="en_US">
+            <language code="en_US" desc="_(English)"/>
+            <language code="fr_FR" desc="_(French)"/>
+            <language code="pt_BR" desc="_(Portugese (Brazil))"/>
+            <language code="ca_ES" desc="_(Catalan)"/>
+            <language code="cs_CZ" desc="_(Czech)"/>
+            <language code="es_ES" desc="_(Spanish)"/>
+            <language code="it_IT" desc="_(Italian)"/>
+            <language code="pl_PL" desc="_(Polish)"/>
+            <language code="ru_RU" desc="_(Russian)"/>
+            <language code="zh_CN" desc="_(Chinese (Simplified))"/>
+            <language code="zh_TW" desc="_(Chinese (Traditional))"/>
+            <language code="de_DE" desc="_(German)"/>
+            <language code="ja_JP" desc="_(Japanese)"/>
+            <language code="uk_UA" desc="_(Ukrainian)"/>
+        </languages>
+        <java-heap-memory heap-size="256"/>
     </body>
-  </confirmation-dialogs>
-  <desktop-layout title="_(Desktop layout)">
-    <body>
-      <layouts id="0">
-        <layout id="0" name="_(Integrated)" path="$SCI/modules/gui/etc/integratedConfiguration.xml" image="file:///$SCI/modules/gui/images/preferences/integrated.png"/>
-        <layout id="1" name="_(Simple)" path="$SCI/modules/gui/etc/simpleConfiguration.xml" image="file:///$SCI/modules/gui/images/preferences/simple.png"/>
-      </layouts>
-    </body>
-  </desktop-layout>
-  <shortcuts title="_(Shortcuts)">
-    <body>
-      <actions active="scilab" name="Console" item="1" browse="--choose a file --" filter="">
-        <action-folder name="Console" xconf-uid="console">
-          <action key="OSSCKEY X" description="_(Cut or interrupt)" name="console-cut-or-interrupt"/>
-          <action key="OSSCKEY C" description="_(Copy or interrupt)" name="console-copy-or-interrupt"/>
-          <action key="OSSCKEY S" description="_(Select all)" name="console-select-all"/>
-          <action key="OSSCKEY A" description="_(Line beginning)" name="console-line-begin"/>
-          <action key="OSSCKEY E" description="_(Line end)" name="console-line-end"/>
-          <action key="OSSCKEY B" description="_(Previous char)" name="console-prev-char"/>
-          <action key="OSSCKEY F" description="_(Next char)" name="console-next-char"/>
-          <action key="OSSCKEY D" description="_(Delete next char)" name="console-del-next-char"/>
-          <action key="OSSCKEY H" description="_(Delete previous char)" name="console-del-prev-char"/>
-          <action key="OSSCKEY K" description="_(Delete end of line)" name="console-del-end-line"/>
-          <action key="OSSCKEY U" description="_(Delete whole line)" name="console-del-whole-line"/>
-          <action key="OSSCKEY ESCAPE" description="_(Delete whole line)" name="console-del-whole-line"/>
-          <action key="OSSCKEY W" description="_(Delete last word)" name="console-del-last-word"/>
-          <action key="OSSCKEY X" description="_(Delete last word)" name="console-del-last-word"/>
-          <action key="PAGE_UP" description="_(Previous console page)" name="console-prev-page"/>
-          <action key="PAGE_DOWN" description="_(Next console page)" name="console-next-page"/>
-          <action key="ENTER" description="_(Validate input)" name="console-enter"/>
-          <action key="F2" description="_(Clear console)" name="console-clear"/>
-          <action key="F12" description="_(Console box)" name="console-box"/>
-          <action key="OSSCKEY SPACE" description="_(Completion)" name="console-completion"/>
-          <action key="TAB" description="_(Completion)" name="console-completion"/>
-          <action key="UP" description="_(Previous history line)" name="console-prev-history"/>
-          <action key="DOWN" description="_(Next history line)" name="console-next-history"/>
-          <action key="OSSCKEY N" description="_(Previous history line)" name="console-prev-history"/>
-          <action key="OSSCKEY P" description="_(Next history line)" name="console-next-history"/>
-          <action key="F1" description="_(Help Browser)" name="console-help-browser"/>
-          <!--action key="OSSCKEY V" description="_(Paste)" name="console-paste"/>
+    <confirmation-dialogs title="_(Confirmation dialogs)"> 
+        <body>
+            <tools>
+                <tool state="checked" id="console-exit" name="Console" description="_(Warn before exiting Scilab)"/>
+                <tool state="checked" id="delete-history-item" name="Command History" description="_(Warn before deleting Command History items)"/>
+                <tool state="checked" id="console-clear" name="Console" description="_(Warn before clearing the Console)"/>
+            </tools>
+        </body>
+    </confirmation-dialogs>
+    <desktop-layout title="_(Desktop layout)">
+        <body>
+            <layouts id="0">
+                <layout id="0" name="_(Integrated)" path="$SCI/modules/gui/etc/integratedConfiguration.xml" image="file:///$SCI/modules/gui/images/preferences/integrated.png"/>
+                <layout id="1" name="_(Simple)" path="$SCI/modules/gui/etc/simpleConfiguration.xml" image="file:///$SCI/modules/gui/images/preferences/simple.png"/>
+            </layouts>
+        </body>
+    </desktop-layout>
+    <shortcuts title="_(Shortcuts)">
+        <body>
+            <actions active="scilab" name="Console" item="1" browse="--choose a file --" filter="">
+                <action-folder name="Console" xconf-uid="console">
+                    <action key="OSSCKEY X" description="_(Cut or interrupt)" name="console-cut-or-interrupt"/>
+                    <action key="OSSCKEY C" description="_(Copy or interrupt)" name="console-copy-or-interrupt"/>
+                    <action key="OSSCKEY S" description="_(Select all)" name="console-select-all"/>
+                    <action key="OSSCKEY A" description="_(Line beginning)" name="console-line-begin"/>
+                    <action key="OSSCKEY E" description="_(Line end)" name="console-line-end"/>
+                    <action key="OSSCKEY B" description="_(Previous char)" name="console-prev-char"/>
+                    <action key="OSSCKEY F" description="_(Next char)" name="console-next-char"/>
+                    <action key="OSSCKEY D" description="_(Delete next char)" name="console-del-next-char"/>
+                    <action key="OSSCKEY H" description="_(Delete previous char)" name="console-del-prev-char"/>
+                    <action key="OSSCKEY K" description="_(Delete end of line)" name="console-del-end-line"/>
+                    <action key="OSSCKEY U" description="_(Delete whole line)" name="console-del-whole-line"/>
+                    <action key="OSSCKEY ESCAPE" description="_(Delete whole line)" name="console-del-whole-line"/>
+                    <action key="OSSCKEY W" description="_(Delete last word)" name="console-del-last-word"/>
+                    <action key="OSSCKEY X" description="_(Delete last word)" name="console-del-last-word"/>
+                    <action key="PAGE_UP" description="_(Previous console page)" name="console-prev-page"/>
+                    <action key="PAGE_DOWN" description="_(Next console page)" name="console-next-page"/>
+                    <action key="ENTER" description="_(Validate input)" name="console-enter"/>
+                    <action key="F2" description="_(Clear console)" name="console-clear"/>
+                    <action key="F12" description="_(Console box)" name="console-box"/>
+                    <action key="OSSCKEY SPACE" description="_(Completion)" name="console-completion"/>
+                    <action key="TAB" description="_(Completion)" name="console-completion"/>
+                    <action key="UP" description="_(Previous history line)" name="console-prev-history"/>
+                    <action key="DOWN" description="_(Next history line)" name="console-next-history"/>
+                    <action key="OSSCKEY N" description="_(Previous history line)" name="console-prev-history"/>
+                    <action key="OSSCKEY P" description="_(Next history line)" name="console-next-history"/>
+                    <action key="F1" description="_(Help Browser)" name="console-help-browser"/>
+                    <!--action key="OSSCKEY V" description="_(Paste)" name="console-paste"/>
           <action key="OSSCKEY O" description="_(Open a file)" name="console-open"/>
           <action key="OSSCKEY L" description="_(Load environment)" name="console-load"/>
           <action key="OSSCKEY S" description="_(Save environment)" name="console-save"/>
           <action key="" description="_(Open Forge website)" name="console-forge-website"/>
           <action key="" description="_(Open Bugzilla)" name="console-bugzilla-website"/>
           <action key="Shift F1" description="_(About Scilab)" name="console-about"/-->
-        </action-folder>
-        <action-folder name="Scinotes" xconf-uid="scinotes">
-          <action key="OSSCKEY H" description="_(Auto complete (, [,...)" name="scinotes-autocomplete-openers"/>
-          <action key="OSSCKEY Shift H" description="_(Auto complete keyword)" name="scinotes-autocomplete-keyword"/>
-          <action key="OSSCKEY Shift G" description="_(Generate Help prototype)" name="scinotes-help-prototype"/>
-          <action key="TAB" description="_(Tabify)" name="scinotes-tabify"/>
-          <action key="Shift TAB" description="_(Untabify)" name="scinotes-untabify"/>
-          <action key="OSSCKEY I" description="_(Indent)" name="scinotes-indent"/>
-          <action key="OSSCKEY D" description="_(Comment)" name="scinotes-comment"/>
-          <action key="OSSCKEY Shift D" description="_(Uncomment)" name="scinotes-uncomment"/>
-          <action key="OSSCKEY Shift W" description="_(Remove trailing whites)" name="scinotes-remove-whites"/>
-          <action key="OSSCKEY A" description="_(Select all)" name="scinotes-select-all"/>
-          <action key="OSSCKEY B" description="_(Select block)" name="scinotes-select-block"/>
-          <action key="OSSCKEY Shift T" description="_(Open current tab in a new window)" name="scinotes-clone-current"/>
-          <action key="OSSCKEY Shift X" description="_(Export current tab in a new window)" name="scinotes-export-current"/>
-          <action key="OSSCKEY C" description="_(Copy)" name="scinotes-copy"/>
-          <action key="OSSCKEY X" description="_(Cut)" name="scinotes-cut"/>
-          <action key="OSSCKEY V" description="_(Paste)" name="scinotes-paste"/>
-          <action key="OSSCKEY Shift V" description="_(Paste a column)" name="scinotes-paste-column"/>
-          <action key="OSSCKEY Shift Z" description="_(Repeat selection on column)" name="scinotes-repeat-column"/>
-          <action key="OSSCKEY Z" description="_(Undo)" name="scinotes-undo"/>
-          <action key="OSSCKEY Y" description="_(Redo)" name="scinotes-redo"/>
-          <action key="OSSCKEY Shift C" description="_(Copy as HTML with line number)" name="scinotes-copy-with-lines"/>
-          <action key="OSSCKEY N" description="_(New)" name="scinotes-new"/>
-          <action key="OSSCKEY O" description="_(Open)" name="scinotes-open"/>
-          <action key="OSSCKEY U" description="_(Open URL)" name="scinotes-open-url"/>
-          <action key="OSSCKEY Shift O" description="_(Open source)" name="scinotes-open-source"/>
-          <action key="OSSCKEY S" description="_(Save)" name="scinotes-save"/>
-          <action key="OSSCKEY Shift S" description="_(Save as)" name="scinotes-save-as"/>
-          <action key="OSSCKEY Shift R" description="_(Reload)" name="scinotes-reload"/>
-          <action key="OSSCKEY Shift P" description="_(Print preview)" name="scinotes-print-preview"/>
-          <action key="OSSCKEY P" description="_(Print)" name="scinotes-print"/>
-          <action key="OSSCKEY W" description="_(Close)" name="scinotes-close"/>
-          <action key="OSSCKEY Q" description="_(Exit)" name="scinotes-exit"/>
-          <action key="OSSCKEY J" description="_(To lower case)" name="scinotes-tolowercase"/>
-          <action key="OSSCKEY Shift J" description="_(To upper case)" name="scinotes-touppercase"/>
-          <action key="OSSCKEY Shift A" description="_(Capitalize)" name="scinotes-capitalize"/>
-          <action key="OSSCKEY F1" description="_(Help on keyword)" name="scinotes-help-keyword"/>
-          <action key="OSSCKEY L" description="_(Load in Scilab)" name="scinotes-load-scilab"/>
-          <action key="OSSCKEY Shift E" description="_(Execute in Scilab)" name="scinotes-execute-scilab"/>
-          <action key="OSSCKEY E" description="_(Evaluate selection)" name="scinotes-evaluate-selection"/>
-          <action key="F5" description="_(Save and execute)" name="scinotes-save-execute"/>
-          <action key="OSSCKEY F5" description="_(Save and execute all)" name="scinotes-save-execute-all"/>
-          <action key="OSSCKEY F" description="_(Find)" name="scinotes-find"/>
-          <action key="OSSCKEY K" description="_(Find next)" name="scinotes-find-next"/>
-          <action key="OSSCKEY Shift K" description="_(Find previous)" name="scinotes-find-previous"/>
-          <action key="F3" description="_(Incremental search)" name="scinotes-incremental-search"/>
-          <action key="OSSCKEY M" description="_(Set anchor)" name="scinotes-set-anchor"/>
-          <action key="OSSCKEY Shift M" description="_(Remove anchor)" name="scinotes-remove-anchor"/>
-          <action key="OSSCKEY Shift LESS" description="_(Go to next anchor)" name="scinotes-next-anchor"/>
-          <action key="OSSCKEY LESS" description="_(Go to previous anchor)" name="scinotes-previous-anchor"/>
-          <action key="OSSCKEY G" description="_(Start Code Navigator)" name="scinotes-code-navigator"/>
-          <action key="OSSCKEY Shift F" description="_(Search word in file)" name="scinotes-word-file"/>
-          <action key="OSSCKEY Shift B" description="_(Search files)" name="scinotes-search-files"/>
-          <action key="OSSCKEY SPACE" description="_(Keyword completion)" name="scinotes-completion"/>
-          <action key="F1" description="_(Help)" name="scinotes-help"/>
-          <action key="Shift F1" description="_(About)" name="scinotes-about"/>
-          <action key="OSSCKEY PAGE_DOWN" description="_(Next tab)" name="scinotes-next-tab"/>
-          <action key="OSSCKEY PAGE_UP" description="_(Previous tab)" name="scinotes-previous-tab"/>
-          <action key="DELETE" description="_(Delete)" name="scinotes-delete"/>
-          <action key="OSSCKEY DOWN" description="_(Next paragraph)" name="scinotes-next-paragraph"/>
-          <action key="OSSCKEY UP" description="_(Previous paragraph)" name="scinotes-previous-paragraph"/>
-          <action key="" description="_(Save all)" name="scinotes-save-all"/>
-          <action key="" description="_(Overwrite)" name="scinotes-overwrite"/>
-          <action key="" description="_(Page setup)" name="scinotes-page-setup"/>
-          <action key="" description="_(Close all)" name="scinotes-close-all"/>
-          <action key="" description="_(Close all but this)" name="scinotes-close-all-but"/>
-          <action key="" description="_(Convert quote to double quote)" name="scinotes-double-quote"/>
-          <action key="" description="_(Line numbering)" name="scinotes-line-numbering"/>
-        </action-folder>
-        <!--action-folder name="Xcos" xconf-uid="xcos">
-          <action key="OSSCKEY S" description="_(Save diagram)" name="xcos-save"/>
-        </action-folder>
-        <action-folder name="Variable Browser" xconf-uid="browsevar">
+                </action-folder>
+                <action-folder name="Scinotes" xconf-uid="scinotes">
+                    <action key="OSSCKEY H" description="_(Auto complete (, [,...)" name="scinotes-autocomplete-openers"/>
+                    <action key="OSSCKEY Shift H" description="_(Auto complete keyword)" name="scinotes-autocomplete-keyword"/>
+                    <action key="OSSCKEY Shift G" description="_(Generate Help prototype)" name="scinotes-help-prototype"/>
+                    <action key="TAB" description="_(Tabify)" name="scinotes-tabify"/>
+                    <action key="Shift TAB" description="_(Untabify)" name="scinotes-untabify"/>
+                    <action key="OSSCKEY I" description="_(Indent)" name="scinotes-indent"/>
+                    <action key="OSSCKEY D" description="_(Comment)" name="scinotes-comment"/>
+                    <action key="OSSCKEY Shift D" description="_(Uncomment)" name="scinotes-uncomment"/>
+                    <action key="OSSCKEY Shift W" description="_(Remove trailing whites)" name="scinotes-remove-whites"/>
+                    <action key="OSSCKEY A" description="_(Select all)" name="scinotes-select-all"/>
+                    <action key="OSSCKEY B" description="_(Select block)" name="scinotes-select-block"/>
+                    <action key="OSSCKEY Shift T" description="_(Open current tab in a new window)" name="scinotes-clone-current"/>
+                    <action key="OSSCKEY Shift X" description="_(Export current tab in a new window)" name="scinotes-export-current"/>
+                    <action key="OSSCKEY C" description="_(Copy)" name="scinotes-copy"/>
+                    <action key="OSSCKEY X" description="_(Cut)" name="scinotes-cut"/>
+                    <action key="OSSCKEY V" description="_(Paste)" name="scinotes-paste"/>
+                    <action key="OSSCKEY Shift V" description="_(Paste a column)" name="scinotes-paste-column"/>
+                    <action key="OSSCKEY Shift Z" description="_(Repeat selection on column)" name="scinotes-repeat-column"/>
+                    <action key="OSSCKEY Z" description="_(Undo)" name="scinotes-undo"/>
+                    <action key="OSSCKEY Y" description="_(Redo)" name="scinotes-redo"/>
+                    <action key="OSSCKEY Shift C" description="_(Copy as HTML with line number)" name="scinotes-copy-with-lines"/>
+                    <action key="OSSCKEY N" description="_(New)" name="scinotes-new"/>
+                    <action key="OSSCKEY O" description="_(Open)" name="scinotes-open"/>
+                    <action key="OSSCKEY U" description="_(Open URL)" name="scinotes-open-url"/>
+                    <action key="OSSCKEY Shift O" description="_(Open source)" name="scinotes-open-source"/>
+                    <action key="OSSCKEY S" description="_(Save)" name="scinotes-save"/>
+                    <action key="OSSCKEY Shift S" description="_(Save as)" name="scinotes-save-as"/>
+                    <action key="OSSCKEY Shift R" description="_(Reload)" name="scinotes-reload"/>
+                    <action key="OSSCKEY Shift P" description="_(Print preview)" name="scinotes-print-preview"/>
+                    <action key="OSSCKEY P" description="_(Print)" name="scinotes-print"/>
+                    <action key="OSSCKEY W" description="_(Close)" name="scinotes-close"/>
+                    <action key="OSSCKEY Q" description="_(Exit)" name="scinotes-exit"/>
+                    <action key="OSSCKEY J" description="_(To lower case)" name="scinotes-tolowercase"/>
+                    <action key="OSSCKEY Shift J" description="_(To upper case)" name="scinotes-touppercase"/>
+                    <action key="OSSCKEY Shift A" description="_(Capitalize)" name="scinotes-capitalize"/>
+                    <action key="OSSCKEY F1" description="_(Help on keyword)" name="scinotes-help-keyword"/>
+                    <action key="OSSCKEY L" description="_(Load in Scilab)" name="scinotes-load-scilab"/>
+                    <action key="OSSCKEY Shift E" description="_(Execute in Scilab)" name="scinotes-execute-scilab"/>
+                    <action key="OSSCKEY E" description="_(Evaluate selection)" name="scinotes-evaluate-selection"/>
+                    <action key="F5" description="_(Save and execute)" name="scinotes-save-execute"/>
+                    <action key="OSSCKEY F5" description="_(Save and execute all)" name="scinotes-save-execute-all"/>
+                    <action key="OSSCKEY F" description="_(Find)" name="scinotes-find"/>
+                    <action key="OSSCKEY K" description="_(Find next)" name="scinotes-find-next"/>
+                    <action key="OSSCKEY Shift K" description="_(Find previous)" name="scinotes-find-previous"/>
+                    <action key="F3" description="_(Incremental search)" name="scinotes-incremental-search"/>
+                    <action key="OSSCKEY M" description="_(Set anchor)" name="scinotes-set-anchor"/>
+                    <action key="OSSCKEY Shift M" description="_(Remove anchor)" name="scinotes-remove-anchor"/>
+                    <action key="OSSCKEY Shift LESS" description="_(Go to next anchor)" name="scinotes-next-anchor"/>
+                    <action key="OSSCKEY LESS" description="_(Go to previous anchor)" name="scinotes-previous-anchor"/>
+                    <action key="OSSCKEY G" description="_(Start Code Navigator)" name="scinotes-code-navigator"/>
+                    <action key="OSSCKEY Shift F" description="_(Search word in file)" name="scinotes-word-file"/>
+                    <action key="OSSCKEY Shift B" description="_(Search files)" name="scinotes-search-files"/>
+                    <action key="OSSCKEY SPACE" description="_(Keyword completion)" name="scinotes-completion"/>
+                    <action key="F1" description="_(Help)" name="scinotes-help"/>
+                    <action key="Shift F1" description="_(About)" name="scinotes-about"/>
+                    <action key="OSSCKEY PAGE_DOWN" description="_(Next tab)" name="scinotes-next-tab"/>
+                    <action key="OSSCKEY PAGE_UP" description="_(Previous tab)" name="scinotes-previous-tab"/>
+                    <action key="DELETE" description="_(Delete)" name="scinotes-delete"/>
+                    <action key="OSSCKEY DOWN" description="_(Next paragraph)" name="scinotes-next-paragraph"/>
+                    <action key="OSSCKEY UP" description="_(Previous paragraph)" name="scinotes-previous-paragraph"/>
+                    <action key="" description="_(Save all)" name="scinotes-save-all"/>
+                    <action key="" description="_(Overwrite)" name="scinotes-overwrite"/>
+                    <action key="" description="_(Page setup)" name="scinotes-page-setup"/>
+                    <action key="" description="_(Close all)" name="scinotes-close-all"/>
+                    <action key="" description="_(Close all but this)" name="scinotes-close-all-but"/>
+                    <action key="" description="_(Convert quote to double quote)" name="scinotes-double-quote"/>
+                    <action key="" description="_(Line numbering)" name="scinotes-line-numbering"/>
+                </action-folder>
+                <action-folder name="Xcos" xconf-uid="xcos">
+                    <!-- File -->
+                    <action key="OSSCKEY N" description="_(New diagram)" name="xcos-new" />
+                    <action key="OSSCKEY O" description="_(Open)" name="xcos-open" />
+                    <action key="" description="_(Open file in Scilab current directory)" name="xcos-open-in-sci" />
+                    <action key="OSSCKEY S" description="_(Save)" name="xcos-save" />
+                    <action key="OSSCKEY Shift S" description="_(Save as)" name="xcos-save-as" />
+                    <action key="OSSCKEY E" description="_(Export)" name="xcos-export" />
+                    <action key="OSSCKEY P" description="_(Print)" name="xcos-print" />
+                    <action key="OSSCKEY W" description="_(Close)" name="xcos-close" />
+                    <action key="OSSCKEY Q" description="_(Quit Xcos)" name="xcos-quit" />
+                    <!-- Edit -->
+                    <action key="OSSCKEY Z" description="_(Undo)" name="xcos-undo" />
+                    <action key="OSSCKEY Y" description="_(Redo)" name="xcos-redo" />
+                    <action key="OSSCKEY X" description="_(Cut)" name="xcos-cut" />
+                    <action key="OSSCKEY C" description="_(Copy)" name="xcos-copy" />
+                    <action key="OSSCKEY V" description="_(Paste)" name="xcos-paste" />
+                    <action key="OSSCKEY DELETE" description="_(Delete)" name="xcos-delete" />
+                    <action key="OSSCKEY A" description="_(Select all)" name="xcos-select-all" />
+                    <action key="" description="_(Invert selection)" name="xcos-invert-selection" />
+                    <action key="OSSCKEY B" description="_(Block Parameters)" name="xcos-block-parameters" />
+                    <action key="" description="_(Region to superblock)" name="xcos-region-to-superblock" />
+                    <!-- View -->
+                    <action key="OSSCKEY ADD" description="_(Zoom In)" name="xcos-zoom-in" />
+                    <action key="OSSCKEY SUBTRACT" description="_(Zoom Out)" name="xcos-zoom-out" />
+                    <action key="OSSCKEY SPACE" description="_(Fit diagram to view)" name="xcos-fit-diagram" />
+                    <action key="" description="_(Normal 100%)" name="xcos-zoom-normal" />
+                    <action key="" description="_(Palette browser)" name="xcos-view-palette" />
+                    <action key="" description="_(Diagram browser)" name="xcos-view-diagram" />
+                    <action key="" description="_(Viewport)" name="xcos-view-viewport" />
+                    <action key="" description="_(Details)" name="xcos-view-details" />
+                    <!-- Simulation -->
+                    <action key="" description="_(Setup)" name="xcos-setup" />
+                    <action key="" description="_(Execution trace and Debug)" name="xcos-debug-level" />
+                    <action key="" description="_(Set Context)" name="xcos-set-context" />
+                    <action key="" description="_(Compile)" name="xcos-compile" />
+                    <action key="" description="_(Start)" name="xcos-start" />
+                    <action key="" description="_(Stop)" name="xcos-stop" />
+                    <!-- Format -->
+                    <action key="OSSCKEY R" description="_(Rotate)" name="xcos-rotate" />
+                    <action key="OSSCKEY F" description="_(Flip)" name="xcos-flip" />
+                    <action key="OSSCKEY M" description="_(Mirror)" name="xcos-mirror" />
+                    <action key="" description="_(Show/Hide shadow)" name="xcos-shadow" />
+                    <action key="" description="_(Left)" name="xcos-align-left" />
+                    <action key="" description="_(Center)" name="xcos-align-center" />
+                    <action key="" description="_(Right)" name="xcos-align-right" />
+                    <action key="" description="_(Top)" name="xcos-align-top" />
+                    <action key="" description="_(Middle)" name="xcos-align-middle" />
+                    <action key="" description="_(Bottom)" name="xcos-align-bottom" />
+                    <action key="" description="_(Border Color)" name="xcos-border-color" />
+                    <action key="" description="_(Fill Color)" name="xcos-fill-color" />
+                    <action key="H" description="_(Horizontal)" name="xcos-link-horizontal" />
+                    <action key="S" description="_(Straight)" name="xcos-link-straight" />
+                    <action key="V" description="_(Vertical)" name="xcos-fill-vertical" />
+                    <action key="" description="_(Diagram background)" name="xcos-background" />
+                    <action key="" description="_(Grid)" name="xcos-grid" />
+                    <!-- Tools -->
+                    <action key="" description="_(Code generation)" name="xcos-code-generation" />
+                    <!-- Help -->
+                    <action key="F1" description="_(Xcos Help)" name="xcos-help" />
+                    <action key="OSSCKEY H" description="_(Block Help)" name="xcos-help-block" />
+                    <action key="" description="_(Xcos Demos)" name="xcos-demo" />
+                    <action key="" description="_(About Xcos)" name="xcos-about" />
+                </action-folder>
+                <!--action-folder name="Variable Browser" xconf-uid="browsevar">
           <action key="OSSCKEY S" description="_(Save)" name="variablebrowser-save"/>
         </action-folder>
         <action-folder name="Variable Editor" xconf-uid="editvar">
         <action-folder name="File Browser" xconf-uid="filebrowser">
           <action key="OSSCKEY S" description="_(Save file)" name="filebrowser-save"/>
         </action-folder-->
-      </actions>
-    </body>
-  </shortcuts>
+            </actions>
+        </body>
+    </shortcuts>
 </general>
index 806fc2f..32cb600 100644 (file)
 package org.scilab.modules.graph.actions.base;
 
 import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
+import javax.swing.Action;
+import javax.swing.KeyStroke;
+
 import org.scilab.modules.graph.ScilabGraph;
 
 /**
- * Implement construction methods for Actions. 
+ * Implement construction methods for Actions.
  */
 public final class GraphActionManager {
-       private static Map<ScilabGraph, Set<DefaultAction>> perGraphAction = 
-               new Hashtable<ScilabGraph, Set<DefaultAction>>();
-       private static Set<DefaultAction> nullGraphAction = new HashSet<DefaultAction>();
-
-       /**
-        * Static class so private constructor 
-        */
-       private GraphActionManager() { }
-       
-       /**
-        * As each action is unique per graph, get the action instance for the
-        * graph.
-        * 
-        * If the action has never been instantiated, use the
-        * DefaultAction(ScilabGraph) constructor and put it on the set.
-        * 
-        * @param graph
-        *            the graph to work on
-        * @param action
-        *            the action class we are looking for.
-        * @param <T> the type to work with.
-        * @return the instance or null on error.
-        */
-       public static < T extends DefaultAction> T getInstance(ScilabGraph graph, Class<T> action) {
-               Set<DefaultAction> actionSet = getActionSet(graph);
-               
-               for (DefaultAction defaultAction : actionSet) {
-                       if (defaultAction.getClass() == action) {
-                               // Here we can safely cast the action according to the test.
-                               return (T) defaultAction;
-                       }
-               }
-               
-               T instance = null;
-               try {
-                       instance = action.getConstructor(ScilabGraph.class).newInstance(graph);
-                       actionSet.add(instance);
-               } catch (IllegalArgumentException e) {
-                       e.printStackTrace();
-               } catch (SecurityException e) {
-                       e.printStackTrace();
-               } catch (InstantiationException e) {
-                       e.printStackTrace();
-               } catch (IllegalAccessException e) {
-                       e.printStackTrace();
-               } catch (InvocationTargetException e) {
-                       e.printStackTrace();
-               } catch (NoSuchMethodException e) {
-                       e.printStackTrace();
-               }
-               
-               return instance;
-       }
-
-       /**
-        * Get the action set attached to the graph
-        * @param graph the graph where to search
-        * @return the {@link DefaultAction} set
-        */
-       private static Set<DefaultAction> getActionSet(ScilabGraph graph) {
-               Set<DefaultAction> actionSet;
-               if (graph == null) {
-                       actionSet = nullGraphAction;
-               } else {
-                       if (perGraphAction.containsKey(graph)) {
-                               actionSet = perGraphAction.get(graph);
-                       } else {
-                               actionSet = new HashSet<DefaultAction>();
-                               perGraphAction.put(graph, actionSet);
-                       }
-               }
-               return actionSet;
-       }
-       
-       /**
-        * As each action is unique per graph, get the action instance for the
-        * graph.
-        * 
-        * If the action has never been instantiated, return null.
-        * 
-        * @param graph
-        *            the graph to work on
-        * @param action
-        *            the action class we are looking for.
-        * @param <T> the type to work with.
-        * @return the instance or null if not found.
-        */
-       public static  < T extends DefaultAction> T get(ScilabGraph graph, Class<T> action) {
-               Set<DefaultAction> actionSet = getActionSet(graph);
-
-               for (DefaultAction defaultAction : actionSet) {
-                       if (defaultAction.getClass() == action) {
-                               // Here we can safely cast the action according to the test.
-                               return (T) defaultAction;
-                       }
-               }
-                       
-               return null;
-       }
-       
-       /**
-        * Enable or disable action on all registered graph.
-        * @param actionKlass The action type to enable
-        * @param enable the enable status
-        */
-       public static void setEnable(Class< ? extends DefaultAction> actionKlass, boolean enable) {
-               // Handle null graph
-               for (DefaultAction action : nullGraphAction) {
-                       if (actionKlass.isInstance(action)) {
-                               action.setEnabled(enable);
-                       }
-               }
-               
-               // Handle non-null graph
-               for (Set<DefaultAction> actions : perGraphAction.values()) {
-                       for (DefaultAction action : actions) {
-                               if (actionKlass.isInstance(action)) {
-                                       action.setEnabled(enable);
-                               }
-                       }
-               }
-       }
-       
-       /**
-        * Get status action on all registered graph.
-        * @param actionKlass The action type to enable
-        * @return the status (true if all action are enabled, false otherwise)
-        */
-       public static boolean getEnable(Class< ? extends DefaultAction> actionKlass) {
-               boolean result = true;
-               
-               // Handle null graph
-               for (DefaultAction action : nullGraphAction) {
-                       if (actionKlass.isInstance(action)) {
-                               result &= action.isEnabled();
-                       }
-               }
-               
-               // Handle non-null graph
-               for (Set<DefaultAction> actions : perGraphAction.values()) {
-                       for (DefaultAction action : actions) {
-                               if (actionKlass.isInstance(action)) {
-                                       result &= action.isEnabled();
-                               }
-                       }
-               }
-               
-               return result;
-       }
+    private static HashMap<ScilabGraph, Set<DefaultAction>> perGraphAction = new HashMap<ScilabGraph, Set<DefaultAction>>();
+    private static HashSet<DefaultAction> nullGraphAction = new HashSet<DefaultAction>();
+
+    /**
+     * Static class so private constructor
+     */
+    private GraphActionManager() {
+    }
+
+    /**
+     * As each action is unique per graph, get the action instance for the
+     * graph.
+     *
+     * If the action has never been instantiated, use the
+     * DefaultAction(ScilabGraph) constructor and put it on the set.
+     *
+     * @param graph
+     *            the graph to work on
+     * @param action
+     *            the action class we are looking for.
+     * @param <T>
+     *            the type to work with.
+     * @return the instance or null on error.
+     */
+    public static <T extends DefaultAction> T getInstance(ScilabGraph graph, Class<T> action) {
+        Set<DefaultAction> actionSet = getActionSet(graph);
+
+        for (DefaultAction defaultAction : actionSet) {
+            if (defaultAction.getClass() == action) {
+                // Here we can safely cast the action according to the test.
+                return (T) defaultAction;
+            }
+        }
+
+        T instance = null;
+        try {
+            instance = action.getConstructor(ScilabGraph.class).newInstance(graph);
+            actionSet.add(instance);
+        } catch (IllegalArgumentException e) {
+            e.printStackTrace();
+        } catch (SecurityException e) {
+            e.printStackTrace();
+        } catch (InstantiationException e) {
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        } catch (InvocationTargetException e) {
+            e.printStackTrace();
+        } catch (NoSuchMethodException e) {
+            e.printStackTrace();
+        }
+
+        return instance;
+    }
+
+    /**
+     * Get the action set attached to the graph
+     *
+     * @param graph
+     *            the graph where to search
+     * @return the {@link DefaultAction} set
+     */
+    private static Set<DefaultAction> getActionSet(ScilabGraph graph) {
+        Set<DefaultAction> actionSet;
+        if (graph == null) {
+            actionSet = nullGraphAction;
+        } else {
+            if (perGraphAction.containsKey(graph)) {
+                actionSet = perGraphAction.get(graph);
+            } else {
+                actionSet = new HashSet<DefaultAction>();
+                perGraphAction.put(graph, actionSet);
+            }
+        }
+        return actionSet;
+    }
+
+    /**
+     * As each action is unique per graph, get the action instance for the
+     * graph.
+     *
+     * If the action has never been instantiated, return null.
+     *
+     * @param graph
+     *            the graph to work on
+     * @param action
+     *            the action class we are looking for.
+     * @param <T>
+     *            the type to work with.
+     * @return the instance or null if not found.
+     */
+    public static <T extends DefaultAction> T get(ScilabGraph graph, Class<T> action) {
+        Set<DefaultAction> actionSet = getActionSet(graph);
+
+        for (DefaultAction defaultAction : actionSet) {
+            if (defaultAction.getClass() == action) {
+                // Here we can safely cast the action according to the test.
+                return (T) defaultAction;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Enable or disable action on all registered graph.
+     *
+     * @param actionKlass
+     *            The action type to enable
+     * @param enable
+     *            the enable status
+     */
+    public static void setEnable(Class <? extends DefaultAction > actionKlass, boolean enable) {
+        // Handle null graph
+        for (DefaultAction action : nullGraphAction) {
+            if (actionKlass.isInstance(action)) {
+                action.setEnabled(enable);
+            }
+        }
+
+        // Handle non-null graph
+        for (Set<DefaultAction> actions : perGraphAction.values()) {
+            for (DefaultAction action : actions) {
+                if (actionKlass.isInstance(action)) {
+                    action.setEnabled(enable);
+                }
+            }
+        }
+    }
+
+    /**
+     * Get status action on all registered graph.
+     *
+     * @param actionKlass
+     *            The action type to enable
+     * @return the status (true if all action are enabled, false otherwise)
+     */
+    public static boolean getEnable(Class <? extends DefaultAction > actionKlass) {
+        boolean result = true;
+
+        // Handle null graph
+        for (DefaultAction action : nullGraphAction) {
+            if (actionKlass.isInstance(action)) {
+                result &= action.isEnabled();
+            }
+        }
+
+        // Handle non-null graph
+        for (Set<DefaultAction> actions : perGraphAction.values()) {
+            for (DefaultAction action : actions) {
+                if (actionKlass.isInstance(action)) {
+                    result &= action.isEnabled();
+                }
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * Update the {@link KeyStroke} of all actions of class.
+     *
+     * @param actionKlass
+     *            the action class to update
+     * @param key
+     *            the {@link KeyStroke} to set
+     */
+    public static void updateActionKeyStroke(Class <? extends DefaultAction > actionKlass, KeyStroke key) {
+        /*
+         * Per graph action
+         */
+        final Set<Entry<ScilabGraph, Set<DefaultAction>>> entrySet = perGraphAction.entrySet();
+        for (Entry<ScilabGraph, Set<DefaultAction>> entry : entrySet) {
+            setKeyStroke(entry.getValue(), actionKlass, key);
+        }
+
+        /*
+         * Out of graphs actions
+         */
+        setKeyStroke(nullGraphAction, actionKlass, key);
+    }
+
+    private static final void setKeyStroke(final Set<DefaultAction> actions, final Class <? extends DefaultAction > actionKlass, final KeyStroke key) {
+        for (final DefaultAction a : actions) {
+            if (a.getClass() == actionKlass) {
+                a.putValue(Action.ACCELERATOR_KEY, key);
+            }
+        }
+    }
 }
index b8279b7..010f7f5 100644 (file)
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
-<interface version="0.06" path="1/" width="800" height="550">
-  <general/>
-  <web/>
-  <preference/>
-  <fonts/>
-  <colors/>
-  <console/>
-  <command-history/>
-  <scinotes/>
-  <xcos/>
+<interface version="0.07" path="1/" width="800" height="550">
+    <general/>
+    <web/>
+    <preference/>
+    <fonts/>
+    <colors/>
+    <console/>
+    <command-history/>
+    <scinotes/>
+    <xcos/>
 </interface>
index 3762638..f80a7e6 100644 (file)
@@ -1,36 +1,38 @@
 <?xml version="1.0" encoding="utf-8"?>
 <xcos title="Xcos">
-  <body>
-    <xcos-preferences />
-  </body>
-  <!-- deactivate on beta2
-  <edition title="Edition">
     <body>
-      <xcos-edition edge-style="0"/>
-      <edge-style code="0" description="_(Straight)"/>
-      <edge-style code="1" description="_(Horizontal)"/>
-      <edge-style code="2" description="_(Vertical)"/>
+        <xcos-preferences number-of-recently-open="5" file-format="0">
+            <file-format code="0" description="ZCOS"/>
+            <file-format code="1" description="XCOS"/>
+        </xcos-preferences>
     </body>
-  </edition>
--->
-  <simulation title="_(Simulation)">
-    <body>
-      <xcos-simulation final-integration-time="1.0E05" real-time-scaling="0.0E00" integrator-absolute-tolerance="1.0E-06" integrator-relative-tolerance="1.0E-06" tolerance-on-time="1.0E-10" max-integration-interval="1.0E05" solver="2" max-step-size="0.0" trace="0">
-        <!-- Available solver values list from scicos -->
-        <!-- <solver code="0" description="lsodar - BDF - NEWTON "/> -->
-        <solver code="1" description="Sundials/CVODE - BDF - NEWTON"/>
-        <solver code="2" description="Sundials/CVODE - BDF - FUNCTIONAL"/>
-        <solver code="3" description="Sundials/CVODE - ADAMS - NEWTON"/>
-        <solver code="4" description="Sundials/CVODE - ADAMS - FUNCTIONAL"/>
-        <!-- <solver code="5" description="DOPRI5 - Runge-Kutta 4(5)"/> -->
-        <solver code="100" description="Sundials/IDA"/>
-        <!-- Available trace values lists from scicos -->        
-        <trace code="0" description="_(No trace nor debug printing)"/>
-        <trace code="1" description="_(Light Simulation trace (Discrete and Continuous part switches))"/>
-        <trace code="2" description="_(Per block execution trace and Debug block calls)"/>
-        <trace code="3" description="_(Debug block calls without trace)"/>
-      </xcos-simulation>
-    </body>
-  </simulation>
+    <edition title="Edition">
+        <body>
+            <xcos-edition edge-style="0" graph-background="0xffffff" graph-grid-enable="true" graph-grid="10">
+                <edge-style code="0" description="_(Straight)"/>
+                <edge-style code="1" description="_(Horizontal)"/>
+                <edge-style code="2" description="_(Vertical)"/>
+            </xcos-edition>
+        </body>
+    </edition>
+    <simulation title="Simulation">
+        <body>
+            <xcos-simulation final-integration-time="1.0E05" real-time-scaling="0.0E00" integrator-absolute-tolerance="1.0E-06" integrator-relative-tolerance="1.0E-06" tolerance-on-time="1.0E-10" max-integration-interval="1.0E05" solver="2" max-step-size="0.0" trace="0">
+                <!-- Available solver values list from scicos -->
+                <!-- <solver code="0" description="lsodar - BDF - NEWTON "/> -->
+                <solver code="1" description="Sundials/CVODE - BDF - NEWTON"/>
+                <solver code="2" description="Sundials/CVODE - BDF - FUNCTIONAL"/>
+                <solver code="3" description="Sundials/CVODE - ADAMS - NEWTON"/>
+                <solver code="4" description="Sundials/CVODE - ADAMS - FUNCTIONAL"/>
+                <!-- <solver code="5" description="DOPRI5 - Runge-Kutta 4(5)"/> -->
+                <solver code="100" description="Sundials/IDA"/>
+                <!-- Available trace values lists from scicos -->        
+                <trace code="0" description="_(No trace nor debug printing)"/>
+                <trace code="1" description="_(Light Simulation trace (Discrete and Continuous part switches))"/>
+                <trace code="2" description="_(Per block execution trace and Debug block calls)"/>
+                <trace code="3" description="_(Debug block calls without trace)"/>
+            </xcos-simulation>
+        </body>
+    </simulation>
 </xcos>
 
index db07198..f34401a 100644 (file)
-<?xml version='1.0' encoding='utf-8'?>
-
-<xsl:stylesheet version ="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-    
-    
-    
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
     <!-- Default settings for Xcos -->
-    
     <xsl:template match="xcos-preferences">
-        
-        <HBox>
-            
-            Xcos Preferences window.
-            
-            <Glue />
-            
-        </HBox>
-        
+        <Grid>
+            <Label gridx="1" gridy="1" text="_(Number of recently opened files to display: )"/>
+            <NumericalSpinner gridx="2"
+                          gridy="1"
+                          min-value = "0"
+                          increment = "1"
+                          length = "4"
+                          listener = "ActionListener"
+                          value = "{@number-of-recently-open}">
+                <actionPerformed choose="number-of-recently-open">
+                    <xsl:call-template name="context"/>
+                </actionPerformed>
+            </NumericalSpinner>
+            <Label gridx="1" gridy="2" text="_(Default file format)"/>
+            <Select gridx="2" gridy="2" listener="ActionListener">
+                <xsl:variable name="file-format" select="@file-format"/>
+                <actionPerformed choose="file-format">
+                    <xsl:call-template name="context"/>
+                </actionPerformed>
+                <xsl:for-each select="file-format">
+                    <option value="{@description}" key="{@code}">
+                        <xsl:if test="@code=$file-format">
+                            <xsl:attribute name="selected">selected</xsl:attribute>
+                        </xsl:if>
+                    </option>
+                </xsl:for-each>
+            </Select>
+        </Grid>
     </xsl:template>
-    
     <!-- Customize Xcos editing behavior-->
-    
-    <!-- deactivate on beta2\r
-       <xsl:template match="xcos-edition">\r
-               <HBox>\r
-                       Xcos edition window.\r
-                       <Glue />\r
-               </HBox>\r
-       </xsl:template>\r
--->
-    
+    <xsl:template match="xcos-edition">
+        <Grid>
+            <Label gridx="1" gridy="1" text="_(Link Style)"/>
+            <Select gridx="2" gridy="1" listener="ActionListener">
+                <xsl:variable name="edge-style" select="@edge-style"/>
+                <actionPerformed choose="edge-style">
+                    <xsl:call-template name="context"/>
+                </actionPerformed>
+                <xsl:for-each select="edge-style">
+                    <option value="{@description}" key="{@code}">
+                        <xsl:if test="@code=$edge-style">
+                            <xsl:attribute name="selected">selected</xsl:attribute>
+                        </xsl:if>
+                    </option>
+                </xsl:for-each>
+            </Select>
+            <Label gridx="1" gridy="2" text="_(Diagram background)"/>
+            <Color gridx="2" gridy="2" color="{@graph-background}" listener="ActionListener">
+                <actionPerformed choose="graph-background">
+                    <xsl:call-template name="context"/>
+                </actionPerformed>
+            </Color>
+            <Checkbox gridx="1" gridy="3" text="_(Grid)" checked="{@graph-grid-enable}" selected-value="true" unselected-value="false" listener="ActionListener">
+                <actionPerformed choose="graph-grid-enable">
+                    <xsl:call-template name="context"/>
+                </actionPerformed>
+            </Checkbox>
+            <NumericalSpinner gridx="2" gridy="3" value="{@graph-grid}" enable="{@graph-grid-enable}" increment="1" min-value="1" listener="ActionListener">
+                <actionPerformed choose="graph-grid">
+                    <xsl:call-template name="context"/>
+                </actionPerformed>
+            </NumericalSpinner>
+        </Grid>
+    </xsl:template>
     <!-- Simulation settings for Xcos -->
-    
     <xsl:template match="xcos-simulation">
-        
         <Title text="_(Default simulation settings)">
-            
             <Grid>
-                
                 <Label gridx="1" gridy="1" text="_(Final integration time)"/>
-                
                 <ScilabDoubleEntry gridx="2" gridy="1" value="{@final-integration-time}" listener="PropertyChangeListener">
-                    
                     <propertyChange name="value" choose="final-integration-time">
-                        
                         <xsl:call-template name="context"/>
-                        
                     </propertyChange>
-                    
                 </ScilabDoubleEntry>
-                
                 <Label gridx="1" gridy="2" text="_(Real time scaling)"/>
-                
                 <ScilabDoubleEntry gridx="2" gridy="2" value="{@real-time-scaling}" listener="PropertyChangeListener">
-                    
                     <propertyChange name="value" choose="real-time-scaling">
-                        
                         <xsl:call-template name="context"/>
-                        
                     </propertyChange>
-                    
                 </ScilabDoubleEntry>
-                
                 <Label gridx="1" gridy="3" text="_(Integrator absolute tolerance)"/>
-                
                 <ScilabDoubleEntry gridx="2" gridy="3" value="{@integrator-absolute-tolerance}" listener="PropertyChangeListener">
-                    
                     <propertyChange name="value" choose="integrator-absolute-tolerance">
-                        
                         <xsl:call-template name="context"/>
-                        
                     </propertyChange>
-                    
                 </ScilabDoubleEntry>
-                
                 <Label gridx="1" gridy="4" text="_(Integrator relative tolerance)"/>
-                
                 <ScilabDoubleEntry gridx="2" gridy="4" value="{@integrator-relative-tolerance}" listener="PropertyChangeListener">
-                    
                     <propertyChange name="value" choose="integrator-relative-tolerance">
-                        
                         <xsl:call-template name="context"/>
-                        
                     </propertyChange>
-                    
                 </ScilabDoubleEntry>
-                
                 <Label gridx="1" gridy="5" text="_(Tolerance on time)"/>
-                
                 <ScilabDoubleEntry gridx="2" gridy="5" value="{@tolerance-on-time}" listener="PropertyChangeListener">
-                    
                     <propertyChange name="value" choose="tolerance-on-time">
-                        
                         <xsl:call-template name="context"/>
-                        
                     </propertyChange>
-                    
                 </ScilabDoubleEntry>
-                
                 <Label gridx="1" gridy="6" text="_(Max integration time interval)"/>
-                
                 <ScilabDoubleEntry gridx="2" gridy="6" value="{@max-integration-interval}" listener="PropertyChangeListener">
-                    
                     <propertyChange name="value" choose="max-integration-interval">
-                        
                         <xsl:call-template name="context"/>
-                        
                     </propertyChange>
-                    
                 </ScilabDoubleEntry>
-                
                 <Label gridx="1" gridy="7" text="_(Solver kind)"/>
-                
                 <Select gridx="2" gridy="7" listener="ActionListener">
-                    
                     <xsl:variable name="solver" select="@solver"/>
-                    
                     <actionPerformed choose="solver">
-                        
                         <xsl:call-template name="context"/>
-                        
                     </actionPerformed>
-                    
                     <xsl:for-each select="solver">
-                        
                         <option value="{@description}" key="{@code}">
-                            
                             <xsl:if test="@code=$solver">
-                                
                                 <xsl:attribute name="selected">selected</xsl:attribute>
-                                
                             </xsl:if>
-                            
                         </option>
-                        
                     </xsl:for-each>
-                    
                 </Select>
-                
                 <Label gridx="1" gridy="8" text="_(Maximum step size (0 means no limit))"/>
-                
-                <NumericalSpinner gridx="2" gridy="8"\r
-                          min-value = "0"\r
-                          increment = "1"\r
-                          length = "4"\r
-                          listener = "ActionListener"\r
-                          value = "{@max-step-size}">
-                    
+                <NumericalSpinner gridx="2" gridy="8" min-value="0" increment="1" length="4" listener="ActionListener" value="{@max-step-size}">
                     <actionPerformed choose="max-step-size">
-                        
                         <xsl:call-template name="context"/>
-                        
                     </actionPerformed>
-                    
                 </NumericalSpinner>
-                
             </Grid>
-            
         </Title>
-        
         <VSpace height="10"/>
-        
         <Title text="_(Default trace settings)">
-            
             <Select listener="ActionListener">
-                
                 <xsl:variable name="trace" select="@trace"/>
-                
                 <actionPerformed choose="trace">
-                    
                     <xsl:call-template name="context"/>
-                    
                 </actionPerformed>
-                
                 <xsl:for-each select="trace">
-                    
                     <option value="{@description}" key="{@code}">
-                        
                         <xsl:if test="@code=$trace">
-                            
                             <xsl:attribute name="selected">selected</xsl:attribute>
-                            
                         </xsl:if>
-                        
                     </option>
-                    
                 </xsl:for-each>
-                
             </Select>
-            
         </Title>
-        
     </xsl:template>
-    
-    
-    
 </xsl:stylesheet>
-
index 1c80129..944523c 100644 (file)
@@ -2,17 +2,18 @@
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2009 - DIGITEO - Vincent COUVERT
  * Copyright (C) 2009 - DIGITEO - Clement DAVID
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
 
 package org.scilab.modules.xcos.actions;
 
+import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 
@@ -35,11 +36,11 @@ public final class FitDiagramToViewAction extends OneBlockDependantAction {
     /** Mnemonic key of the action */
     public static final int MNEMONIC_KEY = KeyEvent.VK_SPACE;
     /** Accelerator key for the action */
-    public static final int ACCELERATOR_KEY = 0;
+    public static final int ACCELERATOR_KEY = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
 
     /**
      * Constructor
-     * 
+     *
      * @param scilabGraph
      *            associated diagram
      */
@@ -49,7 +50,7 @@ public final class FitDiagramToViewAction extends OneBlockDependantAction {
 
     /**
      * Menu to add to the menubar
-     * 
+     *
      * @param scilabGraph
      *            associated diagram
      * @return the menu
@@ -60,7 +61,7 @@ public final class FitDiagramToViewAction extends OneBlockDependantAction {
 
     /**
      * Button to add to the toolbar
-     * 
+     *
      * @param scilabGraph
      *            associated diagram
      * @return the button
@@ -83,7 +84,7 @@ public final class FitDiagramToViewAction extends OneBlockDependantAction {
         if (comp.isEditing()) {
             return;
         }
-        
+
         // If diagram is empty (has one default child) : do nothing.
         if (graph.getModel().getChildCount(graph.getDefaultParent()) < 1) {
             return;
index cafb7bd..e8bc292 100644 (file)
@@ -26,20 +26,21 @@ import org.scilab.modules.graph.actions.base.GraphActionManager;
 public abstract class SimulationNotRunningAction extends DefaultAction {
     /**
      * Default constructor
-     * 
+     *
      * @param scilabGraph
      *            the associated scilab graph
      */
     public SimulationNotRunningAction(ScilabGraph scilabGraph) {
         super(scilabGraph);
 
-        GraphActionManager.get(scilabGraph, StartAction.class)
-                .addPropertyChangeListener(new PropertyChangeListener() {
-                    @Override
-                    public void propertyChange(PropertyChangeEvent evt) {
-                        setEnabled((Boolean) evt.getNewValue());
-                    }
-                });
+        GraphActionManager.get(scilabGraph, StartAction.class).addPropertyChangeListener(new PropertyChangeListener() {
+            @Override
+            public void propertyChange(PropertyChangeEvent evt) {
+                if (evt.getPropertyName().equals("enabled")) {
+                    setEnabled((Boolean) evt.getNewValue());
+                }
+            }
+        });
     }
 
 }
index 96f3f5b..7727d52 100644 (file)
@@ -50,6 +50,7 @@ import org.scilab.modules.xcos.configuration.utils.ConfigurationConstants;
 import org.scilab.modules.xcos.graph.SuperBlockDiagram;
 import org.scilab.modules.xcos.graph.XcosDiagram;
 import org.scilab.modules.xcos.io.XcosFileType;
+import org.scilab.modules.xcos.preferences.XcosOptions;
 import org.scilab.modules.xcos.utils.FileUtils;
 import org.scilab.modules.xcos.utils.XcosConstants;
 import org.scilab.modules.xcos.utils.XcosMessages;
@@ -269,8 +270,9 @@ public final class ConfigurationManager {
         } else {
             // Element not found, remove the last element if
             // there is no more place.
-            if (files.size() == ConfigurationConstants.MAX_RECENT_FILES) {
-                oldElement = files.remove(ConfigurationConstants.MAX_RECENT_FILES - 1);
+            final int numberOfRecentlyOpen = XcosOptions.getPreferences().getNumberOfRecentlyOpen();
+            if (files.size() == numberOfRecentlyOpen) {
+                oldElement = files.remove(numberOfRecentlyOpen - 1);
             }
         }
 
index 1b8050f..d9cb6f4 100644 (file)
@@ -43,11 +43,6 @@ public final class ConfigurationConstants {
         }
     };
 
-    /**
-     * The maximum number of recently opened files
-     */
-    public static final int MAX_RECENT_FILES = 10;
-
     /*
      * Properties applicable to the ConfigurationManager change support
      */
index 55ee695..9601e8a 100644 (file)
@@ -13,7 +13,6 @@
 
 package org.scilab.modules.xcos.graph;
 
-import java.awt.Color;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.beans.PropertyChangeEvent;
@@ -81,6 +80,7 @@ import org.scilab.modules.xcos.port.input.ExplicitInputPort;
 import org.scilab.modules.xcos.port.input.ImplicitInputPort;
 import org.scilab.modules.xcos.port.output.ExplicitOutputPort;
 import org.scilab.modules.xcos.port.output.ImplicitOutputPort;
+import org.scilab.modules.xcos.preferences.XcosOptions;
 import org.scilab.modules.xcos.utils.BlockPositioning;
 import org.scilab.modules.xcos.utils.XcosConstants;
 import org.scilab.modules.xcos.utils.XcosDialogs;
@@ -925,9 +925,14 @@ public class XcosDiagram extends ScilabGraph {
         getAsComponent().setTolerance(1);
 
         getAsComponent().getViewport().setOpaque(false);
-        getAsComponent().setBackground(Color.WHITE);
 
-        setGridVisible(true);
+        getAsComponent().setBackground(XcosOptions.getEdition().getGraphBackground());
+
+        final boolean gridEnable = XcosOptions.getEdition().isGraphGridEnable();
+        setGridVisible(gridEnable);
+        if (gridEnable) {
+            setGridSize(XcosOptions.getEdition().getGraphGrid());
+        }
 
         /*
          * Reinstall related listeners
@@ -1743,7 +1748,7 @@ public class XcosDiagram extends ScilabGraph {
     public boolean saveDiagramAs(final File fileName) {
         boolean isSuccess = false;
         File writeFile = fileName;
-        XcosFileType format = XcosFileType.ZCOS;
+        XcosFileType format = XcosOptions.getPreferences().getFileFormat();
 
         info(XcosMessages.SAVING_DIAGRAM);
         if (fileName == null) {
@@ -1767,7 +1772,7 @@ public class XcosDiagram extends ScilabGraph {
                         escaped = escaped.replace(c, '-');
                     }
 
-                    fc.setSelectedFile(new File(escaped + XcosFileType.ZCOS.getDottedExtension()));
+                    fc.setSelectedFile(new File(escaped + XcosOptions.getPreferences().getFileFormat().getDottedExtension()));
                 }
                 ConfigurationManager.configureCurrentDirectory(fc);
             }
@@ -1792,11 +1797,11 @@ public class XcosDiagram extends ScilabGraph {
         final String filename = writeFile.getName();
 
         /*
-         * Look for the user extension
-         * if it does not exists, append a default one
+         * Look for the user extension if it does not exists, append a default
+         * one
          *
-         * if the specified extension is handled, update the save format ;
-         * else append a default extension and use the default format
+         * if the specified extension is handled, update the save format ; else
+         * append a default extension and use the default format
          */
         XcosFileType userExtension = XcosFileType.findFileType(filename);
         if (userExtension == null) {
index c737fcd..2414698 100644 (file)
@@ -48,7 +48,7 @@ public class GraphComponent extends ScilabComponent {
 
     /**
      * Default constructor.
-     * 
+     *
      * @param graph
      *            the graph
      */
@@ -115,9 +115,8 @@ public class GraphComponent extends ScilabComponent {
         /*---*/
         menu.add(XcosDocumentationAction.createMenu((ScilabGraph) getGraph()));
 
-        ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation(
-                MouseInfo.getPointerInfo().getLocation().x, MouseInfo
-                        .getPointerInfo().getLocation().y);
+        ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo()
+                .getLocation().y);
 
         menu.setVisible(true);
     }
index 5e5df71..fbdbd53 100644 (file)
@@ -260,18 +260,21 @@ public enum XcosFileType {
      * @return The determined filetype
      */
     public static XcosFileType findFileType(FileFilter filter) {
-        XcosFileType retValue = null;
-
-        for (XcosFileType currentFileType : XcosFileType.values()) {
-            final File sample = new File("sample." + currentFileType.getExtension());
+        final FileFilter[] filters = getSavingFilters();
 
-            if (filter.accept(sample)) {
-                retValue = currentFileType;
+        int index = 0;
+        for (FileFilter fileFilter : filters) {
+            if (fileFilter == filter)
                 break;
-            }
+
+            index++;
         }
 
-        return retValue;
+        if (index > 0) {
+            return XcosFileType.values()[index - 1];
+        } else {
+            return null;
+        }
     }
 
     /**
index 98bf97a..8c00041 100644 (file)
@@ -36,6 +36,7 @@ import org.scilab.modules.xcos.link.explicit.ExplicitLink;
 import org.scilab.modules.xcos.link.implicit.ImplicitLink;
 import org.scilab.modules.xcos.port.BasicPort;
 import org.scilab.modules.xcos.port.BasicPort.Type;
+import org.scilab.modules.xcos.preferences.XcosOptions;
 import org.scilab.modules.xcos.utils.XcosMessages;
 
 import com.mxgraph.model.mxGeometry;
@@ -50,8 +51,7 @@ import com.mxgraph.util.mxRectangle;
  */
 // CSOFF: ClassDataAbstractionCoupling
 public abstract class BasicLink extends ScilabGraphUniqueObject {
-    private static final mxGeometry DEFAULT_GEOMETRY = new mxGeometry(0, 0, 80,
-            80);
+    private static final mxGeometry DEFAULT_GEOMETRY = new mxGeometry(0, 0, 80, 80);
     private static final int DETECTION_RECTANGLE_DIMENSION = 10;
     private transient int ordering;
 
@@ -65,7 +65,7 @@ public abstract class BasicLink extends ScilabGraphUniqueObject {
         super();
         setVertex(false);
         setEdge(true);
-        setStyle(style);
+        setStyle(style + XcosOptions.getEdition().getEdgeStyle());
     }
 
     /**
@@ -119,12 +119,10 @@ public abstract class BasicLink extends ScilabGraphUniqueObject {
 
         final List<mxPoint> points = getGeometry().getPoints();
         if (fromStart) {
-            return new ArrayList<mxPoint>(points.subList(0,
-                                          Math.min(points.size(), index)));
+            return new ArrayList<mxPoint>(points.subList(0, Math.min(points.size(), index)));
         } else {
             if (index < points.size()) {
-                return new ArrayList<mxPoint>(points.subList(index,
-                                              points.size()));
+                return new ArrayList<mxPoint>(points.subList(index, points.size()));
             } else {
                 return new ArrayList<mxPoint>();
             }
@@ -152,15 +150,11 @@ public abstract class BasicLink extends ScilabGraphUniqueObject {
             return 0;
         }
 
-        double startX = (getSource().getParent().getGeometry().getX() + getSource()
-                         .getGeometry().getX());
-        double startY = (getSource().getParent().getGeometry().getY() + getSource()
-                         .getGeometry().getY());
+        double startX = (getSource().getParent().getGeometry().getX() + getSource().getGeometry().getX());
+        double startY = (getSource().getParent().getGeometry().getY() + getSource().getGeometry().getY());
 
-        double endX = (getTarget().getParent().getGeometry().getX() + getTarget()
-                       .getGeometry().getX());
-        double endY = (getTarget().getParent().getGeometry().getY() + getTarget()
-                       .getGeometry().getY());
+        double endX = (getTarget().getParent().getGeometry().getX() + getTarget().getGeometry().getX());
+        double endY = (getTarget().getParent().getGeometry().getY() + getTarget().getGeometry().getY());
 
         double saveDist = -1;
         int findPos = 0;
@@ -172,21 +166,16 @@ public abstract class BasicLink extends ScilabGraphUniqueObject {
             if (i == 0) { // first block
                 point1 = new Point2D.Double(startX, startY);
             } else {
-                point1 = new Point2D.Double(
-                    (int) (getGeometry().getPoints().get(i - 1)).getX(),
-                    (int) (getGeometry().getPoints().get(i - 1)).getY());
+                point1 = new Point2D.Double((int) (getGeometry().getPoints().get(i - 1)).getX(), (int) (getGeometry().getPoints().get(i - 1)).getY());
             }
 
             if (i == getGeometry().getPoints().size()) {
                 point2 = new Point2D.Double(endX, endY);
             } else {
-                point2 = new Point2D.Double(
-                    (int) (getGeometry().getPoints().get(i)).getX(),
-                    (int) (getGeometry().getPoints().get(i)).getY());
+                point2 = new Point2D.Double((int) (getGeometry().getPoints().get(i)).getX(), (int) (getGeometry().getPoints().get(i)).getY());
             }
 
-            Point2D.Double addPoint = new Point2D.Double(point.getX(),
-                    point.getY());
+            Point2D.Double addPoint = new Point2D.Double(point.getX(), point.getY());
             Line2D.Double line = new Line2D.Double(point1, point2);
 
             if (saveDist == -1) {
@@ -246,11 +235,8 @@ public abstract class BasicLink extends ScilabGraphUniqueObject {
             // check to delete an old point before try to insert
             for (int i = 0; i < getGeometry().getPoints().size(); i++) {
                 mxPoint oldPoint = getGeometry().getPoints().get(i);
-                mxRectangle rect = new mxRectangle(oldPoint.getX()
-                                                   - (DETECTION_RECTANGLE_DIMENSION / 2), oldPoint.getY()
-                                                   - (DETECTION_RECTANGLE_DIMENSION / 2),
-                                                   DETECTION_RECTANGLE_DIMENSION,
-                                                   DETECTION_RECTANGLE_DIMENSION);
+                mxRectangle rect = new mxRectangle(oldPoint.getX() - (DETECTION_RECTANGLE_DIMENSION / 2),
+                                                   oldPoint.getY() - (DETECTION_RECTANGLE_DIMENSION / 2), DETECTION_RECTANGLE_DIMENSION, DETECTION_RECTANGLE_DIMENSION);
                 if (rect.contains(point.getX(), point.getY())) {
                     getGeometry().getPoints().remove(i);
                     return;
@@ -265,8 +251,7 @@ public abstract class BasicLink extends ScilabGraphUniqueObject {
     /** @return True if the link is on the same block, false otherwise */
     private boolean isLoopLink() {
         if (getSource() != null && getTarget() != null) {
-            if (getSource().getParent() == getParent()
-                    && getTarget().getParent() == getParent()) {
+            if (getSource().getParent() == getParent() && getTarget().getParent() == getParent()) {
                 return true;
             }
         }
@@ -304,9 +289,8 @@ public abstract class BasicLink extends ScilabGraphUniqueObject {
 
         menu.add(linkStyle);
 
-        ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation(
-            MouseInfo.getPointerInfo().getLocation().x, MouseInfo
-            .getPointerInfo().getLocation().y);
+        ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()).setLocation(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo()
+                .getLocation().y);
 
         menu.setVisible(true);
     }
index fe59342..223db07 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET
+ * Copyright (C) 2012 - Scilab Enterprises - Clement DAVID
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
@@ -30,19 +30,25 @@ public class XcosConfiguration implements XConfigurationListener {
      */
     @Override
     public void configurationChanged(XConfigurationEvent e) {
-        Conf conf = new Conf(e.getModifiedPaths());
-        if (conf.changed()) {
-            XcosOptions.invalidate(conf);
-            // Xcos.configurationChanged(conf);
+        final Options options = new Options(e.getModifiedPaths());
+        if (options.changed()) {
+            XcosOptions.invalidate(options);
+        }
+
+        final KeyMap keymap = new KeyMap(e.getModifiedPaths());
+        if (keymap.changed()) {
+            XcosKeyMap.invalidate(keymap);
+
+            XcosKeyMap.updateActionKeys();
         }
     }
 
-    public static class Conf {
+    protected static class Options {
         public boolean preferences;
         public boolean edition;
         public boolean simulation;
 
-        public Conf(Set<String> path) {
+        public Options(Set<String> path) {
             if (path.contains("ALL")) {
                 preferences = true;
                 edition = true;
@@ -58,4 +64,20 @@ public class XcosConfiguration implements XConfigurationListener {
             return preferences || edition || simulation;
         }
     }
+
+    protected static class KeyMap {
+        public boolean keymap;
+
+        public KeyMap(Set<String> path) {
+            if (path.contains("ALL")) {
+                keymap = true;
+            } else {
+                keymap = path.contains(XcosKeyMap.KEYMAP_XPATH);
+            }
+        }
+
+        public boolean changed() {
+            return keymap;
+        }
+    }
 }
diff --git a/scilab/modules/xcos/src/java/org/scilab/modules/xcos/preferences/XcosKeyMap.java b/scilab/modules/xcos/src/java/org/scilab/modules/xcos/preferences/XcosKeyMap.java
new file mode 100644 (file)
index 0000000..cee2e69
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Clement DAVID
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+package org.scilab.modules.xcos.preferences;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+
+import javax.swing.KeyStroke;
+
+import org.scilab.modules.commons.xml.XConfiguration;
+import org.scilab.modules.graph.actions.CopyAction;
+import org.scilab.modules.graph.actions.CutAction;
+import org.scilab.modules.graph.actions.DeleteAction;
+import org.scilab.modules.graph.actions.InvertSelectionAction;
+import org.scilab.modules.graph.actions.PasteAction;
+import org.scilab.modules.graph.actions.RedoAction;
+import org.scilab.modules.graph.actions.SelectAllAction;
+import org.scilab.modules.graph.actions.UndoAction;
+import org.scilab.modules.graph.actions.ZoomInAction;
+import org.scilab.modules.graph.actions.ZoomOutAction;
+import org.scilab.modules.graph.actions.base.DefaultAction;
+import org.scilab.modules.graph.actions.base.GraphActionManager;
+import org.scilab.modules.xcos.actions.AboutXcosAction;
+import org.scilab.modules.xcos.actions.CloseAction;
+import org.scilab.modules.xcos.actions.CompileAction;
+import org.scilab.modules.xcos.actions.DebugLevelAction;
+import org.scilab.modules.xcos.actions.DiagramBackgroundAction;
+import org.scilab.modules.xcos.actions.ExportAction;
+import org.scilab.modules.xcos.actions.FitDiagramToViewAction;
+import org.scilab.modules.xcos.actions.NewDiagramAction;
+import org.scilab.modules.xcos.actions.NormalViewAction;
+import org.scilab.modules.xcos.actions.OpenAction;
+import org.scilab.modules.xcos.actions.OpenInSciAction;
+import org.scilab.modules.xcos.actions.PrintAction;
+import org.scilab.modules.xcos.actions.QuitAction;
+import org.scilab.modules.xcos.actions.SaveAction;
+import org.scilab.modules.xcos.actions.SaveAsAction;
+import org.scilab.modules.xcos.actions.SetContextAction;
+import org.scilab.modules.xcos.actions.SetupAction;
+import org.scilab.modules.xcos.actions.ShowHideShadowAction;
+import org.scilab.modules.xcos.actions.StartAction;
+import org.scilab.modules.xcos.actions.StopAction;
+import org.scilab.modules.xcos.actions.ViewDiagramBrowserAction;
+import org.scilab.modules.xcos.actions.ViewViewportAction;
+import org.scilab.modules.xcos.actions.XcosDemonstrationsAction;
+import org.scilab.modules.xcos.actions.XcosDocumentationAction;
+import org.scilab.modules.xcos.block.actions.BlockDocumentationAction;
+import org.scilab.modules.xcos.block.actions.BlockParametersAction;
+import org.scilab.modules.xcos.block.actions.BorderColorAction;
+import org.scilab.modules.xcos.block.actions.CodeGenerationAction;
+import org.scilab.modules.xcos.block.actions.FilledColorAction;
+import org.scilab.modules.xcos.block.actions.FlipAction;
+import org.scilab.modules.xcos.block.actions.MirrorAction;
+import org.scilab.modules.xcos.block.actions.RegionToSuperblockAction;
+import org.scilab.modules.xcos.block.actions.RotateAction;
+import org.scilab.modules.xcos.block.actions.ViewDetailsAction;
+import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionBottom;
+import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionCenter;
+import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionLeft;
+import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionMiddle;
+import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionRight;
+import org.scilab.modules.xcos.block.actions.alignement.AlignBlockActionTop;
+import org.scilab.modules.xcos.link.actions.StyleHorizontalAction;
+import org.scilab.modules.xcos.link.actions.StyleStraightAction;
+import org.scilab.modules.xcos.link.actions.StyleVerticalAction;
+import org.scilab.modules.xcos.palette.actions.ViewPaletteBrowserAction;
+import org.w3c.dom.Document;
+
+@SuppressWarnings("unchecked")
+public final class XcosKeyMap {
+    protected static final String KEYMAP_XPATH = "//general/shortcuts/body/actions/action-folder[@xconf-uid=\"xcos\"]/action";
+    private static Map<String, KeyStroke> actionKeys;
+
+    private static String[] actionMapKeys;
+    private static Class <? extends DefaultAction > [] actionMapValues;
+
+    private XcosKeyMap() {
+        // private constructor : static class
+    }
+
+    // static constructor to fill the action map key - values
+    static {
+        final TreeMap < String, Class <? extends DefaultAction >> tree = new TreeMap < String, Class <? extends DefaultAction >> ();
+
+        /*
+         * Append
+         */
+        tree.put("xcos-new", NewDiagramAction.class);
+        tree.put("xcos-open", OpenAction.class);
+        tree.put("xcos-open-in-sci", OpenInSciAction.class);
+        tree.put("xcos-save", SaveAction.class);
+        tree.put("xcos-save-as", SaveAsAction.class);
+        tree.put("xcos-export", ExportAction.class);
+        // recent is not handled
+        tree.put("xcos-print", PrintAction.class);
+        tree.put("xcos-close", CloseAction.class);
+        tree.put("xcos-quit", QuitAction.class);
+
+        tree.put("xcos-undo", UndoAction.class);
+        tree.put("xcos-redo", RedoAction.class);
+        tree.put("xcos-cut", CutAction.class);
+        tree.put("xcos-copy", CopyAction.class);
+        tree.put("xcos-paste", PasteAction.class);
+        tree.put("xcos-delete", DeleteAction.class);
+        tree.put("xcos-select-all", SelectAllAction.class);
+        tree.put("xcos-invert-selection", InvertSelectionAction.class);
+        tree.put("xcos-block-parameters", BlockParametersAction.class);
+        tree.put("xcos-region-to-superblock", RegionToSuperblockAction.class);
+
+        tree.put("xcos-zoom-in", ZoomInAction.class);
+        tree.put("xcos-zoom-out", ZoomOutAction.class);
+        tree.put("xcos-fit-diagram", FitDiagramToViewAction.class);
+        tree.put("xcos-zoom-normal", NormalViewAction.class);
+        tree.put("xcos-view-palette", ViewPaletteBrowserAction.class);
+        tree.put("xcos-view-diagram", ViewDiagramBrowserAction.class);
+        tree.put("xcos-view-viewport", ViewViewportAction.class);
+        tree.put("xcos-view-details", ViewDetailsAction.class);
+
+        tree.put("xcos-setup", SetupAction.class);
+        tree.put("xcos-debug-level", DebugLevelAction.class);
+        tree.put("xcos-set-context", SetContextAction.class);
+        tree.put("xcos-compile", CompileAction.class);
+        tree.put("xcos-start", StartAction.class);
+        tree.put("xcos-stop", StopAction.class);
+
+        tree.put("xcos-rotate", RotateAction.class);
+        tree.put("xcos-flip", FlipAction.class);
+        tree.put("xcos-mirror", MirrorAction.class);
+        tree.put("xcos-shadow", ShowHideShadowAction.class);
+        tree.put("xcos-align-left", AlignBlockActionLeft.class);
+        tree.put("xcos-align-center", AlignBlockActionCenter.class);
+        tree.put("xcos-align-right", AlignBlockActionRight.class);
+        tree.put("xcos-align-top", AlignBlockActionTop.class);
+        tree.put("xcos-align-middle", AlignBlockActionMiddle.class);
+        tree.put("xcos-align-bottom", AlignBlockActionBottom.class);
+        tree.put("xcos-border-color", BorderColorAction.class);
+        tree.put("xcos-fill-color", FilledColorAction.class);
+        tree.put("xcos-link-horizontal", StyleHorizontalAction.class);
+        tree.put("xcos-link-straight", StyleStraightAction.class);
+        tree.put("xcos-fill-vertical", StyleVerticalAction.class);
+        tree.put("xcos-background", DiagramBackgroundAction.class);
+        tree.put("xcos-grid", DiagramBackgroundAction.class);
+
+        tree.put("xcos-code-generation", CodeGenerationAction.class);
+
+        tree.put("xcos-help", XcosDocumentationAction.class);
+        tree.put("xcos-help-block", BlockDocumentationAction.class);
+        tree.put("xcos-demo", XcosDemonstrationsAction.class);
+        tree.put("xcos-about", AboutXcosAction.class);
+
+        /*
+         * Copy to the local sorted map
+         */
+        final int len = tree.size();
+        actionMapKeys = tree.keySet().toArray(new String[len]);
+        actionMapValues = tree.values().toArray(new Class[len]);
+    }
+
+    private static Map<String, KeyStroke> getActionKeys() {
+        if (actionKeys == null) {
+            Document doc = XConfiguration.getXConfigurationDocument();
+            actionKeys = XConfiguration.get(doc, "name", String.class, "key", KeyStroke.class, KEYMAP_XPATH);
+
+        }
+
+        return actionKeys;
+    }
+
+    public static void invalidate(XcosConfiguration.KeyMap conf) {
+        if (conf.keymap) {
+            actionKeys = null;
+        }
+    }
+
+    public static void updateActionKeys() {
+        /*
+         * Update all the graph actions after an update
+         */
+        final Map<String, KeyStroke> actions = getActionKeys();
+
+        for (final Entry<String, KeyStroke> it : actions.entrySet()) {
+            final int found = Arrays.binarySearch(actionMapKeys, it.getKey());
+            if (found >= 0) {
+                GraphActionManager.updateActionKeyStroke(actionMapValues[found], it.getValue());
+            }
+        }
+    }
+}
index 1cecd4e..acce4b7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2012 - Scilab Enterprises -Calixte DENIZET
+ * Copyright (C) 2012 - Scilab Enterprises - Clement DAVID
  *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
 
 package org.scilab.modules.xcos.preferences;
 
+import java.awt.Color;
+
 import org.scilab.modules.commons.xml.XConfiguration;
 import org.scilab.modules.commons.xml.XConfiguration.XConfAttribute;
 import org.scilab.modules.xcos.graph.ScicosParameters;
-import org.w3c.dom.Document;
+import org.scilab.modules.xcos.io.XcosFileType;
 
 /**
  * Xcos options
@@ -24,32 +26,101 @@ public class XcosOptions {
     protected static final String PREFERENCES_XPATH = "//xcos/body/xcos-preferences";
     protected static final String EDITION_XPATH = "//xcos/edition/body/xcos-edition";
     protected static final String SIMULATION_XPATH = "//xcos/simulation/body/xcos-simulation";
-    protected static final String KEYMAP_XPATH = "//general/shortcuts/body/actions/action-folder[@xconf-uid=\"xcos\"]/action";
 
     private static XcosOptions.Preferences preferences;
     private static XcosOptions.Edition edition;
     private static XcosOptions.Simulation simulation;
 
-    private static Document doc;
-
-    @XConfAttribute
     public static class Preferences {
+        private int numberOfRecentlyOpen = 5;
+        private XcosFileType fileFormat = XcosFileType.ZCOS;
+
         private Preferences() {
         }
 
-        @XConfAttribute(tag = "xcos-preferences", attributes = {})
-        private void set() {
+        /*
+         * Preference accessors
+         */
+
+        public void setNumberOfRecentlyOpen(int numberOfRecentlyOpen) {
+            this.numberOfRecentlyOpen = numberOfRecentlyOpen;
+        }
+
+        public void setFileFormat(final int fileFormat) {
+            this.fileFormat = XcosFileType.values()[fileFormat];
+        }
+
+        /*
+         * Implementation accessors
+         */
+
+        public int getNumberOfRecentlyOpen() {
+            return numberOfRecentlyOpen;
+        }
+
+        public XcosFileType getFileFormat() {
+            return fileFormat;
         }
     }
 
-    @XConfAttribute
     public static class Edition {
+        private String edgeStyle = "";
+        private Color graphBackground;
+
+        private boolean graphGridEnable = true;
+        private int graphGrid = 10;
 
         private Edition() {
         }
 
-        @XConfAttribute(tag = "xcos-edition", attributes = {})
-        private void set() {
+        /*
+         * Preference accessors
+         */
+
+        public void setEdgeStyle(final int edgeStyle) {
+            switch (edgeStyle) {
+                case 0: // straight
+                    this.edgeStyle = "";
+                    break;
+                case 1: // horizontal
+                    this.edgeStyle = ";noEdgeStyle=0;edgeStyle=elbowEdgeStyle;elbow=horizontal";
+                    break;
+                case 2: // vertical
+                    this.edgeStyle = ";noEdgeStyle=0;edgeStyle=elbowEdgeStyle;elbow=vertical";
+                    break;
+            }
+        }
+
+        public void setGraphBackground(Color graphBackground) {
+            this.graphBackground = graphBackground;
+        }
+
+        public void setGraphGridEnable(boolean graphGridEnable) {
+            this.graphGridEnable = graphGridEnable;
+        }
+
+        public void setGraphGrid(int graphGrid) {
+            this.graphGrid = graphGrid;
+        }
+
+        /*
+         * Implementation accessors
+         */
+
+        public String getEdgeStyle() {
+            return edgeStyle;
+        }
+
+        public Color getGraphBackground() {
+            return graphBackground;
+        }
+
+        public boolean isGraphGridEnable() {
+            return graphGridEnable;
+        }
+
+        public int getGraphGrid() {
+            return graphGrid;
         }
     }
 
@@ -71,33 +142,28 @@ public class XcosOptions {
             ScicosParameters.INTEGRATOR_RELATIVE_TOLERANCE = Double.parseDouble(integratorRelativeTolerance);
             ScicosParameters.TOLERANCE_ON_TIME = Double.parseDouble(toleranceOnTime);
             ScicosParameters.MAX_INTEGRATION_TIME_INTERVAL = Double.parseDouble(maxIntegrationTimeInterval);
+            ScicosParameters.REAL_TIME_SCALING = Double.parseDouble(realTimeScaling);
             ScicosParameters.SOLVER = solver;
             ScicosParameters.MAXIMUM_STEP_SIZE = Double.parseDouble(maximumStepSize);
             ScicosParameters.DEBUG_LEVEL = debugLevel;
         }
     }
 
-    public static void invalidate(XcosConfiguration.Conf conf) {
+    public static void invalidate(XcosConfiguration.Options conf) {
         if (conf.preferences) {
             preferences = null;
-            doc = null;
         }
         if (conf.edition) {
             edition = null;
-            doc = null;
         }
         if (conf.simulation) {
             simulation = null;
-            doc = null;
         }
     }
 
     public static final XcosOptions.Preferences getPreferences() {
         if (preferences == null) {
-            if (doc == null) {
-                doc = XConfiguration.getXConfigurationDocument();
-            }
-            preferences = XConfiguration.get(XcosOptions.Preferences.class, doc, PREFERENCES_XPATH)[0];
+            preferences = XConfiguration.get(XcosOptions.Preferences.class, XConfiguration.getXConfigurationDocument(), PREFERENCES_XPATH)[0];
         }
 
         return preferences;
@@ -105,10 +171,7 @@ public class XcosOptions {
 
     public static final XcosOptions.Edition getEdition() {
         if (edition == null) {
-            if (doc == null) {
-                doc = XConfiguration.getXConfigurationDocument();
-            }
-            edition = XConfiguration.get(XcosOptions.Edition.class, doc, EDITION_XPATH)[0];
+            edition = XConfiguration.get(XcosOptions.Edition.class, XConfiguration.getXConfigurationDocument(), EDITION_XPATH)[0];
         }
 
         return edition;
@@ -116,10 +179,7 @@ public class XcosOptions {
 
     public static final XcosOptions.Simulation getSimulation() {
         if (simulation == null) {
-            if (doc == null) {
-                doc = XConfiguration.getXConfigurationDocument();
-            }
-            simulation = XConfiguration.get(XcosOptions.Simulation.class, doc, SIMULATION_XPATH)[0];
+            simulation = XConfiguration.get(XcosOptions.Simulation.class, XConfiguration.getXConfigurationDocument(), SIMULATION_XPATH)[0];
         }
 
         return simulation;