cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [2/4] cayenne git commit: CAY-2407 add prefetch to sqlTemplate in Modeler
Date Mon, 05 Mar 2018 07:47:33 GMT
CAY-2407 add prefetch to sqlTemplate in Modeler


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/193c6aa4
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/193c6aa4
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/193c6aa4

Branch: refs/heads/master
Commit: 193c6aa4f6221efc7ac9d436fca50e865d63c229
Parents: 8b48c7c
Author: Arseni Bulatski <ancarseni@gmail.com>
Authored: Tue Feb 20 12:39:14 2018 +0300
Committer: Arseni Bulatski <ancarseni@gmail.com>
Committed: Tue Feb 20 13:08:03 2018 +0300

----------------------------------------------------------------------
 RELEASE-NOTES.txt                               |   1 +
 .../cayenne/map/QueryDescriptorLoader.java      |   1 +
 .../cayenne/map/SQLTemplateDescriptor.java      |  24 +-
 .../org/apache/cayenne/query/SQLTemplate.java   |   1 +
 .../modeler/editor/SQLTemplateOrderingTab.java  | 237 -------------------
 .../modeler/editor/SQLTemplatePrefetchTab.java  | 193 ++++++++++++++-
 6 files changed, 213 insertions(+), 244 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/193c6aa4/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index bcbd440..cfd075a 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -23,6 +23,7 @@ CAY-2395 cdbimport: add option to create project file
 CAY-2396 Upgrade maven-assembly-plugin to 3.1.0
 CAY-2403 Extract eventbridges to top level
 CAY-2404 Move itests to maven-plugins
+CAY-2407 Modeler: add prefetch support for the SQLTemplate query
 
 Bug Fixes:
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/193c6aa4/cayenne-server/src/main/java/org/apache/cayenne/map/QueryDescriptorLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/QueryDescriptorLoader.java
b/cayenne-server/src/main/java/org/apache/cayenne/map/QueryDescriptorLoader.java
index d8370de..8b05207 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/QueryDescriptorLoader.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/QueryDescriptorLoader.java
@@ -75,6 +75,7 @@ public class QueryDescriptorLoader {
                 break;
             case QueryDescriptor.SQL_TEMPLATE:
                 ((SQLTemplateDescriptor) descriptor).setSql(sql);
+                ((SQLTemplateDescriptor) descriptor).setPrefetches(prefetches);
                 ((SQLTemplateDescriptor) descriptor).setAdapterSql(adapterSql);
                 break;
             case QueryDescriptor.EJBQL_QUERY:

http://git-wip-us.apache.org/repos/asf/cayenne/blob/193c6aa4/cayenne-server/src/main/java/org/apache/cayenne/map/SQLTemplateDescriptor.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/SQLTemplateDescriptor.java
b/cayenne-server/src/main/java/org/apache/cayenne/map/SQLTemplateDescriptor.java
index 7e449ca..e3a0709 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/SQLTemplateDescriptor.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/SQLTemplateDescriptor.java
@@ -19,10 +19,15 @@
 package org.apache.cayenne.map;
 
 import org.apache.cayenne.configuration.ConfigurationNodeVisitor;
+import org.apache.cayenne.query.PrefetchTreeNode;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.util.XMLEncoder;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeSet;
 
 /**
  * @since 4.0
@@ -102,16 +107,17 @@ public class SQLTemplateDescriptor extends QueryDescriptor {
             template.setRoot(root);
         }
 
-        template.initWithProperties(this.getProperties());
 
-        List<String> prefetches = this.getPrefetches();
 
+        List<String> prefetches = this.getPrefetches();
         if (prefetches != null && !prefetches.isEmpty()) {
             for (String prefetch : prefetches) {
-                template.addPrefetch(prefetch);
+                template.addPrefetch(PrefetchTreeNode.withPath(prefetch, PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS));
             }
         }
 
+        template.initWithProperties(this.getProperties());
+
         // init SQL
         template.setDefaultTemplate(this.getSql());
 
@@ -188,6 +194,16 @@ public class SQLTemplateDescriptor extends QueryDescriptor {
             }
         }
 
+        PrefetchTreeNode prefetchTree = new PrefetchTreeNode();
+
+        for (String prefetchPath : prefetches) {
+            PrefetchTreeNode node = prefetchTree.addPath(prefetchPath);
+            node.setSemantics(PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS);
+            node.setPhantom(false);
+        }
+
+        encoder.nested(prefetchTree, delegate);
+
         delegate.visitQuery(this);
         encoder.end();
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/193c6aa4/cayenne-server/src/main/java/org/apache/cayenne/query/SQLTemplate.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/query/SQLTemplate.java b/cayenne-server/src/main/java/org/apache/cayenne/query/SQLTemplate.java
index eed51c1..3a5230f 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/query/SQLTemplate.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/query/SQLTemplate.java
@@ -491,6 +491,7 @@ public class SQLTemplate extends AbstractQuery implements ParameterizedQuery
{
 		return metaData.getPrefetchTree();
 	}
 
+
 	/**
 	 * Adds a prefetch.
 	 * 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/193c6aa4/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateOrderingTab.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateOrderingTab.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateOrderingTab.java
deleted file mode 100644
index c21841d..0000000
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateOrderingTab.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*****************************************************************
- *   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.editor;
-
-import org.apache.cayenne.configuration.event.QueryEvent;
-import org.apache.cayenne.map.Entity;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.cayenne.map.SQLTemplateDescriptor;
-import org.apache.cayenne.map.SelectQueryDescriptor;
-import org.apache.cayenne.modeler.Application;
-import org.apache.cayenne.modeler.ProjectController;
-import org.apache.cayenne.modeler.util.EntityTreeModel;
-import org.apache.cayenne.modeler.util.MultiColumnBrowser;
-import org.apache.cayenne.modeler.util.UIUtil;
-import org.apache.cayenne.query.Ordering;
-import org.apache.cayenne.query.SQLTemplate;
-import org.apache.cayenne.query.SortOrder;
-import org.apache.cayenne.swing.components.image.FilteredIconFactory;
-import org.apache.cayenne.util.CayenneMapEntry;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSplitPane;
-import javax.swing.JTable;
-import javax.swing.ListSelectionModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableModel;
-import javax.swing.tree.TreeModel;
-import java.awt.BorderLayout;
-import java.awt.CardLayout;
-import java.awt.Dimension;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.prefs.Preferences;
-
-/**
- * A panel for picking SQLTemplate orderings.
- *
- */
-public class SQLTemplateOrderingTab extends JPanel implements PropertyChangeListener {
-    // property for split pane divider size
-    private static final String SPLIT_DIVIDER_LOCATION_PROPERTY = "query.orderings.divider.location";
-
-    static final Dimension BROWSER_CELL_DIM = new Dimension(150, 100);
-    static final Dimension TABLE_DIM = new Dimension(460, 60);
-
-    static final String PATH_HEADER = "Path";
-    static final String ASCENDING_HEADER = "Ascending";
-    static final String IGNORE_CASE_HEADER = "Ignore Case";
-
-    static final String REAL_PANEL = "real";
-    static final String PLACEHOLDER_PANEL = "placeholder";
-
-    protected ProjectController mediator;
-    protected SQLTemplateDescriptor sqlTemplate;
-
-    protected MultiColumnBrowser browser;
-    protected JTable table;
-
-    protected CardLayout cardLayout;
-    protected JPanel messagePanel;
-
-    public SQLTemplateOrderingTab(ProjectController mediator) {
-        this.mediator = mediator;
-
-        initView();
-        initController();
-    }
-
-    protected void initView() {
-
-        messagePanel = new JPanel(new BorderLayout());
-        cardLayout = new CardLayout();
-
-        Preferences detail = Application.getInstance().getPreferencesNode(this.getClass(),
"");
-
-        int defLocation = Application.getFrame().getHeight() / 2;
-        int location = detail != null ? detail.getInt(
-                getDividerLocationProperty(),
-                defLocation) : defLocation;
-
-        //As of CAY-888 #3 main pane is now a JSplitPane. Top component is a bit larger.
-        JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
-        mainPanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, this);
-        mainPanel.setDividerLocation(location);
-
-        mainPanel.setTopComponent(createEditorPanel());
-        mainPanel.setBottomComponent(createSelectorPanel());
-
-        setLayout(cardLayout);
-        add(mainPanel, REAL_PANEL);
-        add(messagePanel, PLACEHOLDER_PANEL);
-    }
-
-    protected void initController() {
-
-        // scroll to selected row whenever a selection even occurs
-        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
-
-            public void valueChanged(ListSelectionEvent e) {
-                if (!e.getValueIsAdjusting()) {
-                    UIUtil.scrollToSelectedRow(table);
-                }
-            }
-        });
-    }
-
-    protected void initFromModel() {
-        QueryDescriptor query = mediator.getCurrentQuery();
-
-        if (query == null || !QueryDescriptor.SQL_TEMPLATE.equals(query.getType())) {
-            processInvalidModel("Unknown query.");
-            return;
-        }
-
-        if (!(query.getRoot() instanceof Entity)) {
-            processInvalidModel("SQLTemplate has no root set.");
-            return;
-        }
-
-        this.sqlTemplate = (SQLTemplateDescriptor) query;
-        browser.setModel(createBrowserModel((Entity) sqlTemplate.getRoot()));
-
-        // init column sizes
-       // table.getColumnModel().getColumn(0).setPreferredWidth(250);
-
-        cardLayout.show(this, REAL_PANEL);
-    }
-
-    protected void processInvalidModel(String message) {
-        JLabel messageLabel = new JLabel(message, JLabel.CENTER);
-
-        messagePanel.removeAll();
-        messagePanel.add(messageLabel, BorderLayout.CENTER);
-        cardLayout.show(this, PLACEHOLDER_PANEL);
-    }
-
-    protected JPanel createEditorPanel() {
-
-        table = new JTable();
-        table.setRowHeight(25);
-        table.setRowMargin(3);
-        table.setPreferredScrollableViewportSize(TABLE_DIM);
-        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-
-        JPanel panel = new JPanel(new BorderLayout());
-        panel.add(new JScrollPane(table), BorderLayout.CENTER);
-
-        return panel;
-    }
-
-    protected JPanel createSelectorPanel() {
-        browser = new MultiColumnBrowser();
-        browser.setPreferredColumnSize(BROWSER_CELL_DIM);
-        browser.setDefaultRenderer();
-
-        JPanel panel = new JPanel(new BorderLayout());
-        panel.add(new JScrollPane(
-                browser,
-                JScrollPane.VERTICAL_SCROLLBAR_NEVER,
-                JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
-
-        // setting minimal size, otherwise scrolling looks awful, because of
-        // VERTICAL_SCROLLBAR_NEVER strategy
-        panel.setMinimumSize(panel.getPreferredSize());
-
-        return panel;
-    }
-
-    protected TreeModel createBrowserModel(Entity entity) {
-        return new EntityTreeModel(entity);
-    }
-
-    protected String getSelectedPath() {
-        Object[] path = browser.getSelectionPath().getPath();
-
-        // first item in the path is Entity, so we must have
-        // at least two elements to constitute a valid ordering path
-        if (path.length < 2) {
-            return null;
-        }
-
-        StringBuilder buffer = new StringBuilder();
-
-        // attribute or relationships
-        CayenneMapEntry first = (CayenneMapEntry) path[1];
-        buffer.append(first.getName());
-
-        for (int i = 2; i < path.length; i++) {
-            CayenneMapEntry pathEntry = (CayenneMapEntry) path[i];
-            buffer.append(".").append(pathEntry.getName());
-        }
-
-        return buffer.toString();
-    }
-
-    /**
-     * Updates split pane divider location in properties
-     */
-    public void propertyChange(PropertyChangeEvent evt) {
-        if (JSplitPane.DIVIDER_LOCATION_PROPERTY.equals(evt.getPropertyName())) {
-            int value = (Integer) evt.getNewValue();
-
-            Preferences detail = Application.getInstance().getPreferencesNode(this.getClass(),
"");
-            detail.putInt(getDividerLocationProperty(), value);
-        }
-    }
-
-    /**
-     * Returns name of a property for divider location.
-     */
-    protected String getDividerLocationProperty() {
-        return SPLIT_DIVIDER_LOCATION_PROPERTY;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/193c6aa4/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplatePrefetchTab.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplatePrefetchTab.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplatePrefetchTab.java
index b9e7147..0398eee 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplatePrefetchTab.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplatePrefetchTab.java
@@ -25,32 +25,177 @@ import org.apache.cayenne.exp.ExpressionException;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.Entity;
+import org.apache.cayenne.map.QueryDescriptor;
 import org.apache.cayenne.map.Relationship;
+import org.apache.cayenne.map.SQLTemplateDescriptor;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
-import org.apache.cayenne.modeler.undo.AddPrefetchUndoableEdit;
 import org.apache.cayenne.modeler.undo.AddPrefetchUndoableEditForSqlTemplate;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.util.EntityTreeFilter;
 import org.apache.cayenne.modeler.util.EntityTreeModel;
 import org.apache.cayenne.modeler.util.ModelerUtil;
+import org.apache.cayenne.modeler.util.MultiColumnBrowser;
+import org.apache.cayenne.modeler.util.UIUtil;
 import org.apache.cayenne.swing.components.image.FilteredIconFactory;
+import org.apache.cayenne.util.CayenneMapEntry;
 
 import javax.swing.BorderFactory;
 import javax.swing.Icon;
 import javax.swing.JButton;
 import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.JTable;
 import javax.swing.JToolBar;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
 import javax.swing.table.AbstractTableModel;
 import javax.swing.table.TableModel;
 import javax.swing.tree.TreeModel;
+import java.awt.BorderLayout;
+import java.awt.CardLayout;
+import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.prefs.Preferences;
 
-public class SQLTemplatePrefetchTab extends SQLTemplateOrderingTab{
+public class SQLTemplatePrefetchTab extends JPanel implements PropertyChangeListener {
+
+    // property for split pane divider size
+    private static final String SPLIT_DIVIDER_LOCATION_PROPERTY = "query.orderings.divider.location";
+
+    static final Dimension BROWSER_CELL_DIM = new Dimension(150, 100);
+    static final Dimension TABLE_DIM = new Dimension(460, 60);
+
+    static final String PATH_HEADER = "Path";
+    static final String ASCENDING_HEADER = "Ascending";
+    static final String IGNORE_CASE_HEADER = "Ignore Case";
+
+    static final String REAL_PANEL = "real";
+    static final String PLACEHOLDER_PANEL = "placeholder";
+
+    protected ProjectController mediator;
+    protected SQLTemplateDescriptor sqlTemplate;
+
+    protected MultiColumnBrowser browser;
+    protected JTable table;
+
+    protected CardLayout cardLayout;
+    protected JPanel messagePanel;
 
     public SQLTemplatePrefetchTab(ProjectController mediator) {
-        super(mediator);
+        this.mediator = mediator;
+
+        initView();
+        initController();
+    }
+
+    protected void initView() {
+
+        messagePanel = new JPanel(new BorderLayout());
+        cardLayout = new CardLayout();
+
+        Preferences detail = Application.getInstance().getPreferencesNode(this.getClass(),
"");
+
+        int defLocation = Application.getFrame().getHeight() / 2;
+        int location = detail != null ? detail.getInt(
+                getDividerLocationProperty(),
+                defLocation) : defLocation;
+
+        //As of CAY-888 #3 main pane is now a JSplitPane. Top component is a bit larger.
+        JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+        mainPanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, this);
+        mainPanel.setDividerLocation(location);
+
+        mainPanel.setTopComponent(createEditorPanel());
+        mainPanel.setBottomComponent(createSelectorPanel());
+
+        setLayout(cardLayout);
+        add(mainPanel, REAL_PANEL);
+        add(messagePanel, PLACEHOLDER_PANEL);
+    }
+
+    protected void initController() {
+
+        // scroll to selected row whenever a selection even occurs
+        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+
+            public void valueChanged(ListSelectionEvent e) {
+                if (!e.getValueIsAdjusting()) {
+                    UIUtil.scrollToSelectedRow(table);
+                }
+            }
+        });
+    }
+
+    protected void initFromModel() {
+        QueryDescriptor query = mediator.getCurrentQuery();
+
+        if (query == null || !QueryDescriptor.SQL_TEMPLATE.equals(query.getType())) {
+            processInvalidModel("Unknown query.");
+            return;
+        }
+
+        if (!(query.getRoot() instanceof Entity)) {
+            processInvalidModel("SQLTemplate has no root set.");
+            return;
+        }
+
+        this.sqlTemplate = (SQLTemplateDescriptor) query;
+        browser.setModel(createBrowserModel((Entity) sqlTemplate.getRoot()));
+        table.setModel(createTableModel());
+
+        // init column sizes
+        table.getColumnModel().getColumn(0).setPreferredWidth(250);
+
+        cardLayout.show(this, REAL_PANEL);
+    }
+
+    protected void processInvalidModel(String message) {
+        JLabel messageLabel = new JLabel(message, JLabel.CENTER);
+
+        messagePanel.removeAll();
+        messagePanel.add(messageLabel, BorderLayout.CENTER);
+        cardLayout.show(this, PLACEHOLDER_PANEL);
+    }
+
+    protected JPanel createEditorPanel() {
+
+        table = new JTable();
+        table.setRowHeight(25);
+        table.setRowMargin(3);
+        table.setPreferredScrollableViewportSize(TABLE_DIM);
+        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+
+        JPanel panel = new JPanel(new BorderLayout());
+        panel.add(new JScrollPane(table), BorderLayout.CENTER);
+
+        return panel;
+    }
+
+    protected JPanel createSelectorPanel() {
+        browser = new MultiColumnBrowser();
+        browser.setPreferredColumnSize(BROWSER_CELL_DIM);
+        browser.setDefaultRenderer();
+
+        JPanel panel = new JPanel(new BorderLayout());
+        panel.add(createToolbar(), BorderLayout.NORTH);
+        panel.add(new JScrollPane(
+                browser,
+                JScrollPane.VERTICAL_SCROLLBAR_NEVER,
+                JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
+
+        // setting minimal size, otherwise scrolling looks awful, because of
+        // VERTICAL_SCROLLBAR_NEVER strategy
+        panel.setMinimumSize(panel.getPreferredSize());
+
+        return panel;
     }
 
     protected JComponent createToolbar() {
@@ -106,6 +251,29 @@ public class SQLTemplatePrefetchTab extends SQLTemplateOrderingTab{
         return toolBar;
     }
 
+    protected String getSelectedPath() {
+        Object[] path = browser.getSelectionPath().getPath();
+
+        // first item in the path is Entity, so we must have
+        // at least two elements to constitute a valid ordering path
+        if (path.length < 2) {
+            return null;
+        }
+
+        StringBuilder buffer = new StringBuilder();
+
+        // attribute or relationships
+        CayenneMapEntry first = (CayenneMapEntry) path[1];
+        buffer.append(first.getName());
+
+        for (int i = 2; i < path.length; i++) {
+            CayenneMapEntry pathEntry = (CayenneMapEntry) path[i];
+            buffer.append(".").append(pathEntry.getName());
+        }
+
+        return buffer.toString();
+    }
+
     protected TreeModel createBrowserModel(Entity entity) {
         EntityTreeModel treeModel = new EntityTreeModel(entity);
         treeModel.setFilter(
@@ -172,6 +340,25 @@ public class SQLTemplatePrefetchTab extends SQLTemplateOrderingTab{
     }
 
     /**
+     * Updates split pane divider location in properties
+     */
+    public void propertyChange(PropertyChangeEvent evt) {
+        if (JSplitPane.DIVIDER_LOCATION_PROPERTY.equals(evt.getPropertyName())) {
+            int value = (Integer) evt.getNewValue();
+
+            Preferences detail = Application.getInstance().getPreferencesNode(this.getClass(),
"");
+            detail.putInt(getDividerLocationProperty(), value);
+        }
+    }
+
+    /**
+     * Returns name of a property for divider location.
+     */
+    protected String getDividerLocationProperty() {
+        return SPLIT_DIVIDER_LOCATION_PROPERTY;
+    }
+
+    /**
      * A table model for the Ordering editing table.
      */
     final class PrefetchModel extends AbstractTableModel {


Mime
View raw message