001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008: package com.gwtext.sample.showcase2.client.form;
009:
010: import com.google.gwt.user.client.ui.Image;
011: import com.gwtext.client.widgets.PaddedPanel;
012: import com.gwtext.client.widgets.Panel;
013: import com.gwtext.client.widgets.ToolTip;
014: import com.gwtext.client.widgets.form.*;
015: import com.gwtext.client.widgets.layout.ColumnLayoutData;
016: import com.gwtext.sample.showcase2.client.ShowcasePanel;
017:
018: public class MultiFieldFormSample extends ShowcasePanel {
019:
020: public String getSourceUrl() {
021: return "source/form/MultiFieldFormSample.java.html";
022: }
023:
024: public Panel getViewPanel() {
025: if (panel == null) {
026: panel = new Panel();
027:
028: final FormPanel formPanel = new FormPanel();
029: formPanel.setFrame(true);
030: formPanel.setBorder(true);
031: formPanel.setTitle("Multiple Fields on Row");
032: formPanel.setWidth(550);
033: formPanel.setLabelWidth(100);
034: formPanel.setUrl("save-form.php");
035:
036: TextField firstName = new TextField("First / Last",
037: "first", 110, "Sanjiv");
038:
039: TextField lastName = new TextField("Last Name", "last",
040: 110, "Jivan");
041: lastName.setHideLabel(true);
042:
043: MultiFieldPanel namePanel = new MultiFieldPanel();
044: namePanel.addToRow(firstName, 220);
045: namePanel.addToRow(lastName, new ColumnLayoutData(1));
046: formPanel.add(namePanel);
047:
048: TextField company = new TextField("Company", "company", 222);
049: formPanel.add(company);
050:
051: MultiFieldPanel dateTimePanel = new MultiFieldPanel();
052: dateTimePanel.addToRow(new DateField("Appointment",
053: "appointment", 140), 250);
054: TimeField timeField = new TimeField();
055: timeField.setHideLabel(true);
056: timeField.setWidth(80);
057: dateTimePanel.addToRow(timeField, new ColumnLayoutData(1));
058: formPanel.add(dateTimePanel);
059:
060: TextField email = new TextField("Email", "email", 222);
061: email.setVtype(VType.EMAIL);
062: formPanel.add(email);
063:
064: Image image = new Image("images/captcha.jpg");
065: Panel imagePanel = new Panel();
066: imagePanel.setBorder(false);
067: imagePanel.add(image);
068:
069: ToolTip imageToolTip = new ToolTip("Tooltip on an Image");
070: imageToolTip.applyTo(image.getElement());
071:
072: formPanel.add(new PaddedPanel(imagePanel, 0, 110, 0, 5));
073:
074: MultiFieldPanel captchaPanel = new MultiFieldPanel();
075: TextField captchaField = new TextField("Captcha",
076: "captcha", 110);
077: captchaPanel.addToRow(captchaField, 220);
078:
079: ToolTip fieldToolTip = new ToolTip("Tooltip on a Field.");
080: fieldToolTip.applyTo(captchaField);
081:
082: Image info = new Image("images/silk/information.gif");
083:
084: ToolTip tooltip = new ToolTip();
085: tooltip
086: .setHtml("A <b>CAPTCHA</b> is a challenge-response test to determine whether the user is human.");
087: tooltip.setWidth(150);
088: tooltip.applyTo(info.getElement());
089:
090: captchaPanel.addToRow(info, new ColumnLayoutData(1));
091: formPanel.add(captchaPanel);
092:
093: panel.add(formPanel);
094: }
095:
096: return panel;
097: }
098:
099: public String getIntro() {
100: return "<p>This example demonstrates how multiple Fields can be added to a single row.</p><p>It also demonstrates an image being added to the form and the use of "
101: + "tooltips on any element, including Images and TextFields.</p>";
102: }
103: }
|