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.Border;
033: import nextapp.echo2.app.Color;
034: import nextapp.echo2.app.Extent;
035: import nextapp.echo2.app.Insets;
036: import nextapp.echo2.app.Column;
037: import nextapp.echo2.app.Label;
038: import nextapp.echo2.app.SplitPane;
039: import nextapp.echo2.app.TextArea;
040: import nextapp.echo2.app.event.ActionEvent;
041: import nextapp.echo2.app.event.ActionListener;
042: import nextapp.echo2.app.layout.SplitPaneLayoutData;
043: import nextapp.echo2.app.text.StringDocument;
044: import nextapp.echo2.testapp.interactive.ButtonColumn;
045:
046: public class TextSyncTest extends SplitPane {
047:
048: public TextSyncTest() {
049: super (SplitPane.ORIENTATION_HORIZONTAL, new Extent(250,
050: Extent.PX));
051: setStyleName("DefaultResizable");
052:
053: SplitPaneLayoutData splitPaneLayoutData;
054:
055: ButtonColumn controlsColumn = new ButtonColumn();
056: controlsColumn.setStyleName("TestControlsColumn");
057: add(controlsColumn);
058:
059: final Column testColumn = new Column();
060: testColumn.setCellSpacing(new Extent(15));
061: splitPaneLayoutData = new SplitPaneLayoutData();
062: splitPaneLayoutData.setInsets(new Insets(15));
063: testColumn.setLayoutData(splitPaneLayoutData);
064: add(testColumn);
065:
066: Label testLabel = new Label(
067: "This test is used to evaluate the capability of TextComponents to continue receiving "
068: + "user input during server interactions. This capability is critical as server-pushed operations may be "
069: + "taking place while the user is typing (which would otherwise result in typed characters silently being "
070: + "dropped if they were typed at the exact instant that the server were performing a synchronization. "
071: + "To use this test, focus the text field, click one of the test buttons and begin typing during the "
072: + "synchronization operation. Verify using the debug pane that the input is being handled correctly for each "
073: + "scenario.");
074: testColumn.add(testLabel);
075:
076: final TextArea textArea = new TextArea(new StringDocument(),
077: null, 40, 8);
078: textArea
079: .setBorder(new Border(1, Color.BLUE, Border.STYLE_SOLID));
080: testColumn.add(textArea);
081:
082: controlsColumn.addButton("3 Second Server Interaction Delay",
083: new ActionListener() {
084: public void actionPerformed(ActionEvent e) {
085: try {
086: Thread.sleep(3000);
087: } catch (InterruptedException ex) {
088: }
089: }
090: });
091:
092: controlsColumn.addButton(
093: "3 Second Server Interaction Delay; Set Text",
094: new ActionListener() {
095: public void actionPerformed(ActionEvent e) {
096: try {
097: Thread.sleep(3000);
098: } catch (InterruptedException ex) {
099: }
100: textArea.getDocument().setText(
101: "The text value has been reset.");
102: }
103: });
104:
105: controlsColumn.addButton(
106: "3 Second Server Interaction Delay; Remove Text Area",
107: new ActionListener() {
108: public void actionPerformed(ActionEvent e) {
109: try {
110: Thread.sleep(3000);
111: } catch (InterruptedException ex) {
112: }
113: testColumn.remove(textArea);
114: }
115: });
116: }
117: }
|