Exemplo n.º 1
0
 @Override
 public void generateParameterCode(
     DesignComponent component, MultiGuardedSection section, int index) {
   PropertyValue value = component.readProperty(PROP_CONSTRAINTS);
   if (value.getKind() == PropertyValue.Kind.VALUE) {
     int constraint = MidpTypes.getInteger(value);
     int core = constraint & TextFieldCD.VALUE_CONSTRAINT_MASK;
     CodeWriter writer = section.getWriter();
     switch (core) {
       case TextFieldCD.VALUE_ANY:
         writer.write("TextField.ANY"); // NOI18N
         break;
       case TextFieldCD.VALUE_EMAILADDR:
         writer.write("TextField.EMAILADDR"); // NOI18N
         break;
       case TextFieldCD.VALUE_NUMERIC:
         writer.write("TextField.NUMERIC"); // NOI18N
         break;
       case TextFieldCD.VALUE_PHONENUMBER:
         writer.write("TextField.PHONENUMBER"); // NOI18N
         break;
       case TextFieldCD.VALUE_URL:
         writer.write("TextField.URL"); // NOI18N
         break;
       case TextFieldCD.VALUE_DECIMAL:
         writer.write("TextField.DECIMAL"); // NOI18N
         break;
       default:
         writer.write(Integer.toString(core));
     }
     if ((constraint & TextFieldCD.VALUE_PASSWORD) != 0) {
       writer.write(" | TextField.PASSWORD"); // NOI18N
     }
     if ((constraint & TextFieldCD.VALUE_UNEDITABLE) != 0) {
       writer.write(" | TextField.UNEDITABLE"); // NOI18N
     }
     if ((constraint & TextFieldCD.VALUE_SENSITIVE) != 0) {
       writer.write(" | TextField.SENSITIVE"); // NOI18N
     }
     if ((constraint & TextFieldCD.VALUE_NON_PREDICTIVE) != 0) {
       writer.write(" | TextField.NON_PREDICTIVE"); // NOI18N
     }
     if ((constraint & TextFieldCD.VALUE_INITIAL_CAPS_WORD) != 0) {
       writer.write(" | TextField.INITIAL_CAPS_WORD"); // NOI18N
     }
     if ((constraint & TextFieldCD.VALUE_INITIAL_CAPS_SENTENCE) != 0) {
       writer.write(" | TextField.INITIAL_CAPS_SENTENCE"); // NOI18N
     }
     return;
   }
   super.generateParameterCode(component, section, index);
 }
Exemplo n.º 2
0
 private static Presenter createSetterPresenter() {
   return new CodeSetterPresenter()
       .addParameters(MidpParameter.create(PROP_TEXT, PROP_MAX_SIZE, PROP_INITIAL_INPUT_MODE))
       .addParameters(new TextFieldConstraintsParameter())
       .addSetters(
           MidpSetter.createConstructor(TYPEID, MidpVersionable.MIDP)
               .addParameters(
                   ItemCD.PROP_LABEL,
                   PROP_TEXT,
                   PROP_MAX_SIZE,
                   TextFieldConstraintsParameter.PARAM_CONSTRAINTS))
       .addSetters(
           MidpSetter.createSetter("setString", MidpVersionable.MIDP)
               .addParameters(PROP_TEXT)) // NOI18N
       .addSetters(
           MidpSetter.createSetter("setConstraints", MidpVersionable.MIDP)
               .addParameters(TextFieldConstraintsParameter.PARAM_CONSTRAINTS)) // NOI18N
       .addSetters(
           MidpSetter.createSetter("setInitialInputMode", MidpVersionable.MIDP_2)
               .addParameters(PROP_INITIAL_INPUT_MODE)) // NOI18N
       .addSetters(
           MidpSetter.createSetter("setMaxSize", MidpVersionable.MIDP)
               .addParameters(PROP_MAX_SIZE)); // NOI18N
 }