cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r649267 - in /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor: ObjectQueryPropertiesPanel.java RawQueryPropertiesPanel.java SelectPropertiesPanel.java
Date Thu, 17 Apr 2008 20:50:05 GMT
Author: aadamchik
Date: Thu Apr 17 13:50:02 2008
New Revision: 649267

URL: http://svn.apache.org/viewvc?rev=649267&view=rev
Log:
CAY-1035 Replace QueryMetadata String cache policies with an enum
(Modeler)

Modified:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java?rev=649267&r1=649266&r2=649267&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjectQueryPropertiesPanel.java
Thu Apr 17 13:50:02 2008
@@ -62,7 +62,7 @@
         builder.addSeparator("", cc.xywh(1, 1, 4, 1));
 
         builder.addLabel("Result Caching:", cc.xy(1, 3));
-        builder.add(cachePolicy, cc.xywh(3, 3, 2, 1));
+        builder.add(cacheStrategy, cc.xywh(3, 3, 2, 1));
         builder.addLabel("Fetch Data Rows:", cc.xy(1, 7));
         builder.add(dataRows, cc.xy(3, 7));
         builder.addLabel("Refresh Results:", cc.xy(1, 9));

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java?rev=649267&r1=649266&r2=649267&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
Thu Apr 17 13:50:02 2008
@@ -88,7 +88,7 @@
         builder.addSeparator("Select Properties", cc.xywh(1, 1, 7, 1));
 
         builder.addLabel("Result Caching:", cc.xy(1, 3));
-        builder.add(cachePolicy, cc.xywh(3, 3, 5, 1));
+        builder.add(cacheStrategy, cc.xywh(3, 3, 5, 1));
         builder.addLabel("Fetch Data Objects:", cc.xy(1, 7));
         builder.add(dataObjects, cc.xy(3, 7));
         builder.add(entities, cc.xywh(5, 7, 3, 1));

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java?rev=649267&r1=649266&r2=649267&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java
Thu Apr 17 13:50:02 2008
@@ -40,7 +40,7 @@
 import org.apache.cayenne.modeler.util.CayenneWidgetFactory;
 import org.apache.cayenne.modeler.util.TextAdapter;
 import org.apache.cayenne.query.Query;
-import org.apache.cayenne.query.QueryMetadata;
+import org.apache.cayenne.query.QueryCacheStrategy;
 import org.apache.cayenne.reflect.PropertyUtils;
 import org.apache.cayenne.validation.ValidationException;
 import org.apache.commons.logging.Log;
@@ -58,24 +58,25 @@
     private static final Integer ZERO = new Integer(0);
 
     private static final String NO_CACHE_LABEL = "No Result Caching";
-    private static final String LOCAL_CACHE_LABEL = "DataContext Cache";
+    private static final String LOCAL_CACHE_LABEL = "Local Cache (per ObjectContext)";
     private static final String SHARED_CACHE_LABEL = "Shared Cache";
 
     private static final Object[] CACHE_POLICIES = new Object[] {
-            QueryMetadata.NO_CACHE, QueryMetadata.LOCAL_CACHE, QueryMetadata.SHARED_CACHE
+            QueryCacheStrategy.NO_CACHE, QueryCacheStrategy.LOCAL_CACHE,
+            QueryCacheStrategy.SHARED_CACHE
     };
 
-    private static final Map cachePolicyLabels = new TreeMap();
+    private static final Map<QueryCacheStrategy, String> cachePolicyLabels = new TreeMap<QueryCacheStrategy,
String>();
 
     static {
-        cachePolicyLabels.put(QueryMetadata.NO_CACHE, NO_CACHE_LABEL);
-        cachePolicyLabels.put(QueryMetadata.LOCAL_CACHE, LOCAL_CACHE_LABEL);
-        cachePolicyLabels.put(QueryMetadata.SHARED_CACHE, SHARED_CACHE_LABEL);
+        cachePolicyLabels.put(QueryCacheStrategy.NO_CACHE, NO_CACHE_LABEL);
+        cachePolicyLabels.put(QueryCacheStrategy.LOCAL_CACHE, LOCAL_CACHE_LABEL);
+        cachePolicyLabels.put(QueryCacheStrategy.SHARED_CACHE, SHARED_CACHE_LABEL);
     }
 
     protected TextAdapter fetchLimit;
     protected TextAdapter pageSize;
-    protected JComboBox cachePolicy;
+    protected JComboBox cacheStrategy;
     protected JCheckBox refreshesResults;
 
     protected ProjectController mediator;
@@ -101,17 +102,17 @@
             }
         };
 
-        cachePolicy = CayenneWidgetFactory.createComboBox();
-        cachePolicy.setRenderer(new CachePolicyRenderer());
+        cacheStrategy = CayenneWidgetFactory.createComboBox();
+        cacheStrategy.setRenderer(new CacheStrategyRenderer());
         refreshesResults = new JCheckBox();
     }
 
     protected void initController() {
-        cachePolicy.addActionListener(new ActionListener() {
+        cacheStrategy.addActionListener(new ActionListener() {
 
             public void actionPerformed(ActionEvent event) {
-                Object policy = cachePolicy.getModel().getSelectedItem();
-                setQueryProperty("cachePolicy", policy);
+                Object strategy = cacheStrategy.getModel().getSelectedItem();
+                setQueryProperty("cacheStrategy", strategy);
             }
         });
 
@@ -131,8 +132,15 @@
     public void initFromModel(Query query) {
         EntityResolver resolver = mediator.getCurrentDataDomain().getEntityResolver();
         DefaultComboBoxModel cacheModel = new DefaultComboBoxModel(CACHE_POLICIES);
-        cacheModel.setSelectedItem(query.getMetaData(resolver).getCachePolicy());
-        cachePolicy.setModel(cacheModel);
+
+        QueryCacheStrategy selectedStrategy = query
+                .getMetaData(resolver)
+                .getCacheStrategy();
+
+        cacheModel.setSelectedItem(selectedStrategy != null
+                ? selectedStrategy
+                : QueryCacheStrategy.getDefaultStrategy());
+        cacheStrategy.setModel(cacheModel);
 
         fetchLimit.setText(String.valueOf(query.getMetaData(resolver).getFetchLimit()));
         pageSize.setText(String.valueOf(query.getMetaData(resolver).getPageSize()));
@@ -200,7 +208,7 @@
         }
     }
 
-    final class CachePolicyRenderer extends DefaultListCellRenderer {
+    final class CacheStrategyRenderer extends DefaultListCellRenderer {
 
         public Component getListCellRendererComponent(
                 JList list,



Mime
View raw message