Source Code Cross Referenced for Component.java in  » Ajax » gwtext-2.01 » com » gwtext » client » widgets » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » gwtext 2.01 » com.gwtext.client.widgets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * GWT-Ext Widget Library
0003:         * Copyright(c) 2007-2008, GWT-Ext.
0004:         * licensing@gwt-ext.com
0005:         * 
0006:         * http://www.gwt-ext.com/license
0007:         */
0008:
0009:        package com.gwtext.client.widgets;
0010:
0011:        import com.google.gwt.core.client.GWT;
0012:        import com.google.gwt.core.client.JavaScriptObject;
0013:        import com.google.gwt.user.client.DOM;
0014:        import com.google.gwt.user.client.Element;
0015:        import com.google.gwt.user.client.ui.RootPanel;
0016:        import com.google.gwt.user.client.ui.Widget;
0017:        import com.gwtext.client.core.Ext;
0018:        import com.gwtext.client.core.ExtElement;
0019:        import com.gwtext.client.core.Function;
0020:        import com.gwtext.client.util.DOMUtil;
0021:        import com.gwtext.client.util.JavaScriptObjectHelper;
0022:        import com.gwtext.client.widgets.event.ComponentListener;
0023:
0024:        import java.util.*;
0025:
0026:        /**
0027:         * <p>Base class for all Ext components.  All subclasses of Component can automatically participate in the standard
0028:         * Ext component lifecycle of creation, rendering and destruction.  They also have automatic support for basic hide/show
0029:         * and enable/disable behavior.   All visual widgets that require rendering into a layout should subclass Component (or
0030:         * BoxComponent if managed box model handling is required).</p>
0031:         * <p>Every component has a specific xtype.  This is the list of all valid xtypes:</p>
0032:         * <pre>
0033:         * <p/>
0034:         * xtype            Class
0035:         * -------------    ------------------
0036:         * box              BoxComponent
0037:         * button           Button
0038:         * colorpalette     ColorPalette
0039:         * component        Component
0040:         * container        Container
0041:         * cycle            CycleButton
0042:         * dataview         DataView
0043:         * datepicker       DatePicker
0044:         * editor           Editor
0045:         * editorgrid       EditorGridPanel
0046:         * grid             GridPanel
0047:         * paging           PagingToolbar
0048:         * panel            Panel
0049:         * progress         ProgressBar
0050:         * splitbutton      SplitButton
0051:         * tabpanel         TabPanel
0052:         * treepanel        TreePanel
0053:         * viewport         ViewPort
0054:         * window           Window
0055:         * <p/>
0056:         * Toolbar components
0057:         * ---------------------------------------
0058:         * toolbar          Toolbar
0059:         * <p/>
0060:         * Form components
0061:         * ---------------------------------------
0062:         * checkbox         Checkbox
0063:         * combo            ComboBox
0064:         * datefield        DateField
0065:         * field            Field
0066:         * fieldset         FieldSet
0067:         * form             FormPanel
0068:         * hidden           Hidden
0069:         * htmleditor       HtmlEditor
0070:         * numberfield      NumberField
0071:         * radio            Radio
0072:         * textarea         TextArea
0073:         * textfield        TextField
0074:         * timefield        TimeField</pre>
0075:         */
0076:        public abstract class Component extends Widget implements  Observable {
0077:
0078:            private static JavaScriptObject configPrototype;
0079:            private Map configListeners = new HashMap();
0080:
0081:            protected String id;
0082:
0083:            protected JavaScriptObject config;
0084:            private boolean initHidden = false;
0085:            private boolean initDisabled = false;
0086:
0087:            static {
0088:                init();
0089:            }
0090:
0091:            protected native JavaScriptObject cloneConfig(
0092:                    JavaScriptObject config)/*-{
0093:                    var clone = {};
0094:                    var id = $wnd.Ext.id();
0095:                    var cfg = $wnd.Ext.applyIf(clone, config);
0096:                    cfg.id = id; // prevent dup id
0097:                    return clone;
0098:                }-*/;
0099:
0100:            private static native void init()/*-{
0101:                    var c = new $wnd.Ext.Component();
0102:                    @com.gwtext.client.widgets.Component::configPrototype = c.initialConfig;
0103:                    
0104:                    $wnd.Ext.Component.prototype.initComponent=function() {
0105:                        var compJ = this.__compJ;
0106:                        if(compJ != null) {
0107:                            compJ.@com.gwtext.client.widgets.Component::doInitComponent()();
0108:                        }
0109:                    };
0110:                }-*/;
0111:
0112:            /**
0113:             * Create a new Component.
0114:             */
0115:            public Component() {
0116:                id = Ext.generateId();
0117:                initConfig();
0118:                if (config == null) {
0119:                    config = JavaScriptObjectHelper.createObject();
0120:                }
0121:                JavaScriptObjectHelper.setAttribute(config, "__compJ", this );
0122:                JavaScriptObjectHelper.setAttribute(config, "id", id);
0123:                JavaScriptObjectHelper
0124:                        .setAttribute(config, "xtype", getXType());
0125:                makeObservable(config);
0126:            }
0127:
0128:            /**
0129:             * Component Constructor. Applies the Component to an existing element.
0130:             *
0131:             * @param element the Element to apply the Component to
0132:             */
0133:            public Component(Element element) {
0134:                id = DOMUtil.getID(element);
0135:                if (id == null) {
0136:                    id = Ext.generateId();
0137:                    DOMUtil.setID(element, id);
0138:                }
0139:                config = JavaScriptObjectHelper.createObject();
0140:                setId(id);
0141:                setApplyTo(element);
0142:                getOrCreateJsObj();
0143:            }
0144:
0145:            public Component(JavaScriptObject jsObj) {
0146:                id = JavaScriptObjectHelper.getAttribute(jsObj, "id");
0147:                config = jsObj;
0148:                setElement(getElement(jsObj));
0149:            }
0150:
0151:            /**
0152:             * Creates a Component object reference for an already rendered Component.
0153:             *
0154:             * @param id the Component ID
0155:             */
0156:            public Component(String id) {
0157:                setElement(getElement(getComponentJS(id)));
0158:            }
0159:
0160:            private void doInitComponent() {
0161:                doClear();
0162:                for (Iterator iterator = configListeners.keySet().iterator(); iterator
0163:                        .hasNext();) {
0164:                    String event = (String) iterator.next();
0165:                    List listeners = (List) configListeners.get(event);
0166:                    for (int i = 0; i < listeners.size(); i++) {
0167:                        JavaScriptObject listener = (JavaScriptObject) listeners
0168:                                .get(i);
0169:                        addListener(event, listener);
0170:                    }
0171:                }
0172:                configListeners.clear();
0173:                configListeners = null;
0174:                initComponent();
0175:                addListener("render", new Function() {
0176:                    public void execute() {
0177:                        Component.this .afterRender();
0178:                    }
0179:                });
0180:
0181:                addListener("beforedestroy", new Function() {
0182:                    public void execute() {
0183:                        JavaScriptObjectHelper.setAttribute(Component.this 
0184:                                .getConfig(), "__compJ", (String) null);
0185:                        if (isRendered()) {
0186:                            doBeforeDestroy(Component.this .getJsObj());
0187:                        }
0188:                        beforeDestroy();
0189:                    }
0190:
0191:                    private native void doBeforeDestroy(JavaScriptObject jsObj) /*-{
0192:                                   if(jsObj != null && jsObj.__compJ) {
0193:                                       jsObj.__compJ = null;
0194:                                   }
0195:                               }-*/;
0196:                });
0197:                addListener("destroy", new Function() {
0198:                    public void execute() {
0199:                        onDestroy();
0200:                    }
0201:                });
0202:            }
0203:
0204:            /**
0205:             * This template method is called after the Component has been instantiated but before it's rendered. Subclasses
0206:             * can override it to provide any "constructor" type logic thats desired/
0207:             */
0208:            protected void initComponent() {
0209:            }
0210:
0211:            /**
0212:             * Template method that is called after the Component has been renedered.
0213:             */
0214:            protected void afterRender() {
0215:            }
0216:
0217:            /**
0218:             * This template method is called before the component is destroy. Subclasses can add any cleanup logic on destoy here.
0219:             */
0220:            protected void beforeDestroy() {
0221:            }
0222:
0223:            /**
0224:             * This template method is called on component destroy. Subclasses can add any cleanup logic on destoy here.
0225:             */
0226:            protected void onDestroy() {
0227:            }
0228:
0229:            private native void doClear() /*-{
0230:                   var config = this.@com.gwtext.client.widgets.Component::config;
0231:                   config['__compJ'] = null;
0232:               }-*/;
0233:
0234:            private native void makeObservable(JavaScriptObject config) /*-{
0235:                   if(config.listeners == null || config.listeners === undefined) {
0236:                       //config.listeners = new $wnd.Array();
0237:                       config.listeners = new Object();
0238:                   }
0239:               }-*/;
0240:
0241:            public JavaScriptObject getJsObj() {
0242:                JavaScriptObject jsObj = getComponentJS(id);
0243:                return jsObj;
0244:            }
0245:
0246:            //create only, dont render
0247:            public JavaScriptObject getOrCreateJsObj() {
0248:                JavaScriptObject jsObj = getComponentJS(id);
0249:                if (jsObj != null) {
0250:                    return jsObj;
0251:                } else {
0252:                    //create object here
0253:                    return create(config);
0254:                }
0255:            }
0256:
0257:            protected static native JavaScriptObject getComponentJS(String id)/*-{
0258:                    var cmp = $wnd.Ext.ComponentMgr.get(id);
0259:            		return (cmp === undefined || cmp == null) ? null : cmp;
0260:            	}-*/;
0261:
0262:            protected void addListener(String event, JavaScriptObject fn) {
0263:                if (!isCreated()) {
0264:                    addConfigListener(event, fn);
0265:                } else {
0266:                    addWidgetListener(event, fn);
0267:                }
0268:            }
0269:
0270:            private native void addWidgetListener(String event,
0271:                    JavaScriptObject fn) /*-{
0272:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0273:                   component.addListener(event, fn);
0274:               }-*/;
0275:
0276:            private void addConfigListener(String event, JavaScriptObject fn) {
0277:                List listeners = (List) configListeners.get(event);
0278:                if (listeners == null)
0279:                    listeners = new ArrayList();
0280:                listeners.add(fn);
0281:                configListeners.put(event, listeners);
0282:            }
0283:
0284:            public JavaScriptObject getConfig() {
0285:                return config;
0286:            }
0287:
0288:            protected abstract JavaScriptObject getConfigPrototype();
0289:
0290:            private void initConfig() {
0291:                config = cloneConfig(getConfigPrototype());
0292:                JavaScriptObjectHelper
0293:                        .setAttribute(config, "xtype", getXType());
0294:            }
0295:
0296:            protected native Element getElement(JavaScriptObject jsObj) /*-{
0297:                   //var el = jsObj.el;
0298:                   var extEl = jsObj.getEl();
0299:                   if(extEl == null || extEl === undefined) {
0300:                       return null;
0301:                   }
0302:                   var el = extEl.dom;
0303:                   if(el == null || el === undefined) {
0304:                       return null;
0305:                       //forms buttons are detached when initially added
0306:                       //throw new Error('Widget ' + jsObj + ' has no element property set');
0307:                   } else {
0308:                       //There's an inconsistency in Ext where most elements have the property 'el' set to Ext's Element
0309:                       //with the exception of Menu->Item, Menu->Separator, Menu->TextItem,  Toolbar.Item and subclasses
0310:                       //(Toolbar.Separator, Toolbar.Spacer, Toolbar.TextItem) where the 'el' property is set to
0311:                       //the DOM element itself. Therefore retruning 'el' if 'el' is not Ext's Element. See details in issue 39.
0312:                        return el.dom || el ;
0313:                   }
0314:               }-*/;
0315:
0316:            protected abstract JavaScriptObject create(JavaScriptObject config);
0317:
0318:            public Element getElement() {
0319:                if (super .getElement() == null) {
0320:                    JavaScriptObject jsObj = getComponentJS(id);
0321:                    if (!isRendered()) {
0322:                        if (jsObj == null) {
0323:                            jsObj = create(config);
0324:                        }
0325:                        if (getParent() != null
0326:                                && getParent().getElement() != null) {
0327:                            render(getParent().getElement());
0328:                        } else {
0329:                            render(RootPanel.getBodyElement());
0330:                        }
0331:                    }
0332:                    setElement(getElement(jsObj));
0333:                }
0334:                return super .getElement();
0335:            }
0336:
0337:            public void addEvents(String[] events) {
0338:                for (int i = 0; i < events.length; i++) {
0339:                    String event = events[i];
0340:                    addEvent(event);
0341:                }
0342:            }
0343:
0344:            public native void addEvent(String events) /*-{
0345:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0346:                   component.addEvents(events);
0347:               }-*/;
0348:
0349:            /**
0350:             * True if this component is disabled.
0351:             *
0352:             * @return true if disabled
0353:             */
0354:            public boolean isDisabled() {
0355:                if (!isRendered()) {
0356:                    return initDisabled;
0357:                } else {
0358:                    return isDisabledRendered();
0359:                }
0360:            }
0361:
0362:            private native boolean isDisabledRendered() /*-{
0363:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0364:                   return component == null? false : component.disabled;
0365:               }-*/;
0366:
0367:            /**
0368:             * @return true if the component is hidden
0369:             */
0370:            public boolean isHidden() {
0371:                if (!isRendered()) {
0372:                    return initHidden;
0373:                } else {
0374:                    return isHiddenRendered();
0375:                }
0376:            }
0377:
0378:            private native boolean isHiddenRendered() /*-{
0379:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0380:                   return component == null? false : component.hidden;
0381:               }-*/;
0382:
0383:            /**
0384:             * The component's owner Ext.Container (defaults to undefined, and is set automatically when the
0385:             * component is added to a container).
0386:             * <br>
0387:             * <b>Note:</b> This method should be called only after the component has been rendered.
0388:             *
0389:             * @return the owner container
0390:             */
0391:            public native Container getOwnerContainer() /*-{
0392:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0393:            	if (component == null) return null;
0394:            	var ct = component.ownerCt;
0395:                   return ct == null || ct === undefined ? null : @com.gwtext.client.widgets.Container::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(ct);
0396:               }-*/;
0397:
0398:            /**
0399:             * @return true if the underlying widget object has been created
0400:             */
0401:            public boolean isCreated() {
0402:                //JavaScriptObject jsObj = getComponentJS(id);
0403:                return doIsCreated(id);
0404:            }
0405:
0406:            private static native boolean doIsCreated(String id)/*-{
0407:                    var cmp = $wnd.Ext.ComponentMgr.get(id);
0408:            		return cmp == null || cmp === undefined? false : true;
0409:            	}-*/;
0410:
0411:            /**
0412:             * @return true if component has been rendered
0413:             */
0414:            public native boolean isRendered() /*-{
0415:                   var component = this.@com.gwtext.client.widgets.Component::getJsObj()();
0416:                   return component != null && component.rendered;
0417:               }-*/;
0418:
0419:            /**
0420:             * Adds a CSS class to the component's underlying element.
0421:             *
0422:             * @param cls the CSS class
0423:             */
0424:            public void addClass(String cls) {
0425:                if (!isCreated()) {
0426:                    setCls(getCls() == null ? cls : getCls() + " " + cls);
0427:                } else {
0428:                    addClassCreated(cls);
0429:                }
0430:            }
0431:
0432:            public native void addClassCreated(String cls) /*-{
0433:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0434:                   component.addClass(cls);
0435:               }-*/;
0436:
0437:            /**
0438:             * Clone the current component using the original config values passed into this instance by default.
0439:             *
0440:             * @return the cloned copy of this component
0441:             */
0442:            public Component cloneComponent() {
0443:                JavaScriptObject clone = doClone(null);
0444:                return ComponentFactory.getComponent(clone);
0445:            }
0446:
0447:            /**
0448:             * Clone the current component using the original config values passed into this instance by default.
0449:             *
0450:             * @param overrides when cloning
0451:             * @return the cloned copy of this component
0452:             */
0453:            public Component cloneComponent(Component overrides) {
0454:                JavaScriptObject clone = doClone(overrides.getConfig());
0455:                return ComponentFactory.getComponent(clone);
0456:            }
0457:
0458:            private native JavaScriptObject doClone(JavaScriptObject config) /*-{
0459:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0460:                   return component.cloneConfig(config);
0461:               }-*/;
0462:
0463:            /**
0464:             * Destroys this component by purging any event listeners, removing the component's element from the DOM, removing
0465:             * the component from its {@link Container} (if applicable) and unregistering it from {@link ComponentMgr}. Destruction
0466:             * is generally handled automatically by the framework and this method should usually not need to be called directly.
0467:             */
0468:            public native void destroy() /*-{
0469:                   var component = this.@com.gwtext.client.widgets.Component::getJsObj()();
0470:            	if(component != null) component.destroy();
0471:               }-*/;
0472:
0473:            /**
0474:             * Disable this component.
0475:             */
0476:            public void disable() {
0477:                if (!isRendered()) {
0478:                    initDisabled = true;
0479:                    addListener("render", new Function() {
0480:                        public void execute() {
0481:                            disableRendered();
0482:                        }
0483:                    });
0484:                } else {
0485:                    disableRendered();
0486:                }
0487:            }
0488:
0489:            private native void disableRendered() /*-{
0490:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0491:                   component.disable();
0492:               }-*/;
0493:
0494:            /**
0495:             * Enable this component.
0496:             */
0497:            public void enable() {
0498:                if (!isRendered()) {
0499:                    addListener("render", new Function() {
0500:                        public void execute() {
0501:                            enableRendered();
0502:                        }
0503:                    });
0504:                } else {
0505:                    enableRendered();
0506:                }
0507:            }
0508:
0509:            private native void enableRendered() /*-{
0510:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0511:                   component.enable();
0512:               }-*/;
0513:
0514:            /**
0515:             * Try to focus this component.
0516:             */
0517:            public void focus() {
0518:                if (!isRendered()) {
0519:                    addListener("render", new Function() {
0520:                        public void execute() {
0521:                            focusRendered();
0522:                        }
0523:                    });
0524:                }
0525:            }
0526:
0527:            private native void focusRendered() /*-{
0528:                   var component = this.@com.gwtext.client.widgets.Component::getJsObj()();
0529:                   if(component != null) component.focus();
0530:               }-*/;
0531:
0532:            /**
0533:             * Try to focus this component.
0534:             *
0535:             * @param selectText True to also select the text in this component (if applicable)
0536:             */
0537:            public native void focus(boolean selectText) /*-{
0538:                   var component = this.@com.gwtext.client.widgets.Component::getJsObj()();
0539:                   if(component != null) component.focus(selectText);
0540:               }-*/;
0541:
0542:            /**
0543:             * Try to focus this component.
0544:             *
0545:             * @param selectText True to also select the text in this component (if applicable)
0546:             * @param delay	  delay the focus this number of milliseconds (true for 10 milliseconds)
0547:             */
0548:            public native void focus(boolean selectText, int delay) /*-{
0549:                   var component = this.@com.gwtext.client.widgets.Component::getJsObj()();
0550:                   if(component != null) component.focus(selectText);
0551:            }-*/;
0552:
0553:            public native ExtElement getEl() /*-{
0554:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0555:                   var el = component.getEl();
0556:                   if(el == null || el === undefined) {
0557:                       return null;
0558:                   } else {
0559:                       return @com.gwtext.client.core.ExtElement::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(el);
0560:                   }
0561:               }-*/;
0562:
0563:            /**
0564:             * Returns the item id of this component.
0565:             *
0566:             * @return the item ID
0567:             */
0568:            public native String getItemId() /*-{
0569:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0570:                   return component.getItemId();
0571:               }-*/;
0572:
0573:            /**
0574:             * Gets the xtype for this component as registered with ComponentMgr. For a list of all available xtypes,
0575:             * see the Component javadocs.
0576:             * <p/>
0577:             * <pre>
0578:             * <code>
0579:             * <p/>
0580:             * TextField field = new TextField();
0581:             * field.getXType() returns "textfield"
0582:             * </code>
0583:             * </pre>
0584:             *
0585:             * @return the xtype
0586:             */
0587:            public String getXType() {
0588:                return "";
0589:            }
0590:
0591:            /**
0592:             * Returns this component's xtype hierarchy as a slash-delimited string. For a list of all available xtypes, see the
0593:             * Component class javadocs.
0594:             * <p/>
0595:             * <pre>
0596:             * <code>
0597:             * <p/>
0598:             * TextField field = new TextField();
0599:             * field.getXTypes() returns "component/box/field/textfield"
0600:             * </code>
0601:             * </pre>
0602:             *
0603:             * @return the xtype hierarchy string
0604:             */
0605:            public native String getXTypes() /*-{
0606:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0607:                   return component.getXTypes();
0608:               }-*/;
0609:
0610:            /**
0611:             * Hide this component.
0612:             */
0613:            public void hide() {
0614:                if (!isRendered()) {
0615:                    initHidden = true;
0616:                    addListener("render", new Function() {
0617:                        public void execute() {
0618:                            hideRendered();
0619:                        }
0620:                    });
0621:                } else {
0622:                    hideRendered();
0623:                }
0624:            }
0625:
0626:            private native void hideRendered() /*-{
0627:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0628:                   component.hide();
0629:               }-*/;
0630:
0631:            /**
0632:             * Returns true if this component is visible.
0633:             *
0634:             * @return true if visible
0635:             */
0636:            public native boolean isVisible() /*-{
0637:                   var component = this.@com.gwtext.client.widgets.Component::getJsObj()();
0638:                   return component == null ? false : component.isVisible();
0639:               }-*/;
0640:
0641:            /**
0642:             * Tests whether or not this component is of a specific xtype. This can test whether this component is descended from
0643:             * the xtype (default) or whether it is directly of the xtype specified (shallow = true). For a list of all available xtypes,
0644:             * see the {@link Component} header. Example usage:
0645:             * <p/>
0646:             * <pre>
0647:             * <code>
0648:             * <p/>
0649:             * <p/>
0650:             * TextField t = new TextField();
0651:             * boolean isText = t.isXType('textfield');        // true
0652:             * boolean isBoxSubclass = t.isXType('box');       // true, descended from BoxComponent
0653:             * boolean  isBoxInstance = t.isXType('box', true); // false, not a direct BoxComponent instance
0654:             * <p/>
0655:             * </code>
0656:             * </pre>
0657:             *
0658:             * @param xtype the xtype to check for this component
0659:             * @return true if is style
0660:             */
0661:            public native boolean isXType(String xtype) /*-{
0662:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0663:                   return component.isXType(xtype);
0664:               }-*/;
0665:
0666:            /**
0667:             * Tests whether or not this component is of a specific xtype. This can test whether this component is descended from
0668:             * the xtype (default) or whether it is directly of the xtype specified (shallow = true). For a list of all available xtypes,
0669:             * see the {@link Component} header. Example usage:
0670:             * <p/>
0671:             * <pre>
0672:             * <code>
0673:             * <p/>
0674:             * <p/>
0675:             * TextField t = new TextField();
0676:             * boolean isText = t.isXType('textfield');        // true
0677:             * boolean isBoxSubclass = t.isXType('box');       // true, descended from BoxComponent
0678:             * boolean  isBoxInstance = t.isXType('box', true); // false, not a direct BoxComponent instance
0679:             * <p/>
0680:             * </code>
0681:             * </pre>
0682:             *
0683:             * @param xtype   the xtype to check for this component
0684:             * @param shallow false to check whether this component is descended from the xtype (this is the default), or true to check whether this component is directly of the specified xtype.
0685:             * @return true if is style
0686:             */
0687:            public native boolean isXType(String xtype, boolean shallow) /*-{
0688:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0689:                   return component.isXType(xtype, shallow);
0690:               }-*/;
0691:
0692:            /**
0693:             * Removes a CSS class from the component's underlying element.
0694:             *
0695:             * @param cls the CSS class to remove
0696:             */
0697:            public native void removeClass(String cls) /*-{
0698:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0699:                   component.removeClass(cls);
0700:               }-*/;
0701:
0702:            /**
0703:             * Convenience function for setting disabled/enabled by boolean.
0704:             *
0705:             * @param disabled true to disable
0706:             */
0707:            public void setDisabled(boolean disabled) {
0708:                if (disabled) {
0709:                    disable();
0710:                } else {
0711:                    enable();
0712:                }
0713:            }
0714:
0715:            /**
0716:             * Convenience function to hide or show this component by boolean.
0717:             *
0718:             * @param visible True to show, false to hide
0719:             */
0720:            public void setVisible(boolean visible) {
0721:                if (visible) {
0722:                    show();
0723:                } else {
0724:                    hide();
0725:                }
0726:            }
0727:
0728:            /**
0729:             * If this is a lazy rendering component, render it to its container element.
0730:             *
0731:             * @param id the element id
0732:             */
0733:            public native void render(String id) /*-{
0734:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0735:                   component.render(id);
0736:               }-*/;
0737:
0738:            /**
0739:             * If this is a lazy rendering component, render it to its container element.
0740:             *
0741:             * @param id	   the element id
0742:             * @param position the element ID within the container <b>before</b> which this
0743:             *                 component will be inserted (defaults to appending to the end of the container)
0744:             */
0745:            public native void render(String id, String position) /*-{
0746:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0747:                   component.render(id, position);
0748:               }-*/;
0749:
0750:            /**
0751:             * If this is a lazy rendering component, render it to its container element.
0752:             *
0753:             * @param id	   the element id
0754:             * @param position the DOM node index within the container <b>before</b> which this
0755:             *                 component will be inserted (defaults to appending to the end of the container)
0756:             */
0757:            public native void render(String id, int position) /*-{
0758:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0759:                   component.render(id, position);
0760:               }-*/;
0761:
0762:            /**
0763:             * If this is a lazy rendering component, render it to its container element.
0764:             *
0765:             * @param element the element
0766:             */
0767:            public native void render(Element element) /*-{
0768:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0769:                   component.render(element);
0770:               }-*/;
0771:
0772:            /**
0773:             * If this is a lazy rendering component, render it to its container element.
0774:             *
0775:             * @param element  the element
0776:             * @param position the element ID within the container <b>before</b> which this
0777:             *                 component will be inserted (defaults to appending to the end of the container)
0778:             */
0779:            public native void render(Element element, String position) /*-{
0780:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0781:                   component.render(element);
0782:               }-*/;
0783:
0784:            /**
0785:             * If this is a lazy rendering component, render it to its container element.
0786:             *
0787:             * @param element  the element
0788:             * @param position the DOM node index within the container <b>before</b> which this
0789:             *                 component will be inserted (defaults to appending to the end of the container)
0790:             */
0791:            public native void render(Element element, int position) /*-{
0792:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0793:                   component.render(element);
0794:               }-*/;
0795:
0796:            /**
0797:             * Show this component.
0798:             */
0799:            public void show() {
0800:                if (!isRendered()) {
0801:                    addListener("render", new Function() {
0802:                        public void execute() {
0803:                            showRendered();
0804:                        }
0805:                    });
0806:                } else {
0807:                    showRendered();
0808:                }
0809:            }
0810:
0811:            private native void showRendered() /*-{
0812:                   var component = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
0813:                   component.show();
0814:               }-*/;
0815:
0816:            /**
0817:             * Add a raw event listener.
0818:             *
0819:             * @param event the event name
0820:             * @param funtion the fintion to execute
0821:             */
0822:            public native void addListener(String event, Function funtion)/*-{
0823:                    this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)(event,
0824:                            function() {
0825:                                return funtion.@com.gwtext.client.core.Function::execute()();
0826:                            }
0827:                    );
0828:                }-*/;
0829:
0830:            /**
0831:             * Add a component listner.
0832:             *
0833:             * @param listener the listener
0834:             */
0835:            protected native void addListener(ComponentListener listener) /*-{
0836:                   var componentJ = this;
0837:
0838:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('beforedestroy',
0839:                           function(source) {
0840:                               return listener.@com.gwtext.client.widgets.event.ComponentListener::doBeforeDestroy(Lcom/gwtext/client/widgets/Component;)(componentJ);
0841:                           }
0842:                   );
0843:
0844:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('beforehide',
0845:                           function(source) {
0846:                               return listener.@com.gwtext.client.widgets.event.ComponentListener::doBeforeHide(Lcom/gwtext/client/widgets/Component;)(componentJ);
0847:                           }
0848:                   );
0849:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('beforerender',
0850:                           function(source) {
0851:                               return listener.@com.gwtext.client.widgets.event.ComponentListener::doBeforeRender(Lcom/gwtext/client/widgets/Component;)(componentJ);
0852:                           }
0853:                   );
0854:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('beforeshow',
0855:                           function(source) {
0856:                               return listener.@com.gwtext.client.widgets.event.ComponentListener::doBeforeShow(Lcom/gwtext/client/widgets/Component;)(componentJ);
0857:                           }
0858:                   );
0859:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('beforestaterestore',
0860:                           function(source, state) {
0861:                               return listener.@com.gwtext.client.widgets.event.ComponentListener::doBeforeStateRestore(Lcom/gwtext/client/widgets/Component;Lcom/google/gwt/core/client/JavaScriptObject;)(componentJ, state);
0862:                           }
0863:                   );
0864:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('beforestatesave',
0865:                           function(source, state) {
0866:                               return listener.@com.gwtext.client.widgets.event.ComponentListener::doBeforeStateSave(Lcom/gwtext/client/widgets/Component;Lcom/google/gwt/core/client/JavaScriptObject;)(componentJ, state);
0867:                           }
0868:                   );
0869:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('destroy',
0870:                           function(source) {
0871:                               listener.@com.gwtext.client.widgets.event.ComponentListener::onDestroy(Lcom/gwtext/client/widgets/Component;)(componentJ);
0872:                           }
0873:                   );
0874:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('disable',
0875:                           function(source) {
0876:                               listener.@com.gwtext.client.widgets.event.ComponentListener::onDisable(Lcom/gwtext/client/widgets/Component;)(componentJ);
0877:                           }
0878:                   );
0879:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('enable',
0880:                           function(source) {
0881:                               listener.@com.gwtext.client.widgets.event.ComponentListener::onEnable(Lcom/gwtext/client/widgets/Component;)(componentJ);
0882:                           }
0883:                   );
0884:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('hide',
0885:                           function(source) {
0886:                               listener.@com.gwtext.client.widgets.event.ComponentListener::onHide(Lcom/gwtext/client/widgets/Component;)(componentJ);
0887:                           }
0888:                   );
0889:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('render',
0890:                           function(source) {
0891:                               listener.@com.gwtext.client.widgets.event.ComponentListener::onRender(Lcom/gwtext/client/widgets/Component;)(componentJ);
0892:                           }
0893:                   );
0894:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('show',
0895:                           function(source) {
0896:                               listener.@com.gwtext.client.widgets.event.ComponentListener::onShow(Lcom/gwtext/client/widgets/Component;)(componentJ);
0897:                           }
0898:                   );
0899:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('staterestore',
0900:                           function(source, state) {
0901:                               listener.@com.gwtext.client.widgets.event.ComponentListener::onStateRestore(Lcom/gwtext/client/widgets/Component;Lcom/google/gwt/core/client/JavaScriptObject;)(componentJ, state);
0902:                           }
0903:                   );
0904:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('statesave',
0905:                           function(source, state) {
0906:                               listener.@com.gwtext.client.widgets.event.ComponentListener::onStateSave(Lcom/gwtext/client/widgets/Component;Lcom/google/gwt/core/client/JavaScriptObject;)(componentJ, state);
0907:                           }
0908:                   );
0909:               }-*/;
0910:
0911:            protected void check() throws IllegalStateException {
0912:                if (isRendered()) {
0913:                    if (GWT.isScript()) {
0914:                        MessageBox
0915:                                .alert("Error",
0916:                                        "Cannot change configuration property after the component has been rendered");
0917:                        throw new IllegalStateException(
0918:                                "Cannot change configuration property after the component has been rendered");
0919:                    }
0920:                }
0921:            }
0922:
0923:            // --------------------- config properties --------------------------
0924:
0925:            //public abstract String getXType();
0926:
0927:            /**
0928:             * The id of the node, a DOM node or an existing Element corresponding to a DIV that is
0929:             * already present in the document that specifies some structural markup for this component.
0930:             * When applyTo is used, constituent parts of the component can also be specified by id or CSS class name within the
0931:             * main element, and the component being created may attempt to create its subcomponents from that markup if applicable.
0932:             * Using this config, a call to render() is not required. If applyTo is specified, any value passed for renderTo will be
0933:             * ignored and the target element's parent node will automatically be used as the component's container.
0934:             *
0935:             * @param element the ID of existing DIV
0936:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
0937:             */
0938:            public void setApplyTo(Element element)
0939:                    throws IllegalStateException {
0940:                setAttribute("applyTo", element, false);
0941:            }
0942:
0943:            /**
0944:             * @return the Element this component was applied to
0945:             */
0946:            public Element getApplyTo() {
0947:                return JavaScriptObjectHelper.getAttributeAsElement(config,
0948:                        "applyTo");
0949:            }
0950:
0951:            public void setAutoEl(String autoEl) {
0952:                setAttribute("autoEl", autoEl, true);
0953:            }
0954:
0955:            /**
0956:             * True if the component should check for hidden classes (e.g. 'x-hidden' or 'x-hide-display') and remove them on render (defaults to false).
0957:             *
0958:             * @param autoShow true to autoShow
0959:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
0960:             */
0961:            public void setAutoShow(boolean autoShow)
0962:                    throws IllegalStateException {
0963:                setAttribute("autoShow", autoShow, true);
0964:            }
0965:
0966:            /**
0967:             * @return true if auto show
0968:             */
0969:            public boolean getAutoShow() {
0970:                return getAttributeAsBoolean("autoShow");
0971:            }
0972:
0973:            /**
0974:             * An optional extra CSS class that will be added to this component's Element (defaults to ''). This can be useful
0975:             * for adding customized styles to the component or any of its children using standard CSS rules.
0976:             *
0977:             * @param cls the CSS class
0978:             */
0979:            public void setCls(String cls) {
0980:                if (isCreated()) {
0981:                    addClass(cls);
0982:                } else {
0983:                    setAttribute("cls", cls, false);
0984:                }
0985:            }
0986:
0987:            /**
0988:             * @return the extra CSS applied to the components Element
0989:             */
0990:            public String getCls() {
0991:                return getAttribute("cls");
0992:            }
0993:
0994:            /**
0995:             * An optional extra CSS class that will be added to this component's container (defaults to ''). This can be useful
0996:             * for adding customized styles to the container or any of its children using standard CSS rules.
0997:             *
0998:             * @param ctCls the container CSS class
0999:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
1000:             */
1001:            public void setCtCls(String ctCls) throws IllegalStateException {
1002:                setAttribute("ctCls", ctCls, true);
1003:            }
1004:
1005:            /**
1006:             * @return the extra CSS class applied to the components container.
1007:             */
1008:            public String getCtCls() {
1009:                return getAttribute("ctCls");
1010:            }
1011:
1012:            /**
1013:             * CSS class added to the component when it is disabled (defaults to "x-item-disabled").
1014:             *
1015:             * @param disabledClass the disabled CSS class
1016:             */
1017:            public void setDisabledClass(String disabledClass) {
1018:                setAttribute("disabledClass", disabledClass, true);
1019:            }
1020:
1021:            /**
1022:             * @return the CSS class used when the component is disabled
1023:             */
1024:            public String getDisabledClass() {
1025:                return getAttribute("disabledClass");
1026:            }
1027:
1028:            /**
1029:             * Sets the underlying Element for the component.
1030:             *
1031:             * @param el the element
1032:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
1033:             */
1034:            public void setEl(Element el) throws IllegalStateException {
1035:                setAttribute("el", new ExtElement(el).getJsObj(), false);
1036:            }
1037:
1038:            public void setEl(String elementID) throws IllegalStateException {
1039:                setAttribute("el", elementID, false);
1040:            }
1041:
1042:            /**
1043:             * How this component should hidden. Supported values are "visibility" (css visibility), "offsets" (negative offset
1044:             * position) and "display" (css display) - defaults to "display".
1045:             *
1046:             * @param hideMode the hide mode
1047:             */
1048:            public void setHideMode(String hideMode) {
1049:                setAttribute("hideMode", hideMode, true);
1050:            }
1051:
1052:            /**
1053:             * How this component should hidden. Supported values are "visibility" (css visibility), "offsets" (negative offset
1054:             * position) and "display" (css display) - defaults to "display".
1055:             *
1056:             * @return the hide mode
1057:             */
1058:            public String getHideMode() {
1059:                return getAttribute("hideMode");
1060:            }
1061:
1062:            /**
1063:             * True to hide and show the component's container when hide/show is called on the component, false to hide and show
1064:             * the component itself (defaults to false). For example, this can be used as a shortcut for a hide button on a window
1065:             * by setting hide:true on the button when adding it to its parent container.
1066:             *
1067:             * @param hideParent true to hide and show the component's container when hide/show is called on the component
1068:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
1069:             */
1070:            public void setHideParent(boolean hideParent)
1071:                    throws IllegalStateException {
1072:                setAttribute("hideParent", hideParent, true);
1073:            }
1074:
1075:            /**
1076:             * @return true if hideParent enabled
1077:             */
1078:            public boolean getHideParent() {
1079:                return getAttributeAsBoolean("hideParent");
1080:            }
1081:
1082:            /**
1083:             * The unique id of this component (defaults to an auto-assigned id).
1084:             *
1085:             * <br>
1086:             * <b>Note:</b> ID's cannot be changed after the component has been rendered.
1087:             *
1088:             * @param id the components ID
1089:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
1090:             */
1091:            public final void setId(String id) throws IllegalStateException {
1092:                setAttribute("id", id, false);
1093:                this .id = id;
1094:            }
1095:
1096:            /**
1097:             * @return the ID of the Component
1098:             */
1099:            public String getId() {
1100:                return id;
1101:            }
1102:
1103:            //todo ext 2.0
1104:            /*public void setPlugins(ComponentPlugin plugins) {
1105:            		JavaScriptObjectHelper.setAttribute(jsObj, "plugins", plugins);
1106:            	}*/
1107:
1108:            /**
1109:             * The id of the node, a DOM node or an existing Element that will be the container to render this component into.
1110:             * Using this config, a call to render() is not required.
1111:             *
1112:             * @param elem the container element
1113:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
1114:             */
1115:            public void setRenderTo(Element elem) throws IllegalStateException {
1116:                setAttribute("renderTo", elem, false);
1117:            }
1118:
1119:            /**
1120:             * @return the element the Component is rendered to
1121:             */
1122:            public Element getRenderTo() {
1123:                return JavaScriptObjectHelper.getAttributeAsElement(config,
1124:                        "renderTo");
1125:            }
1126:
1127:            /**
1128:             * An array of events that, when fired, should trigger this component to save its state (defaults to none). These can be
1129:             * any types of events supported by this component, including browser or custom events (e.g., ['click', 'customerchange']).
1130:             *
1131:             * @param stateEvents an array of state events
1132:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
1133:             */
1134:            public void setStateEvents(String[] stateEvents)
1135:                    throws IllegalStateException {
1136:                setAttribute("stateEvents", stateEvents, true);
1137:            }
1138:
1139:            /**
1140:             * An array of events that, when fired, should trigger this component to save its state (defaults to none). These can be
1141:             * any types of events supported by this component, including browser or custom events (e.g., ['click', 'customerchange']).
1142:             *
1143:             * @return an array of state events
1144:             */
1145:            public String[] getStateEvents() {
1146:                return JavaScriptObjectHelper.getAttributeAsStringArray(config,
1147:                        "stateEvents");
1148:            }
1149:
1150:            /**
1151:             * The unique id for this component to use for state management purposes (defaults to the component id).
1152:             *
1153:             * @param stateId the state ID
1154:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
1155:             */
1156:            public void setStateId(String stateId) throws IllegalStateException {
1157:                setAttribute("stateId", stateId, false);
1158:            }
1159:
1160:            /**
1161:             * The unique id for this component to use for state management purposes (defaults to the component id).
1162:             *
1163:             * @return the state ID
1164:             */
1165:            public String getStateId() {
1166:                return getAttribute("stateId");
1167:            }
1168:
1169:            /**
1170:             * A custom style specification to be applied to this component's Element.
1171:             *
1172:             * @param style the CSS style specification
1173:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
1174:             */
1175:            public void setStyle(String style) throws IllegalStateException {
1176:                if (!isRendered()) {
1177:                    setAttribute("style", style, true);
1178:                } else {
1179:                    Ext.get(getId()).applyStyles(style);
1180:                }
1181:            }
1182:
1183:            /**
1184:             * @return the custom style specification applied to the element
1185:             */
1186:            public String getStyle() {
1187:                return getAttribute("style");
1188:            }
1189:
1190:            //fix GWT code for element access by using accessor and not member reference, this bug is fixed
1191:            //in GWT 1.5
1192:            public int getOffsetHeight() {
1193:                return DOM.getElementPropertyInt(getElement(), "offsetHeight");
1194:            }
1195:
1196:            public int getOffsetWidth() {
1197:                return DOM.getElementPropertyInt(getElement(), "offsetWidth");
1198:            }
1199:
1200:            protected Element getStyleElement() {
1201:                return getElement();
1202:            }
1203:
1204:            public String getTitle() {
1205:                return DOM.getElementProperty(getElement(), "title");
1206:            }
1207:
1208:            public void setHeight(String height) {
1209:                // This exists to deal with an inconsistency in IE's implementation where
1210:                // it won't accept negative numbers in length measurements
1211:                assert extractLengthValue(height.trim().toLowerCase()) >= 0 : "CSS heights should not be negative";
1212:                DOM.setStyleAttribute(getElement(), "height", height);
1213:            }
1214:
1215:            private native double extractLengthValue(String s) /*-{
1216:               if (s == "auto" || s == "inherit" || s == "") {
1217:                 return 0;
1218:               } else {
1219:                 return parseFloat(s);
1220:               }
1221:             }-*/;
1222:
1223:            public void setTitle(final String title) {
1224:                if (isRendered()) {
1225:                    if (title == null || title.length() == 0) {
1226:                        DOM.removeElementAttribute(getElement(), "title");
1227:                    } else {
1228:                        DOM.setElementAttribute(getElement(), "title", title);
1229:                    }
1230:                } else {
1231:                    addListener("render", new Function() {
1232:                        public void execute() {
1233:                            setTitle(title);
1234:                        }
1235:                    });
1236:                }
1237:            }
1238:
1239:            protected String getAttribute(String attribute) {
1240:                if (isCreated()) {
1241:                    return JavaScriptObjectHelper.getAttribute(getJsObj(),
1242:                            attribute);
1243:                } else {
1244:                    return JavaScriptObjectHelper.getAttribute(config,
1245:                            attribute);
1246:                }
1247:            }
1248:
1249:            protected JavaScriptObject getAttributeAsJavaScriptObject(
1250:                    String attribute) {
1251:                if (isCreated()) {
1252:                    return JavaScriptObjectHelper
1253:                            .getAttributeAsJavaScriptObject(getJsObj(),
1254:                                    attribute);
1255:                } else {
1256:                    return JavaScriptObjectHelper
1257:                            .getAttributeAsJavaScriptObject(config, attribute);
1258:                }
1259:            }
1260:
1261:            protected int getAttributeAsInt(String attribute) {
1262:                if (isCreated()) {
1263:                    return JavaScriptObjectHelper.getAttributeAsInt(getJsObj(),
1264:                            attribute);
1265:                } else {
1266:                    return JavaScriptObjectHelper.getAttributeAsInt(config,
1267:                            attribute);
1268:                }
1269:            }
1270:
1271:            protected float getAttributeAsFloat(String attribute) {
1272:                if (isCreated()) {
1273:                    return JavaScriptObjectHelper.getAttributeAsFloat(
1274:                            getJsObj(), attribute);
1275:                } else {
1276:                    return JavaScriptObjectHelper.getAttributeAsFloat(config,
1277:                            attribute);
1278:                }
1279:            }
1280:
1281:            protected boolean getAttributeAsBoolean(String attribute) {
1282:                if (isRendered()) {
1283:                    return JavaScriptObjectHelper.getAttributeAsBoolean(
1284:                            getJsObj(), attribute);
1285:                } else {
1286:                    return JavaScriptObjectHelper.getAttributeAsBoolean(config,
1287:                            attribute);
1288:                }
1289:            }
1290:
1291:            private void error(String attribute, String value,
1292:                    boolean allowPostCreate) throws IllegalStateException {
1293:                if (allowPostCreate) {
1294:                    error("Cannot change configuration property '" + attribute
1295:                            + "' after the component has been rendered.");
1296:                } else {
1297:                    error("Cannot change configuration property '" + attribute
1298:                            + "' after the component has been created.");
1299:                }
1300:            }
1301:
1302:            protected void error(String message) throws IllegalStateException {
1303:                if (!GWT.isScript()) {
1304:                    MessageBox.alert("Error", message);
1305:                    throw new IllegalStateException(message);
1306:                }
1307:            }
1308:
1309:            protected void setAttribute(String attribute, String value,
1310:                    boolean allowPostCreate) {
1311:                setAttribute(attribute, value, allowPostCreate, false);
1312:            }
1313:
1314:            protected void setAttribute(String attribute, String value,
1315:                    boolean allowPostCreate, boolean allowPostRendered) {
1316:                if (!isCreated()) {
1317:                    JavaScriptObjectHelper.setAttribute(config, attribute,
1318:                            value);
1319:                } else if (!isRendered() && allowPostCreate
1320:                        || allowPostRendered) {
1321:                    JavaScriptObjectHelper.setAttribute(getJsObj(), attribute,
1322:                            value);
1323:                } else {
1324:                    error(attribute, value, allowPostCreate);
1325:                }
1326:            }
1327:
1328:            protected void setAttribute(String attribute, int[] value,
1329:                    boolean allowPostCreate) {
1330:                setAttribute(attribute, value, allowPostCreate, false);
1331:            }
1332:
1333:            protected void setAttribute(String attribute, int[] value,
1334:                    boolean allowPostCreate, boolean allowPostRender) {
1335:                if (!isCreated()) {
1336:                    JavaScriptObjectHelper.setAttribute(config, attribute,
1337:                            value);
1338:                } else if (!isRendered() && allowPostCreate || allowPostRender) {
1339:                    JavaScriptObjectHelper.setAttribute(getJsObj(), attribute,
1340:                            value);
1341:                } else {
1342:                    error(attribute, value.toString(), allowPostCreate);
1343:                }
1344:            }
1345:
1346:            protected void setAttribute(String attribute, long value,
1347:                    boolean allowPostCreate) {
1348:                if (!isCreated()) {
1349:                    JavaScriptObjectHelper.setAttribute(config, attribute,
1350:                            value);
1351:                } else if (!isRendered() && allowPostCreate) {
1352:                    JavaScriptObjectHelper.setAttribute(getJsObj(), attribute,
1353:                            value);
1354:                } else {
1355:                    error(attribute, String.valueOf(value), allowPostCreate);
1356:                }
1357:            }
1358:
1359:            protected void setAttribute(String attribute, double value,
1360:                    boolean allowPostCreate) {
1361:                if (!isCreated()) {
1362:                    JavaScriptObjectHelper.setAttribute(config, attribute,
1363:                            value);
1364:                } else if (!isRendered() && allowPostCreate) {
1365:                    JavaScriptObjectHelper.setAttribute(getJsObj(), attribute,
1366:                            value);
1367:                } else {
1368:                    error(attribute, String.valueOf(value), allowPostCreate);
1369:                }
1370:            }
1371:
1372:            protected void setAttribute(String attribute, int value,
1373:                    boolean allowPostCreate) {
1374:                setAttribute(attribute, value, allowPostCreate, false);
1375:            }
1376:
1377:            protected void setAttribute(String attribute, int value,
1378:                    boolean allowPostCreate, boolean allowPostRender) {
1379:                if (!isCreated()) {
1380:                    JavaScriptObjectHelper.setAttribute(config, attribute,
1381:                            value);
1382:                } else if (!isRendered() && allowPostCreate || allowPostRender) {
1383:                    JavaScriptObjectHelper.setAttribute(getJsObj(), attribute,
1384:                            value);
1385:                } else {
1386:                    error(attribute, String.valueOf(value), allowPostCreate);
1387:                }
1388:            }
1389:
1390:            protected void setAttribute(String attribute, Date value,
1391:                    boolean allowPostCreate) {
1392:                if (!isCreated()) {
1393:                    JavaScriptObjectHelper.setAttribute(config, attribute,
1394:                            value);
1395:                } else if (!isRendered() && allowPostCreate) {
1396:                    JavaScriptObjectHelper.setAttribute(getJsObj(), attribute,
1397:                            value);
1398:                } else {
1399:                    error(attribute, String.valueOf(value), allowPostCreate);
1400:                }
1401:            }
1402:
1403:            protected void setAttribute(String attribute,
1404:                    JavaScriptObject value, boolean allowPostCreate) {
1405:                setAttribute(attribute, value, allowPostCreate, false);
1406:            }
1407:
1408:            protected void setAttribute(String attribute,
1409:                    JavaScriptObject value, boolean allowPostCreate,
1410:                    boolean allowPostRender) {
1411:                if (!isCreated()) {
1412:                    JavaScriptObjectHelper.setAttribute(config, attribute,
1413:                            value);
1414:                } else if (!isRendered() && allowPostCreate || allowPostRender) {
1415:                    JavaScriptObjectHelper.setAttribute(getJsObj(), attribute,
1416:                            value);
1417:                } else {
1418:                    error(attribute, String.valueOf(value), allowPostCreate);
1419:                }
1420:            }
1421:
1422:            protected void setAttribute(String attribute, String[] value,
1423:                    boolean allowPostCreate) {
1424:                setAttribute(attribute, value, allowPostCreate, false);
1425:            }
1426:
1427:            protected void setAttribute(String attribute, String[] value,
1428:                    boolean allowPostCreate, boolean allowPostRender) {
1429:                if (!isCreated()) {
1430:                    JavaScriptObjectHelper.setAttribute(config, attribute,
1431:                            value);
1432:                } else if (!isRendered() && allowPostCreate || allowPostRender) {
1433:                    JavaScriptObjectHelper.setAttribute(getJsObj(), attribute,
1434:                            value);
1435:                } else {
1436:                    error(attribute, String.valueOf(value), allowPostCreate);
1437:                }
1438:            }
1439:
1440:            protected void setAttribute(String attribute, boolean value,
1441:                    boolean allowPostCreate) {
1442:                setAttribute(attribute, value, allowPostCreate, false);
1443:            }
1444:
1445:            protected void setAttribute(String attribute, boolean value,
1446:                    boolean allowPostCreate, boolean allowPostRendered) {
1447:                if (!isCreated()) {
1448:                    JavaScriptObjectHelper.setAttribute(config, attribute,
1449:                            value);
1450:                } else if (!isRendered() && allowPostCreate
1451:                        || allowPostRendered) {
1452:                    JavaScriptObjectHelper.setAttribute(getJsObj(), attribute,
1453:                            value);
1454:                } else {
1455:                    error(attribute, String.valueOf(value), allowPostCreate);
1456:                }
1457:            }
1458:
1459:            protected void setAttribute(String attribute, Element value,
1460:                    boolean allowPostCreate) {
1461:                setAttribute(attribute, value, allowPostCreate, false);
1462:            }
1463:
1464:            protected void setAttribute(String attribute, Element value,
1465:                    boolean allowPostCreate, boolean allowPostRendered) {
1466:                if (!isCreated()) {
1467:                    JavaScriptObjectHelper.setAttribute(config, attribute,
1468:                            value);
1469:                } else if (!isRendered() && allowPostCreate
1470:                        || allowPostRendered) {
1471:                    JavaScriptObjectHelper.setAttribute(getJsObj(), attribute,
1472:                            value);
1473:                } else {
1474:                    error(attribute, String.valueOf(value), allowPostCreate);
1475:                }
1476:            }
1477:
1478:            public void setWidth(String width) {
1479:                // This exists to deal with an inconsistency in IE's implementation where
1480:                // it won't accept negative numbers in length measurements
1481:                assert extractLengthValue(width.trim().toLowerCase()) >= 0 : "CSS widths should not be negative";
1482:                DOM.setStyleAttribute(getElement(), "width", width);
1483:            }
1484:
1485:            public boolean equals(Object obj) {
1486:                if (obj instanceof  BaseExtWidget) {
1487:                    return getElement().equals(
1488:                            ((BaseExtWidget) obj).getElement());
1489:                } else {
1490:                    return false;
1491:                }
1492:            }
1493:
1494:            public int hashCode() {
1495:                return getElement().hashCode();
1496:            }
1497:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.