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.Style;
11:
12: import com.google.gwt.user.client.DOM;
13: import com.google.gwt.user.client.ui.Widget;
14: import com.google.gwt.user.client.ui.WidgetHelper;
15:
16: /**
17: * Allows any widget to be placed in a tool bar.
18: */
19: public class ToolItemAdapter extends ToolItem {
20:
21: private Widget widget;
22:
23: /**
24: * Creates a new adapter.
25: *
26: * @param widget the widget to be adapted
27: */
28: public ToolItemAdapter(Widget widget) {
29: super (Style.PUSH);
30: this .widget = widget;
31: if (isAttached()) {
32: WidgetHelper.doAttach(widget);
33: }
34: overStyleEnabled = false;
35: }
36:
37: protected void onRender() {
38: setElement(DOM.createDiv());
39: DOM.appendChild(getElement(), widget.getElement());
40: }
41:
42: protected void doAttachChildren() {
43: super .doAttachChildren();
44: WidgetHelper.doAttach(widget);
45: }
46:
47: protected void doDetachChildren() {
48: super.doDetachChildren();
49: WidgetHelper.doDetach(widget);
50: }
51:
52: }
|