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;
09:
10: import com.gwtext.client.data.Record;
11: import com.gwtext.client.data.SimpleStore;
12: import com.gwtext.client.data.Store;
13: import com.gwtext.client.util.CSS;
14: import com.gwtext.client.widgets.form.ComboBox;
15: import com.gwtext.client.widgets.form.event.ComboBoxListenerAdapter;
16:
17: /**
18: * A simple dynamic Theme Changer ComboBox. You must have the Ext theme stylesheet declared in your host html page
19: * using the id "theme".
20: *
21: * For example
22: *
23: * <link id="theme" rel="stylesheet" type="text/css" href="js/ext/resources/css/xtheme-gray.css"/>
24: * or
25: * <link id="theme" rel="stylesheet" type="text/css" href="xtheme-default.css"/>
26: *
27: */
28: public class ThemeChanger extends ComboBox {
29:
30: public ThemeChanger() {
31:
32: final Store store = new SimpleStore(new String[] { "theme",
33: "label" }, new Object[][] {
34: new Object[] { "js/ext/resources/css/xtheme-gray.css",
35: "Gray" },
36: new Object[] { "xtheme-default.css", "Aero Glass" } });
37: store.load();
38:
39: setFieldLabel("Select Theme");
40: setEditable(false);
41: setStore(store);
42: setDisplayField("label");
43: setForceSelection(true);
44: setTriggerAction(ComboBox.ALL);
45: setValue("Gray");
46: setFieldLabel("Switch theme");
47: addListener(new ComboBoxListenerAdapter() {
48: public void onSelect(ComboBox comboBox, Record record,
49: int index) {
50: String theme = record.getAsString("theme");
51: CSS.swapStyleSheet("theme", theme);
52: }
53: });
54: setWidth(100);
55: }
56: }
|