001: /*
002: * Copyright (C) 2005 Jeff Tassin
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */
018:
019: package com.jeta.swingbuilder.gui.formmgr;
020:
021: import java.awt.BorderLayout;
022: import java.awt.FlowLayout;
023: import java.awt.event.ActionEvent;
024: import java.awt.event.ActionListener;
025:
026: import javax.swing.JButton;
027: import javax.swing.JComponent;
028: import javax.swing.JPanel;
029: import javax.swing.JScrollPane;
030: import javax.swing.JTabbedPane;
031: import javax.swing.JTable;
032:
033: import com.jeta.open.gui.framework.JETAPanel;
034: import com.jeta.swingbuilder.gui.components.TableUtils;
035:
036: /**
037: * This class displays the list of forms in the form manager.
038: *
039: * @author Jeff Tassin
040: */
041: public class FormManagerView extends JETAPanel {
042: /** the table that displays the forms */
043: private JTable m_table;
044: /** the scroll pane for the table */
045: private JScrollPane m_scrollpane;
046: /* model for the triggers */
047: private FormsModel m_model;
048: private FormsTree m_forms_tree;
049:
050: /**
051: * ctor
052: */
053: public FormManagerView() {
054: setLayout(new BorderLayout());
055: m_model = new FormsModel();
056: add(createButtonPanel(), BorderLayout.NORTH);
057:
058: JTabbedPane tab = new JTabbedPane();
059: tab.addTab("Table", createTable());
060: tab.addTab("Tree", createTree());
061: add(tab, BorderLayout.CENTER);
062: setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5,
063: 5));
064: }
065:
066: private JPanel createButtonPanel() {
067: JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
068: JButton btn = new JButton("Reload");
069: btn.addActionListener(new ActionListener() {
070: public void actionPerformed(ActionEvent evt) {
071: reload();
072: }
073: });
074: panel.add(btn);
075: return panel;
076: }
077:
078: /**
079: * Creates the JTable that displays the table triggers
080: *
081: * @returns the table component
082: */
083: private JComponent createTable() {
084: JTable table = TableUtils.createBasicTablePanel(m_model, false);
085: return new JScrollPane(table);
086: }
087:
088: private JComponent createTree() {
089: m_forms_tree = new FormsTree();
090: JScrollPane scroll = new JScrollPane(m_forms_tree);
091: return scroll;
092: }
093:
094: /**
095: * @return the underlying data model
096: */
097: public FormsModel getTableModel() {
098: return m_model;
099: }
100:
101: public void reload() {
102: m_model.reload();
103: m_forms_tree.reload();
104: }
105:
106: }
|