[hg] main-silver: #222929: seems that the whole editable combo m...

  • From: Jan Lahoda < >
  • To:
  • Subject: [hg] main-silver: #222929: seems that the whole editable combo m...
  • Date: Mon, 03 Dec 2012 04:40:35 -0800

changeset 3c46a995443a in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/3c46a995443a
description:
        #222929: seems that the whole editable combo might receive focus lost 
before (or instead?) of focus lost of its editor - need to finish the editing 
even in such a case.

diffstat:

 
code.analysis/src/org/netbeans/modules/analysis/ui/AdjustConfigurationPanel.java
 |   7 +++-
 
code.analysis/src/org/netbeans/modules/analysis/ui/ConfigurationsComboModel.java
 |  19 +++++++--
 2 files changed, 21 insertions(+), 5 deletions(-)

diffs (115 lines):

diff --git 
a/code.analysis/src/org/netbeans/modules/analysis/ui/AdjustConfigurationPanel.java
 
b/code.analysis/src/org/netbeans/modules/analysis/ui/AdjustConfigurationPanel.java
--- 
a/code.analysis/src/org/netbeans/modules/analysis/ui/AdjustConfigurationPanel.java
+++ 
b/code.analysis/src/org/netbeans/modules/analysis/ui/AdjustConfigurationPanel.java
@@ -45,6 +45,7 @@
 import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.util.EventObject;
 import java.util.HashMap;
 import java.util.IdentityHashMap;
 import java.util.Map;
@@ -88,12 +89,16 @@
         initComponents();
 
         if (preselected == null) {
-            configurationCombo.setModel(new ConfigurationsComboModel(true));
+            final ConfigurationsComboModel model = new 
ConfigurationsComboModel(true);
+            configurationCombo.setModel(model);
             configurationCombo.setRenderer(new ConfigurationRenderer(false));
             configurationCombo.addActionListener(new ActionListener() {
                 @Override public void actionPerformed(ActionEvent e) {
                     if (configurationCombo.getSelectedItem() instanceof 
ActionListener) {
                         ((ActionListener) 
configurationCombo.getSelectedItem()).actionPerformed(e);
+                    } else if (configurationCombo.getSelectedItem() 
instanceof String) {
+                        assert model.currentActiveItem != null;
+                        model.currentActiveItem.confirm(new 
EventObject(configurationCombo.getEditor().getEditorComponent()));
                     } else {
                         updateConfiguration();
                     }
diff --git 
a/code.analysis/src/org/netbeans/modules/analysis/ui/ConfigurationsComboModel.java
 
b/code.analysis/src/org/netbeans/modules/analysis/ui/ConfigurationsComboModel.java
--- 
a/code.analysis/src/org/netbeans/modules/analysis/ui/ConfigurationsComboModel.java
+++ 
b/code.analysis/src/org/netbeans/modules/analysis/ui/ConfigurationsComboModel.java
@@ -84,6 +84,7 @@
     private Object selected;
     private Configuration lastSelected;
     private boolean canModify;
+            Confirmable currentActiveItem;
 
     public ConfigurationsComboModel(boolean canModify) {
         selected = getSize() == 0 ? null :getElementAt(0);
@@ -140,7 +141,7 @@
         fireContentsChanged(this, -1, -1);
     }
 
-    private class New implements ActionListener, FocusListener, KeyListener, 
PopupMenuListener {
+    private class New implements ActionListener, FocusListener, KeyListener, 
PopupMenuListener, Confirmable {
 
         private final String actionName;
         private final String configName;
@@ -152,6 +153,8 @@
 
         @Override
         public void actionPerformed(ActionEvent ae) {
+            currentActiveItem = this;
+            
             JComboBox combo = (JComboBox) ae.getSource();
             combo.setEditable(true);
             combo.getEditor().getEditorComponent().addFocusListener(this);
@@ -174,7 +177,7 @@
             confirm(fe);
         }
 
-        private void confirm(EventObject fe) {
+        public void confirm(EventObject fe) {
             JTextField tf = (JTextField) fe.getSource();
             JComboBox combo = (JComboBox) tf.getParent();
             if (combo==null)
@@ -189,6 +192,7 @@
                     ConfigurationsManager.getDefault().create(tf.getText(), 
tf.getText());
             combo.setSelectedItem(config);
             combo.setEditable(false);
+            currentActiveItem = null;
         }
 
         @Override
@@ -222,10 +226,12 @@
         }
     }
 
-    private class Rename implements ActionListener, FocusListener, 
KeyListener, PopupMenuListener {
+    private class Rename implements ActionListener, FocusListener, 
KeyListener, PopupMenuListener, Confirmable {
 
         @Override
         public void actionPerformed(ActionEvent ae) {
+            currentActiveItem = this;
+            
             JComboBox combo = (JComboBox) ae.getSource();
             combo.setEditable(true);
             JTextField editorComponent = (JTextField) 
combo.getEditor().getEditorComponent();
@@ -249,7 +255,7 @@
             confirm(fe);
         }
 
-        private void confirm(EventObject fe) {
+        public void confirm(EventObject fe) {
             JTextField tf = (JTextField) fe.getSource();
             JComboBox combo = (JComboBox) tf.getParent();
             if (combo==null)
@@ -263,6 +269,7 @@
             config.setDisplayName(tf.getText());
             combo.setSelectedItem(config);
             combo.setEditable(false);
+            currentActiveItem = null;
         }
 
         @Override
@@ -321,4 +328,8 @@
             return Bundle.CTL_Delete();
         }
     }
+    
+    interface Confirmable {
+        public void confirm(EventObject fe);
 }
+}

[hg] main-silver: #222929: seems that the whole editable combo m...

Jan Lahoda 12/03/2012

Project Features

About this Project

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