cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r693000 - /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/ComboBoxCellEditor.java
Date Mon, 08 Sep 2008 07:13:18 GMT
Author: aadamchik
Date: Mon Sep  8 00:13:17 2008
New Revision: 693000

URL: http://svn.apache.org/viewvc?rev=693000&view=rev
Log:
CAY-1104 Modeler misses new renamed attributes, relationship mappings
(patch 2 by Andrey Razumovskiy)

Modified:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/ComboBoxCellEditor.java

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/ComboBoxCellEditor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/ComboBoxCellEditor.java?rev=693000&r1=692999&r2=693000&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/ComboBoxCellEditor.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/combo/ComboBoxCellEditor.java
Mon Sep  8 00:13:17 2008
@@ -22,6 +22,8 @@
 import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
 import java.awt.event.MouseEvent;
 import java.io.Serializable;
 import java.util.EventObject;
@@ -38,7 +40,9 @@
  *
  * @author Andrey Razumovsky
  */
-public class ComboBoxCellEditor extends AbstractCellEditor implements ActionListener, TableCellEditor,
Serializable {
+public class ComboBoxCellEditor extends AbstractCellEditor 
+    implements ActionListener, TableCellEditor, FocusListener, Serializable {
+    
     static final String IS_TABLE_CELL_EDITOR_PROPERTY = "JComboBox.isTableCellEditor";
     
     private final JComboBox comboBox;
@@ -49,6 +53,10 @@
 
         // hitting enter in the combo box should stop cellediting (see below)
         this.comboBox.addActionListener(this);
+        
+        //  Editing should be stopped when textfield loses its focus
+        //  otherwise the value may get lost (e.g. see CAY-1104)
+        this.comboBox.getEditor().getEditorComponent().addFocusListener(this);
 
         // remove the editor's border - the cell itself already has one
         ((JComponent) comboBox.getEditor().getEditorComponent()).setBorder(null);
@@ -100,4 +108,13 @@
         
         return true;
     }
+
+    public void focusGained(FocusEvent e) {
+    }
+
+    public void focusLost(FocusEvent e) {
+        if (e.getOppositeComponent() != null) {
+            stopCellEditing();
+        }
+    }
 }



Mime
View raw message