Commit 52d56c82 authored by Simon Barner's avatar Simon Barner
Browse files

Add IListPropertySection::canRemoveModelListElement()

Issue-Ref: 3470
Issue-Url: https://af3-developer.fortiss.org/issues/3470

Signed-off-by: Simon Barner's avatarSimon Barner <barner@fortiss.org>
parent b11e0874
......@@ -2,10 +2,10 @@ ConstraintUIBases.java 3676a600e0866091db9798763c6eee97eec5b55b GREEN
ContextMenuSubMenuContributorBase.java 6275d96fe8690d9d4744bcbaef3c7d14ba8e30ff GREEN
DialogMessageHandler.java 8714da09a777c8557de0a5c48ff68c340f9fa91d GREEN
EObjectActionBase.java 4ef9f8be59e64d4838acc9e268d418ba5d94fa1a GREEN
EReferenceListPropertySectionBase.java bbc5f6851842a9cb0af5e9898d9c6e197a36312a YELLOW
EReferenceListPropertySectionBase.java 7390dd7bfdc979e8ff0c5c30c67ab7b6c9d70c92 YELLOW
EReferencePropertySectionBase.java 0548da6778516003257f59d0b4c2b60d458be3b6 YELLOW
EditorBase.java 9c09fff92945256bb8680992ae7bb2c78f47b150 GREEN
IListPropertySection.java a093a8a625d291b8adecec5082e32748a2d99f9e YELLOW
IListPropertySection.java 8bb00fe7959583e794ff9437b7a77404c9a9e70f YELLOW
ModelEditorBindingBase.java 4c5ac569c0b6e7678fc8191096b26dfd09fdcb98 GREEN
ModelElementHandlerBase.java 384727748f125c9d43f19d9c0eba4ba1be5a7a26 GREEN
MultiEObjectActionBase.java 9e237d8ea640c4194e4877af4a9cfce88698e543 GREEN
......
......@@ -97,7 +97,9 @@ public abstract class EReferenceListPropertySectionBase<I extends EObject, R ext
// refresh() does not work here. It is based on isRemoveButtonEnabled(), that
// queries the selection of the 'listViewer' has not been updated yet. When this
// listener is triggered, only the 'event' already contains the new selection.
removeButton.setEnabled(getFirstSelectedElement(event.getSelection()) != null);
R selectedElement = getFirstSelectedElement(event.getSelection());
removeButton.setEnabled(selectedElement != null && section
.canRemoveModelListElement(section.getSectionInput(), selectedElement));
}
});
......@@ -170,7 +172,9 @@ public abstract class EReferenceListPropertySectionBase<I extends EObject, R ext
* </p>
*/
protected boolean isRemoveButtonEnabled() {
return getFirstSelectedElement(listViewer.getSelection()) != null;
R selectedElement = getFirstSelectedElement(listViewer.getSelection());
return selectedElement != null &&
section.canRemoveModelListElement(section.getSectionInput(), selectedElement);
}
/** Refreshes the input and the enabled state of the controls. */
......@@ -245,9 +249,12 @@ public abstract class EReferenceListPropertySectionBase<I extends EObject, R ext
@Override
protected final EObject getModelValue(I input) {
List<R> elements = getValues(input);
// The value selected in the combo box is not directly stored in the model (see
// setModelValue()). Hence, instead of retrieving a value for the model from the combobox,
// by default the first element is selected.
if(elements.contains(selectedElement)) {
return selectedElement;
}
// In the currently selected element is not in the list of available elements, default to
// the first element in the list
selectedElement = elements.isEmpty() ? null : elements.get(0);
return selectedElement;
}
......
......@@ -36,6 +36,9 @@ public interface IListPropertySection<I extends EObject, R extends EObject> {
/** Removes the given {@code element} from the edited {@link EReference} list. */
public void removeModelListElement(I input, R element);
/** Predicate if the given {@code element} may be removed from the list. */
public boolean canRemoveModelListElement(I input, R element);
/** Returns the currently selected element of the viewer used to edit the element list. */
public R getSelectedElement();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment