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.form;
09:
10: import com.google.gwt.core.client.JavaScriptObject;
11: import com.google.gwt.user.client.ui.RootPanel;
12: import com.gwtext.client.core.EventObject;
13: import com.gwtext.client.widgets.ColorPalette;
14: import com.gwtext.client.widgets.event.ColorPaletteListenerAdapter;
15: import com.gwtext.client.widgets.form.TriggerField;
16:
17: public class LookupField extends TriggerField {
18:
19: private ColorPalette colorPalette;
20:
21: public LookupField() {
22: }
23:
24: public LookupField(JavaScriptObject jsObj) {
25: super (jsObj);
26: }
27:
28: protected void onTriggerClick(EventObject event) {
29: if (colorPalette == null) {
30: colorPalette = new ColorPalette();
31: colorPalette.addListener(new ColorPaletteListenerAdapter() {
32: public void onSelect(ColorPalette colorPalette,
33: String color) {
34: LookupField.this .setStyle("background-color:"
35: + color + ";background-image:none;");
36: colorPalette.hide();
37: }
38: });
39: colorPalette.render(RootPanel.getBodyElement());
40: }
41: colorPalette.getEl().setXY(event.getXY()[0], event.getXY()[1],
42: false);
43: colorPalette.show();
44: }
45:
46: }
|