Threaded View

  1. #1
    Ext GWT Premium Member mariusz.pala's Avatar
    Join Date
    Jun 2008
    Location
    Poland
    Posts
    298
    Vote Rating
    2
    mariusz.pala is on a distinguished road

      0  

    Default ComboBox with a possibility to clear value

    ComboBox with a possibility to clear value


    I guess some people may find it usefull. The main problem with ComboBox is that there is no way to clear once selected value (if combobox is readonly). That's why I extended it with an additional clear button.

    Code:
    public class XComboBox<D extends ModelData> extends ComboBox<D> {
    
        protected El twinTrigger;
    
        private final String twinTriggerStyle = "x-form-clear-trigger";
        private El span;
    
        public XComboBox() {
            super();
        }
    
        @Override
        protected Size adjustInputSize() {
            return new Size(span.getWidth(), 0);
        }
    
        protected void afterRender() {
            super.afterRender();
            addStyleOnOver(twinTrigger.dom, "x-form-trigger-over");
        }
    
        @Override
        public void onComponentEvent(ComponentEvent ce) {
            super.onComponentEvent(ce);
            int type = ce.getEventTypeInt();
            if ((ce.getTarget() == twinTrigger.dom) && (type == Event.ONCLICK)) {
                onTwinTriggerClick(ce);
            }
        }
    
        @Override
        protected void onRender(Element target, int index) {
            input = new El(DOM.createInputText());
            setElement(DOM.createDiv(), target, index);
            addStyleName("x-form-field-wrap");
    
            trigger = new El(DOM.createImg());
            trigger.dom.setClassName("x-form-trigger " + triggerStyle);
            trigger.dom.setPropertyString("src", GXT.BLANK_IMAGE_URL);
    
            twinTrigger = new El(DOM.createImg());
            twinTrigger.dom.setClassName("x-form-trigger " + twinTriggerStyle);
            twinTrigger.dom.setPropertyString("src", GXT.BLANK_IMAGE_URL);
    
            span = new El(DOM.createSpan());
            span.dom.setClassName("x-form-twin-triggers");
    
            span.appendChild(trigger.dom);
            span.appendChild(twinTrigger.dom);
    
            el().appendChild(input.dom);
            el().appendChild(span.dom);
    
            if (isHideTrigger()) {
                span.setVisible(false);
            }
    
            super.onRender(target, index);
    
            if (!isEditable()) {
                setEditable(false);
            }
        }
    
        protected void onTwinTriggerClick(ComponentEvent ce) {
            boolean allowBlank = getAllowBlank();
            if (!allowBlank) {
                setAllowBlank(true);
            }
            setValue(null);
            setAllowBlank(allowBlank);
    
            fireEvent(Events.TwinTriggerClick, ce);
        }
    
    }
    Attached Images

Thread Participants: 3

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi