Skip to content
Snippets Groups Projects
Commit 6034d10e authored by Simon Barner's avatar Simon Barner
Browse files

ComboBoxEditingSupport:

- Do not expose createComboBoxLabelValueMapping()
- Instead, provide getLabel()
refs 1841
parent 2b78e0f7
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,6 @@ package org.fortiss.tooling.base.ui.annotation.editingsupport;
import java.util.Collection;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.viewers.ArrayContentProvider;
......@@ -117,26 +116,18 @@ public class ComboBoxEditingSupport extends AnnotationEditingSupportBase {
return null;
}
AnnotationEntry entry = (AnnotationEntry)element;
comboBoxLabelValueMapping =
createComboBoxLabelValueMapping(((AnnotationEntry)element).getModelElement(),
((AnnotationEntry)element).getSpecification((specClass)));
new LabelValueMapping(eStructuralFeatureDescriptor,
entry.getSpecification(specClass), entry.getModelElement(),
stringInputChoice);
cellEditor.setInput(comboBoxLabelValueMapping.getLabels());
return cellEditor;
}
/**
* Creates a {@link LabelValueMapping} for the annotation shown in this
* {@link ComboBoxEditingSupport}.
*/
public LabelValueMapping createComboBoxLabelValueMapping(EObject modelElement,
IAnnotatedSpecification specification) {
return new LabelValueMapping(eStructuralFeatureDescriptor, specification,
modelElement, stringInputChoice);
}
/** {@inheritDoc} */
@Override
protected void setValue(Object element, Object label) {
......@@ -155,9 +146,18 @@ public class ComboBoxEditingSupport extends AnnotationEditingSupportBase {
/** {@inheritDoc} */
@Override
protected Object getValue(Object element) {
return getLabel(element);
}
/**
* Returns a {@link String} label for the given annotation (identified by its
* {@link AnnotationEntry}).
*/
public String getLabel(Object element) {
// super.getValue() checks if element is actually an AnnotationEntry
Object value = super.getValue(element);
if(value != null) {
if(value != null && comboBoxLabelValueMapping != null) {
return comboBoxLabelValueMapping.getLabelForValue(value);
}
......
......@@ -25,7 +25,6 @@ import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.model.element.IDerivedAnnotation;
import org.fortiss.tooling.base.ui.annotation.AnnotationEntry;
import org.fortiss.tooling.base.ui.annotation.editingsupport.ComboBoxEditingSupport;
import org.fortiss.tooling.base.ui.annotation.editingsupport.LabelValueMapping;
import org.fortiss.tooling.base.ui.annotation.editingsupport.MultiSelectionEditingSupport;
import org.fortiss.tooling.base.ui.annotation.view.IAnnotationViewPart;
......@@ -83,12 +82,7 @@ public class AnnotationLabelProvider extends LabelProviderBase {
}
if(value != null) {
if(editingSupport instanceof ComboBoxEditingSupport) {
LabelValueMapping comboBoxLabelValueMapping =
((ComboBoxEditingSupport)editingSupport)
.createComboBoxLabelValueMapping(
annotationEntry.getModelElement(),
annotationEntry.getSpecification(specClass));
return comboBoxLabelValueMapping.getLabelForValue(value);
return ((ComboBoxEditingSupport)editingSupport).getLabel(element);
} else if(editingSupport instanceof MultiSelectionEditingSupport) {
return ((MultiSelectionEditingSupport)editingSupport).getLabel(element);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment