SciNotes: auto-completion on keywords or openers was not correctly activated 49/13949/2
Calixte DENIZET [Fri, 7 Mar 2014 10:27:06 +0000 (11:27 +0100)]
Change-Id: I12006f818c836d341143df6755cc9548dcea41dc

scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/HelpOnTypingManager.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/ScilabEditorPane.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/ActivateHelpOnTypingForKeywordsAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/ActivateHelpOnTypingForOpenersAction.java

index b25127f..45e94dc 100644 (file)
@@ -26,8 +26,8 @@ import org.scilab.modules.commons.xml.XConfiguration;
 public final class HelpOnTypingManager implements KeyListener {
 
     private static HelpOnTypingManager instance;
-    private static boolean openers;
-    private static boolean keywords;
+    private boolean openers;
+    private boolean keywords;
 
     /**
      * Constructor
@@ -60,7 +60,7 @@ public final class HelpOnTypingManager implements KeyListener {
     /**
      * @param b true if autocompletion on '(', '{', ...
      */
-    public static void enableOpeners(boolean b) {
+    public void enableOpeners(boolean b) {
         openers = b;
         SciNotesOptions.getSciNotesDisplay().autoCompleteOpeners = b;
         XConfiguration.set(XConfiguration.getXConfigurationDocument(), SciNotesOptions.DISPLAYPATH + "/@auto-complete-openers", Boolean.toString(b));
@@ -69,7 +69,7 @@ public final class HelpOnTypingManager implements KeyListener {
     /**
      * @param b true if autocompletion on 'if', 'function', ...
      */
-    public static void enableKeywords(boolean b) {
+    public void enableKeywords(boolean b) {
         keywords = b;
         SciNotesOptions.getSciNotesDisplay().autoCompleteKeywords = b;
         XConfiguration.set(XConfiguration.getXConfigurationDocument(), SciNotesOptions.DISPLAYPATH + "/@auto-complete-keywords", Boolean.toString(b));
@@ -78,21 +78,21 @@ public final class HelpOnTypingManager implements KeyListener {
     /**
      * @return true if help on typing is active
      */
-    public static boolean isActive() {
+    public boolean isActive() {
         return openers || keywords;
     }
 
     /**
      * @return true if help on typing for the openers is active
      */
-    public static boolean isOpenersActive() {
+    public boolean isOpenersActive() {
         return openers;
     }
 
     /**
      * @return true if help on typing for the openers is active
      */
-    public static boolean isKeywordsActive() {
+    public boolean isKeywordsActive() {
         return keywords;
     }
 
index 4f0ce46..7599b83 100644 (file)
@@ -1101,7 +1101,7 @@ public class ScilabEditorPane extends JEditorPane implements Highlighter.Highlig
      * Activate or desactivate the help on typing
      */
     public void activateHelpOnTyping() {
-        boolean isActive = HelpOnTypingManager.isActive();
+        boolean isActive = HelpOnTypingManager.getInstance().isActive();
         if (isActive && helpOnTyping == null) {
             helpOnTyping = HelpOnTypingManager.getInstance();
             addKeyListener(helpOnTyping);
index c283911..bb05ee2 100644 (file)
@@ -43,7 +43,7 @@ public final class ActivateHelpOnTypingForKeywordsAction extends DefaultCheckAct
      * doAction
      */
     public void doAction() {
-        HelpOnTypingManager.enableKeywords(getState());
+        HelpOnTypingManager.getInstance().enableKeywords(getState());
         SciNotes.activateHelpOnTyping();
     }
 
@@ -56,10 +56,10 @@ public final class ActivateHelpOnTypingForKeywordsAction extends DefaultCheckAct
      */
     public static CheckBoxMenuItem createMenu(String label, SciNotes editor, KeyStroke key) {
         final CheckBoxMenuItem cb = createCheckBoxMenu(label, null, new ActivateHelpOnTypingForKeywordsAction(label, editor), key);
-        cb.setChecked(HelpOnTypingManager.isKeywordsActive());
+        cb.setChecked(HelpOnTypingManager.getInstance().isKeywordsActive());
         ((JCheckBoxMenuItem) cb.getAsSimpleCheckBoxMenuItem()).addPropertyChangeListener(new PropertyChangeListener() {
             public void propertyChange(PropertyChangeEvent e) {
-                cb.setChecked(HelpOnTypingManager.isKeywordsActive());
+                cb.setChecked(HelpOnTypingManager.getInstance().isKeywordsActive());
             }
         });
 
index 3e7a43a..e747cdc 100644 (file)
@@ -43,7 +43,7 @@ public final class ActivateHelpOnTypingForOpenersAction extends DefaultCheckActi
      * doAction
      */
     public void doAction() {
-        HelpOnTypingManager.enableOpeners(getState());
+        HelpOnTypingManager.getInstance().enableOpeners(getState());
         SciNotes.activateHelpOnTyping();
     }
 
@@ -56,10 +56,10 @@ public final class ActivateHelpOnTypingForOpenersAction extends DefaultCheckActi
      */
     public static CheckBoxMenuItem createMenu(String label, SciNotes editor, KeyStroke key) {
         final CheckBoxMenuItem cb = createCheckBoxMenu(label, null, new ActivateHelpOnTypingForOpenersAction(label, editor), key);
-        cb.setChecked(HelpOnTypingManager.isOpenersActive());
+        cb.setChecked(HelpOnTypingManager.getInstance().isOpenersActive());
         ((JCheckBoxMenuItem) cb.getAsSimpleCheckBoxMenuItem()).addPropertyChangeListener(new PropertyChangeListener() {
             public void propertyChange(PropertyChangeEvent e) {
-                cb.setChecked(HelpOnTypingManager.isOpenersActive());
+                cb.setChecked(HelpOnTypingManager.getInstance().isOpenersActive());
             }
         });