Update of /cvsroot/squirrel-sql/sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22065
Modified Files:
CellComponentFactory.java
Log Message:
add getControlPanels so panels can be found before instances of DataTypes created
Index: CellComponentFactory.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/CellComponentFactory.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** CellComponentFactory.java 11 May 2004 14:26:57 -0000 1.23
--- CellComponentFactory.java 13 May 2004 17:01:26 -0000 1.24
***************
*** 8,11 ****
--- 8,13 ----
import javax.swing.JTextArea;
import javax.swing.JLabel;
+ import javax.swing.JPanel;
+
import java.awt.Component;
import java.sql.Types;
***************
*** 19,24 ****
--- 21,30 ----
import java.io.IOException;
import java.lang.reflect.Constructor;
+ import java.lang.reflect.Method;
import java.util.HashMap;
+ import java.util.ArrayList;
+ import java.util.Iterator;
+ import java.util.Arrays;
import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DefaultColumnRenderer;
***************
*** 653,657 ****
--- 659,722 ----
}
}
+
+ /*
+ * Get control panels to let user adjust properties
+ * on DataType classes.
+ */
+
+ /**
+ * Get the Control Panels (JPanels containing controls) that let the
+ * user adjust the properties of static properties in specific DataTypes.
+ * The only DataType objects checked for here are:
+ * - those that are registered through the registerDataType method, and
+ * - those that are specifically listed in the variable initialClassNameList
+ */
+ public static JPanel[] getControlPanels() {
+ ArrayList panelList = new ArrayList();
+
+ /*
+ * This is the list of names of classes that:
+ * - support standard SQL type codes and thus do not need to be registered
+ * - provide the getControlPanel method to allow manipulation of properties
+ * These classes should all be named
+ * net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeXXXX
+ * because they are part of the standard delivery of the product, and thus should
+ * be local to this directory.
+ */
+ String [] initialClassNameList = {
+ "net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeBlob",
+ "net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeClob",
+ "net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeOther",
+ "net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeUnknown",
+ };
+
+ // make a single list of all class names that we need to check.
+ // Start with the names of known, standard classes that provide Control Panels
+ ArrayList classNameList = new ArrayList(Arrays.asList(initialClassNameList));
+
+ // add to that the list of all names that have been registered by plugins
+ Iterator classNames = _registeredDataTypes.keySet().iterator();
+ while (classNames.hasNext())
+ classNameList.add(classNames.next());
+
+ // Now go through the list in the given order to get the panels
+ for (int i=0; i< classNameList.size(); i++) {
+ String className = (String)classNameList.get(i);
+ Class[] parameterTypes = new Class[0];
+ try {
+ Method panelMethod =
+ Class.forName(className).getMethod("getControlPanel", parameterTypes);
+
+ JPanel panel = (JPanel)panelMethod.invoke(null, null);
+ panelList.add(panel);
+ }
+ catch (Exception e) {
+ // assume that errors here are not fatal and ignore them??
+ }
+ }
+
+ return (JPanel[])panelList.toArray(new JPanel[0]);
+ }
|