Update of /cvsroot/squirrel-sql/sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22778
Modified Files:
DTProperties.java
Log Message:
get Control Panels from data types
Index: DTProperties.java
===================================================================
RCS file: /cvsroot/squirrel-sql/sql12/fw/src/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/DTProperties.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DTProperties.java 12 May 2004 17:33:28 -0000 1.1
--- DTProperties.java 13 May 2004 00:30:44 -0000 1.2
***************
*** 57,60 ****
--- 57,64 ----
import java.util.Iterator;
+ import java.lang.reflect.Method;
+
+ import javax.swing.JPanel;
+
public class DTProperties {
***************
*** 174,176 ****
--- 178,212 ----
return (String)h.get(propertyName);
}
+
+ /**
+ * Get the panels containing the controls needed to adjust all of the properties.
+ * This assumes that the only DataTypes that want to put up control panels
+ * are the ones that have properties to be adjusted.
+ * We do not assume that all properties require a panel.
+ * When this method calls the DataType class to get the panel, the class may return null.
+ */
+ public static JPanel[] getControlPanels() {
+ ArrayList panelList = new ArrayList();
+
+ // get a unique set of names of classes with properties
+ Iterator classNames = dataTypes.keySet().iterator();
+
+ // run through the list getting the panel from each of the named classes
+ while (classNames.hasNext()) {
+ String className = (String)classNames.next();
+ 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]);
+ }
}
|