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; ...@@ -20,7 +20,6 @@ package org.fortiss.tooling.base.ui.annotation.editingsupport;
import java.util.Collection; import java.util.Collection;
import org.eclipse.emf.ecore.EEnum; import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ArrayContentProvider;
...@@ -117,26 +116,18 @@ public class ComboBoxEditingSupport extends AnnotationEditingSupportBase { ...@@ -117,26 +116,18 @@ public class ComboBoxEditingSupport extends AnnotationEditingSupportBase {
return null; return null;
} }
AnnotationEntry entry = (AnnotationEntry)element;
comboBoxLabelValueMapping = comboBoxLabelValueMapping =
createComboBoxLabelValueMapping(((AnnotationEntry)element).getModelElement(), new LabelValueMapping(eStructuralFeatureDescriptor,
((AnnotationEntry)element).getSpecification((specClass))); entry.getSpecification(specClass), entry.getModelElement(),
stringInputChoice);
cellEditor.setInput(comboBoxLabelValueMapping.getLabels()); cellEditor.setInput(comboBoxLabelValueMapping.getLabels());
return cellEditor; 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} */ /** {@inheritDoc} */
@Override @Override
protected void setValue(Object element, Object label) { protected void setValue(Object element, Object label) {
...@@ -155,9 +146,18 @@ public class ComboBoxEditingSupport extends AnnotationEditingSupportBase { ...@@ -155,9 +146,18 @@ public class ComboBoxEditingSupport extends AnnotationEditingSupportBase {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected Object getValue(Object element) { 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); Object value = super.getValue(element);
if(value != null) { if(value != null && comboBoxLabelValueMapping != null) {
return comboBoxLabelValueMapping.getLabelForValue(value); return comboBoxLabelValueMapping.getLabelForValue(value);
} }
......
...@@ -25,7 +25,6 @@ import org.fortiss.tooling.base.model.element.IAnnotatedSpecification; ...@@ -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.model.element.IDerivedAnnotation;
import org.fortiss.tooling.base.ui.annotation.AnnotationEntry; 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.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.editingsupport.MultiSelectionEditingSupport;
import org.fortiss.tooling.base.ui.annotation.view.IAnnotationViewPart; import org.fortiss.tooling.base.ui.annotation.view.IAnnotationViewPart;
...@@ -83,12 +82,7 @@ public class AnnotationLabelProvider extends LabelProviderBase { ...@@ -83,12 +82,7 @@ public class AnnotationLabelProvider extends LabelProviderBase {
} }
if(value != null) { if(value != null) {
if(editingSupport instanceof ComboBoxEditingSupport) { if(editingSupport instanceof ComboBoxEditingSupport) {
LabelValueMapping comboBoxLabelValueMapping = return ((ComboBoxEditingSupport)editingSupport).getLabel(element);
((ComboBoxEditingSupport)editingSupport)
.createComboBoxLabelValueMapping(
annotationEntry.getModelElement(),
annotationEntry.getSpecification(specClass));
return comboBoxLabelValueMapping.getLabelForValue(value);
} else if(editingSupport instanceof MultiSelectionEditingSupport) { } else if(editingSupport instanceof MultiSelectionEditingSupport) {
return ((MultiSelectionEditingSupport)editingSupport).getLabel(element); 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