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.testscreen;
031:
032: import nextapp.echo2.app.Button;
033: import nextapp.echo2.app.Color;
034: import nextapp.echo2.app.ContentPane;
035: import nextapp.echo2.app.Extent;
036: import nextapp.echo2.app.FloatingPane;
037: import nextapp.echo2.app.Insets;
038: import nextapp.echo2.app.Label;
039: import nextapp.echo2.app.SplitPane;
040: import nextapp.echo2.app.WindowPane;
041: import nextapp.echo2.app.event.ActionEvent;
042: import nextapp.echo2.app.event.ActionListener;
043: import nextapp.echo2.app.layout.SplitPaneLayoutData;
044: import nextapp.echo2.testapp.interactive.ButtonColumn;
045: import nextapp.echo2.testapp.interactive.InteractiveApp;
046: import nextapp.echo2.testapp.interactive.StyleUtil;
047:
048: /**
049: * Interactive test module for <code>ContentPane</code>s.
050: */
051: public class ContentPaneTest extends SplitPane {
052:
053: public ContentPaneTest() {
054: super (SplitPane.ORIENTATION_HORIZONTAL, new Extent(250,
055: Extent.PX));
056: setStyleName("DefaultResizable");
057:
058: final ContentPane rootContentPane = InteractiveApp.getApp()
059: .getDefaultWindow().getContent();
060: final Label contentLabel = new Label(
061: StyleUtil.QUASI_LATIN_TEXT_1
062: + StyleUtil.QUASI_LATIN_TEXT_1);
063:
064: ButtonColumn controlsColumn = new ButtonColumn();
065: controlsColumn.setStyleName("TestControlsColumn");
066: add(controlsColumn);
067:
068: final ContentPane testContentPane = new ContentPane();
069: add(testContentPane);
070:
071: controlsColumn.add(new Label("Root Content Pane"));
072:
073: controlsColumn.addButton("Reset", new ActionListener() {
074: public void actionPerformed(ActionEvent e) {
075: rootContentPane.setBackground(null);
076: rootContentPane.setForeground(null);
077: rootContentPane.setFont(null);
078: }
079: });
080: controlsColumn.addButton("Change Background",
081: new ActionListener() {
082: public void actionPerformed(ActionEvent e) {
083: rootContentPane.setBackground(StyleUtil
084: .randomColor());
085: }
086: });
087: controlsColumn.addButton("Change Foreground",
088: new ActionListener() {
089: public void actionPerformed(ActionEvent e) {
090: rootContentPane.setForeground(StyleUtil
091: .randomColor());
092: }
093: });
094: controlsColumn.addButton("Change Font", new ActionListener() {
095: public void actionPerformed(ActionEvent e) {
096: rootContentPane.setFont(StyleUtil.randomFont());
097: }
098: });
099:
100: controlsColumn.add(new Label("Test Content Pane"));
101:
102: controlsColumn.addButton("Reset", new ActionListener() {
103: public void actionPerformed(ActionEvent e) {
104: testContentPane.setBackground(null);
105: testContentPane.setForeground(null);
106: testContentPane.setFont(null);
107: }
108: });
109: controlsColumn.addButton("Change Background",
110: new ActionListener() {
111: public void actionPerformed(ActionEvent e) {
112: testContentPane.setBackground(StyleUtil
113: .randomColor());
114: }
115: });
116: controlsColumn.addButton("Change Foreground",
117: new ActionListener() {
118: public void actionPerformed(ActionEvent e) {
119: testContentPane.setForeground(StyleUtil
120: .randomColor());
121: }
122: });
123: controlsColumn.addButton("Change Font", new ActionListener() {
124: public void actionPerformed(ActionEvent e) {
125: testContentPane.setFont(StyleUtil.randomFont());
126: }
127: });
128:
129: controlsColumn.addButton("Add Label", new ActionListener() {
130: public void actionPerformed(ActionEvent e) {
131: removeAllContent(testContentPane);
132: testContentPane.add(contentLabel);
133: }
134: });
135: controlsColumn.addButton("Add SplitPane", new ActionListener() {
136: public void actionPerformed(ActionEvent e) {
137: removeAllContent(testContentPane);
138: SplitPane splitPane = new SplitPane();
139: splitPane.setResizable(true);
140:
141: Label label;
142: SplitPaneLayoutData layoutData;
143:
144: layoutData = new SplitPaneLayoutData();
145: layoutData.setBackground(new Color(0xafafff));
146: label = new Label(StyleUtil.QUASI_LATIN_TEXT_1);
147: label.setLayoutData(layoutData);
148: splitPane.add(label);
149:
150: layoutData = new SplitPaneLayoutData();
151: layoutData.setBackground(new Color(0xafffaf));
152: label = new Label(StyleUtil.QUASI_LATIN_TEXT_1);
153: label.setLayoutData(layoutData);
154: splitPane.add(label);
155:
156: testContentPane.add(splitPane);
157: }
158: });
159: controlsColumn.addButton(
160: "Add SplitPane / ContentPane / Button",
161: new ActionListener() {
162: public void actionPerformed(ActionEvent e) {
163: removeAllContent(testContentPane);
164: SplitPane splitPane = new SplitPane();
165: splitPane.setResizable(true);
166:
167: Label label;
168: SplitPaneLayoutData layoutData;
169:
170: layoutData = new SplitPaneLayoutData();
171: layoutData.setBackground(new Color(0xafafff));
172: ContentPane subContentPane = new ContentPane();
173: subContentPane.setLayoutData(layoutData);
174: splitPane.add(subContentPane);
175:
176: SplitPane splitPane2 = new SplitPane(
177: SplitPane.ORIENTATION_VERTICAL);
178: subContentPane.add(splitPane2);
179:
180: ContentPane subContentPane2 = new ContentPane();
181: splitPane2.add(subContentPane2);
182: subContentPane2.add(new Label("Test!"));
183:
184: ContentPane subContentPane3 = new ContentPane();
185: splitPane2.add(subContentPane3);
186:
187: final Button button = new Button("Alpha");
188: button.addActionListener(new ActionListener() {
189: public void actionPerformed(ActionEvent e) {
190: button
191: .setText("Alpha".equals(button
192: .getText()) ? "Omega"
193: : "Alpha");
194: }
195: });
196: subContentPane3.add(button);
197:
198: layoutData = new SplitPaneLayoutData();
199: layoutData.setBackground(new Color(0xafffaf));
200: label = new Label(StyleUtil.QUASI_LATIN_TEXT_1);
201: label.setLayoutData(layoutData);
202: splitPane.add(label);
203:
204: testContentPane.add(splitPane);
205: }
206: });
207:
208: controlsColumn.addButton("Add WindowPane",
209: new ActionListener() {
210: public void actionPerformed(ActionEvent e) {
211: testContentPane.add(new WindowPane());
212: }
213: });
214: controlsColumn.addButton("Set Horizontal Scroll = null",
215: new ActionListener() {
216: public void actionPerformed(ActionEvent e) {
217: testContentPane.setHorizontalScroll(null);
218: }
219: });
220: controlsColumn.addButton("Set Horizontal Scroll = 0",
221: new ActionListener() {
222: public void actionPerformed(ActionEvent e) {
223: testContentPane.setHorizontalScroll(new Extent(
224: 0));
225: }
226: });
227: controlsColumn.addButton("Set Horizontal Scroll = 50",
228: new ActionListener() {
229: public void actionPerformed(ActionEvent e) {
230: testContentPane.setHorizontalScroll(new Extent(
231: 50));
232: }
233: });
234: controlsColumn.addButton("Set Horizontal Scroll = 100",
235: new ActionListener() {
236: public void actionPerformed(ActionEvent e) {
237: testContentPane.setHorizontalScroll(new Extent(
238: 100));
239: }
240: });
241: controlsColumn.addButton("Set Horizontal Scroll = End (-1)",
242: new ActionListener() {
243: public void actionPerformed(ActionEvent e) {
244: testContentPane.setHorizontalScroll(new Extent(
245: -1));
246: }
247: });
248:
249: controlsColumn.addButton("Set Vertical Scroll = null",
250: new ActionListener() {
251: public void actionPerformed(ActionEvent e) {
252: testContentPane.setVerticalScroll(null);
253: }
254: });
255: controlsColumn.addButton("Set Vertical Scroll = 0",
256: new ActionListener() {
257: public void actionPerformed(ActionEvent e) {
258: testContentPane
259: .setVerticalScroll(new Extent(0));
260: }
261: });
262: controlsColumn.addButton("Set Vertical Scroll = 50",
263: new ActionListener() {
264: public void actionPerformed(ActionEvent e) {
265: testContentPane
266: .setVerticalScroll(new Extent(50));
267: }
268: });
269: controlsColumn.addButton("Set Vertical Scroll = 100",
270: new ActionListener() {
271: public void actionPerformed(ActionEvent e) {
272: testContentPane.setVerticalScroll(new Extent(
273: 100));
274: }
275: });
276: controlsColumn.addButton("Set Vertical Scroll = End (-1)",
277: new ActionListener() {
278: public void actionPerformed(ActionEvent e) {
279: testContentPane
280: .setVerticalScroll(new Extent(-1));
281: }
282: });
283:
284: controlsColumn.addButton("Insets -> null",
285: new ActionListener() {
286: public void actionPerformed(ActionEvent e) {
287: testContentPane.setInsets(null);
288: }
289: });
290: controlsColumn.addButton("Insets -> 0px", new ActionListener() {
291: public void actionPerformed(ActionEvent e) {
292: testContentPane.setInsets(new Insets(0));
293: }
294: });
295: controlsColumn.addButton("Insets -> 5px", new ActionListener() {
296: public void actionPerformed(ActionEvent e) {
297: testContentPane.setInsets(new Insets(5));
298: }
299: });
300: controlsColumn.addButton("Insets -> 10/20/30/40px",
301: new ActionListener() {
302: public void actionPerformed(ActionEvent e) {
303: testContentPane.setInsets(new Insets(10, 20,
304: 30, 40));
305: }
306: });
307: }
308:
309: private void removeAllContent(ContentPane contentPane) {
310: int count = contentPane.getComponentCount();
311: for (int i = count - 1; i >= 0; --i) {
312: if (contentPane.getComponent(i) instanceof FloatingPane) {
313: continue;
314: }
315: contentPane.remove(i);
316: }
317: }
318: }
|