Example #1
0
 // Not a designer property, since this could lead to unpredictable
 // results if Selection is set to an incompatible value.
 @SimpleProperty
 public void SelectionIndex(int index) {
   if (index <= 0 || index > items.size()) {
     selectionIndex = 0;
     selection = "";
   } else {
     selectionIndex = index;
     // YailLists are 0-based, but we want to be 1-based.
     selection = items.getString(selectionIndex - 1);
   }
 }
Example #2
0
 /** Selection property setter method. */
 @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_STRING, defaultValue = "")
 @SimpleProperty
 public void Selection(String value) {
   selection = value;
   // Now, we need to change SelectionIndex to correspond to Selection.
   // If multiple Selections have the same SelectionIndex, use the first.
   // If none do, arbitrarily set the SelectionIndex to its default value
   // of 0.
   for (int i = 0; i < items.size(); i++) {
     // The comparison is case-sensitive to be consistent with yail-equal?.
     if (items.getString(i).equals(value)) {
       selectionIndex = i + 1;
       return;
     }
   }
   selectionIndex = 0;
 }