001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.examples.swinglets;
006:
007: import java.util.*;
008: import java.io.*;
009: import java.awt.*;
010:
011: import javax.servlet.*;
012: import javax.servlet.http.*;
013: import javax.swing.table.*;
014:
015: import com.javelin.swinglets.*;
016: import com.javelin.swinglets.table.*;
017: import com.javelin.swinglets.event.*;
018:
019: /**
020: * A Demo SQL Table
021: *
022: * @author Robin Sharp
023: */
024:
025: public class DemoSQL extends SPanel {
026: public DemoSQL() {
027: //Query
028: SForm form = new SForm();
029:
030: form.add(new SLabel("User "));
031: form.add(userField);
032: form.add(new SLabel("Password "));
033: form.add(passwordField);
034: form.add(newLine);
035:
036: form.add(new SLabel("URL "));
037: form.add(urlField);
038: form.add(newLine);
039:
040: form.add(new SLabel("SQL "));
041: form.add(sqlField);
042: form.add(new SButton("Submit"));
043: form.add(newLine);
044:
045: form.addFormEventListener(new FormListener() {
046: public void formReset(
047: com.javelin.swinglets.event.FormEvent ev) {
048: passwordField.setText("");
049: }
050:
051: public void formSubmitted(
052: com.javelin.swinglets.event.FormEvent ev) {
053: tableModel.setSql(sqlField.getText());
054: System.out.println("***");
055: tableModel.setUser(userField.getText());
056: tableModel.setURL(urlField.getText());
057: tableModel.setPassword(passwordField.getText());
058: tableModel.execute();
059: }
060: });
061: add(form);
062:
063: //Results
064: SortedTableHeader sortedTableHeader = new SortedTableHeader(
065: table);
066: sortedTableHeader.setBackground(SColor.getColor("darkblue"));
067: sortedTableHeader.setForeground(SColor.white);
068: sortedTableHeader.setFont(SFont.getFont("Arial,Helvetica",
069: SFont.BOLD, 10));
070: table.setTableHeader(sortedTableHeader);
071:
072: PagedTableFooter pagedTableFooter = new PagedTableFooter(table);
073: pagedTableFooter.setBackground(SColor.getColor("darkblue"));
074: pagedTableFooter.setForeground(SColor.white);
075: pagedTableFooter.setFont(SFont.getFont("Arial,Helvetica",
076: SFont.BOLD, 10));
077: pagedTableFooter.setHorizontalAlignment(SConstants.CENTER);
078: table.setTableFooter(pagedTableFooter);
079:
080: pagedTableModel.setPageSize(5);
081:
082: SQLTableRenderer renderer = new SQLTableRenderer();
083: renderer.setLink(4, "NEW");
084: table.setTableCellRenderer(renderer);
085: table.setBackground(SColor.white);
086: add(table);
087:
088: }
089:
090: protected SCharacter newLine = new SCharacter(SCharacter.BREAK);
091:
092: protected STextField urlField = new STextField();
093: protected STextField userField = new STextField();
094: protected SPasswordField passwordField = new SPasswordField();
095:
096: protected STextArea sqlField = new STextArea(10, 60);
097:
098: protected SQLTableModel tableModel = new SQLTableModel();
099: protected PagedTableModel pagedTableModel = new PagedTableModel(
100: tableModel);
101: protected STable table = new STable(pagedTableModel);
102: //protected STable table = new STable( tableModel );
103:
104: }
|