01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.sample.showcase2.client.layout;
09:
10: import com.gwtext.client.core.EventObject;
11: import com.gwtext.client.widgets.Button;
12: import com.gwtext.client.widgets.Panel;
13: import com.gwtext.client.widgets.Window;
14: import com.gwtext.client.widgets.event.ButtonListenerAdapter;
15: import com.gwtext.client.widgets.layout.AccordionLayout;
16: import com.gwtext.client.widgets.layout.HorizontalLayout;
17: import com.gwtext.sample.showcase2.client.ShowcasePanel;
18:
19: public class AccordionLayoutSample extends ShowcasePanel {
20:
21: public String getSourceUrl() {
22: return "source/layout/AccordionLayoutSample.java.html";
23: }
24:
25: public String getCssUrl() {
26: return "source/layout/AccordionLayoutSample.java.html";
27: }
28:
29: public Panel getViewPanel() {
30: if (panel == null) {
31:
32: panel = new Panel();
33: panel.setLayout(new HorizontalLayout(15));
34:
35: Panel accordionPanel = createAccordionPanel();
36: accordionPanel.setTitle("Accordion Panel");
37: accordionPanel.setHeight(400);
38: accordionPanel.setWidth(200);
39:
40: Button button = new Button("Show Accordion in Window",
41: new ButtonListenerAdapter() {
42: public void onClick(Button button, EventObject e) {
43: Panel accordionPanel = createAccordionPanel();
44: Window window = new Window();
45: window.setTitle("Accordion Window");
46: window.setWidth(200);
47: window.setHeight(400);
48: window.add(accordionPanel);
49: window.show(button.getId());
50: }
51: });
52:
53: panel.add(accordionPanel);
54: panel.add(button);
55:
56: }
57: return panel;
58: }
59:
60: private Panel createAccordionPanel() {
61: Panel accordionPanel = new Panel();
62: accordionPanel.setLayout(new AccordionLayout(true));
63:
64: Panel panelOne = new Panel("Panel 1", "<p>Panel1 content!</p>");
65: panelOne.setIconCls("settings-icon");
66: accordionPanel.add(panelOne);
67:
68: Panel panelTwo = new Panel("Panel 2", "<p>Panel2 content!</p>");
69: panelTwo.setIconCls("folder-icon");
70: accordionPanel.add(panelTwo);
71:
72: Panel panelThree = new Panel("Panel 3",
73: "<p>Panel3 content!</p>");
74: panelThree.setIconCls("user-add-icon");
75: accordionPanel.add(panelThree);
76:
77: return accordionPanel;
78: }
79:
80: public String getIntro() {
81: return "<p>This example illustrates how the create an Accordion using the AccordionLayout. You simply create a parent panel, "
82: + "assign it the AccordionLayout and then add sub-panels to the main panel. Thats it! They layout manager takes care of "
83: + "rendering the panels as an Accordion.</p>"
84: + "<p>In this example clicking the Botton displays a Window to which an Accodion has been added.</p>";
85: }
86: }
|