Author: thomasobrien95
Date: Thu Dec  4 15:33:35 2008
New Revision: 2864

Added:
trunk/src/ca/sqlpower/architect/swingui/ArchitectPropertiesDataSourceTypeOptionPanel.java
Modified:
   trunk/src/ca/sqlpower/architect/profile/ProfileFunctionDescriptor.java
   trunk/src/ca/sqlpower/architect/profile/RemoteDatabaseProfileCreator.java
   trunk/src/ca/sqlpower/architect/swingui/PreferencesEditor.java
   trunk/src/ca/sqlpower/architect/swingui/messages.properties

Log:
This is a fix for bug 1615. A user received a NPE when profiling due
to missing profile properties on a new data source type. To resolve
this we added a new tab to the data source type editor to allow
users to modify the more advanced part of a data source type. This also allows users to understand what values are in the pl.ini as eight true/false values in a row is somewhat hard to read.

Modified: trunk/src/ca/sqlpower/architect/profile/ProfileFunctionDescriptor.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/profile/ProfileFunctionDescriptor.java (original) +++ trunk/src/ca/sqlpower/architect/profile/ProfileFunctionDescriptor.java Thu Dec 4 15:33:35 2008
@@ -19,7 +19,42 @@
 package ca.sqlpower.architect.profile;

 public class ProfileFunctionDescriptor {
-
+
+    /**
+ * This will create a ProfileFunctionDescriptor from a string. The string should + * be a comma separated string of the values needed for a ProfileFunctionDescriptor.
+     */
+ public static ProfileFunctionDescriptor parseDescriptorString(String descString) {
+        String[] dataTypeParts = descString.split(",");
+        int dataTypeValue = Integer.parseInt(dataTypeParts[2].trim());
+
+ ProfileFunctionDescriptor pfd = new ProfileFunctionDescriptor(dataTypeParts[1].trim(), + dataTypeValue, dataTypeParts[3].trim().startsWith("t"), dataTypeParts[4].trim().startsWith("t"), + dataTypeParts[5].trim().startsWith("t"), dataTypeParts[6].trim().startsWith("t"), + dataTypeParts[7].trim().startsWith("t"), dataTypeParts[8].trim().startsWith("t"), + dataTypeParts[9].trim().startsWith("t"), dataTypeParts[10].trim().startsWith("t"));
+
+        pfd.setArchitectSpecificName(dataTypeParts[0].trim());
+
+        return pfd;
+    }
+
+    /**
+ * This generates a comma separated string of the values of a [EMAIL PROTECTED] ProfileFunctionDescriptor}. + * This string can be used to store a [EMAIL PROTECTED] ProfileFunctionDescriptor} in a file to be loaded
+     * back later.
+     */
+ public static String createDescriptorString(ProfileFunctionDescriptor pfd) { + return pfd.getArchitectSpecificName() + "," + pfd.getDataTypeName() + "," + pfd.getDataTypeCode() + "," + Boolean.toString(pfd.isCountDist()) + + "," + Boolean.toString(pfd.isMaxValue()) + "," + Boolean.toString(pfd.isMinValue()) + "," + Boolean.toString(pfd.isAvgValue()) + + "," + Boolean.toString(pfd.isMaxLength()) + "," + Boolean.toString(pfd.isMinLength()) + "," + Boolean.toString(pfd.isAvgLength()) +
+                "," + Boolean.toString(pfd.isSumDecode());
+    }
+
+    /**
+ * This is the architect specific name the data type is being mapped to.
+     */
+    private String architectSpecificName;
     private String dataTypeName;
     private int dataTypeCode;
     private boolean countDist;
@@ -152,6 +187,14 @@

     public void setSumDecode(boolean sumDecode) {
         this.sumDecode = sumDecode;
+    }
+
+    public void setArchitectSpecificName(String architectSpecificName) {
+        this.architectSpecificName = architectSpecificName;
+    }
+
+    public String getArchitectSpecificName() {
+        return architectSpecificName;
     }



Modified: trunk/src/ca/sqlpower/architect/profile/RemoteDatabaseProfileCreator.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/profile/RemoteDatabaseProfileCreator.java (original) +++ trunk/src/ca/sqlpower/architect/profile/RemoteDatabaseProfileCreator.java Thu Dec 4 15:33:35 2008
@@ -72,7 +72,7 @@
      * This class is used to hold the specific start and end to a LENGTH
      * SQL command based on the database in use.
      */
-    private class StringLengthSQLFunction {
+    public class StringLengthSQLFunction {

         /**
* The part of the LENGTH SQL command that comes before the argument
@@ -102,7 +102,7 @@
      * This class is used to hold the specific start and end to a AVERAGE
      * SQL command based on the database in use.
      */
-    private class AverageSQLFunction {
+    public class AverageSQLFunction {

         /**
* The part of the AVERAGE SQL command that comes before the argument
@@ -139,7 +139,7 @@
* for those platforms (i.e. Oracle) will be different, but should have the
      * same meaning.
      */
-    private class CaseWhenNullSQLFunction {
+    public class CaseWhenNullSQLFunction {

         /**
* The part of the CASE statement for evaluating a null expression in SQL that
@@ -581,14 +581,8 @@
String dataTypeToParse = dsType.getProperty(ProfileFunctionDescriptor.class.getName() + "_" + dataTypeCount);
             if (dataTypeToParse == null) break;

-            String[] dataTypeParts = dataTypeToParse.split(",");
-            int dataTypeValue = Integer.parseInt(dataTypeParts[2].trim());
-
- profileFunctionMap.put(dataTypeParts[0].trim(), new ProfileFunctionDescriptor(dataTypeParts[1].trim(), - dataTypeValue, dataTypeParts[3].trim().startsWith("t"), dataTypeParts[4].trim().startsWith("t"), - dataTypeParts[5].trim().startsWith("t"), dataTypeParts[6].trim().startsWith("t"), - dataTypeParts[7].trim().startsWith("t"), dataTypeParts[8].trim().startsWith("t"), - dataTypeParts[9].trim().startsWith("t"), dataTypeParts[10].trim().startsWith("t"))); + ProfileFunctionDescriptor pfd = ProfileFunctionDescriptor.parseDescriptorString(dataTypeToParse);
+            profileFunctionMap.put(pfd.getArchitectSpecificName(), pfd);
         }

logger.debug("The property to retrieve is " + propName(StringLengthSQLFunction.class));
@@ -700,7 +694,7 @@
      * @param forClass
      * @return
      */
-    private String propName(Class<?> forClass) {
+    public static String propName(Class<?> forClass) {
         if (forClass == AverageSQLFunction.class) {
return "ca.sqlpower.architect.profile.ColumnProfileResult$AverageSQLFunction";
         } else if (forClass == CaseWhenNullSQLFunction.class) {

Added: trunk/src/ca/sqlpower/architect/swingui/ArchitectPropertiesDataSourceTypeOptionPanel.java
==============================================================================
--- (empty file)
+++ trunk/src/ca/sqlpower/architect/swingui/ArchitectPropertiesDataSourceTypeOptionPanel.java Thu Dec 4 15:33:35 2008
@@ -0,0 +1,436 @@
+/*
+ * Copyright (c) 2008, SQL Power Group Inc.
+ *
+ * This file is part of Power*Architect.
+ *
+ * Power*Architect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Power*Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect.swingui;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.swing.AbstractAction;
+import javax.swing.DefaultCellEditor;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableModel;
+
+import ca.sqlpower.architect.SQLIndex;
+import ca.sqlpower.architect.SQLType;
+import ca.sqlpower.architect.ddl.DB2DDLGenerator;
+import ca.sqlpower.architect.ddl.GenericDDLGenerator;
+import ca.sqlpower.architect.ddl.HSQLDBDDLGenerator;
+import ca.sqlpower.architect.ddl.MySqlDDLGenerator;
+import ca.sqlpower.architect.ddl.OracleDDLGenerator;
+import ca.sqlpower.architect.ddl.PostgresDDLGenerator;
+import ca.sqlpower.architect.ddl.SQLServer2000DDLGenerator;
+import ca.sqlpower.architect.ddl.SQLServer2005DDLGenerator;
+import ca.sqlpower.architect.ddl.SQLServerDDLGenerator;
+import ca.sqlpower.architect.profile.ColumnProfileResult;
+import ca.sqlpower.architect.profile.ProfileFunctionDescriptor;
+import ca.sqlpower.architect.profile.RemoteDatabaseProfileCreator;
+import ca.sqlpower.architect.profile.RemoteDatabaseProfileCreator.AverageSQLFunction; +import ca.sqlpower.architect.profile.RemoteDatabaseProfileCreator.CaseWhenNullSQLFunction; +import ca.sqlpower.architect.profile.RemoteDatabaseProfileCreator.StringLengthSQLFunction;
+import ca.sqlpower.sql.SPDataSourceType;
+import ca.sqlpower.swingui.AddRemoveIcon;
+import ca.sqlpower.swingui.db.DataSourceTypeEditorTabPanel;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.FormLayout;
+
+/**
+ * This properties panel will allow users to modify all of the architect specific properties in
+ * one tab panel.
+ *
+ * This name beats the [EMAIL PROTECTED] KettleDataSourceTypeOptionPanel} name for length.
+ */
+public class ArchitectPropertiesDataSourceTypeOptionPanel implements DataSourceTypeEditorTabPanel {
+
+    /**
+ * This stores the known DDL generator types. This list will need to be increased + * as more DDL Generators are added if we want users to be able to select them
+     * from this menu.
+     */
+    private enum KnownDDLGenerators {
+        GENERIC("Generic", GenericDDLGenerator.class.getName()),
+        DB2("DB2", DB2DDLGenerator.class.getName()),
+        HSQLDB("HSQLDB", HSQLDBDDLGenerator.class.getName()),
+        MY_SQL("My SQL", MySqlDDLGenerator.class.getName()),
+        ORACLE("Oracle", OracleDDLGenerator.class.getName()),
+        POSTGRES("Postgres", PostgresDDLGenerator.class.getName()),
+ SQL_SERVER_2000("SQL Server 2000", SQLServer2000DDLGenerator.class.getName()), + SQL_SERVER_2005("SQL Server 2005", SQLServer2005DDLGenerator.class.getName()),
+        SQL_SERVER("SQL Server", SQLServerDDLGenerator.class.getName());
+
+        private String name;
+        private String ddlClassName;
+
+        private KnownDDLGenerators(String name, String ddlClassName) {
+            this.name = name;
+            this.ddlClassName = ddlClassName;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getDDLClassName() {
+            return ddlClassName;
+        }
+
+        @Override
+        public String toString() {
+            return name;
+        }
+    }
+
+    private class ProfileFunctionTableModel implements TableModel {
+
+ private final List<ProfileFunctionDescriptor> descriptors = new ArrayList<ProfileFunctionDescriptor>(); + private final List<TableModelListener> listeners = new ArrayList<TableModelListener>();
+
+        public void addTableModelListener(TableModelListener l) {
+            listeners.add(l);
+        }
+
+        public Class<?> getColumnClass(int columnIndex) {
+            if (columnIndex == 0 || columnIndex == 1) {
+                return String.class;
+            } else if (columnIndex == 2) {
+                return JComboBox.class;
+            } else if (columnIndex >= 3 && columnIndex <= 10) {
+                return Boolean.class;
+            } else {
+                return null;
+            }
+        }
+
+        public int getColumnCount() {
+            return 11;
+        }
+
+        public String getColumnName(int columnIndex) {
+            if (columnIndex == 0) {
+                return "Architect Name";
+            } else if (columnIndex == 1) {
+                return "Data Type Name";
+            } else if (columnIndex == 2) {
+                return "Java Code";
+            } else if (columnIndex == 3) {
+                return "Allow Count Distinct";
+            } else if (columnIndex == 4) {
+                return "Allow Max Value";
+            } else if (columnIndex == 5) {
+                return "Allow Min Value";
+            } else if (columnIndex == 6) {
+                return "Allow Avg Value";
+            } else if (columnIndex == 7) {
+                return "Allow Max Length";
+            } else if (columnIndex == 8) {
+                return "Allow Min Length";
+            } else if (columnIndex == 9) {
+                return "Allow Avg Length";
+            } else if (columnIndex == 10) {
+                return "Allow Sum Decode";
+            } else {
+                return null;
+            }
+        }
+
+        public int getRowCount() {
+            return descriptors.size();
+        }
+
+        public Object getValueAt(int rowIndex, int columnIndex) {
+            ProfileFunctionDescriptor pfd = descriptors.get(rowIndex);
+            if (columnIndex == 0) {
+                return pfd.getArchitectSpecificName();
+            } else if (columnIndex == 1) {
+                return pfd.getDataTypeName();
+            } else if (columnIndex == 2) {
+                return SQLType.getType(pfd.getDataTypeCode());
+            } else if (columnIndex == 3) {
+                return pfd.isCountDist();
+            } else if (columnIndex == 4) {
+                return pfd.isMaxValue();
+            } else if (columnIndex == 5) {
+                return pfd.isMinValue();
+            } else if (columnIndex == 6) {
+                return pfd.isAvgValue();
+            } else if (columnIndex == 7) {
+                return pfd.isMaxLength();
+            } else if (columnIndex == 8) {
+                return pfd.isMinLength();
+            } else if (columnIndex == 9) {
+                return pfd.isAvgLength();
+            } else if (columnIndex == 10) {
+                return pfd.isSumDecode();
+            } else {
+                return null;
+            }
+        }
+
+        public boolean isCellEditable(int rowIndex, int columnIndex) {
+            return true;
+        }
+
+        public void removeTableModelListener(TableModelListener l) {
+            listeners.remove(l);
+        }
+
+ public void setValueAt(Object value, int rowIndex, int columnIndex) {
+            ProfileFunctionDescriptor pfd = descriptors.get(rowIndex);
+            if (columnIndex == 0) {
+                pfd.setArchitectSpecificName((String) value);
+            } else if (columnIndex == 1) {
+                pfd.setDataTypeName((String) value);
+            } else if (columnIndex == 2) {
+                pfd.setDataTypeCode(((SQLType) value).getType());
+            } else if (columnIndex == 3) {
+                pfd.setCountDist((Boolean) value);
+            } else if (columnIndex == 4) {
+                pfd.setMaxValue((Boolean) value);
+            } else if (columnIndex == 5) {
+                pfd.setMinValue((Boolean) value);
+            } else if (columnIndex == 6) {
+                pfd.setAvgValue((Boolean) value);
+            } else if (columnIndex == 7) {
+                pfd.setMaxLength((Boolean) value);
+            } else if (columnIndex == 8) {
+                pfd.setMinLength((Boolean) value);
+            } else if (columnIndex == 9) {
+                pfd.setAvgLength((Boolean) value);
+            } else if (columnIndex == 10) {
+                pfd.setSumDecode((Boolean) value);
+            }
+            for (int i = listeners.size() -1; i >= 0; i--) {
+ listeners.get(i).tableChanged(new TableModelEvent(this, rowIndex));
+            }
+        }
+
+ public void addProfileFunctionDescriptor(ProfileFunctionDescriptor pfd) {
+            descriptors.add(pfd);
+            for (int i = listeners.size() -1; i >= 0; i--) {
+                listeners.get(i).tableChanged(new TableModelEvent(this));
+            }
+        }
+
+ public ProfileFunctionDescriptor removeProfileFunctionDescriptor(int rowIndex) {
+            ProfileFunctionDescriptor pfd = descriptors.remove(rowIndex);
+            for (int i = listeners.size() -1; i >= 0; i--) {
+                listeners.get(i).tableChanged(new TableModelEvent(this));
+            }
+            return pfd;
+        }
+
+ public List<ProfileFunctionDescriptor> getProfileFunctionDescriptors() {
+            return Collections.unmodifiableList(descriptors);
+        }
+
+    }
+
+    private JPanel panel;
+
+    private SPDataSourceType currentDSType;
+
+    private final JTextField averageSQLFunctionField = new JTextField();
+    private final JTextField stringLengthSQLFuncField = new JTextField();
+    private final JTextField caseWhenNullSQLFuncField = new JTextField();
+ private final JCheckBox updatableRSField = new JCheckBox("Supports Updatable Result Sets"); + private final JComboBox ddlGeneratorCombo = new JComboBox(KnownDDLGenerators.values());
+
+    /**
+ * This is the table model displaying all of the profile function descriptors for editing.
+     */
+    private ProfileFunctionTableModel profileFunctionTableModel;
+
+    /**
+ * This is the table model displaying all of the index types for the current database type
+     * for editing.
+     */
+    private DefaultTableModel indexTableModel;
+
+    public ArchitectPropertiesDataSourceTypeOptionPanel() {
+        panel = new JPanel(new BorderLayout());
+        panel.setPreferredSize(new Dimension(100, 100));
+    }
+
+    public void editDsType(SPDataSourceType dsType) {
+        if (dsType == null) {
+            panel.removeAll();
+            return;
+        }
+
+        averageSQLFunctionField.setText("");
+        stringLengthSQLFuncField.setText("");
+        caseWhenNullSQLFuncField.setText("");
+        updatableRSField.setSelected(false);
+        ddlGeneratorCombo.setSelectedItem(KnownDDLGenerators.GENERIC);
+
+        currentDSType = dsType;
+        profileFunctionTableModel = new ProfileFunctionTableModel();
+ final JTable profileFunctionTable = new JTable(profileFunctionTableModel); + profileFunctionTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + profileFunctionTable.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(new JComboBox(SQLType.getTypes())));
+
+        indexTableModel = new DefaultTableModel();
+        indexTableModel.addColumn("Index Type");
+        JTable indexTypeJTable = new JTable(indexTableModel);
+ indexTypeJTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+
+        for (String property : dsType.getPropertyNames()) {
+            if (property.contains("architect")) {
+ if (property.contains("ca.sqlpower.architect.etl.kettle")) { + //Kettle has it's own tab so we will let those properties be defined there. + } else if (property.contains(ProfileFunctionDescriptor.class.getName())) {
+                    String descriptorString = dsType.getProperty(property);
+ final ProfileFunctionDescriptor pfd = ProfileFunctionDescriptor.parseDescriptorString(descriptorString); + profileFunctionTableModel.addProfileFunctionDescriptor(pfd); + } else if (property.contains(ColumnProfileResult.class.getName())) { + if (property.equals(RemoteDatabaseProfileCreator.propName(AverageSQLFunction.class))) { + averageSQLFunctionField.setText(dsType.getProperty(property)); + } else if (property.equals(RemoteDatabaseProfileCreator.propName(StringLengthSQLFunction.class))) { + stringLengthSQLFuncField.setText(dsType.getProperty(property)); + } else if (property.equals(RemoteDatabaseProfileCreator.propName(CaseWhenNullSQLFunction.class))) { + caseWhenNullSQLFuncField.setText(dsType.getProperty(property));
+                    } else {
+ throw new IllegalStateException("No editor defined for the data source type property " + property);
+                    }
+ } else if (property.contains(SQLIndex.INDEX_TYPE_DESCRIPTOR)) { + indexTableModel.addRow(new String[] {dsType.getProperty(property)});
+                } else {
+ throw new IllegalStateException("No editor defined for the data source type property " + property);
+                }
+ } else if (property.equals(SPDataSourceType.SUPPORTS_UPDATEABLE_RESULT_SETS)) { + updatableRSField.setSelected(Boolean.parseBoolean(dsType.getProperty(property)));
+            } else if (property.equals(SPDataSourceType.DDL_GENERATOR)) {
+ ddlGeneratorCombo.setSelectedItem(KnownDDLGenerators.GENERIC); + for (KnownDDLGenerators ddlg : KnownDDLGenerators.values()) { + if (dsType.getProperty(property).equals(ddlg.getDDLClassName())) {
+                        ddlGeneratorCombo.setSelectedItem(ddlg);
+                        break;
+                    }
+                }
+            }
+        }
+
+ JComponent addRemoveProfileFunctionBar = new JPanel(new FlowLayout(FlowLayout.LEFT)); + addRemoveProfileFunctionBar.add(new JButton(new AbstractAction("", new AddRemoveIcon(AddRemoveIcon.Type.ADD)) {
+            public void actionPerformed(ActionEvent e) {
+ ProfileFunctionDescriptor pfd = new ProfileFunctionDescriptor("", SQLType.getTypes()[0].getType(), false, false, false, false, false, false, false, false);
+                pfd.setArchitectSpecificName("");
+ profileFunctionTableModel.addProfileFunctionDescriptor(pfd);
+            }
+        }));
+ addRemoveProfileFunctionBar.add(new JButton(new AbstractAction("", new AddRemoveIcon(AddRemoveIcon.Type.REMOVE)) {
+            public void actionPerformed(ActionEvent e) {
+ int[] selectedRows = profileFunctionTable.getSelectedRows();
+                for (int i = selectedRows.length - 1; i >= 0; i--) {
+ profileFunctionTableModel.removeProfileFunctionDescriptor(selectedRows[i]);
+                }
+            }
+        }));
+
+ JComponent addRemoveIndexBar = new JPanel(new FlowLayout(FlowLayout.LEFT)); + addRemoveIndexBar.add(new JButton(new AbstractAction("", new AddRemoveIcon(AddRemoveIcon.Type.ADD)){
+            public void actionPerformed(ActionEvent e) {
+                indexTableModel.addRow(new String[] {""});
+            }
+        }));
+ addRemoveIndexBar.add(new JButton(new AbstractAction("", new AddRemoveIcon(AddRemoveIcon.Type.REMOVE)) {
+            public void actionPerformed(ActionEvent e) {
+ int [] selectedRows = profileFunctionTable.getSelectedRows();
+                for (int i = selectedRows.length - 1; i >= 0; i--) {
+                    indexTableModel.removeRow(selectedRows[i]);
+                }
+            }
+        }));
+
+        panel.removeAll();
+ DefaultFormBuilder fb = new DefaultFormBuilder(new FormLayout("pref, 4dlu, pref:grow"));
+        fb.append("", updatableRSField);
+        fb.nextLine();
+        fb.append("DDL Generator", ddlGeneratorCombo);
+        fb.nextLine();
+        fb.append("Average SQL Function", averageSQLFunctionField);
+        fb.nextLine();
+        fb.append("String Length SQL Function", stringLengthSQLFuncField);
+        fb.nextLine();
+        fb.append("Case When Null SQL Function", caseWhenNullSQLFuncField);
+        fb.nextLine();
+        fb.append(new JScrollPane(profileFunctionTable), 3);
+        fb.nextLine();
+        fb.append(addRemoveProfileFunctionBar, 3);
+        fb.nextLine();
+        JScrollPane indexScrollPane = new JScrollPane(indexTypeJTable);
+ indexScrollPane.setPreferredSize(new Dimension((int) indexScrollPane.getPreferredSize().getWidth(), indexTypeJTable.getRowHeight() * 5));
+        fb.append(indexScrollPane, 3);
+        fb.nextLine();
+        fb.append(addRemoveIndexBar, 3);
+        panel.add(new JScrollPane(fb.getPanel()), BorderLayout.CENTER);
+    }
+
+    public boolean applyChanges() {
+        if (currentDSType == null) {
+            return true;
+        }
+
+ currentDSType.putProperty(SPDataSourceType.DDL_GENERATOR, ((KnownDDLGenerators) ddlGeneratorCombo.getSelectedItem()).getDDLClassName()); + currentDSType.putProperty(SPDataSourceType.SUPPORTS_UPDATEABLE_RESULT_SETS, new Boolean(updatableRSField.isSelected()).toString()); + currentDSType.putProperty(RemoteDatabaseProfileCreator.propName(AverageSQLFunction.class), averageSQLFunctionField.getText()); + currentDSType.putProperty(RemoteDatabaseProfileCreator.propName(StringLengthSQLFunction.class), stringLengthSQLFuncField.getText()); + currentDSType.putProperty(RemoteDatabaseProfileCreator.propName(CaseWhenNullSQLFunction.class), caseWhenNullSQLFuncField.getText());
+
+ for (int i = 0; i < profileFunctionTableModel.getProfileFunctionDescriptors().size(); i++) { + currentDSType.putProperty(ProfileFunctionDescriptor.class.getName() + "_" + i, ProfileFunctionDescriptor.createDescriptorString(profileFunctionTableModel.getProfileFunctionDescriptors().get(i)));
+        }
+
+        for (int i = 0; i < indexTableModel.getRowCount(); i++) {
+ currentDSType.putProperty(SQLIndex.INDEX_TYPE_DESCRIPTOR + "_" + i, (String) indexTableModel.getValueAt(i, 0));
+        }
+
+        return true;
+    }
+
+    public void discardChanges() {
+        //No action.
+    }
+
+    public JComponent getPanel() {
+        return panel;
+    }
+
+    public boolean hasUnsavedChanges() {
+        return true;
+    }
+
+}

Modified: trunk/src/ca/sqlpower/architect/swingui/PreferencesEditor.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/PreferencesEditor.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/PreferencesEditor.java Thu Dec 4 15:33:35 2008
@@ -87,6 +87,10 @@

dsTypeEditor.addTab(Messages.getString("PreferencesEditor.kettleSection"), kettleOptsPanel); //$NON-NLS-1$

+ final ArchitectPropertiesDataSourceTypeOptionPanel architectPropPanel = new ArchitectPropertiesDataSourceTypeOptionPanel();
+
+ dsTypeEditor.addTab(Messages.getString("PreferencesEditor.propertiesSection"), architectPropPanel);
+
tp.add(Messages.getString("PreferencesEditor.jdbcDriversSection"), dsTypeEditor.getPanel()); //$NON-NLS-1$



Modified: trunk/src/ca/sqlpower/architect/swingui/messages.properties
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/messages.properties (original)
+++ trunk/src/ca/sqlpower/architect/swingui/messages.properties Thu Dec 4 15:33:35 2008
@@ -226,6 +226,7 @@
 PreferencesPanel.onOption=On
 PreferencesPanel.playpenAntialiasingLabel=Antialiased Rendering in PlayPen
 PreferencesPanel.plDotIniFileLabel=PL.INI File
+PreferencesEditor.propertiesSection=Advanced Properties
 PreferencesPanel.showWelcomScreenLabel=Show Welcome Screen
 PreferencesPanel.yesOption=Yes
 PrintPanel.changePageFormatLabel=Change Page Format

Reply via email to