1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    19
    Answers
    1
    Vote Rating
    0
    p33t is on a distinguished road

      0  

    Default Answered: Custom PropertyEditor / ValueBaseInputCell

    Answered: Custom PropertyEditor / ValueBaseInputCell


    I'm trying to write a custom field editor that will translate between Long and String. IE: String representation on screen but field type is a Long.

    I've implemented the PropertyEditor (HrMinPropertyEditor) but don't know how to wire it in. My HrMinField is quite clunky as I needed to use a TriggerFieldCell because the generic types inside TextInputCell prevented me from using it.

    Do I need to do a subclass of ValueBaseInputCell? That seems strange since my PropertyEditor has all the Long / String conversions. It also looks difficult.

    If so, is there a simple example or some documentation I can read?

    BTW, my learning project is Maven based and should be easy to fire up if necessary:
    1. svn checkout http://subversion.assembla.com/svn/f...lic/learn/gwt/ learn-gwt
    2. mvn gwt:run
    3. Navigate to GXT | Forms | Time Edit

    Thanks in advance,
    Pete

  2. Well I managed to get something going using a Converter and a Validator. The code below uses a Builder to construct the UI but you should be able to get the gist...

    From my PeriodBeanEditor:
    Code:
        @Ignore
        TextField hrMinField;
    
        ConverterEditorAdapter<Long, String, TextField> hrMin;
    
        @Override
        protected Widget createWidget() {
            FlowLayoutContainer c = new FlowLayoutContainerBuilder()
                    .add(new FieldLabelBuilder()
                            .text("Hr Min")
                            .widget(hrMinField = new TextFieldBuilder()
                                    .allowBlank(false)
                                    .addValidator(HrMinConverter.VALIDATOR)
                                    .textField)
                            .fieldLabel)
                    .flowLayoutContainer;
            hrMin = new ConverterEditorAdapter(hrMinField, HrMinConverter.INSTANCE);
            return c;
        }
    From my HrMinConverter:
    Code:
    public class HrMinConverter implements Converter<Long, String> {
        private static final String RE_STR = "^(-?)(\\d+)(:([0-5]?)(\\d))?$";
        public static final RegExp RE = RegExp.compile(RE_STR);
        public static final String RE_MSG = "Must be in the form '-h:m', '-' and ':m' are optional";
        public static final HrMinConverter INSTANCE = new HrMinConverter();
        public static final RegExValidator VALIDATOR = new RegExValidator(RE_STR, RE_MSG);
    ...
    For what it's worth I'm trying to publish the bean builder generator tool (b-generation) so I can use it in various places.

  3. #2
    Sencha User
    Join Date
    Dec 2011
    Posts
    19
    Answers
    1
    Vote Rating
    0
    p33t is on a distinguished road

      0  

    Default Converter + Validator Solution

    Converter + Validator Solution


    Well I managed to get something going using a Converter and a Validator. The code below uses a Builder to construct the UI but you should be able to get the gist...

    From my PeriodBeanEditor:
    Code:
        @Ignore
        TextField hrMinField;
    
        ConverterEditorAdapter<Long, String, TextField> hrMin;
    
        @Override
        protected Widget createWidget() {
            FlowLayoutContainer c = new FlowLayoutContainerBuilder()
                    .add(new FieldLabelBuilder()
                            .text("Hr Min")
                            .widget(hrMinField = new TextFieldBuilder()
                                    .allowBlank(false)
                                    .addValidator(HrMinConverter.VALIDATOR)
                                    .textField)
                            .fieldLabel)
                    .flowLayoutContainer;
            hrMin = new ConverterEditorAdapter(hrMinField, HrMinConverter.INSTANCE);
            return c;
        }
    From my HrMinConverter:
    Code:
    public class HrMinConverter implements Converter<Long, String> {
        private static final String RE_STR = "^(-?)(\\d+)(:([0-5]?)(\\d))?$";
        public static final RegExp RE = RegExp.compile(RE_STR);
        public static final String RE_MSG = "Must be in the form '-h:m', '-' and ':m' are optional";
        public static final HrMinConverter INSTANCE = new HrMinConverter();
        public static final RegExValidator VALIDATOR = new RegExValidator(RE_STR, RE_MSG);
    ...
    For what it's worth I'm trying to publish the bean builder generator tool (b-generation) so I can use it in various places.

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