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

- Enable editing of component names from GenericAnnotationView

refs 1841
parent 5ef9da17
No related branches found
No related tags found
No related merge requests found
/*--------------------------------------------------------------------------+
$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.eclipse.jface.viewers.EditingSupport;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.base.ui.annotation.AnnotationEntry;
import org.fortiss.tooling.base.ui.annotation.view.GenericAnnotationView;
import org.fortiss.tooling.kernel.model.INamedElement;
/**
* Base class for {@link EditingSupport}s used in the {@link GenericAnnotationView}.
*
* @author barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED
*/
public class ElementNameEditingSupport extends TextEditingSupport {
/** Constructs a new {@link ElementNameEditingSupport}. */
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);
}
/** {@inheritDoc} */
@Override
protected boolean canEdit(Object element) {
return true;
}
/** {@inheritDoc} */
@Override
protected Object doGetValue(AnnotationEntry annotationEntry) {
IModelElement modelElement = annotationEntry.getModelElement();
if(modelElement instanceof INamedElement) {
return ((INamedElement)modelElement).getName();
}
return null;
}
/** {@inheritDoc} */
@Override
protected void doSetValue(AnnotationEntry annotationEntry, String value) throws Exception {
IModelElement modelElement = annotationEntry.getModelElement();
if(modelElement instanceof INamedElement) {
((INamedElement)modelElement).setName(value);
}
}
}
......@@ -34,6 +34,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.base.ui.annotation.AnnotationEntry;
import org.fortiss.tooling.base.ui.annotation.editingsupport.ElementNameEditingSupport;
import org.fortiss.tooling.base.ui.annotation.valueprovider.IAnnotationValueProvider;
/**
......@@ -192,6 +193,7 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
tableViewer.setContentProvider(new ArrayContentProvider());
firstColumn.setLabelProvider(new ElementNameLabelProvider(this, firstColumn));
firstColumn.setEditingSupport(new ElementNameEditingSupport(tableViewer));
}
/** Creates a column in tableViewer that displays the annotation given in spec */
......
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