... | ... | @@ -363,3 +363,80 @@ passes the method *determineName(AnnotationFS anno)* of our controller as an arg |
|
|
```
|
|
|
|
|
|
|
|
|
## Creating the Controller (The View class)
|
|
|
|
|
|
By definition, this class needs to implement two methods (as defined by its superclass):
|
|
|
|
|
|
```java
|
|
|
//this is mandatory
|
|
|
public abstract boolean initTypes();
|
|
|
|
|
|
//and this is mandatory
|
|
|
protected abstract void initLayout(Composite parent);
|
|
|
```
|
|
|
|
|
|
We saw already how to implement one of them, and will now go into detail on how to implement the method to initialize the types we need in our view.
|
|
|
|
|
|
Additionally, you should implement three more methods to ensure that your view intefrates nicely into the communication framework with the editor. Sadly it is not possible to (or i dont know how to) get those calls in the super class to fully ease up this process. The eclipse framework does not use **abstract** classes for inheritance, instead makes use of annotations (@Inject, @Postconstruct, @Focus). This relatively new concept allows inheritance without the class to even know its abstract superclass, and therefore decouples them almost entirely. The bad news is that the "parent" class now needs to know all its children. The eclipse framework however only knows those classes that are part of the application model, and this is specified in the **application.e4xmi**. We cannot specifiy the abstract class in there and this is why the calls need to be done in every view.
|
|
|
|
|
|
```java
|
|
|
@Inject
|
|
|
public CorefView() {
|
|
|
super();
|
|
|
}
|
|
|
|
|
|
@PostConstruct
|
|
|
public void postConstruct(Composite parent, MPart part) {
|
|
|
|
|
|
super.overlay = parent;
|
|
|
super.overlay.setLayout(new FillLayout());
|
|
|
super.part = part;
|
|
|
super.setBroker(broker);
|
|
|
}
|
|
|
|
|
|
@Focus
|
|
|
public void onFocus() {
|
|
|
// delegate to the superclass, annotating there does not work!
|
|
|
super.onFocus();
|
|
|
|
|
|
}
|
|
|
```
|
|
|
|
|
|
We now focus this tutorial on the second method **initTypes()**. Its purpose is to access the required type and feature information of the CAS to be able to add new annotations or change them. This method shoudl as well be used, to assign a given style to the types and feature you use. With the upcoming changes to ATHEN (this does not work currently), the method could look like this:
|
|
|
|
|
|
```java
|
|
|
@Override
|
|
|
public boolean initTypes() {
|
|
|
|
|
|
// process the annotations on the fields
|
|
|
AnnotationProcessor.processUIMAInfoAnnotations(this, editor.getCas());
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
This method looks yet again extremely clean, since it only has a single method, and guess what you dont even need to implement this function since it is already there. If we want to elaborate on this method we need to understand the concepts and the power of annotations.
|
|
|
|
|
|
TODO since the implementation is not finished yet!
|
|
|
|
|
|
If you managed to annotate your fields correctly, the correct types are about to be injected by the AnnotationProcessor and the editor styles correctly - all this by using declarative elements and without writing any ugly code!
|
|
|
|
|
|
```java
|
|
|
// UIMA Types, everything here will be injected by the annotation processor
|
|
|
@ATHENEditorDrawingInfo(layer = 1)
|
|
|
@UIMAInfo(variableType = VariableType.TYPE, accessingType = AccessingType.PREFERENCES, nameOrKey = ApplicationPreferences.COREFVIEW_OV_TYPE)
|
|
|
private Type typOverride;
|
|
|
|
|
|
@ATHENEditorDrawingInfo(mode = true, layer = 2)
|
|
|
@UIMAInfo(variableType = VariableType.TYPE, accessingType = AccessingType.PREFERENCES, nameOrKey = ApplicationPreferences.COREFVIEW_NE_TYPE)
|
|
|
private Type typNE;
|
|
|
|
|
|
@ATHENEditorDrawingInfo()
|
|
|
@UIMAInfo(variableType = VariableType.TYPE, nameOrKey = TEMP2_TYPE_NAME)
|
|
|
private Type typTemp;
|
|
|
|
|
|
@UIMAInfo(variableType = VariableType.FEATURE, accessingType = AccessingType.PREFERENCES, nameOrKey = ApplicationPreferences.COREFVIEW_NE_ID, correspondingType = ApplicationPreferences.COREFVIEW_NE_TYPE, correspondingAccessingType = AccessingType.PREFERENCES)
|
|
|
private Feature idFeat;
|
|
|
|
|
|
|
|
|
```
|
|
|
|