Revision 33590
tags/tmp_build/libraries/libGDBMS/compile.xml | ||
---|---|---|
1 |
<project name="all" default="compile-javacc" basedir="."> |
|
2 |
|
|
3 |
<target name="init"> |
|
4 |
<tstamp/> |
|
5 |
<property environment="env"/> |
|
6 |
<property name="src" value="src"/> |
|
7 |
<property name="build" value="bin"/> |
|
8 |
<property name="doc" value="/home/andrew/doc/html/javadoc" /> |
|
9 |
<property name="javacchome" value="C:/software/javacc-3.2"/> |
|
10 |
<!-- <property name="build.compiler" value="jikes" /> |
|
11 |
<property name="junitclasspath" value="/home/andrew/junit3.8.1/junit.jar"/> |
|
12 |
<property name="classpath" value="${junitclasspath}:${build}"/>--> |
|
13 |
<!-- <echo message="classpath: ${classpath}"/> --> |
|
14 |
</target> |
|
15 |
|
|
16 |
<target name="clean" depends="init"> |
|
17 |
<delete> |
|
18 |
<fileset dir="${build}"/> |
|
19 |
</delete> |
|
20 |
</target> |
|
21 |
|
|
22 |
<target name="compile-javacc" depends="init"> |
|
23 |
<delete failonerror="true"> |
|
24 |
<fileset dir="${src}/com/hardcode/gdbms/parser"> |
|
25 |
<include name="*.java"/> |
|
26 |
</fileset> |
|
27 |
</delete> |
|
28 |
<!-- <jjtree target="${src}/com/hardcode/gdbms/parser/sql.jj" |
|
29 |
static="no" |
|
30 |
nodescopehook="true" |
|
31 |
javacchome="${javacchome}"/>--> |
|
32 |
<javacc target="${src}/com/hardcode/gdbms/parser/sql.jj" |
|
33 |
static="no" |
|
34 |
javacchome="${javacchome}"/> |
|
35 |
</target> |
|
36 |
<!-- |
|
37 |
<target name="doc-public" depends="init"> |
|
38 |
<delete> |
|
39 |
<fileset dir="${doc}/public"/> |
|
40 |
</delete> |
|
41 |
<javadoc packagenames="org.acooke.*" |
|
42 |
sourcepath="${src}" |
|
43 |
destdir="${doc}/public" |
|
44 |
public="true"> |
|
45 |
<doctitle><![CDATA[<h1>org.acooke - public</h1>]]></doctitle> |
|
46 |
</javadoc> |
|
47 |
</target> |
|
48 |
|
|
49 |
<target name="doc-package" depends="init"> |
|
50 |
<delete> |
|
51 |
<fileset dir="${doc}/package"/> |
|
52 |
</delete> |
|
53 |
<javadoc packagenames="org.acooke.*" |
|
54 |
sourcepath="${src}" |
|
55 |
destdir="${doc}/package" |
|
56 |
package="true"> |
|
57 |
<doctitle><![CDATA[<h1>org.acooke - package</h1>]]></doctitle> |
|
58 |
</javadoc> |
|
59 |
</target> |
|
60 |
|
|
61 |
<target name="doc-private" depends="init"> |
|
62 |
<delete> |
|
63 |
<fileset dir="${doc}/private"/> |
|
64 |
</delete> |
|
65 |
<javadoc packagenames="org.acooke.*" |
|
66 |
sourcepath="${src}" |
|
67 |
destdir="${doc}/private" |
|
68 |
private="true"> |
|
69 |
<doctitle><![CDATA[<h1>org.acooke - private</h1>]]></doctitle> |
|
70 |
</javadoc> |
|
71 |
</target> |
|
72 |
|
|
73 |
<target name="doc" depends="init"> |
|
74 |
<parallel> |
|
75 |
<antcall target="doc-private"/> |
|
76 |
<antcall target="doc-package"/> |
|
77 |
<antcall target="doc-public"/> |
|
78 |
</parallel> |
|
79 |
</target> |
|
80 |
--> |
|
81 |
</project> |
|
0 | 82 |
tags/tmp_build/libraries/libGDBMS/src/test/resources/union.txt | ||
---|---|---|
1 |
ID NOMBRE APELLIDO 0 fernando gonzalez 1 hurac?n gonsales 2 fernan 0 fernando gonzalez 1 hurac?n gonsales 2 fernan |
|
0 | 2 |
tags/tmp_build/libraries/libGDBMS/src/test/resources/.cvsignore | ||
---|---|---|
1 |
testdb.* |
|
2 |
persona.csv |
|
0 | 3 |
tags/tmp_build/libraries/libGDBMS/src/test/resources/select.txt | ||
---|---|---|
1 |
APELLIDO PK gonzalez 0 |
|
0 | 2 |
tags/tmp_build/libraries/libGDBMS/src/test/java/log4j.properties | ||
---|---|---|
1 |
log4j.rootLogger=debug, stdout |
|
2 |
|
|
3 |
log4j.appender.stdout=org.apache.log4j.ConsoleAppender |
|
4 |
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout |
|
5 |
|
|
6 |
# Pattern to output the caller's file name and line number. |
|
7 |
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n |
|
8 |
|
|
0 | 9 |
tags/tmp_build/libraries/libGDBMS/src/test/java/com/hardcode/gdbms/gui/GDBMSTableModel.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 12-oct-2004 |
|
3 |
*/ |
|
4 |
package com.hardcode.gdbms.gui; |
|
5 |
|
|
6 |
import javax.swing.table.AbstractTableModel; |
|
7 |
|
|
8 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
9 |
import com.hardcode.gdbms.engine.data.DataSource; |
|
10 |
|
|
11 |
|
|
12 |
/** |
|
13 |
* DOCUMENT ME! |
|
14 |
* |
|
15 |
* @author Fernando Gonz?lez Cort?s |
|
16 |
*/ |
|
17 |
public class GDBMSTableModel extends AbstractTableModel { |
|
18 |
private DataSource source; |
|
19 |
|
|
20 |
/** |
|
21 |
* Crea un nuevo GDBMSTableModel. |
|
22 |
*/ |
|
23 |
public GDBMSTableModel() { |
|
24 |
} |
|
25 |
|
|
26 |
/** |
|
27 |
* Crea un nuevo GDBMSTableModel. |
|
28 |
* |
|
29 |
* @param ds DOCUMENT ME! |
|
30 |
*/ |
|
31 |
public GDBMSTableModel(DataSource ds) { |
|
32 |
source = ds; |
|
33 |
} |
|
34 |
|
|
35 |
/** |
|
36 |
* DOCUMENT ME! |
|
37 |
* |
|
38 |
* @param ds DOCUMENT ME! |
|
39 |
*/ |
|
40 |
public void setDataSource(DataSource ds) { |
|
41 |
source = ds; |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* @see javax.swing.table.TableModel#getColumnCount() |
|
46 |
*/ |
|
47 |
public int getColumnCount() { |
|
48 |
try { |
|
49 |
return source.getFieldCount(); |
|
50 |
} catch (ReadDriverException e) { |
|
51 |
return 0; |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* @see javax.swing.table.TableModel#getRowCount() |
|
57 |
*/ |
|
58 |
public int getRowCount() { |
|
59 |
try { |
|
60 |
return (int) source.getRowCount(); |
|
61 |
} catch (ReadDriverException e) { |
|
62 |
return 0; |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* @see javax.swing.table.TableModel#getValueAt(int, int) |
|
68 |
*/ |
|
69 |
public Object getValueAt(int arg0, int arg1) { |
|
70 |
try { |
|
71 |
return source.getFieldValue(arg0, arg1); |
|
72 |
} catch (Exception e) { |
|
73 |
e.printStackTrace(); |
|
74 |
|
|
75 |
return e.getMessage(); |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* DOCUMENT ME! |
|
81 |
* |
|
82 |
* @return Returns the source. |
|
83 |
*/ |
|
84 |
public DataSource getDataSource() { |
|
85 |
return source; |
|
86 |
} |
|
87 |
} |
|
0 | 88 |
tags/tmp_build/libraries/libGDBMS/src/test/java/com/hardcode/gdbms/gui/ParseTreeFrame.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 12-oct-2004 |
|
3 |
*/ |
|
4 |
package com.hardcode.gdbms.gui; |
|
5 |
|
|
6 |
import javax.swing.JFrame; |
|
7 |
import javax.swing.JScrollPane; |
|
8 |
import javax.swing.JTree; |
|
9 |
import javax.swing.tree.TreeModel; |
|
10 |
|
|
11 |
|
|
12 |
/** |
|
13 |
* DOCUMENT ME! |
|
14 |
* |
|
15 |
* @author Fernando Gonz?lez Cort?s |
|
16 |
*/ |
|
17 |
public class ParseTreeFrame extends JFrame { |
|
18 |
private javax.swing.JPanel jContentPane = null; |
|
19 |
private JScrollPane jScrollPane = null; |
|
20 |
private JTree tree = null; |
|
21 |
|
|
22 |
/** |
|
23 |
* This is the default constructor |
|
24 |
*/ |
|
25 |
public ParseTreeFrame() { |
|
26 |
super(); |
|
27 |
initialize(); |
|
28 |
} |
|
29 |
|
|
30 |
/** |
|
31 |
* DOCUMENT ME! |
|
32 |
* |
|
33 |
* @param tm DOCUMENT ME! |
|
34 |
*/ |
|
35 |
public void setTreeModel(TreeModel tm) { |
|
36 |
getTree().setModel(tm); |
|
37 |
} |
|
38 |
|
|
39 |
/** |
|
40 |
* This method initializes this |
|
41 |
*/ |
|
42 |
private void initialize() { |
|
43 |
this.setSize(300, 200); |
|
44 |
this.setContentPane(getJContentPane()); |
|
45 |
this.setTitle("JFrame"); |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* This method initializes jContentPane |
|
50 |
* |
|
51 |
* @return javax.swing.JPanel |
|
52 |
*/ |
|
53 |
private javax.swing.JPanel getJContentPane() { |
|
54 |
if (jContentPane == null) { |
|
55 |
jContentPane = new javax.swing.JPanel(); |
|
56 |
jContentPane.setLayout(new java.awt.BorderLayout()); |
|
57 |
jContentPane.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
|
58 |
} |
|
59 |
|
|
60 |
return jContentPane; |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* This method initializes jScrollPane |
|
65 |
* |
|
66 |
* @return javax.swing.JScrollPane |
|
67 |
*/ |
|
68 |
private JScrollPane getJScrollPane() { |
|
69 |
if (jScrollPane == null) { |
|
70 |
jScrollPane = new JScrollPane(); |
|
71 |
jScrollPane.setViewportView(getTree()); |
|
72 |
} |
|
73 |
|
|
74 |
return jScrollPane; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* This method initializes tree |
|
79 |
* |
|
80 |
* @return javax.swing.JTree |
|
81 |
*/ |
|
82 |
private JTree getTree() { |
|
83 |
if (tree == null) { |
|
84 |
tree = new JTree(); |
|
85 |
} |
|
86 |
|
|
87 |
return tree; |
|
88 |
} |
|
89 |
} |
|
0 | 90 |
tags/tmp_build/libraries/libGDBMS/src/test/java/com/hardcode/gdbms/gui/IndexedGDBMSTableModel.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 12-oct-2004 |
|
3 |
*/ |
|
4 |
package com.hardcode.gdbms.gui; |
|
5 |
|
|
6 |
import javax.swing.table.AbstractTableModel; |
|
7 |
|
|
8 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
9 |
import com.hardcode.gdbms.engine.data.DataSource; |
|
10 |
import com.hardcode.gdbms.engine.data.indexes.FixedIndexSet; |
|
11 |
|
|
12 |
|
|
13 |
/** |
|
14 |
* DOCUMENT ME! |
|
15 |
* |
|
16 |
* @author Fernando Gonz?lez Cort?s |
|
17 |
*/ |
|
18 |
public class IndexedGDBMSTableModel extends AbstractTableModel { |
|
19 |
private DataSource source; |
|
20 |
private FixedIndexSet fis; |
|
21 |
|
|
22 |
/** |
|
23 |
* Crea un nuevo IndexedGDBMSTableModel. |
|
24 |
* |
|
25 |
* @param ds DOCUMENT ME! |
|
26 |
* @param fis DOCUMENT ME! |
|
27 |
*/ |
|
28 |
public IndexedGDBMSTableModel(DataSource ds, FixedIndexSet fis) { |
|
29 |
source = ds; |
|
30 |
this.fis = fis; |
|
31 |
} |
|
32 |
|
|
33 |
/** |
|
34 |
* DOCUMENT ME! |
|
35 |
* |
|
36 |
* @param ds DOCUMENT ME! |
|
37 |
*/ |
|
38 |
public void setDataSource(DataSource ds) { |
|
39 |
source = ds; |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* @see javax.swing.table.TableModel#getColumnCount() |
|
44 |
*/ |
|
45 |
public int getColumnCount() { |
|
46 |
try { |
|
47 |
return source.getFieldCount(); |
|
48 |
} catch (ReadDriverException e) { |
|
49 |
return 0; |
|
50 |
} |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* @see javax.swing.table.TableModel#getRowCount() |
|
55 |
*/ |
|
56 |
public int getRowCount() { |
|
57 |
try { |
|
58 |
return (int) source.getRowCount(); |
|
59 |
} catch (ReadDriverException e) { |
|
60 |
return 0; |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* @see javax.swing.table.TableModel#getValueAt(int, int) |
|
66 |
*/ |
|
67 |
public Object getValueAt(int arg0, int arg1) { |
|
68 |
try { |
|
69 |
return source.getFieldValue(fis.getIndex(arg0), arg1); |
|
70 |
} catch (Exception e) { |
|
71 |
e.printStackTrace(); |
|
72 |
|
|
73 |
return e.getMessage(); |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* DOCUMENT ME! |
|
79 |
* |
|
80 |
* @return Returns the source. |
|
81 |
*/ |
|
82 |
public DataSource getDataSource() { |
|
83 |
return source; |
|
84 |
} |
|
85 |
} |
|
0 | 86 |
tags/tmp_build/libraries/libGDBMS/src/test/java/com/hardcode/gdbms/gui/GDBMSParseTreeModel.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 12-oct-2004 |
|
3 |
*/ |
|
4 |
package com.hardcode.gdbms.gui; |
|
5 |
|
|
6 |
import com.hardcode.gdbms.engine.instruction.Utilities; |
|
7 |
import com.hardcode.gdbms.parser.SimpleNode; |
|
8 |
|
|
9 |
import java.util.Enumeration; |
|
10 |
import java.util.Hashtable; |
|
11 |
|
|
12 |
import javax.swing.tree.DefaultTreeModel; |
|
13 |
import javax.swing.tree.TreeNode; |
|
14 |
|
|
15 |
|
|
16 |
/** |
|
17 |
* DOCUMENT ME! |
|
18 |
* |
|
19 |
* @author Fernando Gonz?lez Cort?s |
|
20 |
*/ |
|
21 |
public class GDBMSParseTreeModel extends DefaultTreeModel { |
|
22 |
/** |
|
23 |
* DOCUMENT ME! |
|
24 |
* |
|
25 |
* @param arg0 |
|
26 |
* @param arg1 |
|
27 |
*/ |
|
28 |
public GDBMSParseTreeModel(TreeNode arg0, boolean arg1) { |
|
29 |
super(arg0, arg1); |
|
30 |
} |
|
31 |
|
|
32 |
/** |
|
33 |
* DOCUMENT ME! |
|
34 |
* |
|
35 |
* @param arg0 |
|
36 |
*/ |
|
37 |
public GDBMSParseTreeModel(TreeNode arg0) { |
|
38 |
super(arg0); |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* Crea un nuevo GDBMSParseTreeModel. |
|
43 |
* |
|
44 |
* @param root DOCUMENT ME! |
|
45 |
*/ |
|
46 |
public GDBMSParseTreeModel(SimpleNode root) { |
|
47 |
super(null); |
|
48 |
this.setRoot(new ParseNode(root)); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* DOCUMENT ME! |
|
53 |
* |
|
54 |
* @param root DOCUMENT ME! |
|
55 |
*/ |
|
56 |
public void setTree(SimpleNode root) { |
|
57 |
this.setRoot(new ParseNode(root)); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* DOCUMENT ME! |
|
62 |
* |
|
63 |
* @author Fernando Gonz?lez Cort?s |
|
64 |
*/ |
|
65 |
public class ParseNode implements TreeNode { |
|
66 |
private SimpleNode node; |
|
67 |
|
|
68 |
/** |
|
69 |
* Crea un nuevo ParseNode. |
|
70 |
* |
|
71 |
* @param n DOCUMENT ME! |
|
72 |
*/ |
|
73 |
public ParseNode(SimpleNode n) { |
|
74 |
node = n; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* @see javax.swing.tree.TreeNode#getChildCount() |
|
79 |
*/ |
|
80 |
public int getChildCount() { |
|
81 |
return node.jjtGetNumChildren(); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* @see javax.swing.tree.TreeNode#getAllowsChildren() |
|
86 |
*/ |
|
87 |
public boolean getAllowsChildren() { |
|
88 |
return true; |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* @see javax.swing.tree.TreeNode#isLeaf() |
|
93 |
*/ |
|
94 |
public boolean isLeaf() { |
|
95 |
return node.jjtGetNumChildren() == 0; |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* @see javax.swing.tree.TreeNode#children() |
|
100 |
*/ |
|
101 |
public Enumeration children() { |
|
102 |
Hashtable foo = new Hashtable(); |
|
103 |
|
|
104 |
for (int i = 0; i < node.jjtGetNumChildren(); i++) { |
|
105 |
foo.put(new ParseNode((SimpleNode) node.jjtGetChild(i)), ""); |
|
106 |
} |
|
107 |
|
|
108 |
return foo.keys(); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* @see javax.swing.tree.TreeNode#getParent() |
|
113 |
*/ |
|
114 |
public TreeNode getParent() { |
|
115 |
return new ParseNode((SimpleNode) node.jjtGetParent()); |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* @see javax.swing.tree.TreeNode#getChildAt(int) |
|
120 |
*/ |
|
121 |
public TreeNode getChildAt(int arg0) { |
|
122 |
return new ParseNode((SimpleNode) node.jjtGetChild(arg0)); |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode) |
|
127 |
*/ |
|
128 |
public int getIndex(TreeNode arg0) { |
|
129 |
for (int i = 0; i < node.jjtGetNumChildren(); i++) { |
|
130 |
if (((ParseNode) arg0).node == node) { |
|
131 |
return i; |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
135 |
return -1; |
|
136 |
} |
|
137 |
|
|
138 |
/** |
|
139 |
* DOCUMENT ME! |
|
140 |
* |
|
141 |
* @return DOCUMENT ME! |
|
142 |
*/ |
|
143 |
public String toString() { |
|
144 |
String className = node.getClass().getName(); |
|
145 |
className = className.substring(className.lastIndexOf(".")); |
|
146 |
|
|
147 |
return className + "(" + Utilities.getText(node) + ")"; |
|
148 |
} |
|
149 |
} |
|
150 |
} |
|
0 | 151 |
tags/tmp_build/libraries/libGDBMS/src/test/java/com/hardcode/gdbms/gui/Frame.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 12-oct-2004 |
|
3 |
*/ |
|
4 |
package com.hardcode.gdbms.gui; |
|
5 |
|
|
6 |
import javax.swing.JFrame; |
|
7 |
import javax.swing.JScrollPane; |
|
8 |
import javax.swing.JTable; |
|
9 |
import javax.swing.table.TableModel; |
|
10 |
|
|
11 |
|
|
12 |
/** |
|
13 |
* DOCUMENT ME! |
|
14 |
* |
|
15 |
* @author Fernando Gonz?lez Cort?s |
|
16 |
*/ |
|
17 |
public class Frame extends JFrame { |
|
18 |
private javax.swing.JPanel jContentPane = null; |
|
19 |
private JTable table = null; |
|
20 |
private JScrollPane jScrollPane = null; |
|
21 |
|
|
22 |
/** |
|
23 |
* This is the default constructor |
|
24 |
*/ |
|
25 |
public Frame() { |
|
26 |
super(); |
|
27 |
initialize(); |
|
28 |
} |
|
29 |
|
|
30 |
/** |
|
31 |
* DOCUMENT ME! |
|
32 |
* |
|
33 |
* @param t DOCUMENT ME! |
|
34 |
*/ |
|
35 |
public void setTableModel(TableModel t) { |
|
36 |
getTable().setModel(t); |
|
37 |
} |
|
38 |
|
|
39 |
/** |
|
40 |
* This method initializes this |
|
41 |
*/ |
|
42 |
private void initialize() { |
|
43 |
this.setSize(300, 200); |
|
44 |
this.setContentPane(getJContentPane()); |
|
45 |
this.setTitle("JFrame"); |
|
46 |
this.addWindowListener(new java.awt.event.WindowAdapter() { |
|
47 |
public void windowClosing(java.awt.event.WindowEvent e) { |
|
48 |
try { |
|
49 |
((GDBMSTableModel) getTable().getModel()).getDataSource() |
|
50 |
.stop(); |
|
51 |
} catch (Exception e1) { |
|
52 |
e1.printStackTrace(); |
|
53 |
} |
|
54 |
} |
|
55 |
}); |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* This method initializes jContentPane |
|
60 |
* |
|
61 |
* @return javax.swing.JPanel |
|
62 |
*/ |
|
63 |
private javax.swing.JPanel getJContentPane() { |
|
64 |
if (jContentPane == null) { |
|
65 |
jContentPane = new javax.swing.JPanel(); |
|
66 |
jContentPane.setLayout(new java.awt.BorderLayout()); |
|
67 |
jContentPane.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
|
68 |
} |
|
69 |
|
|
70 |
return jContentPane; |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* This method initializes table |
|
75 |
* |
|
76 |
* @return javax.swing.JTable |
|
77 |
*/ |
|
78 |
private JTable getTable() { |
|
79 |
if (table == null) { |
|
80 |
table = new JTable(); |
|
81 |
} |
|
82 |
|
|
83 |
return table; |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* This method initializes jScrollPane |
|
88 |
* |
|
89 |
* @return javax.swing.JScrollPane |
|
90 |
*/ |
|
91 |
private JScrollPane getJScrollPane() { |
|
92 |
if (jScrollPane == null) { |
|
93 |
jScrollPane = new JScrollPane(); |
|
94 |
jScrollPane.setViewportView(getTable()); |
|
95 |
} |
|
96 |
|
|
97 |
return jScrollPane; |
|
98 |
} |
|
99 |
} |
|
0 | 100 |
tags/tmp_build/libraries/libGDBMS/src/test/java/com/hardcode/gdbms/gui/editingTable/EditingTable.java | ||
---|---|---|
1 |
package com.hardcode.gdbms.gui.editingTable; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Component; |
|
5 |
import java.awt.event.KeyAdapter; |
|
6 |
import java.awt.event.KeyEvent; |
|
7 |
import java.text.ParseException; |
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.EventObject; |
|
10 |
|
|
11 |
import javax.swing.JPanel; |
|
12 |
import javax.swing.JScrollPane; |
|
13 |
import javax.swing.JTable; |
|
14 |
import javax.swing.JTextField; |
|
15 |
import javax.swing.KeyStroke; |
|
16 |
import javax.swing.event.CellEditorListener; |
|
17 |
import javax.swing.event.ChangeEvent; |
|
18 |
import javax.swing.event.TableModelEvent; |
|
19 |
import javax.swing.event.TableModelListener; |
|
20 |
import javax.swing.table.AbstractTableModel; |
|
21 |
import javax.swing.table.TableCellEditor; |
|
22 |
import javax.swing.table.TableModel; |
|
23 |
|
|
24 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
25 |
import com.hardcode.gdbms.driver.exceptions.WriteDriverException; |
|
26 |
import com.hardcode.gdbms.engine.data.DataSource; |
|
27 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
|
28 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
|
29 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
|
30 |
import com.hardcode.gdbms.engine.values.Value; |
|
31 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
32 |
/** |
|
33 |
* @author Fernando Gonz?lez Cort?s |
|
34 |
*/ |
|
35 |
public class EditingTable extends JPanel { |
|
36 |
|
|
37 |
private JTable jTable = null; |
|
38 |
private JScrollPane jScrollPane = null; |
|
39 |
|
|
40 |
private DataSource ds; |
|
41 |
private DataWare dw = null; |
|
42 |
|
|
43 |
public void setDataSource(DataSource ds){ |
|
44 |
this.ds = ds; |
|
45 |
MyCellEditor ce = new MyCellEditor(); |
|
46 |
getJTable().setModel(new DataSourceDataModel()); |
|
47 |
for (int i = 0; i < jTable.getColumnModel().getColumnCount(); i++) { |
|
48 |
jTable.getColumnModel().getColumn(i).setCellEditor(ce); |
|
49 |
} |
|
50 |
getJTable().setCellEditor(ce); |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* This is the default constructor |
|
55 |
*/ |
|
56 |
public EditingTable() { |
|
57 |
super(); |
|
58 |
initialize(); |
|
59 |
} |
|
60 |
/** |
|
61 |
* This method initializes this |
|
62 |
* |
|
63 |
* @return void |
|
64 |
*/ |
|
65 |
private void initialize() { |
|
66 |
this.setLayout(new BorderLayout()); |
|
67 |
this.setSize(300,200); |
|
68 |
this.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
|
69 |
} |
|
70 |
/** |
|
71 |
* This method initializes jTable |
|
72 |
* |
|
73 |
* @return javax.swing.JTable |
|
74 |
*/ |
|
75 |
private JTable getJTable() { |
|
76 |
if (jTable == null) { |
|
77 |
jTable = new JTable() { |
|
78 |
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, |
|
79 |
int condition, boolean pressed) { |
|
80 |
boolean value = super.processKeyBinding( ks, e, |
|
81 |
condition, pressed ); |
|
82 |
|
|
83 |
// Make sure that the editor component has focus. |
|
84 |
if ( isEditing() ) { |
|
85 |
getEditorComponent().requestFocus(); |
|
86 |
} |
|
87 |
return value; |
|
88 |
} |
|
89 |
}; |
|
90 |
} |
|
91 |
return jTable; |
|
92 |
} |
|
93 |
/** |
|
94 |
* This method initializes jScrollPane |
|
95 |
* |
|
96 |
* @return javax.swing.JScrollPane |
|
97 |
*/ |
|
98 |
private JScrollPane getJScrollPane() { |
|
99 |
if (jScrollPane == null) { |
|
100 |
jScrollPane = new JScrollPane(); |
|
101 |
jScrollPane.setViewportView(getJTable()); |
|
102 |
} |
|
103 |
return jScrollPane; |
|
104 |
} |
|
105 |
|
|
106 |
|
|
107 |
/** |
|
108 |
* DOCUMENT ME! |
|
109 |
* |
|
110 |
* @author Fernando Gonz?lez Cort?s |
|
111 |
*/ |
|
112 |
public class DataSourceDataModel extends AbstractTableModel { |
|
113 |
|
|
114 |
public DataSourceDataModel(){ |
|
115 |
this.addTableModelListener(new TableModelListener() { |
|
116 |
public void tableChanged(TableModelEvent e) { |
|
117 |
int row = e.getFirstRow(); |
|
118 |
int field = e.getColumn(); |
|
119 |
TableModel model = (TableModel)e.getSource(); |
|
120 |
String columnName = model.getColumnName(field); |
|
121 |
Object data = model.getValueAt(row, field); |
|
122 |
System.out.println(data); |
|
123 |
} |
|
124 |
}); |
|
125 |
} |
|
126 |
|
|
127 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
128 |
Value v; |
|
129 |
try { |
|
130 |
v = ValueFactory.createValueByType(aValue.toString(), ds.getFieldType(columnIndex)); |
|
131 |
dw.setFieldValue(rowIndex, columnIndex, v); |
|
132 |
} catch (ReadDriverException e1) { |
|
133 |
throw new RuntimeException(e1); |
|
134 |
} catch (ParseException e) { |
|
135 |
throw new RuntimeException(e); |
|
136 |
} catch (WriteDriverException e) { |
|
137 |
throw new RuntimeException(e); |
|
138 |
} |
|
139 |
} |
|
140 |
/** |
|
141 |
* DOCUMENT ME! |
|
142 |
* |
|
143 |
* @param col DOCUMENT ME! |
|
144 |
* |
|
145 |
* @return DOCUMENT ME! |
|
146 |
*/ |
|
147 |
public String getColumnName(int col) { |
|
148 |
try { |
|
149 |
return ds.getFieldName(col).trim(); |
|
150 |
} catch (ReadDriverException e) { |
|
151 |
return e.getMessage(); |
|
152 |
} |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* DOCUMENT ME! |
|
157 |
* |
|
158 |
* @return DOCUMENT ME! |
|
159 |
*/ |
|
160 |
public int getColumnCount() { |
|
161 |
try { |
|
162 |
return ds.getFieldCount(); |
|
163 |
} catch (ReadDriverException e) { |
|
164 |
return 0; |
|
165 |
} |
|
166 |
} |
|
167 |
|
|
168 |
/** |
|
169 |
* DOCUMENT ME! |
|
170 |
* |
|
171 |
* @return DOCUMENT ME! |
|
172 |
*/ |
|
173 |
public int getRowCount() { |
|
174 |
try { |
|
175 |
return (int) ds.getRowCount(); |
|
176 |
} catch (ReadDriverException e) { |
|
177 |
return 0; |
|
178 |
} |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* DOCUMENT ME! |
|
183 |
* |
|
184 |
* @param row DOCUMENT ME! |
|
185 |
* @param col DOCUMENT ME! |
|
186 |
* |
|
187 |
* @return DOCUMENT ME! |
|
188 |
*/ |
|
189 |
public Object getValueAt(int row, int col) { |
|
190 |
try { |
|
191 |
if (dw != null){ |
|
192 |
return dw.getFieldValue(row, col); |
|
193 |
}else{ |
|
194 |
return ds.getFieldValue(row, col); |
|
195 |
} |
|
196 |
} catch (ReadDriverException e) { |
|
197 |
return ValueFactory.createValue("").toString(); |
|
198 |
} |
|
199 |
} |
|
200 |
|
|
201 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
202 |
return true; |
|
203 |
} |
|
204 |
} |
|
205 |
|
|
206 |
|
|
207 |
/** |
|
208 |
* @throws DriverException |
|
209 |
* |
|
210 |
*/ |
|
211 |
public void startEditing() throws ReadDriverException { |
|
212 |
dw = ds.getDataWare(DataSourceFactory.DATA_WARE_COHERENT_ROW_ORDER); |
|
213 |
dw.start(); |
|
214 |
dw.beginTrans(); |
|
215 |
} |
|
216 |
|
|
217 |
public void commit() throws ReadDriverException, WriteDriverException { |
|
218 |
dw.commitTrans(); |
|
219 |
dw.stop(); |
|
220 |
dw = null; |
|
221 |
} |
|
222 |
|
|
223 |
public void rollBack() throws ReadDriverException, WriteDriverException { |
|
224 |
dw.rollBackTrans(); |
|
225 |
dw.stop(); |
|
226 |
dw = null; |
|
227 |
} |
|
228 |
|
|
229 |
public class MyCellEditor extends JTextField implements TableCellEditor { |
|
230 |
|
|
231 |
private ArrayList listeners = new ArrayList(); |
|
232 |
private String initialValue; |
|
233 |
|
|
234 |
public MyCellEditor() { |
|
235 |
addKeyListener(new KeyAdapter() { |
|
236 |
public void keyReleased(KeyEvent e) { |
|
237 |
if (e.getKeyCode() == KeyEvent.VK_ENTER){ |
|
238 |
stopCellEditing(); |
|
239 |
}else if (e.getKeyCode() == KeyEvent.VK_ESCAPE){ |
|
240 |
cancelCellEditing(); |
|
241 |
} |
|
242 |
} |
|
243 |
}); |
|
244 |
} |
|
245 |
|
|
246 |
/** |
|
247 |
* @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int) |
|
248 |
*/ |
|
249 |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
250 |
this.setText(value.toString()); |
|
251 |
return this; |
|
252 |
} |
|
253 |
|
|
254 |
/** |
|
255 |
* @see javax.swing.CellEditor#cancelCellEditing() |
|
256 |
*/ |
|
257 |
public void cancelCellEditing() { |
|
258 |
setText(initialValue); |
|
259 |
for (int i = 0; i < listeners.size(); i++) { |
|
260 |
CellEditorListener l = (CellEditorListener) listeners.get(i); |
|
261 |
ChangeEvent evt = new ChangeEvent(this); |
|
262 |
l.editingCanceled(evt); |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
266 |
/** |
|
267 |
* @see javax.swing.CellEditor#stopCellEditing() |
|
268 |
*/ |
|
269 |
public boolean stopCellEditing() { |
|
270 |
for (int i = 0; i < listeners.size(); i++) { |
|
271 |
CellEditorListener l = (CellEditorListener) listeners.get(i); |
|
272 |
ChangeEvent evt = new ChangeEvent(this); |
|
273 |
l.editingStopped(evt); |
|
274 |
} |
|
275 |
|
|
276 |
return true; |
|
277 |
} |
|
278 |
|
|
279 |
/** |
|
280 |
* @see javax.swing.CellEditor#getCellEditorValue() |
|
281 |
*/ |
|
282 |
public Object getCellEditorValue() { |
|
283 |
return getText(); |
|
284 |
} |
|
285 |
|
|
286 |
/** |
|
287 |
* @see javax.swing.CellEditor#isCellEditable(java.util.EventObject) |
|
288 |
*/ |
|
289 |
public boolean isCellEditable(EventObject anEvent) { |
|
290 |
return true; |
|
291 |
} |
|
292 |
|
|
293 |
/** |
|
294 |
* @see javax.swing.CellEditor#shouldSelectCell(java.util.EventObject) |
|
295 |
*/ |
|
296 |
public boolean shouldSelectCell(EventObject anEvent) { |
|
297 |
return false; |
|
298 |
} |
|
299 |
|
|
300 |
/** |
|
301 |
* @see javax.swing.CellEditor#addCellEditorListener(javax.swing.event.CellEditorListener) |
|
302 |
*/ |
|
303 |
public void addCellEditorListener(CellEditorListener l) { |
|
304 |
listeners.add(l); |
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* @see javax.swing.CellEditor#removeCellEditorListener(javax.swing.event.CellEditorListener) |
|
309 |
*/ |
|
310 |
public void removeCellEditorListener(CellEditorListener l) { |
|
311 |
listeners.remove(l); |
|
312 |
} |
|
313 |
|
|
314 |
} |
|
315 |
|
|
316 |
} |
|
0 | 317 |
tags/tmp_build/libraries/libGDBMS/src/test/java/com/hardcode/gdbms/gui/editingTable/EditingFrame.java | ||
---|---|---|
1 |
package com.hardcode.gdbms.gui.editingTable; |
|
2 |
|
|
3 |
import java.awt.event.WindowAdapter; |
|
4 |
import java.awt.event.WindowEvent; |
|
5 |
|
|
6 |
import javax.swing.JButton; |
|
7 |
import javax.swing.JFrame; |
|
8 |
import javax.swing.JPanel; |
|
9 |
|
|
10 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
11 |
import com.hardcode.gdbms.driver.exceptions.WriteDriverException; |
|
12 |
import com.hardcode.gdbms.engine.data.DataSource; |
|
13 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
|
14 |
import com.hardcode.gdbms.engine.data.SetUp; |
|
15 |
/** |
|
16 |
* @author Fernando Gonz?lez Cort?s |
|
17 |
*/ |
|
18 |
public class EditingFrame extends JFrame { |
|
19 |
|
|
20 |
private javax.swing.JPanel jContentPane = null; |
|
21 |
private EditingTable editingTable = null; |
|
22 |
private JButton jButton = null; |
|
23 |
private JPanel jPanel = null; |
|
24 |
private JButton jButton1 = null; |
|
25 |
/** |
|
26 |
* This is the default constructor |
|
27 |
*/ |
|
28 |
public EditingFrame() { |
|
29 |
super(); |
|
30 |
initialize(); |
|
31 |
} |
|
32 |
/** |
|
33 |
* This method initializes this |
|
34 |
* |
|
35 |
* @return void |
|
36 |
*/ |
|
37 |
private void initialize() { |
|
38 |
this.setSize(1000,200); |
|
39 |
this.setContentPane(getJContentPane()); |
|
40 |
this.setTitle("JFrame"); |
|
41 |
} |
|
42 |
/** |
|
43 |
* This method initializes jContentPane |
|
44 |
* |
|
45 |
* @return javax.swing.JPanel |
|
46 |
*/ |
|
47 |
private javax.swing.JPanel getJContentPane() { |
|
48 |
if(jContentPane == null) { |
|
49 |
jContentPane = new javax.swing.JPanel(); |
|
50 |
jContentPane.setLayout(new java.awt.BorderLayout()); |
|
51 |
jContentPane.add(getEditingTable(), java.awt.BorderLayout.CENTER); |
|
52 |
jContentPane.add(getJPanel(), java.awt.BorderLayout.WEST); |
|
53 |
} |
|
54 |
return jContentPane; |
|
55 |
} |
|
56 |
/** |
|
57 |
* This method initializes editingTable |
|
58 |
* |
|
59 |
* @return com.hardcode.gdbms.gui.editingTable.EditingTable |
|
60 |
*/ |
|
61 |
private EditingTable getEditingTable() { |
|
62 |
if (editingTable == null) { |
|
63 |
editingTable = new EditingTable(); |
|
64 |
} |
|
65 |
return editingTable; |
|
66 |
} |
|
67 |
/** |
|
68 |
* This method initializes jButton |
|
69 |
* |
|
70 |
* @return javax.swing.JButton |
|
71 |
*/ |
|
72 |
private JButton getJButton() { |
|
73 |
if (jButton == null) { |
|
74 |
jButton = new JButton(); |
|
75 |
} |
|
76 |
return jButton; |
|
77 |
} |
|
78 |
/** |
|
79 |
* This method initializes jPanel |
|
80 |
* |
|
81 |
* @return javax.swing.JPanel |
|
82 |
*/ |
|
83 |
private JPanel getJPanel() { |
|
84 |
if (jPanel == null) { |
|
85 |
jPanel = new JPanel(); |
|
86 |
jPanel.add(getJButton1(), null); |
|
87 |
jPanel.add(getJButton(), null); |
|
88 |
} |
|
89 |
return jPanel; |
|
90 |
} |
|
91 |
/** |
|
92 |
* This method initializes jButton1 |
|
93 |
* |
|
94 |
* @return javax.swing.JButton |
|
95 |
*/ |
|
96 |
private JButton getJButton1() { |
|
97 |
if (jButton1 == null) { |
|
98 |
jButton1 = new JButton(); |
|
99 |
} |
|
100 |
return jButton1; |
|
101 |
} |
|
102 |
|
|
103 |
public static void main(String[] args) throws Exception { |
|
104 |
DataSourceFactory dsf = SetUp.setUp(); |
|
105 |
final DataSource ds = dsf.createRandomDataSource("persona", DataSourceFactory.MANUAL_OPENING); |
|
106 |
ds.start(); |
|
107 |
final EditingFrame ef = new EditingFrame(); |
|
108 |
ef.getEditingTable().setDataSource(ds); |
|
109 |
ef.getEditingTable().startEditing(); |
|
110 |
ef.addWindowListener(new WindowAdapter () { |
|
111 |
public void windowClosing(WindowEvent e) { |
|
112 |
try { |
|
113 |
ef.getEditingTable().commit(); |
|
114 |
ds.stop(); |
|
115 |
System.exit(0); |
|
116 |
} catch (ReadDriverException e1) { |
|
117 |
throw new RuntimeException(e1); |
|
118 |
} catch (WriteDriverException e1) { |
|
119 |
throw new RuntimeException(e1); |
|
120 |
} |
|
121 |
} |
|
122 |
}); |
|
123 |
ef.show(); |
|
124 |
} |
|
125 |
} |
|
0 | 126 |
tags/tmp_build/libraries/libGDBMS/src/test/java/com/hardcode/gdbms/gui/GDBMSAdapterTreeModel.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 12-oct-2004 |
|
3 |
*/ |
|
4 |
package com.hardcode.gdbms.gui; |
|
5 |
|
|
6 |
import com.hardcode.gdbms.engine.instruction.Adapter; |
|
7 |
import com.hardcode.gdbms.engine.instruction.Utilities; |
|
8 |
|
|
9 |
import java.util.Enumeration; |
|
10 |
import java.util.Hashtable; |
|
11 |
|
|
12 |
import javax.swing.tree.DefaultTreeModel; |
|
13 |
import javax.swing.tree.TreeNode; |
|
14 |
|
|
15 |
|
|
16 |
/** |
|
17 |
* DOCUMENT ME! |
|
18 |
* |
|
19 |
* @author Fernando Gonz?lez Cort?s |
|
20 |
*/ |
|
21 |
public class GDBMSAdapterTreeModel extends DefaultTreeModel { |
|
22 |
/** |
|
23 |
* DOCUMENT ME! |
|
24 |
* |
|
25 |
* @param arg0 |
|
26 |
* @param arg1 |
|
27 |
*/ |
|
28 |
public GDBMSAdapterTreeModel(TreeNode arg0, boolean arg1) { |
|
29 |
super(arg0, arg1); |
|
30 |
} |
|
31 |
|
|
32 |
/** |
|
33 |
* DOCUMENT ME! |
|
34 |
* |
|
35 |
* @param arg0 |
|
36 |
*/ |
|
37 |
public GDBMSAdapterTreeModel(TreeNode arg0) { |
|
38 |
super(arg0); |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* Crea un nuevo GDBMSAdapterTreeModel. |
|
43 |
* |
|
44 |
* @param root DOCUMENT ME! |
|
45 |
*/ |
|
46 |
public GDBMSAdapterTreeModel(Adapter root) { |
|
47 |
super(null); |
|
48 |
this.setRoot(new AdapterNode(root)); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* DOCUMENT ME! |
|
53 |
* |
|
54 |
* @param root DOCUMENT ME! |
|
55 |
*/ |
|
56 |
public void setTree(Adapter root) { |
|
57 |
this.setRoot(new AdapterNode(root)); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* DOCUMENT ME! |
|
62 |
* |
|
63 |
* @author Fernando Gonz?lez Cort?s |
|
64 |
*/ |
|
65 |
public class AdapterNode implements TreeNode { |
|
66 |
private Adapter node; |
|
67 |
|
|
68 |
/** |
|
69 |
* Crea un nuevo AdapterNode. |
|
70 |
* |
|
71 |
* @param n DOCUMENT ME! |
|
72 |
*/ |
|
73 |
public AdapterNode(Adapter n) { |
|
74 |
node = n; |
Also available in: Unified diff