/** * Sets a value on a model object. If the feature is multi-valued, only the single value that * the wrapper represents is set. */ protected void setValue(IResource object, IReference property, Object value) { if (object.getApplicableCardinality(property).getSecond() != 1) { @SuppressWarnings("unchecked") List<Object> list = ((List<Object>) object.get(property)); list.set(index, value); } else { object.set(property, value); } }
/** * Returns a value from a model object. If the feature is multi-valued, only the single value * that the wrapper represents is returned. */ @Override protected Object getValue(IResource object, IReference property) { // When the value is changed, the property sheet page doesn't update // the property sheet viewer input // before refreshing, and this gets called on the obsolete wrapper. // So, we need to read directly from the // model object. // // return value; Object result = object.get(property); if (object.getApplicableCardinality(property).getSecond() != 1) { // If the last object was deleted and the selection was in the // property sheet view, the obsolete wrapper will // reference past the end of the list. // List<?> list = (List<?>) result; result = index >= 0 && index < list.size() ? list.get(index) : value; } return result; }