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

- Make ComboBoxEditingSupport aware of instance keys

- Unify (merge) MultiInstanceAnnotationSupport with (into) TextEditingSupport
refs 1841
parent 2699c49c
No related branches found
No related tags found
No related merge requests found
Showing
with 18 additions and 90 deletions
......@@ -40,11 +40,15 @@ public abstract class AnnotationEditingSupportBase extends EditingSupport {
/** Specification class of this column */
protected Class<? extends IAnnotatedSpecification> specClass;
/** Instance key to identify the corresponding instance of the annotation */
protected String instanceKey;
/** Constructor. */
public AnnotationEditingSupportBase(ColumnViewer viewer,
Class<? extends IAnnotatedSpecification> specClass) {
Class<? extends IAnnotatedSpecification> specClass, String instanceKey) {
super(viewer);
this.specClass = specClass;
this.instanceKey = instanceKey;
}
/** {@inheritDoc} */
......@@ -52,7 +56,7 @@ public abstract class AnnotationEditingSupportBase extends EditingSupport {
protected boolean canEdit(Object element) {
if(element instanceof AnnotationEntry) {
AnnotationEntry annotationEntry = (AnnotationEntry)element;
return annotationEntry.canEdit(specClass);
return annotationEntry.canEdit(specClass, instanceKey);
}
return true;
......@@ -60,7 +64,7 @@ public abstract class AnnotationEditingSupportBase extends EditingSupport {
/** Actually gets the value from the {@link IAnnotatedSpecification}. */
protected Object doGetValue(AnnotationEntry annotationEntry) {
return annotationEntry.getSpecificationValue(specClass);
return annotationEntry.getSpecificationValue(specClass, instanceKey);
}
/** {@inheritDoc} */
......@@ -74,7 +78,7 @@ public abstract class AnnotationEditingSupportBase extends EditingSupport {
/** Actually sets a {@link String} value into a {@link IAnnotatedSpecification}. */
protected void doSetValue(AnnotationEntry annotationEntry, String value) throws Exception {
annotationEntry.setSpecificationValue(value, specClass);
annotationEntry.setSpecificationValue(value, specClass, instanceKey);
}
/** {@inheritDoc} */
......
......@@ -58,8 +58,8 @@ public class ComboBoxEditingSupport extends AnnotationEditingSupportBase {
*/
public ComboBoxEditingSupport(ColumnViewer viewer,
Class<? extends IAnnotatedSpecification> clazz, Collection<String> values,
boolean isEditable) {
super(viewer, clazz);
String instanceKey, boolean isEditable) {
super(viewer, clazz, instanceKey);
this.isEditable = isEditable;
cellEditor = new ComboBoxViewerCellEditor((Composite)getViewer().getControl());
cellEditor.setLabelProvider(new LabelProvider());
......
......@@ -38,7 +38,7 @@ public class ElementNameEditingSupport extends TextEditingSupport {
public ElementNameEditingSupport(ColumnViewer viewer) {
// Specification class is not needed, since the name is stored directly in the model (hence
// pass {@code null}).
super(viewer, null);
super(viewer, null, null);
}
/** {@inheritDoc} */
......
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2014 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.annotation.editingsupport;
import org.eclipse.jface.viewers.ColumnViewer;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.ui.annotation.AnnotationEntry;
import org.fortiss.tooling.base.ui.annotation.valueprovider.DynamicInstanceAnnotationValueProviderBase;
/**
* This class extends {@link TextEditingSupport} to support text annotations for which multiple
* instances can exist.
*
* @see DynamicInstanceAnnotationValueProviderBase
*
* @author diewald, barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public class MultiInstanceAnnotationTextEditingSupport extends TextEditingSupport {
/** Instance key to identify the corresponding instance of the annotation */
private String instanceKey;
/** Constructs a new {@link MultiInstanceAnnotationTextEditingSupport} for a specific column. */
public MultiInstanceAnnotationTextEditingSupport(ColumnViewer viewer,
Class<? extends IAnnotatedSpecification> clazz, String instanceKey) {
super(viewer, clazz);
this.instanceKey = instanceKey;
}
/** {@inheritDoc} */
@Override
protected Object doGetValue(AnnotationEntry annotationEntry) {
return annotationEntry.getSpecificationValue(specClass, instanceKey);
}
/** {@inheritDoc} */
@Override
protected void doSetValue(AnnotationEntry annotationEntry, String value) throws Exception {
annotationEntry.setSpecificationValue(value, specClass, instanceKey);
}
/** {@inheritDoc} */
@Override
protected boolean canEdit(Object element) {
if(element instanceof AnnotationEntry) {
AnnotationEntry annotationEntry = (AnnotationEntry)element;
return annotationEntry.canEdit(specClass);
}
return false;
}
}
......@@ -41,8 +41,8 @@ public class TextEditingSupport extends AnnotationEditingSupportBase {
/** Constructor. */
public TextEditingSupport(ColumnViewer viewer,
Class<? extends IAnnotatedSpecification> specClass) {
super(viewer, specClass);
Class<? extends IAnnotatedSpecification> specClass, String instanceKey) {
super(viewer, specClass, instanceKey);
cellEditor = new TextCellEditor((Composite)getViewer().getControl(), SWT.NONE);
}
......
......@@ -29,7 +29,7 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.EditingSupport;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.ui.annotation.editingsupport.MultiInstanceAnnotationTextEditingSupport;
import org.fortiss.tooling.base.ui.annotation.editingsupport.TextEditingSupport;
/**
* <p>
......@@ -136,7 +136,7 @@ public abstract class DynamicInstanceAnnotationValueProviderBase<T extends IAnno
public EditingSupport createEditingSupport(ColumnViewer viewer,
Class<? extends IAnnotatedSpecification> clazz, String instanceKey) {
return new MultiInstanceAnnotationTextEditingSupport(viewer, clazz, instanceKey);
return new TextEditingSupport(viewer, clazz, instanceKey);
}
/** {@inheritDoc} */
......
......@@ -271,7 +271,7 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
enumValues.add(e.getName());
}
return new ComboBoxEditingSupport(viewer, clazz, enumValues, false);
return new ComboBoxEditingSupport(viewer, clazz, enumValues, instanceKey, false);
}
return super.createEditingSupport(viewer, clazz, instanceKey);
......
......@@ -37,7 +37,6 @@ import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
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.MultiInstanceAnnotationTextEditingSupport;
import org.fortiss.tooling.base.ui.annotation.editingsupport.TextEditingSupport;
import org.fortiss.tooling.kernel.utils.EcoreUtils;
......@@ -164,10 +163,7 @@ public abstract class ValueProviderBase<T extends IAnnotatedSpecification> imple
// Input is not restricted -> free editing in text cell
if(currentInputChoiceMap.get(instanceKey) == null) {
if(instanceKey == null) {
return new TextEditingSupport(viewer, clazz);
}
return new MultiInstanceAnnotationTextEditingSupport(viewer, clazz, instanceKey);
return new TextEditingSupport(viewer, clazz, instanceKey);
}
// Multiple instances are not supported (yet) for input to be edited in Comboboxes
......@@ -176,7 +172,7 @@ public abstract class ValueProviderBase<T extends IAnnotatedSpecification> imple
// Input is restricted to concrete set of values
// (use SingleEnumAttributeValueProviderBase for Enum types!)
return new ComboBoxEditingSupport(viewer, clazz, currentInputChoiceMap.get(instanceKey),
fixedInputChoiceMap.get(instanceKey).isEmpty());
instanceKey, fixedInputChoiceMap.get(instanceKey).isEmpty());
}
/**
......
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