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.toolbar;
009:
010: import com.gwtext.client.widgets.*;
011: import com.gwtext.client.widgets.menu.*;
012: import com.gwtext.client.widgets.menu.event.CheckItemListenerAdapter;
013: import com.gwtext.sample.showcase2.client.Showcase2;
014: import com.gwtext.sample.showcase2.client.ShowcasePanel;
015:
016: public class ToolbarSample extends ShowcasePanel {
017:
018: public String getSourceUrl() {
019: return "source/toolbar/ToolbarSample.java.html";
020: }
021:
022: public String getCssUrl() {
023: return "source/toolbar/ToolbarSample.css.html";
024: }
025:
026: public Panel getViewPanel() {
027: if (panel == null) {
028: panel = new Panel();
029:
030: //create a toolbar and various menu items
031: Toolbar toolbar = new Toolbar();
032:
033: Menu menu = new Menu();
034: menu.setShadow(true);
035: menu.setMinWidth(10);
036:
037: final CheckItemListenerAdapter listener = new CheckItemListenerAdapter() {
038: public void onCheckChange(CheckItem item,
039: boolean checked) {
040: Showcase2.showMessage("Event: checkchange", "'"
041: + item.getText() + "' is now "
042: + (checked ? "checked" : "unchecked"));
043: }
044: };
045:
046: CheckItem checkItem = new CheckItem();
047: checkItem.setText("I like Ext");
048: checkItem.setChecked(true);
049: checkItem.addListener(listener);
050: menu.addItem(checkItem);
051:
052: CheckItem checkItem2 = new CheckItem();
053: checkItem2.setText("I also like GWT-Ext :)");
054: checkItem2.setChecked(true);
055: checkItem2.addListener(listener);
056: menu.addItem(checkItem2);
057:
058: CheckItem checkItem3 = new CheckItem();
059: checkItem3.setText("I donated");
060: checkItem3.setChecked(false);
061: checkItem3.addListener(listener);
062: menu.addItem(checkItem3);
063:
064: menu.addSeparator();
065:
066: Menu submenu = new Menu();
067: submenu.setShadow(true);
068: submenu.setMinWidth(10);
069: submenu.addItem(new TextItem(
070: "<b class=\"menu-title\">Choose a Theme</b>"));
071:
072: CheckItem checkItem4 = new CheckItem();
073: checkItem4.setText("Aero Glass");
074: checkItem4.setChecked(true);
075: checkItem4.setGroup("theme");
076: checkItem4.addListener(listener);
077: submenu.addItem(checkItem4);
078:
079: CheckItem checkItem5 = new CheckItem();
080: checkItem5.setText("Vista Black");
081: checkItem5.setGroup("theme");
082: checkItem5.addListener(listener);
083: submenu.addItem(checkItem5);
084:
085: CheckItem checkItem7 = new CheckItem();
086: checkItem7.setText("Gray Theme");
087: checkItem7.setGroup("theme");
088: checkItem7.addListener(listener);
089: submenu.addItem(checkItem7);
090:
091: CheckItem checkItem8 = new CheckItem();
092: checkItem8.setText("Default Theme");
093: checkItem8.setGroup("theme");
094: checkItem8.addListener(listener);
095: submenu.addItem(checkItem8);
096:
097: MenuItem menuItem = new MenuItem("Radio Options", submenu);
098: MenuItem dateMenuItem = new MenuItem("Choose a Date",
099: new DateMenu());
100: MenuItem colorMenuItem = new MenuItem("Choose a Color",
101: new ColorMenu());
102: menu.addItem(menuItem);
103: menu.addItem(dateMenuItem);
104: menu.addItem(colorMenuItem);
105: menu.addSeparator();
106:
107: Item item = new Item();
108: item.setText("Dynamically added");
109:
110: Item item2 = new Item("Disabled");
111: item2.setDisabled(true);
112: menu.addItem(item);
113: menu.addItem(item2);
114:
115: ToolbarButton menuButton = new ToolbarButton(
116: "Button w/ Menu");
117: menuButton.setMenu(menu);
118: menuButton.setIconCls("bmenu");
119: toolbar.addButton(menuButton);
120: toolbar.addSeparator();
121:
122: Menu splitMenu = new Menu();
123: Item bi = new Item();
124: bi.setText("<b>Bold</b>");
125: splitMenu.addItem(bi);
126:
127: Item ii = new Item();
128: ii.setText("<i>Italic</i>");
129: splitMenu.addItem(ii);
130:
131: Item ui = new Item();
132: ui.setText("<u>Underline</u>");
133: splitMenu.addItem(ui);
134:
135: splitMenu.addSeparator();
136:
137: Menu colorMenu = new Menu();
138: colorMenu.addItem(new ColorItem());
139: colorMenu.addSeparator();
140: Item moreColors = new Item();
141: moreColors.setText("More Colors...");
142: colorMenu.addItem(moreColors);
143:
144: MenuItem colorMI = new MenuItem("Pic a Color", colorMenu);
145: splitMenu.addItem(colorMI);
146: Item excellent = new Item();
147: excellent.setText("Excellent");
148: splitMenu.addItem(excellent);
149:
150: ToolbarMenuButton button2 = new ToolbarMenuButton(
151: "Split Button", splitMenu);
152:
153: toolbar.addButton(button2);
154: toolbar.addSeparator();
155:
156: ToolbarButton toggleButton = new ToolbarButton("Toggle Me");
157: toggleButton.setEnableToggle(true);
158: toggleButton.setPressed(true);
159: QuickTipsConfig tipsConfig = new QuickTipsConfig();
160: tipsConfig.setText("This is a quicktip with a title");
161: tipsConfig.setTitle("Tip Title");
162: toggleButton.setTooltip(tipsConfig);
163:
164: ToolbarButton iconOnly = new ToolbarButton();
165: iconOnly.setIcon("images/add-feed.gif");
166: iconOnly.setCls("x-btn-icon");
167: iconOnly
168: .setTooltip("<b>Quick Tips</b><br/>Icon only button with tooltip");
169:
170: toolbar.addButton(iconOnly);
171: toolbar.addSeparator();
172: toolbar.addButton(toggleButton);
173:
174: toolbar.addSeparator();
175: ToolbarTextItem ti = new ToolbarTextItem("Text Item");
176: toolbar.addItem(ti);
177:
178: Panel toolbarPanel = new Panel();
179: toolbarPanel.setWidth(500);
180: toolbarPanel.setHeight(400);
181: toolbarPanel.setTopToolbar(toolbar);
182:
183: panel.add(toolbarPanel);
184: }
185: return panel;
186: }
187:
188: protected boolean showEvents() {
189: return true;
190: }
191:
192: public String getIntro() {
193: return "<p>This example demonstrates creatign a Toolbar with various items and menu items. A toobar directly to a Panel "
194: + "or placed at the top and / or bottom on any Panel like a GridPanel, a FormPanel or a TreePanel as illustrated by "
195: + "other examples in this Showcase.</p>";
196: }
197: }
|