/*
@ITMillApache2LicenseForJavaFiles@
*/
package com.itmill.toolkit.demo;
import java.sql.SQLException;
import com.itmill.toolkit.data.util.QueryContainer;
import com.itmill.toolkit.demo.util.SampleDatabase;
import com.itmill.toolkit.event.Action;
import com.itmill.toolkit.ui.Button;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.OrderedLayout;
import com.itmill.toolkit.ui.Table;
import com.itmill.toolkit.ui.Window;
/**
* Similar to QueryContainerDemo
*
* @author IT Mill Ltd.
* @since 4.0.0
*
*/
public class TableDemo extends com.itmill.toolkit.Application implements
Action.Handler {
private static final String ACTION_DESCRIPTION = "Use right mouse button to initiate "
+ "actions menu.
Note: on Opera use meta key "
+ "and left mouse button.";
private static final String TABLE_CAPTION = SampleDatabase.ROWCOUNT
+ " dynamically loaded rows from example SQL table";
// Table component where SQL rows are attached (using QueryContainer)
private final Table table = new Table();
// Label which displays last performed action against table row
private final Label tableLastAction = new Label(
"No action selected for table.");
// Database provided with sample data
private SampleDatabase sampleDatabase;
// Example Actions for table
private final Action ACTION1 = new Action("Upload");
private final Action ACTION2 = new Action("Download");
private final Action ACTION3 = new Action("Show history");
private final Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 };
// Button which is used to disable or enable table
// note: when button click event occurs, tableEnabler() method is called
private final Button tableEnabler = new Button("Disable table", this,
"tableEnabler");
// Button which is used to hide or show table
// note: when button click event occurs, tableVisibility() method is called
private final Button tableVisibility = new Button("Hide table", this,
"tableVisibility");
// Button which is used to hide or show table
// note: when button click event occurs, tableVisibility() method is called
private final Button tableCaption = new Button("Hide caption", this,
"tableCaption");
/**
* Initialize Application. Demo components are added to main window.
*/
public void init() {
final Window main = new Window("Table demo");
setMainWindow(main);
// create demo database
sampleDatabase = new SampleDatabase();
// Main window contains heading, two buttons, table and label
main
.addComponent(new Label(
"