home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
inprise
/
JSAMPLES.Z
/
SchemaPanel.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
28KB
|
816 lines
/*
* Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
*
* This SOURCE CODE FILE, which has been provided by Borland as part
* of a Borland product for use ONLY by licensed users of the product,
* includes CONFIDENTIAL and PROPRIETARY information of Borland.
*
* USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
* OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
* THE PRODUCT.
*
* IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
* COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
* OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
* OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
* OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
* OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
* CODE FILE.
*/
package borland.samples.apps.schemaeditor;
import java.lang.*;
import java.lang.reflect.*;
import java.awt.*;
import java.util.*;
import java.math.*;
import java.io.*;
import borland.jbcl.control.*;
import borland.jbcl.dataset.*;
import borland.jbcl.view.*;
import borland.jbcl.model.*;
import borland.jbcl.util.*;
import borland.jbcl.layout.*;
import java.awt.event.*;
public class SchemaPanel extends BevelPanel {
//Column indices
final static int INDEX=0;
final static int NAME=1;
final static int TYPE=2;
final static int SIZE=3;
//SQL Data Type strings
final static String BIGDECIMAL="BIGDECIMAL";
//final static String BOOLEAN="BOOLEAN";
final static String BOOLEAN="BIT";
//final static String BYTE="BYTE";
final static String BYTE="TINYINT";
final static String DATE="DATE";
final static String DOUBLE="DOUBLE";
final static String FLOAT="FLOAT";
//final static String INT="INT";
final static String INT="INTEGER";
final static String LONG="LONG";
final static String SHORT="SHORT";
//final static String STRING="STRING";
final static String STRING="VARCHAR";
final static String TIME="TIME";
final static String TIMESTAMP="TIMESTAMP";
GridControl gridControl1 = new GridControl();
Label labelDescription = new Label();
Button addField = new Button();
Button delField = new Button();
TableDataSet schema = new TableDataSet();
private int fieldCounter=0;
public SchemaPanel() {
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
};
}
private void jbInit() throws Exception {
Column columns[] = new Column[4];
labelDescription.setText("Define table columns and column types.");
delField.setLabel("Remove Field");
delField.addActionListener(new SchemaPanel_delField_actionAdapter(this));
addField.setLabel("Insert Field");
addField.addActionListener(new SchemaPanel_addField_actionAdapter(this));
this.setLayout(gridBagLayout1);
columns[INDEX]=new Column();
columns[INDEX].setDataType(Variant.INT);
columns[INDEX].setColumnName("Index");
columns[INDEX].setCaption("Index");
columns[INDEX].setWidth(50);
//The index property is for internal use only and should not
//be seen by the user.
columns[INDEX].setVisible(TriStateProperty.FALSE);
columns[NAME]=new Column();
columns[NAME].setDataType(Variant.STRING);
columns[NAME].setColumnName("Field_Name");
columns[NAME].setCaption("Field Name");
columns[NAME].setWidth(150);
columns[NAME].setRequired(true);
columns[TYPE]=new Column();
columns[TYPE].setDataType(Variant.STRING);
columns[TYPE].setColumnName("Field_Type");
columns[TYPE].setCaption("Field Type");
columns[TYPE].setWidth(90);
columns[TYPE].setRequired(true);
columns[TYPE].setItemEditor(new SchemaFieldTypeEditor());
columns[SIZE]=new Column();
columns[SIZE].setDataType(Variant.INT);
columns[SIZE].setColumnName("Size");
columns[SIZE].setCaption("Size");
columns[SIZE].setMin("0");
columns[SIZE].setWidth(50);
schema.setColumns(columns);
schema.setSort(new SortDescriptor("INDEX"));
gridControl1.setDataSet(schema);
gridControl1.setSortOnHeaderClick(false);
addRow(); //Create the first row
this.add(labelDescription, new GridBagConstraints2(0, 0, 3, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 8, 0, 0), 75, 7));
this.add(gridControl1, new GridBagConstraints2(0, 1, 4, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 8, 0, 9), 20, 50));
this.add(addField, new GridBagConstraints2(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(7, 8, 26, 0), 26, 5));
this.add(delField, new GridBagConstraints2(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(7, 17, 26, 0), 14, 5));
}
//Inserts a new default row to the table
private void addRow() {
DataRow row;
try {
if (!schema.isOpen()) {
schema.open();
}
//Renumber index from end to current row
//Since dataset is sorted, each renumber causes a resort.
//By renumbering from the end to the cursor, we keep records
//in the correct order
// This is an alternate way to do the renumbering by using
// a dataset view instead of moving the cursor in the current
// dataset. A dataset view has it's own cursor and sort order
//if (schema.rowCount() > 0 ){
// DataSetView view = schema.cloneDataSetView();
// view.open();
// view.goToRow(schema.getRow());
// view.last();
// while(view.getRow() != schema.getRow()) {
// view.setInt(INDEX, view.getInt(INDEX)+1);
// view.prior();
// }
// view.post();
// view.close();
//}
row=new DataRow(schema);
int currentRow=schema.getRow();
//This turns off grid painting
schema.enableDataSetEvents(false);
schema.last();
while(schema.getRow() != currentRow) {
schema.getDataRow(row);
row.setInt(INDEX,row.getInt(INDEX)+1);
schema.updateRow(row);
schema.prior();
}
row.setInt(INDEX,schema.getInt(INDEX)+1);
row.setString(NAME,"Field"+fieldCounter++);
row.setString(TYPE,STRING);
row.setInt(SIZE,25);
schema.addRow(row);
schema.next(); //Goto new row
//The add button got focus when we clicked it, return
//focus to the grid
gridControl1.requestFocus();
schema.enableDataSetEvents(true);
// In case grid doesn't repaint correctly after enabling
//gridControl1.repaintCells();
}
catch (Exception e) {e.printStackTrace();}
}
//Start with a clean schema
public void newDataSet() {
try {
if (!schema.isOpen()) {
schema.open();
}
schema.deleteAllRows();
fieldCounter=0;
addRow();
}
catch (Exception e) {e.printStackTrace();}
}
//Given an existing DataSet, display the schema for editing
public void setDataSet(StorageDataSet d) {
Column columns[];
DataRow row;
try {
if (!schema.isOpen()) {
schema.open();
}
schema.deleteAllRows();
//For each column in dataset, create a row in schema
columns = d.getColumns();
for (int i=0; i< columns.length ; i++) {
row = new DataRow(schema);
row.setInt(INDEX,i);
row.setString(NAME,columns[i].getColumnName());
row.setInt(SIZE,columns[i].getPrecision());
switch (columns[i].getDataType()) {
case Variant.BIGDECIMAL:
row.setString(TYPE,BIGDECIMAL);
break;
case Variant.BOOLEAN:
row.setString(TYPE,BOOLEAN);
break;
case Variant.BYTE:
row.setString(TYPE,BYTE);
break;
case Variant.DATE:
row.setString(TYPE,DATE);
break;
case Variant.DOUBLE:
row.setString(TYPE,DOUBLE);
break;
case Variant.FLOAT:
row.setString(TYPE,FLOAT);
break;
case Variant.INT:
row.setString(TYPE,INT);
break;
case Variant.LONG:
row.setString(TYPE,LONG);
break;
case Variant.SHORT:
row.setString(TYPE,SHORT);
break;
case Variant.STRING:
row.setString(TYPE,STRING);
break;
case Variant.TIME:
row.setString(TYPE,TIME);
break;
case Variant.TIMESTAMP:
row.setString(TYPE,TIMESTAMP);
break;
}
schema.addRow(row);
schema.post();
}
gridControl1.repaintCells();
} catch (Exception e) {
e.printStackTrace();
}
}
public StorageDataSet getDataSet(boolean sampleData) {
// Construct a temporary dataset from schema and use it to create
// the schema file by saving it. This hides the details of the
// schema syntax in case it changes in the future.
TableDataSet ds = new TableDataSet();
Column column;
String s=null;
Variant v = new Variant();
int recordCounter=0;
String defString;
DataRow sampleRow;
int numRows;
String columnName;
String columnType;
int columnPrecision;
// Walk through the schema and construct columns
try {
if (!schema.isOpen()) {
schema.open();
}
schema.first(); //Make sure dataset is reset to beginning
numRows=schema.getRowCount();
for (int row=0; row < numRows; row++) {
//Is there a field that needs to be created?
schema.getVariant(SchemaPanel.NAME,row,v);
if (!v.isNull()) {
column = new Column();
//Set the column name
columnName=v.getString();
column.setColumnName(columnName);
//Set the size of the field
schema.getVariant(SchemaPanel.SIZE,row,v);
columnPrecision=0;
if (!v.isNull()) {
columnPrecision=v.getInt();
}
column.setPrecision(columnPrecision);
//Set the field type
schema.getVariant(SchemaPanel.TYPE,row,v);
columnType=v.getString();
if (columnType==BIGDECIMAL) {
column.setDataType(Variant.BIGDECIMAL);
}else if (columnType==BOOLEAN) {
column.setDataType(Variant.BOOLEAN);
}else if (columnType==BYTE) {
column.setDataType(Variant.BYTE);
}else if (columnType==DATE) {
column.setDataType(Variant.DATE);
}else if (columnType==DOUBLE) {
column.setDataType(Variant.DOUBLE);
}else if (columnType==FLOAT) {
column.setDataType(Variant.FLOAT);
}else if (columnType==INT) {
column.setDataType(Variant.INT);
}else if (columnType==LONG) {
column.setDataType(Variant.LONG);
}else if (columnType==SHORT) {
column.setDataType(Variant.SHORT);
}else if (columnType==STRING) {
column.setDataType(Variant.STRING);
}else if (columnType==TIME) {
column.setDataType(Variant.TIME);
}else if (columnType==TIMESTAMP) {
column.setDataType(Variant.TIMESTAMP);
}
//Add the column to the template
ds.addColumn(column);
} //end if (schema.getRow...)
} //end for(...)
if (sampleData) {
// Create 10 records of sample data
ds.open();
for (int i=0; i<10;i++) {
sampleRow=new DataRow(ds);
for (int j=0; j<numRows; j++) {
columnPrecision=ds.getColumn(j).getPrecision();
switch (ds.getColumn(j).getDataType()) {
case Variant.BIGDECIMAL:
sampleRow.setBigDecimal(j,new BigDecimal(123.45));
break;
case Variant.BOOLEAN:
sampleRow.setBoolean(j,true);
break;
case Variant.BYTE:
sampleRow.setByte(j, (byte) 127);
break;
case Variant.DATE:
sampleRow.setDate(j,new java.sql.Date(97,7,1));
break;
case Variant.DOUBLE:
sampleRow.setDouble(j,123.45);
break;
case Variant.FLOAT:
sampleRow.setFloat(j,1234.56F);
break;
case Variant.INT:
sampleRow.setInt(j,10);
break;
case Variant.LONG:
sampleRow.setLong(j,1000000L);
break;
case Variant.SHORT:
sampleRow.setShort(j,(short)1000);
break;
case Variant.STRING:
defString=ds.getColumn(j).getColumnName()+recordCounter;
if (defString.length() > ds.getColumn(j).getPrecision()) {
defString=defString.substring(0,columnPrecision);
}
sampleRow.setString(j,defString);
break;
case Variant.TIME:
sampleRow.setTime(j,new java.sql.Time(12,30,30));
break;
case Variant.TIMESTAMP:
sampleRow.setTimestamp(j,new java.sql.Timestamp(97,7,1,12,30,30,30));
break;
}
}
ds.addRow(sampleRow);
ds.post();
recordCounter++;
}
}
ds.close();
}
catch (Exception x) {
x.printStackTrace();
}
return ds;
} // end getDataSet
//Generates a sample application to view text schema
//Strings beginning with "$" in this array result in a method
//call which generates form specific code in place.
//For example, "$codeGen1", will call codeGen1(PrintWriter out)
//This is an interesting example of using reflection to call a method
//specified by a string.
private String codeBlock[] = {
"// Change package name to match actual directory where created",
"package borland.samples.apps.schemaeditor;",
"",
"import java.awt.*;",
"import java.awt.event.*;",
"import borland.jbcl.layout.*;",
"import borland.jbcl.control.*;",
"import borland.jbcl.dataset.*;",
"import borland.sql.dataset.*;",
"",
"$codeGenC0", //"public class TestSchema {",
" // !!! These variables must be hand edited to make sample work",
" boolean useTableDataSet = true; //false->use a query DataSet",
" // If you are using a local data file, set the following",
"$codeGenS0",
" // If you are using a local or remote SQL server, set the following",
" String sqlDataBaseName=\"TestSchema\";",
" String sqlTableName=\"TestSchema\";",
" String sqlUserName=\"SYSDBA\";",
" String sqlPassword=\"masterkey\";",
"",
" StorageDataSet dataSet;",
" Database database1 = new Database();",
" TextDataFile textDataFile1 = new TextDataFile();",
"",
" BorderLayout borderLayout1 = new BorderLayout();",
" DecoratedFrame frame = new DecoratedFrame();",
" TestPanel panel = new TestPanel();",
" NavigatorControl navigatorControl1 = new NavigatorControl();",
" StatusBar statusBar1 = new StatusBar();",
"",
" //Construct the application",
"$codeGenC1", //" public TestSchema() {",
" try {",
" jbInit();",
" }",
" catch (Exception e) {",
" e.printStackTrace();",
" }",
" frame.pack();",
" //Center the window",
" Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();",
" Dimension frameSize = frame.getPreferredSize();",
" if (frameSize.height > screenSize.height)",
" frameSize.height = screenSize.height;",
" if (frameSize.width > screenSize.width)",
" frameSize.width = screenSize.width;",
" frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);",
" frame.setVisible(true);",
" }",
"",
" void jbInit() throws Exception{",
" frame.setExitOnClose(false); //Allows us to grab the window closing event",
"$codeGenC4", //" frame.addWindowListener(new TestSchema_frame_windowAdapter(this));",
" frame.setLayout(borderLayout1);",
" frame.add(navigatorControl1, BorderLayout.NORTH);",
" frame.add(panel,BorderLayout.CENTER);",
" frame.add(statusBar1, BorderLayout.SOUTH);",
" frame.setTitle(\"Schema Editor\");",
" if (useTableDataSet) {",
" textDataFile1.setFileName(tableDataSetName);",
" dataSet=new TableDataSet();",
" dataSet.setDataFile(textDataFile1);",
" } else {",
" database1.setConnection(new borland.sql.dataset.ConnectionDescriptor(\"jdbc:odbc:\" + sqlDataBaseName, sqlUserName, sqlPassword, false, \"sun.jdbc.odbc.JdbcOdbcDriver\"));",
" QueryDataSet qds = new QueryDataSet();",
" qds.setQuery(new borland.sql.dataset.QueryDescriptor(database1, \"select * from \"+sqlTableName, null, true, Load.ALL));",
" dataSet=qds;",
" }",
" panel.setDataSet(dataSet);",
" navigatorControl1.setDataSet(dataSet);",
" statusBar1.setDataSet(dataSet);",
" }",
"",
" void frame_windowClosing(WindowEvent e) {",
" try {",
" //Save any changes",
" if (useTableDataSet) {",
" textDataFile1.save(dataSet);",
" } else {",
" dataSet.saveChanges(); //Save query data set",
" }",
" } catch (Exception x) {x.printStackTrace();}",
" System.exit(0);",
" }",
"",
" //Main method",
" static public void main(String[] args) {",
"$codeGenC2", //" TestSchema ts = new TestSchema();",
" System.out.println(ts.getCreateTableSQL());",
" }",
"",
" //Returns a SQL string that can be used to create this table",
" //in Local Interbase",
" String getCreateTableSQL() {",
" String sql;",
"$codeGen0", //Create SQL string
" }",
"}",
"",
"// This panel can be reused in other applications",
"// Note the use of a split panel to allow resizable panes",
"// You will get a warning when you compile this until you extract it to a separate file",
"public class TestPanel extends SplitPanel {",
" BevelPanel panel1=new BevelPanel();",
" BevelPanel panel2=new BevelPanel();",
" GridLayout gridLayout1 = new GridLayout();",
" DataSet dataSet;",
"",
"$codeGen1", //Create field controls
"",
" public TestPanel() {",
" try {",
" jbInit();",
" }",
" catch (Exception e) {",
" e.printStackTrace();",
" }",
" }",
"",
" public void setDataSet (StorageDataSet s) {",
" dataSet=s;",
"$codeGen3", //Set the dataset for all fields
" }",
"",
" void jbInit() throws Exception{",
" gridLayout1.setRows(-1);",
" gridLayout1.setColumns(1);",
" panel1.setLayout(gridLayout1);",
" panel2.setLayout(gridLayout1);",
"$codeGen2", //Init field controls
" //Create the split panels",
" this.add(panel1,new PaneConstraints(\"panel1\", \"panel1\", PaneConstraints.ROOT, 1.0f));",
" this.add(panel2,new PaneConstraints(\"panel2\", \"panel2\", PaneConstraints.RIGHT, 0.70f));",
" }",
"}",
"",
"$codeGenC3",
" this.adaptee = adaptee;",
" }",
"",
" public void windowClosing(WindowEvent e) {",
" adaptee.frame_windowClosing(e);",
" }",
"}",
""
};
GridBagLayout gridBagLayout1 = new GridBagLayout();
//filename specifies the name of the data table to browse
public void generateApp(String directory, String fileName, String lastSchema) {
Method m;
Class c = this.getClass();
String methodName;
String className; //Derived from fileName, wo .java suffix
if (fileName.endsWith(".java")) {
className=(fileName.substring(0,fileName.lastIndexOf(".java")));
}
else {
className = fileName;
}
//Replace any "\" in the string with "\\" so that we can generate legal code
String schemaName="";
for (int i=0; i<lastSchema.length(); i++) {
if (lastSchema.charAt(i) == '\\') {
schemaName=schemaName+"\\\\";
} else {
schemaName=schemaName+lastSchema.charAt(i);
}
}
try {
PrintWriter out = new PrintWriter(new FileOutputStream(directory+fileName));
schema.enableDataSetEvents(false); //Stop painting
for (int i=0; i<codeBlock.length; i++) {
if (codeBlock[i].startsWith("$")) {
//Code generating function
methodName=codeBlock[i].substring(1);
m = c.getDeclaredMethod(methodName,new Class[] {out.getClass(),String.class,String.class});
m.invoke(this,new Object[] {out,className, schemaName});
} else {
out.println(codeBlock[i]);
}
}
out.close();
schema.enableDataSetEvents(true);
} catch (Exception e) { e.printStackTrace(); }
}
private void codeGenS0(PrintWriter out, String cn, String sn) {
out.println(" String tableDataSetName=\"" + sn +"\";");
}
//Code gen for all classname specific code
private void codeGenC0(PrintWriter out, String cn, String sn) {
out.println("public class " + cn + " {");
}
private void codeGenC1(PrintWriter out, String cn, String sn) {
out.println(" public " + cn + "() {");
}
private void codeGenC2(PrintWriter out, String cn, String sn) {
out.println(" " + cn + " ts = new " + cn + "();");
}
private void codeGenC3(PrintWriter out, String cn, String sn) {
out.println("class "+cn+"_frame_windowAdapter extends java.awt.event.WindowAdapter {");
out.println(" "+cn+" adaptee;");
out.println(" "+cn+"_frame_windowAdapter("+cn+" adaptee) {");
}
private void codeGenC4(PrintWriter out, String cn, String sn) {
out.println(" frame.addWindowListener(new "+cn+"_frame_windowAdapter(this));");
}
//GenCode1 - Create Field controls
private void codeGen1(PrintWriter out, String cn, String sn) {
try {
DataRow row=new DataRow(schema);
String fn; //Field name
schema.first();
for (int i=0; i<schema.getRowCount(); i++,schema.next()) {
schema.getDataRow(row);
fn=row.getString(NAME);
//Label
out.println(" LabelControl label"+i+" = new LabelControl();");
//Field Control
out.println(" FieldControl field"+i+" = new FieldControl(); //"+fn);
}
} catch (Exception e) {e.printStackTrace();}
}
//GenCode2 - Init the fields
private void codeGen2(PrintWriter out, String cn, String sn) {
try {
DataRow row=new DataRow(schema);
String fn; //Field name
schema.first();
for (int i=0; i<schema.getRowCount(); i++,schema.next()) {
schema.getDataRow(row);
fn=row.getString(NAME);
//Label
out.println(" label" + i + ".setText(\"" + fn + "\");");
//Field Control
out.println(" field" + i + ".setColumnName(\"" + fn + "\");");
//Add to panel
out.println(" panel1.add(label" + i + ",null);");
out.println(" panel2.add(field" + i + ",null);");
}
} catch (Exception e) {e.printStackTrace();}
}
//Generate the rest of the setDataSet method
private void codeGen3(PrintWriter out, String cn, String sn) {
try {
DataRow row=new DataRow(schema);
schema.first();
for (int i=0; i<schema.getRowCount(); i++,schema.next()) {
schema.getDataRow(row);
out.println(" field" + i + ".setDataSet(dataSet);");
}
} catch (Exception e) {e.printStackTrace();}
}
// GenCode0 - Generate a method to return a SQL string to create table
private void codeGen0(PrintWriter out, String cn, String sn) {
try {
String sql=new String();
String type=new String();
DataRow row=new DataRow(schema);
schema.first();
for (int i=0; i<schema.getRowCount(); i++,schema.next()) {
schema.getDataRow(row);
type=row.getString(TYPE);
sql=sql + row.getString(NAME) + " " + type;
if (type != INT) { //INTEGER has no size parameter in SQL
sql=sql+ " (" + row.getInt(SIZE) + ")";
}
//First field is considered the primary key
if (i==0) {
sql=sql+" NOT NULL PRIMARY KEY";
}
if (i<schema.getRowCount()-1) {
sql=sql+","; //Last field can't have trailing comma
}
}
out.println(" sql=\"create table \"+sqlTableName+\" (" + sql + ")\";");
out.println(" return sql;");
} catch (Exception e) {e.printStackTrace();}
}
void addField_actionPerformed(ActionEvent e) {
addRow();
}
//Remove the current field
void delField_actionPerformed(ActionEvent e) {
try {
schema.deleteRow();
} catch (Exception x) {
x.printStackTrace();
}
}
} //end class
class SchemaFieldTypeEditor extends Choice implements ItemEditor {
SchemaFieldTypeEditor() {
super();
setBounds(0,0,0,0);
setVisible(false);
//Display all valid datatypes for a TextDataSet
addItem(SchemaPanel.BIGDECIMAL);
addItem(SchemaPanel.BOOLEAN);
addItem(SchemaPanel.BYTE);
addItem(SchemaPanel.DATE);
addItem(SchemaPanel.DOUBLE);
addItem(SchemaPanel.FLOAT);
addItem(SchemaPanel.INT);
addItem(SchemaPanel.LONG);
addItem(SchemaPanel.SHORT);
addItem(SchemaPanel.STRING);
addItem(SchemaPanel.TIME);
addItem(SchemaPanel.TIMESTAMP);
}
public Object getValue() {
return getSelectedItem();
}
public Component getComponent() { return this; }
public void startEdit(Object value, Rectangle bounds, ItemEditSite site) {
select(value.toString()); //Get whatever is in the grid and select it
changeBounds(bounds);
setVisible(true);
}
public void changeBounds(Rectangle bounds) {
setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
}
public boolean canPost() {
return true;
}
public void endEdit(boolean post) {}
}
class SchemaPrimaryKeyEditor extends Checkbox implements ItemEditor {
SchemaPrimaryKeyEditor() {
super();
setBounds(0,0,0,0);
setVisible(false);
}
public Object getValue() {
return new Checkbox();
}
public Component getComponent() { return this; }
public void startEdit(Object value, Rectangle bounds, ItemEditSite site) {
changeBounds(bounds);
setVisible(true);
}
public void changeBounds(Rectangle bounds) {
setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
}
public boolean canPost() {
return true;
}
public void endEdit(boolean post) {}
}
class SchemaPanel_addField_actionAdapter implements java.awt.event.ActionListener {
SchemaPanel adaptee;
SchemaPanel_addField_actionAdapter(SchemaPanel adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.addField_actionPerformed(e);
}
}
class SchemaPanel_delField_actionAdapter implements java.awt.event.ActionListener {
SchemaPanel adaptee;
SchemaPanel_delField_actionAdapter(SchemaPanel adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.delField_actionPerformed(e);
}
}