Esempio n. 1
0
  @Override
  protected Object getValue(Object element) {
    VolumeOption entryBeingAdded = getEntryBeingAdded();
    if (entryBeingAdded == null) {
      return cellEditor.getValue();
    }

    if (entryBeingAdded.getKey().isEmpty()) {
      // editing just about to start. set first element as default.
      return 0;
    }

    return getIndexOfEntry(entryBeingAdded);
  }
Esempio n. 2
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();
  }
Esempio n. 3
0
 private int getIndexOfEntry(VolumeOption entryBeingAdded) {
   for (int index = 0; index < allowedKeys.length; index++) {
     if (allowedKeys[index].equals(entryBeingAdded.getKey())) {
       return index;
     }
   }
   return -1;
 }
Esempio n. 4
0
 @Override
 protected boolean canEdit(Object element) {
   VolumeOption entry = (VolumeOption) element;
   return (entry.getKey().isEmpty() || entry.getValue().isEmpty());
 }