예제 #1
0
 public List<PropertyDescriptor> getDeclaredPropertyDescriptors() {
   return Arrays.asList(
       new PropertyDescriptor(
           PROP_TEXT,
           MidpTypes.TYPEID_JAVA_LANG_STRING,
           PropertyValue.createNull(),
           true,
           true,
           MidpVersionable.MIDP),
       new PropertyDescriptor(
           PROP_MAX_SIZE,
           MidpTypes.TYPEID_INT,
           PropertyValue.createNull(),
           false,
           true,
           MidpVersionable.MIDP),
       new PropertyDescriptor(
           PROP_CONSTRAINTS,
           MidpTypes.TYPEID_INT,
           PropertyValue.createNull(),
           false,
           true,
           MidpVersionable.MIDP),
       new PropertyDescriptor(
           PROP_INITIAL_INPUT_MODE,
           MidpTypes.TYPEID_JAVA_LANG_STRING,
           PropertyValue.createNull(),
           true,
           true,
           MidpVersionable.MIDP_2));
 }
예제 #2
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);
 }
예제 #3
0
  protected Item createItem(DesignComponent designComponent, ResourcesProvider resourcesProvider) {
    String text = null;
    int appearanceMode = StringItem.PLAIN;

    PropertyValue value = designComponent.readProperty(StringItemCD.PROP_TEXT);
    if (value.getKind() == PropertyValue.Kind.VALUE) {
      text = MidpTypes.getString(value);
    } else {
      System.out.println("Unable to retrieve text - Kind=" + value.getKind());
      text = "default";
    }
    value = designComponent.readProperty(StringItemCD.PROP_APPEARANCE_MODE);
    if (value.getKind() == PropertyValue.Kind.VALUE) {
      appearanceMode = MidpTypes.getInteger(value);
    }
    return new StringItem(null, text, appearanceMode);
  }
 private void saveValue(String text) {
   if (text.length() > 0) {
     if (noneItem.equals(text)) {
       super.setValue(NULL_VALUE);
     } else {
       super.setValue(PropertyValue.createComponentReference(getCommandEvenSource(text)));
     }
   }
 }
 public static void initButtonGroup(Map<SVGFormComponent, DesignComponent> producer2Component) {
   for (Entry<SVGFormComponent, DesignComponent> entry : producer2Component.entrySet()) {
     SVGFormComponent component = entry.getKey();
     if (!component.getTypeID().equals(SVGRadioButtonCD.TYPEID)) {
       continue;
     }
     Map<String, Object> map = component.getProperties();
     if (map == null) {
       continue;
     }
     SVGFormComponent buttonGroup = (SVGFormComponent) map.get(SVGRadioButtonCD.PROP_BUTTON_GROUP);
     if (buttonGroup != null) {
       entry
           .getValue()
           .writeProperty(
               SVGRadioButtonCD.PROP_BUTTON_GROUP,
               PropertyValue.createComponentReference(producer2Component.get(buttonGroup)));
     }
   }
 }
 @Override
 public DesignComponent createComponent(DesignComponent parentComponent) {
   DesignComponent dc = parentComponent.getDocument().createComponent(getTypeID());
   if (myEventType != null) {
     DesignComponent svgES = parentComponent.getDocument().createComponent(myEventType);
     svgES.writeProperty(
         SVGComponentEventSourceCD.PROP_SVGCOMPONENT,
         PropertyValue.createComponentReference(dc));
     parentComponent.addComponent(svgES);
   }
   dc.writeProperty(SVGComponentCD.PROP_ID, MidpTypes.createStringValue(getId()));
   Map<String, Object> properties = getProperties();
   if (properties != null) {
     for (Entry<String, Object> entry : properties.entrySet()) {
       if (!entry.getKey().equals(SVGRadioButtonCD.PROP_BUTTON_GROUP)) {
         dc.writeProperty(
             entry.getKey(), MidpTypes.createStringValue(entry.getValue().toString()));
       }
     }
   }
   return dc;
 }
  private String getDecodeValue(final PropertyValue value) {
    final String[] decodeValue = new String[1];
    final DesignComponent valueComponent = value.getComponent();
    if (valueComponent != null) {
      final DesignDocument document = valueComponent.getDocument();
      if (document != null) {
        document
            .getTransactionManager()
            .readAccess(
                new Runnable() {

                  public void run() {
                    DesignComponent valueComponent = value.getComponent();
                    if (valueComponent != null) {
                      PropertyValue pv =
                          valueComponent.readProperty(CommandEventSourceCD.PROP_COMMAND);
                      if (pv != null) {
                        DesignComponent refComponent = pv.getComponent();
                        if (refComponent != null
                            && refComponent.equals(getListSelectCommand(document))) {
                          decodeValue[0] = defaultItem;
                        } else {
                          decodeValue[0] = getComponentDisplayName(valueComponent);
                        }
                      } else {
                        decodeValue[0] = noneItem;
                      }
                    } else {
                      decodeValue[0] = noneItem;
                    }
                  }
                });
      }
    }

    return decodeValue[0];
  }