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.layout;
009:
010: import com.gwtext.client.core.EventObject;
011: import com.gwtext.client.widgets.Button;
012: import com.gwtext.client.widgets.Panel;
013: import com.gwtext.client.widgets.Toolbar;
014: import com.gwtext.client.widgets.ToolbarButton;
015: import com.gwtext.client.widgets.event.ButtonListenerAdapter;
016: import com.gwtext.client.widgets.layout.CardLayout;
017: import com.gwtext.sample.showcase2.client.ShowcasePanel;
018:
019: public class CardLayoutSample extends ShowcasePanel {
020:
021: public String getSourceUrl() {
022: return "source/layout/CardLayoutSample.java.html";
023: }
024:
025: public Panel getViewPanel() {
026: if (panel == null) {
027: panel = new Panel();
028:
029: final Panel wizardPanel = new Panel();
030: wizardPanel.setHeight(250);
031: wizardPanel.setWidth(350);
032: wizardPanel.setTitle("Example Wizard");
033: wizardPanel.setLayout(new CardLayout());
034: wizardPanel.setActiveItem(0);
035: wizardPanel.setPaddings(15);
036:
037: ButtonListenerAdapter listener = new ButtonListenerAdapter() {
038: public void onClick(Button button, EventObject e) {
039: String btnID = button.getId();
040: CardLayout cardLayout = (CardLayout) wizardPanel
041: .getLayout();
042: String panelID = cardLayout.getActiveItem().getId();
043:
044: if (btnID.equals("move-prev")) {
045: if (panelID.equals("card-3")) {
046: cardLayout.setActiveItem(1);
047: } else {
048: cardLayout.setActiveItem(0);
049: }
050: } else {
051:
052: if (panelID.equals("card-1")) {
053: cardLayout.setActiveItem(1);
054: } else {
055: cardLayout.setActiveItem(2);
056: }
057: }
058: }
059: };
060:
061: Toolbar toolbar = new Toolbar();
062:
063: ToolbarButton backButton = new ToolbarButton("Back",
064: listener);
065: backButton.setId("move-prev");
066: toolbar.addButton(backButton);
067: toolbar.addFill();
068:
069: ToolbarButton nextButton = new ToolbarButton("Next",
070: listener);
071: nextButton.setId("move-next");
072: toolbar.addButton(nextButton);
073:
074: wizardPanel.setBottomToolbar(toolbar);
075:
076: Panel first = new Panel();
077: first.setBorder(false);
078: first.setId("card-1");
079: first
080: .setHtml("<h1>Welcome to the Wizard!</h1><p>Step 1 of 3</p>");
081:
082: Panel second = new Panel();
083: second.setBorder(false);
084: second.setId("card-2");
085: second.setHtml("<p>Step 2 of 3</p>");
086:
087: Panel third = new Panel();
088: third.setBorder(false);
089: third.setId("card-3");
090: third
091: .setHtml("<h1>Congratulations!</h1><p>Step 3 of 3 - Complete</p>");
092:
093: wizardPanel.add(first);
094: wizardPanel.add(second);
095: wizardPanel.add(third);
096:
097: panel.add(wizardPanel);
098: }
099: return panel;
100: }
101:
102: public String getIntro() {
103: return "<p>Card layout contains multiple panels, each fit to the container, where only a single panel can be visible at any given time.</p>"
104: + "<p>This layout style is most commonly used for wizards as illustrated by this example.</p>";
105: }
106: }
|