001: /*
002: * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003: * Copyright (C) 2002-2005 NextApp, Inc.
004: *
005: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006: *
007: * The contents of this file are subject to the Mozilla Public License Version
008: * 1.1 (the "License"); you may not use this file except in compliance with
009: * the License. You may obtain a copy of the License at
010: * http://www.mozilla.org/MPL/
011: *
012: * Software distributed under the License is distributed on an "AS IS" basis,
013: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014: * for the specific language governing rights and limitations under the
015: * License.
016: *
017: * Alternatively, the contents of this file may be used under the terms of
018: * either the GNU General Public License Version 2 or later (the "GPL"), or
019: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020: * in which case the provisions of the GPL or the LGPL are applicable instead
021: * of those above. If you wish to allow use of your version of this file only
022: * under the terms of either the GPL or the LGPL, and not to allow others to
023: * use your version of this file under the terms of the MPL, indicate your
024: * decision by deleting the provisions above and replace them with the notice
025: * and other provisions required by the GPL or the LGPL. If you do not delete
026: * the provisions above, a recipient may use your version of this file under
027: * the terms of any one of the MPL, the GPL or the LGPL.
028: */
029:
030: package nextapp.echo2.testapp.interactive;
031:
032: import nextapp.echo2.app.Button;
033: import nextapp.echo2.app.Component;
034: import nextapp.echo2.app.ContentPane;
035: import nextapp.echo2.app.Extent;
036: import nextapp.echo2.app.Label;
037: import nextapp.echo2.app.Column;
038: import nextapp.echo2.app.SplitPane;
039: import nextapp.echo2.app.event.ActionEvent;
040: import nextapp.echo2.app.event.ActionListener;
041:
042: /**
043: * Main InteractiveTest <code>ContentPane</code> which displays a menu
044: * of available tests.
045: */
046: public class TestPane extends ContentPane {
047:
048: private SplitPane horizontalPane;
049:
050: private ActionListener commandActionListener = new ActionListener() {
051:
052: private Button activeButton = null;
053:
054: /**
055: * @see nextapp.echo2.app.event.ActionListener#actionPerformed(nextapp.echo2.app.event.ActionEvent)
056: */
057: public void actionPerformed(ActionEvent e) {
058: try {
059: if (activeButton != null) {
060: activeButton.setStyleName("Default");
061: }
062: Button button = (Button) e.getSource();
063: button.setStyleName("Selected");
064: activeButton = button;
065: String screenClassName = "nextapp.echo2.testapp.interactive.testscreen."
066: + e.getActionCommand();
067: Class screenClass = Class.forName(screenClassName);
068: Component content = (Component) screenClass
069: .newInstance();
070: if (horizontalPane.getComponentCount() > 1) {
071: horizontalPane.remove(1);
072: }
073: horizontalPane.add(content);
074: } catch (ClassNotFoundException ex) {
075: throw new RuntimeException(ex.toString());
076: } catch (InstantiationException ex) {
077: throw new RuntimeException(ex.toString());
078: } catch (IllegalAccessException ex) {
079: throw new RuntimeException(ex.toString());
080: }
081: }
082: };
083:
084: private Column testLaunchButtonsColumn;
085:
086: public TestPane() {
087: super ();
088:
089: SplitPane verticalPane = new SplitPane(
090: SplitPane.ORIENTATION_VERTICAL);
091: verticalPane.setStyleName("TestPane");
092: add(verticalPane);
093:
094: Label titleLabel = new Label("NextApp Echo2 Test Application");
095: titleLabel.setStyleName("TitleLabel");
096: verticalPane.add(titleLabel);
097:
098: horizontalPane = new SplitPane(
099: SplitPane.ORIENTATION_HORIZONTAL, new Extent(215));
100: horizontalPane.setStyleName("DefaultResizable");
101: verticalPane.add(horizontalPane);
102:
103: Column controlsColumn = new Column();
104: controlsColumn.setStyleName("ApplicationControlsColumn");
105: controlsColumn.setCellSpacing(new Extent(5));
106:
107: horizontalPane.add(controlsColumn);
108:
109: testLaunchButtonsColumn = new Column();
110: controlsColumn.add(testLaunchButtonsColumn);
111:
112: addTest("Button", "ButtonTest");
113: addTest("Client Configuration", "ClientConfigurationTest");
114: addTest("Client Exception", "ClientExceptionTest");
115: addTest("Column", "ColumnTest");
116: addTest("Command", "CommandTest");
117: addTest("Composite", "CompositeTest");
118: addTest("Container Context", "ContainerContextTest");
119: addTest("ContentPane", "ContentPaneTest");
120: addTest("Delay", "DelayTest");
121: addTest("Exception", "ExceptionTest");
122: addTest("Grid", "GridTest");
123: addTest("Hierarchy", "HierarchyTest");
124: addTest("Image", "ImageReferenceTest");
125: addTest("Label", "LabelTest");
126: addTest("ListBox", "ListBoxTest");
127: addTest("ListBox (Large Quantity)", "ListRenderTableTest");
128: addTest("Localization", "LocalizationTest");
129: addTest("Panel", "PanelTest");
130: addTest("Push (Basic)", "PushTest");
131: addTest("Push (Ghost Test)", "PushGhostTest");
132: addTest("Random Click", "RandomClickTest");
133: addTest("Row", "RowTest");
134: addTest("SplitPane (Basic)", "SplitPaneTest");
135: addTest("SplitPane (Nested)", "SplitPaneNestedTest");
136: addTest("StyleSheet", "StyleSheetTest");
137: addTest("Table", "TableTest");
138: addTest("Table (Performance)", "TablePerformanceTest");
139: addTest("TextComponent", "TextComponentTest");
140: addTest("Text Sync", "TextSyncTest");
141: addTest("Visibility", "VisibilityTest");
142: addTest("Window", "WindowTest");
143: addTest("WindowPane", "WindowPaneTest");
144: addTest("WindowPane Examples", "WindowPaneExamplesTest");
145:
146: Column applicationControlsColumn = new Column();
147: controlsColumn.add(applicationControlsColumn);
148:
149: Button button = new Button("Exit");
150: button.setRenderId("Exit");
151: button.setId("ExitTestApplication");
152: button.setStyleName("Default");
153: button.addActionListener(new ActionListener() {
154: public void actionPerformed(ActionEvent e) {
155: InteractiveApp.getApp().displayWelcomePane();
156: }
157: });
158: applicationControlsColumn.add(button);
159: }
160:
161: private void addTest(String name, String action) {
162: Button button = new Button(name);
163: button.setRenderId("StartTest" + action);
164: button.setId("StartTest:" + action);
165: button.setActionCommand(action);
166: button.setStyleName("Default");
167: button.addActionListener(commandActionListener);
168: testLaunchButtonsColumn.add(button);
169: }
170: }
|