KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > testapp > interactive > TestPane


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package nextapp.echo2.testapp.interactive;
31
32 import nextapp.echo2.app.Button;
33 import nextapp.echo2.app.Component;
34 import nextapp.echo2.app.ContentPane;
35 import nextapp.echo2.app.Extent;
36 import nextapp.echo2.app.Label;
37 import nextapp.echo2.app.Column;
38 import nextapp.echo2.app.SplitPane;
39 import nextapp.echo2.app.event.ActionEvent;
40 import nextapp.echo2.app.event.ActionListener;
41
42 /**
43  * Main InteractiveTest <code>ContentPane</code> which displays a menu
44  * of available tests.
45  */

46 public class TestPane extends ContentPane {
47
48     private SplitPane horizontalPane;
49     
50     private ActionListener commandActionListener = new ActionListener() {
51         
52         private Button activeButton = null;
53         
54         /**
55          * @see nextapp.echo2.app.event.ActionListener#actionPerformed(nextapp.echo2.app.event.ActionEvent)
56          */

57         public void actionPerformed(ActionEvent e) {
58             try {
59                 if (activeButton != null) {
60                     activeButton.setStyleName("Default");
61                 }
62                 Button button = (Button) e.getSource();
63                 button.setStyleName("Selected");
64                 activeButton = button;
65                 String JavaDoc screenClassName = "nextapp.echo2.testapp.interactive.testscreen." + e.getActionCommand();
66                 Class JavaDoc screenClass = Class.forName(screenClassName);
67                 Component content = (Component) screenClass.newInstance();
68                 if (horizontalPane.getComponentCount() > 1) {
69                     horizontalPane.remove(1);
70                 }
71                 horizontalPane.add(content);
72             } catch (ClassNotFoundException JavaDoc ex) {
73                 throw new RuntimeException JavaDoc(ex.toString());
74             } catch (InstantiationException JavaDoc ex) {
75                 throw new RuntimeException JavaDoc(ex.toString());
76             } catch (IllegalAccessException JavaDoc ex) {
77                 throw new RuntimeException JavaDoc(ex.toString());
78             }
79         }
80     };
81     
82     private Column testLaunchButtonsColumn;
83     
84     public TestPane() {
85         super();
86         
87         SplitPane verticalPane = new SplitPane(SplitPane.ORIENTATION_VERTICAL);
88         verticalPane.setStyleName("TestPane");
89         add(verticalPane);
90
91         Label titleLabel = new Label("NextApp Echo2 Test Application");
92         titleLabel.setStyleName("TitleLabel");
93         verticalPane.add(titleLabel);
94         
95         horizontalPane = new SplitPane(SplitPane.ORIENTATION_HORIZONTAL, new Extent(215));
96         horizontalPane.setStyleName("DefaultResizable");
97         verticalPane.add(horizontalPane);
98         
99         Column controlsColumn = new Column();
100         controlsColumn.setStyleName("ApplicationControlsColumn");
101         controlsColumn.setCellSpacing(new Extent(5));
102         
103         horizontalPane.add(controlsColumn);
104         
105         testLaunchButtonsColumn = new Column();
106         controlsColumn.add(testLaunchButtonsColumn);
107
108         addTest("Button", "ButtonTest");
109         addTest("Client Configuration", "ClientConfigurationTest");
110         addTest("Client Exception", "ClientExceptionTest");
111         addTest("Column", "ColumnTest");
112         addTest("Command", "CommandTest");
113         addTest("Composite", "CompositeTest");
114         addTest("Container Context", "ContainerContextTest");
115         addTest("ContentPane", "ContentPaneTest");
116         addTest("Delay", "DelayTest");
117         addTest("Exception", "ExceptionTest");
118         addTest("Grid", "GridTest");
119         addTest("Hierarchy", "HierarchyTest");
120         addTest("Image", "ImageReferenceTest");
121         addTest("Label", "LabelTest");
122         addTest("ListBox", "ListBoxTest");
123         addTest("ListBox (Large Quantity)", "ListRenderTableTest");
124         addTest("Localization", "LocalizationTest");
125         addTest("Panel", "PanelTest");
126         addTest("Push (Basic)", "PushTest");
127         addTest("Push (Ghost Test)", "PushGhostTest");
128         addTest("Random Click", "RandomClickTest");
129         addTest("Row", "RowTest");
130         addTest("SplitPane (Basic)", "SplitPaneTest");
131         addTest("SplitPane (Nested)", "SplitPaneNestedTest");
132         addTest("StyleSheet", "StyleSheetTest");
133         addTest("Table", "TableTest");
134         addTest("Table (Performance)", "TablePerformanceTest");
135         addTest("TextComponent", "TextComponentTest");
136         addTest("Text Sync", "TextSyncTest");
137         addTest("Visibility", "VisibilityTest");
138         addTest("Window", "WindowTest");
139         addTest("WindowPane", "WindowPaneTest");
140         addTest("WindowPane Examples", "WindowPaneExamplesTest");
141         
142         Column applicationControlsColumn = new Column();
143         controlsColumn.add(applicationControlsColumn);
144
145         Button button = new Button("Exit");
146         button.setRenderId("Exit");
147         button.setId("ExitTestApplication");
148         button.setStyleName("Default");
149         button.addActionListener(new ActionListener() {
150             public void actionPerformed(ActionEvent e) {
151                 InteractiveApp.getApp().displayWelcomePane();
152             }
153         });
154         applicationControlsColumn.add(button);
155     }
156     
157     private void addTest(String JavaDoc name, String JavaDoc action) {
158         Button button = new Button(name);
159         button.setRenderId("StartTest" + action);
160         button.setId("StartTest:" + action);
161         button.setActionCommand(action);
162         button.setStyleName("Default");
163         button.addActionListener(commandActionListener);
164         testLaunchButtonsColumn.add(button);
165     }
166 }
167
Popular Tags