01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.ui.client.widget;
09:
10: import net.mygwt.ui.client.MyGWT;
11: import com.google.gwt.user.client.ui.ChangeListener;
12: import com.google.gwt.user.client.ui.ListBox;
13: import com.google.gwt.user.client.ui.Widget;
14:
15: /**
16: * A ListBox for selecting the MyGWT themes. Changing themes will cause the
17: * application to be reloaded.
18: */
19: public class ThemeSelector extends ListBox {
20:
21: public ThemeSelector() {
22: setStyleName("my-form-field");
23: addChangeListener(new ChangeListener() {
24: public void onChange(Widget sender) {
25: String val = getValue(getSelectedIndex());
26: if (val.indexOf("default") != -1) {
27: MyGWT.switchTheme("default");
28: } else {
29: MyGWT.switchTheme("gray");
30: }
31: reload();
32: }
33: });
34:
35: addItem(MyGWT.MESSAGES.blueTheme(), "default");
36: addItem(MyGWT.MESSAGES.grayTheme(), "gray");
37:
38: String theme = MyGWT.getTheme();
39: if (theme != null && theme.indexOf("g") != -1) {
40: setSelectedIndex(1);
41: }
42:
43: setWidth("100px");
44: }
45:
46: private native void reload() /*-{
47: $wnd.location.reload();
48: }-*/;
49:
50: }
|