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.editor;
020:
021: import java.awt.event.ActionEvent;
022: import java.awt.event.ActionListener;
023:
024: import javax.swing.JFrame;
025: import javax.swing.JMenu;
026: import javax.swing.JMenuBar;
027: import javax.swing.JMenuItem;
028: import javax.swing.JScrollPane;
029:
030: import com.jeta.forms.components.panel.FormPanel;
031: import com.jeta.swingbuilder.gui.utils.FormDesignerUtils;
032:
033: /**
034: * The frame used to contain the form when we are testing
035: *
036: * @author Jeff Tassin
037: */
038: public class RunFrame extends JFrame {
039: private FormPanel m_form;
040:
041: private JScrollPane m_scroll;
042:
043: /**
044: * ctor
045: */
046: public RunFrame(FormPanel panel) {
047: super ("Form Preview");
048: m_form = panel;
049: m_scroll = new JScrollPane(panel);
050: getContentPane().add(m_scroll);
051:
052: if (FormDesignerUtils.isTest()) {
053: JMenuBar menuBar = new JMenuBar();
054: setJMenuBar(menuBar);
055:
056: JMenu menu = new JMenu("Test");
057: menu.add(createMenuItem("Iterator", "std.iterator"));
058: menu.add(createMenuItem("Nested Iterator",
059: "nested.iterator"));
060: menu.add(createMenuItem("Remove Named", "remove.named"));
061: menu.add(createMenuItem("Iterator Remove Named",
062: "iterator.remove.named"));
063: menu.add(createMenuItem("Nested Iterator Remove Named",
064: "iterator.remove.nested"));
065: menu
066: .add(createMenuItem("Remove All",
067: "iterator.remove.all"));
068: menu.add(createMenuItem("Nested Remove All",
069: "iterator.remove.all.nested"));
070: menuBar.add(menu);
071: }
072: }
073:
074: public void setForm(FormPanel panel) {
075: if (m_scroll != null)
076: getContentPane().remove(m_scroll);
077:
078: m_form = panel;
079: m_scroll = new JScrollPane(panel);
080: getContentPane().add(m_scroll);
081:
082: if (getExtendedState() != java.awt.Frame.NORMAL) {
083: setExtendedState(java.awt.Frame.NORMAL);
084: }
085:
086: repaint();
087: }
088:
089: private JMenuItem createMenuItem(String menuName, String cmd) {
090: JMenuItem item = new JMenuItem(menuName);
091: item.setActionCommand(cmd);
092: item.addActionListener(new ActionListener() {
093: public void actionPerformed(ActionEvent evt) {
094: runUnitTest(evt.getActionCommand());
095: }
096: });
097: return item;
098: }
099:
100: private void runUnitTest(String actionCmd) {
101: // com.jeta.swingbuilder.test.JETATestFactory.runTest(
102: // "test.jeta.swingbuilder.gui.main.APIValidator", m_form, actionCmd );
103: }
104:
105: }
|