| 1 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 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 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 screenClassName = "nextapp.echo2.testapp.interactive.testscreen." + e.getActionCommand(); 66 Class 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 ex) { 73 throw new RuntimeException (ex.toString()); 74 } catch (InstantiationException ex) { 75 throw new RuntimeException (ex.toString()); 76 } catch (IllegalAccessException ex) { 77 throw new RuntimeException (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 name, String 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 |