package xui.projects.sqltables;
import java.util.ArrayList;
import net.xoetrope.optional.data.collection.XCollectionTableModel;
import net.xoetrope.xui.*;
import net.xoetrope.swing.*;
import net.xoetrope.optional.data.sql.DatabaseTableModel;
public class MyTable extends XPage
{
XTable myTable;
XTable myTable2;
XComboBox myCombo;
public MyTable()
{
String[] names =
{ "ID", "Title", "Author" };
String[][] rawData = {
{ "0", "Moby Dick", "Herman Melville" },
{ "1", "The Hunchback of Notre Dame", "Victor Hugo" },
{ "2", "The Idiot", "Fyodor Dostoevsky" },
{ "3", "Ulysses", "James Joyce" },
{ "4", "Thus Spake Zarathustra", "Friedrich Nietzsche" },
{ "5", "Bleak House", "Charles Dickens" },
{ "6", "Mansfield Park", "Jane Austen" },
{ "7", "Alice's Adventures in Wonderland", "Lewis Carroll" },
{ "8", "The Republic", "Plato" },
{ "9", "Kidnapped", "Robert Louis Stevenson" },
{ "10", "On the Duty of Civil Disobedience", "Henry David Thoreau" },
{ "11", "The Jungle Book", "Rudyard Kipling" },
{ "12", "The Picture of Dorian Gray", "Oscar Wilde" },
{ "13", "The Rime of the Ancient Mariner", "Samuel Taylor Coleridge" },
{ "14", "Catcher in the Rye", "J. D. Salinger" },
{ "15", "The Glass Bead Game", "Herman Hesse" },
};
ArrayList fieldNames = new ArrayList();
for ( String n : names )
fieldNames.add( n );
ArrayList data = new ArrayList();
for ( String[] row : rawData ) {
ArrayList rowList = new ArrayList();
for ( String field : row ) {
rowList.add( field );
}
data.add( rowList );
}
XCollectionTableModel ctm = new XCollectionTableModel( project, "CollectionTable", fieldNames, data );
rootModel.append( ctm );
}
public void pageCreated()
{
myTable = (XTable)findComponent( "myTable" );
myTable.setUpdateModelSelection( true );
myTable2 = (XTable)findComponent( "yourTable" );
myTable2.setUpdateModelSelection( true );
myCombo = (XComboBox)findComponent( "myList" );
myCombo.doLayout();
}
public void pageActivated()
{
myCombo.doLayout();
}
public void sort()
{
DatabaseTableModel completeVoltageTable = DatabaseTableModel.getTable( project, "Voltages" );
completeVoltageTable.setDistinct( true );
completeVoltageTable.setOrderField( "ID" );
completeVoltageTable.retrieve();
myTable.setModel( completeVoltageTable );
updateBoundComponentValues();
}
public void filter()
{
DatabaseTableModel voltageTable = new DatabaseTableModel( project );
// Set the query elements
// FROM clause, FIELDS, WHERE clause
voltageTable.setupTable( "CS_VOLTAGES", "VOLTAGE_DESCRIPTION, VOLTAGE_MIN, VOLTAGE_MAX", "FREQUENCY=50" );
voltageTable.retrieve();
myTable.setModel( voltageTable );
updateBoundComponentValues();
}
public void next()
{
myTable.next();
updateBoundComponentValues();
}
public void prev()
{
myTable.prev();
updateBoundComponentValues();
}
public void myListKey()
{
saveBoundComponentValues();
// Object value = XModel.getInstance().get( "tables/Voltages/ml" );
}
public void syncMouseSelection()
{
//updateBoundComponentValues();
}
}