cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r823096 [2/2] - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/project/ cayenne-modeler/.settings/ cayenne-modeler/src/main/java...
Date Thu, 08 Oct 2009 09:04:52 GMT
Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjAttributeTableModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjAttributeTableModel.java?rev=823096&r1=823095&r2=823096&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjAttributeTableModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjAttributeTableModel.java
Thu Oct  8 09:04:49 2009
@@ -19,19 +19,12 @@
 
 package org.apache.cayenne.modeler.editor;
 
-import java.awt.Component;
-import java.awt.event.MouseEvent;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.EventObject;
-import java.util.Hashtable;
 import javax.swing.DefaultCellEditor;
 import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.event.CellEditorListener;
-import javax.swing.table.TableCellEditor;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DbAttribute;
@@ -45,6 +38,7 @@
 import org.apache.cayenne.modeler.util.CayenneTable;
 import org.apache.cayenne.modeler.util.CayenneTableModel;
 import org.apache.cayenne.modeler.util.CayenneWidgetFactory;
+import org.apache.cayenne.modeler.util.CellEditorForAttributeTable;
 import org.apache.cayenne.modeler.util.ModelerUtil;
 import org.apache.cayenne.modeler.util.ProjectUtil;
 import org.apache.cayenne.util.Util;
@@ -67,7 +61,7 @@
 
     protected ObjEntity entity;
     protected DbEntity dbEntity;
-    private CellEditor cellEditor;
+    private CellEditorForAttributeTable cellEditor;
     private CayenneTable table;
 
     public ObjAttributeTableModel(ObjEntity entity, ProjectController mediator,
@@ -84,6 +78,11 @@
     protected void orderList() {
         // NOOP
     }
+    
+    
+    public CayenneTable getTable() {
+        return table;
+    }
 
     public Class getColumnClass(int col) {
         switch (col) {
@@ -221,15 +220,15 @@
         }
     }
 
-    public CellEditor setCellEditor(Collection<String> nameAttr, CayenneTable table)
{
-        this.cellEditor = new CellEditor(table, CayenneWidgetFactory.createComboBox(
+    public CellEditorForAttributeTable setCellEditor(Collection<String> nameAttr, CayenneTable
table) {
+        this.cellEditor = new CellEditorForAttributeTable(table, CayenneWidgetFactory.createComboBox(
                 nameAttr,
                 true));
         this.table = table;
         return cellEditor;
     }
 
-    public CellEditor getCellEditor() {
+    public CellEditorForAttributeTable getCellEditor() {
         return cellEditor;
     }
 
@@ -384,85 +383,4 @@
         }
     }
 
-    final class CellEditor implements TableCellEditor {
-
-        protected Hashtable editors;
-        protected TableCellEditor editor, defaultEditor;
-        JTable table;
-
-        public CellEditor(JTable table, JComboBox combo) {
-            this.table = table;
-            editors = new Hashtable();
-            if (combo != null) {
-                defaultEditor = new DefaultCellEditor(combo);
-            }
-            else {
-                defaultEditor = new DefaultCellEditor(new JComboBox());
-            }
-        }
-
-        public void setEditorAt(int row, TableCellEditor editor) {
-            editors.put(new Integer(row), editor);
-        }
-
-        public Component getTableCellEditorComponent(
-                JTable table,
-                Object value,
-                boolean isSelected,
-                int row,
-                int column) {
-
-            return editor.getTableCellEditorComponent(
-                    table,
-                    value,
-                    isSelected,
-                    row,
-                    column);
-        }
-
-        public Object getCellEditorValue() {
-            return editor.getCellEditorValue();
-        }
-
-        public boolean stopCellEditing() {
-            return editor.stopCellEditing();
-        }
-
-        public void cancelCellEditing() {
-            editor.cancelCellEditing();
-        }
-
-        public boolean isCellEditable(EventObject anEvent) {
-            selectEditor((MouseEvent) anEvent);
-            return editor.isCellEditable(anEvent);
-        }
-
-        public void addCellEditorListener(CellEditorListener l) {
-            editor.addCellEditorListener(l);
-        }
-
-        public void removeCellEditorListener(CellEditorListener l) {
-            editor.removeCellEditorListener(l);
-        }
-
-        public boolean shouldSelectCell(EventObject anEvent) {
-            selectEditor((MouseEvent) anEvent);
-            return editor.shouldSelectCell(anEvent);
-        }
-
-        protected void selectEditor(MouseEvent e) {
-            int row;
-            if (e == null) {
-                row = table.getSelectionModel().getAnchorSelectionIndex();
-            }
-            else {
-                row = table.rowAtPoint(e.getPoint());
-            }
-            editor = (TableCellEditor) editors.get(new Integer(row));
-            if (editor == null) {
-                editor = defaultEditor;
-            }
-        }
-    }
-
 }

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellEditorForAttributeTable.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellEditorForAttributeTable.java?rev=823096&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellEditorForAttributeTable.java
(added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellEditorForAttributeTable.java
Thu Oct  8 09:04:49 2009
@@ -0,0 +1,114 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.modeler.util;
+
+import java.awt.Component;
+import java.awt.event.MouseEvent;
+import java.util.EventObject;
+import java.util.Hashtable;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.event.CellEditorListener;
+import javax.swing.table.TableCellEditor;
+
+
+public class CellEditorForAttributeTable implements TableCellEditor {
+
+        protected Hashtable editors;
+        protected TableCellEditor editor, defaultEditor;
+        JTable table;
+
+        public CellEditorForAttributeTable(JTable table, JComboBox combo) {
+            this.table = table;
+            editors = new Hashtable();
+            if (combo != null) {
+                defaultEditor = new DefaultCellEditor(combo);
+            }
+            else {
+                defaultEditor = new DefaultCellEditor(new JComboBox());
+            }
+        }
+
+        public void setEditorAt(int row, TableCellEditor editor) {
+            editors.put(new Integer(row), editor);
+        }
+
+        public Component getTableCellEditorComponent(
+                JTable table,
+                Object value,
+                boolean isSelected,
+                int row,
+                int column) {
+
+            return editor.getTableCellEditorComponent(
+                    table,
+                    value,
+                    isSelected,
+                    row,
+                    column);
+        }
+
+        public Object getCellEditorValue() {
+            return editor.getCellEditorValue();
+        }
+
+        public boolean stopCellEditing() {
+            return editor.stopCellEditing();
+        }
+
+        public void cancelCellEditing() {
+            editor.cancelCellEditing();
+        }
+
+        public boolean isCellEditable(EventObject anEvent) {
+            selectEditor((MouseEvent) anEvent);
+            return editor.isCellEditable(anEvent);
+        }
+
+        public void addCellEditorListener(CellEditorListener l) {
+            editor.addCellEditorListener(l);
+        }
+
+        public void removeCellEditorListener(CellEditorListener l) {
+            editor.removeCellEditorListener(l);
+        }
+
+        public boolean shouldSelectCell(EventObject anEvent) {
+            selectEditor((MouseEvent) anEvent);
+            return editor.shouldSelectCell(anEvent);
+        }
+
+        protected void selectEditor(MouseEvent e) {
+            int row;
+            if (e == null) {
+                row = table.getSelectionModel().getAnchorSelectionIndex();
+            }
+            else {
+                row = table.rowAtPoint(e.getPoint());
+            }
+            editor = (TableCellEditor) editors.get(new Integer(row));
+            if (editor == null) {
+                editor = defaultEditor;
+            }
+        }
+    
+
+}

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/Comparators.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/Comparators.java?rev=823096&r1=823095&r2=823096&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/Comparators.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/Comparators.java
Thu Oct  8 09:04:49 2009
@@ -25,6 +25,7 @@
 import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.Embeddable;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.Procedure;
@@ -146,15 +147,18 @@
             else if (o instanceof ObjEntity) {
                 return 2;
             }
-            else if (o instanceof DbEntity) {
+            else if (o instanceof Embeddable) {
                 return 3;
             }
-            else if (o instanceof Procedure) {
+            else if (o instanceof DbEntity) {
                 return 4;
             }
-            else if (o instanceof Query) {
+            else if (o instanceof Procedure) {
                 return 5;
             }
+            else if (o instanceof Query) {
+                return 6;
+            }
             else {
                 // this should trap nulls among other things
                 return Integer.MAX_VALUE;



Mime
View raw message