cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r404795 - in /incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne: modeler/dialog/codegen/CustomModeController.java modeler/dialog/codegen/CustomModePanel.java pref/PreferenceDetail.java
Date Sun, 07 May 2006 16:56:22 GMT
Author: aadamchik
Date: Sun May  7 09:56:18 2006
New Revision: 404795

URL: http://svn.apache.org/viewcvs?rev=404795&view=rev
Log:
advanced class gen options

Modified:
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/dialog/codegen/CustomModeController.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/dialog/codegen/CustomModePanel.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/pref/PreferenceDetail.java

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/dialog/codegen/CustomModeController.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/dialog/codegen/CustomModeController.java?rev=404795&r1=404794&r2=404795&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/dialog/codegen/CustomModeController.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/dialog/codegen/CustomModeController.java
Sun May  7 09:56:18 2006
@@ -64,6 +64,7 @@
 
 import javax.swing.DefaultComboBoxModel;
 
+import org.objectstyle.cayenne.gen.ClassGenerator;
 import org.objectstyle.cayenne.gen.DefaultClassGenerator;
 import org.objectstyle.cayenne.modeler.CodeTemplateManager;
 import org.objectstyle.cayenne.modeler.dialog.pref.PreferenceDialog;
@@ -101,25 +102,17 @@
     public CustomModeController(CodeGeneratorControllerBase parent) {
         super(parent);
 
-        Object[] choices = new Object[] {
+        Object[] modeChoices = new Object[] {
                 ENTITY_MODE_LABEL, DATA_MAP_MODE_LABEL
         };
-        view.getGenerationMode().setModel(new DefaultComboBoxModel(choices));
+        view.getGenerationMode().setModel(new DefaultComboBoxModel(modeChoices));
 
-        BindingBuilder builder = new BindingBuilder(
-                getApplication().getBindingFactory(),
-                this);
-
-        builder.bindToTextField(
-                view.getSuperclassPackage(),
-                "preferences.superclassPackage").updateView();
+        Object[] versionChoices = new Object[] {
+                ClassGenerator.VERSION_1_1, ClassGenerator.VERSION_1_2
+        };
+        view.getGeneratorVersion().setModel(new DefaultComboBoxModel(versionChoices));
 
-        builder.bindToAction(view.getManageTemplatesLink(), "popPreferencesAction()");
-
-        // init preference defaults
-        if (Util.isEmptyString(preferences.getProperty("mode"))) {
-            preferences.setProperty("mode", MODE_ENTITY);
-        }
+        // bind preferences and init defaults...
 
         if (Util.isEmptyString(preferences.getSuperclassTemplate())) {
             preferences
@@ -130,12 +123,57 @@
             preferences.setSubclassTemplate(CodeTemplateManager.STANDARD_SERVER_SUBCLASS);
         }
 
-        // bind preferences to combo changes
+        if (Util.isEmptyString(preferences.getProperty("mode"))) {
+            preferences.setProperty("mode", MODE_ENTITY);
+        }
+
+        if (Util.isEmptyString(preferences.getProperty("version"))) {
+            preferences.setProperty("version", ClassGenerator.VERSION_1_1);
+        }
+
+        if (Util.isEmptyString(preferences.getProperty("overwrite"))) {
+            preferences.setBooleanProperty("overwrite", false);
+        }
+
+        if (Util.isEmptyString(preferences.getProperty("pairs"))) {
+            preferences.setBooleanProperty("pairs", true);
+        }
+
+        if (Util.isEmptyString(preferences.getProperty("usePackagePath"))) {
+            preferences.setBooleanProperty("usePackagePath", true);
+        }
+
+        BindingBuilder builder = new BindingBuilder(
+                getApplication().getBindingFactory(),
+                this);
+
+        builder.bindToAction(view.getManageTemplatesLink(), "popPreferencesAction()");
+
+        builder.bindToTextField(
+                view.getSuperclassPackage(),
+                "preferences.superclassPackage").updateView();
 
         builder.bindToComboSelection(
                 view.getGenerationMode(),
                 "preferences.property['mode']").updateView();
 
+        builder.bindToComboSelection(
+                view.getGeneratorVersion(),
+                "preferences.property['version']").updateView();
+
+        builder.bindToStateChange(
+                view.getOverwrite(),
+                "preferences.booleanProperty['overwrite']").updateView();
+        builder
+                .bindToStateChange(
+                        view.getPairs(),
+                        "preferences.booleanProperty['pairs']")
+                .updateView();
+
+        builder.bindToStateChange(
+                view.getUsePackagePath(),
+                "preferences.booleanProperty['usePackagePath']").updateView();
+
         subTemplate = builder.bindToComboSelection(
                 view.getSubclassTemplate(),
                 "preferences.subclassTemplate");
@@ -182,7 +220,7 @@
                 new DefaultComboBoxModel(subTemplates.toArray()));
         this.view.getSuperclassTemplate().setModel(
                 new DefaultComboBoxModel(superTemplates.toArray()));
-        
+
         superTemplate.updateView();
         subTemplate.updateView();
     }
@@ -212,6 +250,17 @@
         String subKey = view.getSubclassTemplate().getSelectedItem().toString();
         String subTemplate = templateManager.getTemplatePath(subKey);
         generator.setTemplate(subTemplate);
+
+        if (view.getGeneratorVersion().getSelectedItem() != null) {
+            generator.setVersionString(view
+                    .getGeneratorVersion()
+                    .getSelectedItem()
+                    .toString());
+        }
+
+        generator.setOverwrite(view.getOverwrite().isSelected());
+        generator.setUsePkgPath(view.getUsePackagePath().isSelected());
+        generator.setMakePairs(view.getPairs().isSelected());
 
         return generator;
     }

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/dialog/codegen/CustomModePanel.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/dialog/codegen/CustomModePanel.java?rev=404795&r1=404794&r2=404795&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/dialog/codegen/CustomModePanel.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/modeler/dialog/codegen/CustomModePanel.java
Sun May  7 09:56:18 2006
@@ -58,8 +58,11 @@
 import java.awt.BorderLayout;
 import java.awt.FlowLayout;
 
+import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JPanel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
 
 import org.objectstyle.cayenne.swing.control.ActionLink;
 
@@ -72,6 +75,11 @@
     protected JComboBox generationMode;
     protected JComboBox subclassTemplate;
     protected JComboBox superclassTemplate;
+    protected JCheckBox pairs;
+    protected JComboBox generatorVersion;
+    protected JCheckBox overwrite;
+    protected JCheckBox usePackagePath;
+
     protected ActionLink manageTemplatesLink;
 
     public CustomModePanel() {
@@ -79,14 +87,26 @@
         this.generationMode = new JComboBox();
         this.superclassTemplate = new JComboBox();
         this.subclassTemplate = new JComboBox();
+        this.pairs = new JCheckBox();
+        this.generatorVersion = new JComboBox();
+        this.overwrite = new JCheckBox();
+        this.usePackagePath = new JCheckBox();
         this.manageTemplatesLink = new ActionLink("Customize Templates...");
         manageTemplatesLink.setFont(manageTemplatesLink.getFont().deriveFont(10f));
 
+        pairs.addChangeListener(new ChangeListener() {
+
+            public void stateChanged(ChangeEvent e) {
+                superclassTemplate.setEnabled(pairs.isSelected());
+            }
+        });
+
         // assemble
 
-        PanelBuilder builder = new PanelBuilder(new FormLayout(
-                "right:70dlu, 3dlu, 150dlu, 3dlu, pref",
-                "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p"));
+        PanelBuilder builder = new PanelBuilder(
+                new FormLayout(
+                        "right:70dlu, 3dlu, 150dlu, 3dlu, pref",
+                        "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p,
3dlu, p"));
         builder.setDefaultDialogBorder();
 
         CellConstraints cc = new CellConstraints();
@@ -101,7 +121,8 @@
         builder.addLabel("Generation Mode:", cc.xy(1, 5));
         builder.add(generationMode, cc.xy(3, 5));
 
-        builder.addSeparator("Generation Templates", cc.xywh(1, 7, 3, 1));
+        builder.addLabel("Generator Version:", cc.xy(1, 7));
+        builder.add(generatorVersion, cc.xy(3, 7));
 
         builder.addLabel("Subclass Template:", cc.xy(1, 9));
         builder.add(subclassTemplate, cc.xy(3, 9));
@@ -109,6 +130,15 @@
         builder.addLabel("Superclass Template:", cc.xy(1, 11));
         builder.add(superclassTemplate, cc.xy(3, 11));
 
+        builder.addLabel("Make Pairs:", cc.xy(1, 13));
+        builder.add(pairs, cc.xy(3, 13));
+
+        builder.addLabel("Overwrite Subclasses:", cc.xy(1, 15));
+        builder.add(overwrite, cc.xy(3, 15));
+
+        builder.addLabel("Use Package Path:", cc.xy(1, 17));
+        builder.add(usePackagePath, cc.xy(3, 17));
+
         JPanel links = new JPanel(new FlowLayout(FlowLayout.TRAILING));
         links.add(manageTemplatesLink);
 
@@ -131,5 +161,21 @@
 
     public JComboBox getSuperclassTemplate() {
         return superclassTemplate;
+    }
+
+    public JComboBox getGeneratorVersion() {
+        return generatorVersion;
+    }
+
+    public JCheckBox getOverwrite() {
+        return overwrite;
+    }
+
+    public JCheckBox getPairs() {
+        return pairs;
+    }
+
+    public JCheckBox getUsePackagePath() {
+        return usePackagePath;
     }
 }

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/pref/PreferenceDetail.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/pref/PreferenceDetail.java?rev=404795&r1=404794&r2=404795&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/pref/PreferenceDetail.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/modeler/java/org/objectstyle/cayenne/pref/PreferenceDetail.java
Sun May  7 09:56:18 2006
@@ -160,6 +160,14 @@
         getProperties().setProperty(key, value);
     }
 
+    public boolean getBooleanProperty(String key) {
+        return "true".equalsIgnoreCase(getProperty(key));
+    }
+
+    public void setBooleanProperty(String key, boolean value) {
+        setProperty(key, "" + value);
+    }
+
     public DomainPreference getDomainPreference() {
         if (domainPreference == null) {
             // try to fetch..



Mime
View raw message