Пример #1
0
  @Override
  protected void setValue(final Object element, final Object value) {
    VolumeOption oldEntry = (VolumeOption) element;
    Integer newValue = (Integer) value;
    String newKey = allowedKeys[newValue];

    if (((VolumeOption) element).getKey().equals(newKey)) {
      // selected value is same as old one.
      return;
    }

    // value has changed. set new value and refresh the viewer.
    volume.getOptions().remove(oldEntry.getKey());
    volume.setOption(newKey, "");
    getViewer().refresh();
  }
Пример #2
0
 protected VolumeOption getEntryBeingAdded() {
   List<VolumeOption> options = volume.getOptions().getOptions();
   int size = options.size();
   String lastValue = options.get(size - 1).getValue();
   if (lastValue == null || lastValue.isEmpty()) {
     // it's the LAST entry, and it's value is empty.
     // means this is a new row being added in the table viewer.
     return options.get(size - 1);
   }
   return null;
 }
Пример #3
0
 /** @return array of option keys that are not already set on the volume */
 private String[] getAllowedKeys() {
   ArrayList<String> keys = new ArrayList<String>();
   VolumeOptions volumeOptions = volume.getOptions();
   for (VolumeOptionInfo optionInfo : defaults) {
     String optionName = optionInfo.getName();
     if (!volumeOptions.containsKey(optionName) || volumeOptions.get(optionName).isEmpty()) {
       // key not set => available for setting
       // value not set => this is the row being edited
       keys.add(optionName);
     }
   }
   return keys.toArray(new String[0]);
 }