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.Composite;
033: import nextapp.echo2.app.Extent;
034: import nextapp.echo2.app.Grid;
035: import nextapp.echo2.app.Insets;
036: import nextapp.echo2.app.Label;
037: import nextapp.echo2.app.SplitPane;
038: import nextapp.echo2.app.event.ActionEvent;
039: import nextapp.echo2.app.event.ActionListener;
040: import nextapp.echo2.testapp.interactive.ButtonColumn;
041: import nextapp.echo2.testapp.interactive.StyleUtil;
042:
043: /**
044: * Interactive test for the <code>Container</code> component.
045: */
046: public class CompositeTest extends SplitPane {
047:
048: public CompositeTest() {
049: super (SplitPane.ORIENTATION_HORIZONTAL, new Extent(250,
050: Extent.PX));
051: setStyleName("DefaultResizable");
052:
053: ButtonColumn controlsColumn = new ButtonColumn();
054: controlsColumn.setStyleName("TestControlsColumn");
055: add(controlsColumn);
056:
057: final Composite container = new Composite() {
058: };
059: add(container);
060:
061: controlsColumn.addButton("Reset", new ActionListener() {
062: public void actionPerformed(ActionEvent e) {
063: container.setBackground(null);
064: container.setForeground(null);
065: container.setFont(null);
066: }
067: });
068: controlsColumn.addButton("Change Background",
069: new ActionListener() {
070: public void actionPerformed(ActionEvent e) {
071: container
072: .setBackground(StyleUtil.randomColor());
073: }
074: });
075: controlsColumn.addButton("Change Foreground",
076: new ActionListener() {
077: public void actionPerformed(ActionEvent e) {
078: container
079: .setForeground(StyleUtil.randomColor());
080: }
081: });
082: controlsColumn.addButton("Change Font", new ActionListener() {
083: public void actionPerformed(ActionEvent e) {
084: container.setFont(StyleUtil.randomFont());
085: }
086: });
087: controlsColumn.addButton("Set Content (Label)",
088: new ActionListener() {
089: public void actionPerformed(ActionEvent e) {
090: if (container.getComponentCount() > 0) {
091: container.removeAll();
092: }
093: container.add(new Label("Hello, world!"));
094: }
095: });
096: controlsColumn.addButton("Set Content (Long Label)",
097: new ActionListener() {
098: public void actionPerformed(ActionEvent e) {
099: if (container.getComponentCount() > 0) {
100: container.removeAll();
101: }
102: container.add(new Label(
103: StyleUtil.QUASI_LATIN_TEXT_1));
104: }
105: });
106: controlsColumn.addButton("Set Content (Grid)",
107: new ActionListener() {
108: public void actionPerformed(ActionEvent e) {
109: if (container.getComponentCount() > 0) {
110: container.removeAll();
111: }
112: Grid grid = new Grid();
113: grid.setBorder(StyleUtil.randomBorder());
114: grid.setInsets(new Insets(StyleUtil
115: .randomExtent(8)));
116: grid.add(new Label("A label"));
117: grid.add(new Label("A label"));
118: grid.add(new Label("A label"));
119: grid.add(new Label("A label"));
120: grid.add(new Label("A label"));
121: container.add(grid);
122: }
123: });
124: controlsColumn.addButton("Clear Content", new ActionListener() {
125: public void actionPerformed(ActionEvent e) {
126: container.removeAll();
127: }
128: });
129: controlsColumn.addButton("Add Component", new ActionListener() {
130: public void actionPerformed(ActionEvent e) {
131: if (container.getParent() == null) {
132: CompositeTest.this .add(container);
133: }
134: }
135: });
136: controlsColumn.addButton("Remove Component",
137: new ActionListener() {
138: public void actionPerformed(ActionEvent e) {
139: if (container.getParent() != null) {
140: CompositeTest.this.remove(container);
141: }
142: }
143: });
144: }
145: }
|