cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r583393 - in /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler: ./ action/ dialog/ editor/ event/
Date Wed, 10 Oct 2007 09:05:16 GMT
Author: aadamchik
Date: Wed Oct 10 02:05:15 2007
New Revision: 583393

URL: http://svn.apache.org/viewvc?rev=583393&view=rev
Log:
CAY-869 CayenneModeler free-text search
this patch fixes the last few issues with the search

Modified:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialogView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTabbedView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EntityDisplayEvent.java

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java?rev=583393&r1=583392&r2=583393&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
Wed Oct 10 02:05:15 2007
@@ -25,6 +25,7 @@
 import java.awt.event.AWTEventListener;
 
 import javax.swing.*;
+import javax.swing.border.Border;
 
 import org.apache.cayenne.map.DerivedDbEntity;
 import org.apache.cayenne.modeler.action.AboutAction;
@@ -215,16 +216,11 @@
         toolBar.add(getAction(NavigateBackwardAction.getActionName()).buildButton());
         toolBar.add(getAction(NavigateForwardAction.getActionName()).buildButton());
 
-        toolBar.addSeparator();
-
-        JPanel east = new JPanel();
+        JPanel east = new JPanel(new BorderLayout());   // is used to place search feature
components the most right on a toolbar  
         final JTextField findField = new JTextField(10);
         findField.setAction(getAction(FindAction.getActionName()));
         JLabel findLabel = new JLabel("Search:");
         findLabel.setLabelFor(findField);
-        east.add(findLabel);
-        east.add(findField);
-        toolBar.add(east, BorderLayout.EAST);
         Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
             public void eventDispatched(AWTEvent event) {
                 if (event instanceof KeyEvent) {
@@ -234,6 +230,12 @@
                 }
             }
         }, AWTEvent.KEY_EVENT_MASK);
+        JPanel box = new JPanel();  // is used to place label and text field one after another
+        box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
+        box.add(findLabel);
+        box.add(findField);
+        east.add(box, BorderLayout.EAST);
+        toolBar.add(east);
 
         getContentPane().add(toolBar, BorderLayout.NORTH);
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java?rev=583393&r1=583392&r2=583393&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
Wed Oct 10 02:05:15 2007
@@ -765,6 +765,8 @@
                     (DataDomain) data[data.length - 3]);
             mediator.fireQueryDisplayEvent(e);
         }
+
+        this.scrollPathToVisible(path);
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java?rev=583393&r1=583392&r2=583393&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
Wed Oct 10 02:05:15 2007
@@ -18,23 +18,20 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.action;
 
-import java.awt.event.ActionEvent;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.swing.JTextField;
-
-import org.apache.cayenne.map.Attribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.Entity;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.Relationship;
+import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.dialog.FindDialog;
-import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.ProjectPath;
+import org.apache.cayenne.map.*;
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.*;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
 
 public class FindAction extends CayenneAction {
     private java.util.List paths;
@@ -63,7 +60,7 @@
                 ProjectPath path = (ProjectPath) it.next();
 
                 Object o = path.getObject();
-                if (o instanceof Entity && matchFound(((Entity) o).getName(), pattern))
+                if ((o instanceof ObjEntity || o instanceof DbEntity) && matchFound(((Entity)
o).getName(), pattern))
                     paths.add(path.getPath());
                 else if (o instanceof Attribute && matchFound(((Attribute) o).getName(),
pattern))
                     paths.add(path.getPath());

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java?rev=583393&r1=583392&r2=583393&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java
Wed Oct 10 02:05:15 2007
@@ -32,6 +32,7 @@
 import org.apache.cayenne.modeler.editor.EditorView;
 import org.apache.cayenne.modeler.event.AttributeDisplayEvent;
 import org.apache.cayenne.modeler.event.RelationshipDisplayEvent;
+import org.apache.cayenne.modeler.event.EntityDisplayEvent;
 import org.apache.cayenne.modeler.util.CayenneController;
 import org.apache.cayenne.access.DataDomain;
 
@@ -84,7 +85,7 @@
         makeCloseableOnEscape();
 
         view.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
-        view.setModal(false);
+        view.setModal(true);
         view.setVisible(true);
     }
 
@@ -94,7 +95,6 @@
 
     protected void initBindings() {
         view.getOkButton().addActionListener(new ActionListener() {
-
             public void actionPerformed(ActionEvent e) {
                 view.dispose();
             }
@@ -111,20 +111,30 @@
         private EditorView editor = ((CayenneModelerFrame) application.getFrameController().getView()).getView();
 
         public void actionPerformed(ActionEvent e) {
-            Object[] path = (Object[]) paths.get(((FindDialogView.EntityButtonModel) ((JButton)
e.getSource()).getModel()).getIndex().intValue());
+            JButton source = (JButton) e.getSource();
 
+            Object[] path = (Object[]) paths.get(((FindDialogView.EntityButtonModel) source.getModel()).getIndex().intValue());
 
-            if(path[path.length - 1] instanceof ObjEntity || path[path.length - 1] instanceof
DbEntity)
-                /**
-                 * Make selection in a project tree, open correspondent entity tab.
-                 */
-                editor.getProjectTreeView().getSelectionModel().addSelectionPath(buildTreePath(path));
+            if(path[path.length - 1] instanceof Entity) {
 
+                /** Make selection in a project tree, open correspondent entity tab */
+                editor.getProjectTreeView().getSelectionModel().addSelectionPath(buildTreePath(path));
+                EntityDisplayEvent event = new EntityDisplayEvent(
+                        editor.getProjectTreeView(),
+                        (Entity) path[path.length - 1],
+                        (DataMap) path[path.length - 2],
+                        (DataDomain) path[path.length - 3]);
+                event.setSearched(true);
+
+                if (path[path.length - 1] instanceof ObjEntity)
+                    editor.getObjDetailView().currentObjEntityChanged(event);
+                if (path[path.length - 1] instanceof DbEntity)
+                    editor.getDbDetailView().currentDbEntityChanged(event);
+            }
 
             if(path[path.length - 1] instanceof Attribute || path[path.length - 1] instanceof
Relationship) {
-                /**
-                 * Make selection in a project tree, open correspondent attributes tab.
-                 */
+
+                /** Make selection in a project tree, open correspondent attributes tab */
                 Object[] o = new Object[path.length - 1];
                 for(int i = 0; i < path.length - 1; i++)
                     o[i] = path[i];
@@ -133,46 +143,49 @@
 
                 if (path[path.length - 1] instanceof DbAttribute) {
                     AttributeDisplayEvent event = new AttributeDisplayEvent(
-                            editor.getDbDetailView(),
+                            editor.getProjectTreeView(),
                             (Attribute) path[path.length - 1],
                             (Entity) path[path.length - 2],
                             (DataMap) path[path.length - 3],
                             (DataDomain) path[path.length - 4]);
-
-                    ((CayenneModelerController) parent).getProjectController().fireDbAttributeDisplayEvent(event);
+                    event.setSearched(true);
+                    editor.getDbDetailView().currentDbAttributeChanged(event);
                 }
 
                 if (path[path.length - 1] instanceof ObjAttribute) {
                     AttributeDisplayEvent event = new AttributeDisplayEvent(
-                            editor.getObjDetailView(),
+                            editor.getProjectTreeView(),
                             (Attribute) path[path.length - 1],
                             (Entity) path[path.length - 2],
                             (DataMap) path[path.length - 3],
                             (DataDomain) path[path.length - 4]);
-                    ((CayenneModelerController) parent).getProjectController().fireObjAttributeDisplayEvent(event);
+                    event.setSearched(true);
+                    editor.getObjDetailView().currentObjAttributeChanged(event);
                 }
 
                 if (path[path.length - 1] instanceof DbRelationship) {
                     RelationshipDisplayEvent event = new RelationshipDisplayEvent(
-                            editor.getDbDetailView(),
+                            editor.getProjectTreeView(),
                             (Relationship) path[path.length - 1],
                             (Entity) path[path.length - 2],
                             (DataMap) path[path.length - 3],
                             (DataDomain) path[path.length - 4]
                     );
-                    ((CayenneModelerController) parent).getProjectController().fireDbRelationshipDisplayEvent(event);
+                    event.setSearched(true);
+                    editor.getDbDetailView().currentDbRelationshipChanged(event);
                 }
             }
 
                 if (path[path.length - 1] instanceof ObjRelationship) {
                     RelationshipDisplayEvent event = new RelationshipDisplayEvent(
-                            editor.getObjDetailView(),
+                            editor.getProjectTreeView(),
                             (Relationship) path[path.length - 1],
                             (Entity) path[path.length - 2],
                             (DataMap) path[path.length - 3],
                             (DataDomain) path[path.length - 4]
                     );
-                    ((CayenneModelerController) parent).getProjectController().fireObjRelationshipDisplayEvent(event);
+                    event.setSearched(true);
+                    editor.getObjDetailView().currentObjRelationshipChanged(event);
                 }
         }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialogView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialogView.java?rev=583393&r1=583392&r2=583393&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialogView.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialogView.java
Wed Oct 10 02:05:15 2007
@@ -55,7 +55,7 @@
         JPanel panel = new JPanel();
         panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
         if (objEntityNames.isEmpty() && dbEntityNames.isEmpty() && attrNames.isEmpty()
&& relatNames.isEmpty()) {
-            panel.add(new JLabel("No matched entities found!"));
+            panel.add(new JLabel("Nothing found!"));
         } else {
             panel.add(createResultPanel(
                     objEntityNames, CellRenderers.iconForObject(new ObjEntity())));
@@ -71,13 +71,13 @@
         okButton = new JButton("OK");
         okPanel.add(okButton);
 
-        JComponent container = (JComponent) getContentPane();
-        container.setLayout(new BorderLayout());
-        container.add(new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
-        container.add(okPanel, BorderLayout.SOUTH);
+        JComponent contentPane = (JComponent) getContentPane();
+        contentPane.setLayout(new BorderLayout());
+        contentPane.add(new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
+        contentPane.add(okPanel, BorderLayout.SOUTH);
 
-        container.setPreferredSize(new Dimension(400, 325));
-        setTitle("Found entities");
+        contentPane.setPreferredSize(new Dimension(400, 325));
+        setTitle("Search results");
     }
 
     private JPanel createResultPanel(Map names, Icon icon) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTabbedView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTabbedView.java?rev=583393&r1=583392&r2=583393&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTabbedView.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTabbedView.java
Wed Oct 10 02:05:15 2007
@@ -26,10 +26,7 @@
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 
-import org.apache.cayenne.map.Attribute;
-import org.apache.cayenne.map.ObjAttribute;
-import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.map.Relationship;
+import org.apache.cayenne.map.*;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.action.RemoveAttributeAction;
@@ -51,6 +48,8 @@
         ObjRelationshipDisplayListener, ObjAttributeDisplayListener {
 
     protected ProjectController mediator;
+
+    protected Component entityPanel;
     protected ObjEntityRelationshipTab relationshipsPanel;
     protected ObjEntityAttributeTab attributesPanel;
 
@@ -68,8 +67,8 @@
         // note that those panels that have no internal scrollable tables
         // must be wrapped in a scroll pane
 
-        ObjEntityTab entityPanel = new ObjEntityTab(mediator);
-        addTab("Entity", new JScrollPane(entityPanel));
+        entityPanel = new JScrollPane(new ObjEntityTab(mediator));
+        addTab("Entity", entityPanel);
         
         attributesPanel = new ObjEntityAttributeTab(mediator);
         addTab("Attributes", attributesPanel);
@@ -105,6 +104,14 @@
     }
 
     public void currentObjEntityChanged(EntityDisplayEvent e) {
+        Entity entity = e.getEntity();
+        if (e.isSearched() && entity instanceof ObjEntity) {
+            if (getSelectedComponent() != entityPanel) {
+                setSelectedComponent(entityPanel);
+                entityPanel.setVisible(true);
+            }
+        }
+
         resetRemoveButtons();
         setVisible(e.getEntity() != null);
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EntityDisplayEvent.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EntityDisplayEvent.java?rev=583393&r1=583392&r2=583393&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EntityDisplayEvent.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EntityDisplayEvent.java
Wed Oct 10 02:05:15 2007
@@ -33,6 +33,9 @@
 public class EntityDisplayEvent extends DataMapDisplayEvent {
 	protected Entity entity;
 
+    /** True if the event is generated when an entity is beeing searched for */
+    protected boolean searched;
+
 	/** True if different from current entity */
 	protected boolean entityChanged = true;
 	protected boolean unselectAttributes;
@@ -100,4 +103,15 @@
 	public void setEntity(Entity entity) {
 		this.entity = entity;
 	}
+
+    /**
+     * Sets the searched.
+     * @param searched
+     */
+    public void setSearched(boolean searched) {
+        this.searched = searched;
+    }
+    public boolean isSearched() {
+        return searched;
+    }
 }



Mime
View raw message