[hg] main-silver: #184422 Fixing synchronization

  • From: Milutin Kristofic < >
  • To:
  • Subject: [hg] main-silver: #184422 Fixing synchronization
  • Date: Fri, 26 Apr 2013 11:11:22 -0700

changeset cada3b255526 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/cada3b255526
description:
        #184422 Fixing synchronization

diffstat:

 
options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.form
 |   1 +
 
options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java
 |  67 +++++----
 2 files changed, 37 insertions(+), 31 deletions(-)

diffs (124 lines):

diff --git 
a/options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.form
 
b/options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.form
--- 
a/options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.form
+++ 
b/options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.form
@@ -124,6 +124,7 @@
       </Properties>
       <AuxValues>
         <AuxValue name="JavaCodeGenerator_TypeParameters" 
type="java.lang.String" value="&lt;String&gt;"/>
+        <AuxValue name="JavaCodeGenerator_VariableModifier" 
type="java.lang.Integer" value="18"/>
       </AuxValues>
     </Component>
     <Component class="javax.swing.JLabel" name="lCategory">
diff --git 
a/options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java
 
b/options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java
--- 
a/options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java
+++ 
b/options.editor/src/org/netbeans/modules/options/colors/SyntaxColoringPanel.java
@@ -202,7 +202,6 @@
     private void initComponents() {
 
         lLanguage = new javax.swing.JLabel();
-        cbLanguage = new javax.swing.JComboBox<String>();
         lCategory = new javax.swing.JLabel();
         spCategories = new javax.swing.JScrollPane();
         lCategories = new javax.swing.JList<AttributeSet>();
@@ -340,7 +339,7 @@
     private javax.swing.JComboBox cbEffectColor;
     private javax.swing.JComboBox<String> cbEffects;
     private javax.swing.JComboBox cbForeground;
-    private javax.swing.JComboBox<String> cbLanguage;
+    private final javax.swing.JComboBox<String> cbLanguage = new 
javax.swing.JComboBox<String>();
     private javax.swing.JLabel lBackground;
     private javax.swing.JList<AttributeSet> lCategories;
     private javax.swing.JLabel lCategory;
@@ -367,7 +366,9 @@
             updateData ();
        } else
        if (evt.getSource () == cbLanguage) {
+            synchronized(cbLanguage) {
            setCurrentLanguage ((String) cbLanguage.getSelectedItem ());
+            }
        } else
         if (evt.getSource () == bFont) {
             PropertyEditor pe = PropertyEditorManager.findEditor 
(Font.class);
@@ -446,6 +447,35 @@
             }
         }
     }
+    private final Task updatecbLanguage = new 
RequestProcessor("SyntaxColoringPanel2").create(new Runnable() {
+
+        @Override
+        public void run() {
+            final List<String> languages = new 
ArrayList<String>(colorModel.getLanguages());
+            EventQueue.invokeLater(new Runnable() {
+
+                @Override
+                public void run() {
+                    languages.remove("text/x-all-languages");
+                    Collections.sort(languages, new LanguagesComparator());
+                    Iterator<String> it = languages.iterator();
+                    synchronized (cbLanguage) {
+                        Object lastLanguage = cbLanguage.getSelectedItem();
+                        cbLanguage.removeAllItems();
+                        while (it.hasNext()) {
+                            cbLanguage.addItem(it.next());
+                        }
+                        listen = true;
+                        if (lastLanguage != null) {
+                            cbLanguage.setSelectedItem(lastLanguage);
+                        } else {
+                            cbLanguage.setSelectedIndex(0);
+                        }
+                    }
+                }
+            });
+        }
+    });
     
     @Override
     public void update (final ColorModel colorModel) {
@@ -463,35 +493,7 @@
         preview.addPropertyChangeListener 
             (Preview.PROP_CURRENT_ELEMENT, this);
         listen = false;
-        Task update = new 
RequestProcessor("SyntaxColoringPanel2").create(new Runnable() {
-            
-            @Override
-            public void run() {
-                final List<String> languages = new 
ArrayList<String>(colorModel.getLanguages());
-                EventQueue.invokeLater(new Runnable() {
-
-                    @Override
-                    public void run() {
-                        languages.remove("text/x-all-languages");
-                        Collections.sort(languages, new 
LanguagesComparator());
-                        Iterator<String> it = languages.iterator();
-                        Object lastLanguage = cbLanguage.getSelectedItem();
-                        cbLanguage.removeAllItems();
-                        while (it.hasNext()) {
-                            cbLanguage.addItem(it.next());
-                        }
-                        listen = true;
-                        if (lastLanguage != null) {
-                            cbLanguage.setSelectedItem(lastLanguage);
-                        } else {
-                            cbLanguage.setSelectedIndex(0);
-                        }
-                    }
-                });
-            }
-        });
-
-        update.schedule(20);
+        updatecbLanguage.schedule(20);
     }
     
     @Override
@@ -589,6 +591,9 @@
     }
     
     private void setCurrentLanguage (String language) {
+        if (language == null) {
+            return;
+        }
        currentLanguage = language;
         
         // setup categories list

[hg] main-silver: #184422 Fixing synchronization

Milutin Kristofic 04/26/2013

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 148 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close