01: package com.xoetrope.sql.test;
02:
03: import java.awt.Frame;
04:
05: import junit.framework.TestCase;
06: import net.xoetrope.awt.XEdit;
07: import net.xoetrope.awt.XTable;
08: import net.xoetrope.optional.data.XTableTableBinding;
09: import net.xoetrope.optional.data.sql.ConnectionManager;
10: import net.xoetrope.optional.data.sql.DatabaseTableModel;
11: import net.xoetrope.xui.XProject;
12: import net.xoetrope.xui.XProjectManager;
13: import net.xoetrope.xui.data.XModel;
14: import net.xoetrope.xui.data.XTextBinding;
15:
16: /**
17: * A test for XTable bindings
18: * <p>Copyright (c) Xoetrope Ltd. 2001-2004</p>
19: * $Revision: 1.1 $
20: */
21: public class XGridTest extends TestCase {
22: private Frame frame;
23: private DatabaseTableModel tableModel;
24:
25: public XGridTest() {
26: }
27:
28: public void setUp() {
29: XProject project = XProjectManager.getCurrentProject();
30: project.initialise("");
31: }
32:
33: public void testTable() {
34: XTable table = new XTable();
35:
36: table.setStyle("base/TableData");
37: table.setHeaderStyle("base/TableHeading");
38: XTableTableBinding binding = new XTableTableBinding(table,
39: createDataSource());
40:
41: frame = new Frame("XDataGrid test");
42: frame.setLayout(null);
43: frame.setSize(640, 480);
44: table.setBounds(20, 80, 500, 300);
45: table.setBackground(java.awt.Color.white);
46: frame.add(table);
47:
48: XEdit edit = new XEdit();
49: XModel fieldModel = (XModel) tableModel.get("NAME");
50: XTextBinding textBinding = new XTextBinding(edit, "",
51: fieldModel);
52: edit.setBounds(10, 10, 100, 30);
53: frame.add(edit);
54:
55: frame.setVisible(true);
56: frame.show();
57:
58: textBinding.get();
59: }
60:
61: public DatabaseTableModel createDataSource() {
62: String fields[] = { "ID", "NAME", "C_GOODS_BF", "C_GOODS_BF",
63: "DHSL" };
64:
65: ConnectionManager.getInstance().reset("org.hsqldb.jdbcDriver",
66: "jdbc:hsqldb:hsql://localhost", "sa", "");
67: tableModel = new DatabaseTableModel();
68: tableModel.setupTable("CS_FROZEN_GOODS_OLD");
69: tableModel.retrieve();
70: return tableModel;
71: }
72: }
|