Update athen how to correctly write your own view authored by Markus Krug's avatar Markus Krug
...@@ -17,4 +17,42 @@ The class of the view serves as the glue between the layout of the view and the ...@@ -17,4 +17,42 @@ The class of the view serves as the glue between the layout of the view and the
<img src="/uploads/fc1264bd0d522f662f053e1a2c0ec76e/MVC-ATHEN_Views.PNG" alt="MVC of the editor and the views" style="width: 640px;" style="height: 480px;"/> <img src="/uploads/e1c2b25570dacc1a479eb06dc84b6960/MVC-ATHEN_Views.PNG" alt="MVC of the editor and the views" style="width: 640px;" style="height: 480px;"/>
\ No newline at end of file
So the controller (our view class) serves as the glue between the actual UI and the editor. Let us see how this is done correctly.
# Creating the View (The corresponding UI Element)
Inside the method
```java
initLayout(Composite parent)
```
you should initialize this UI element. The following snippet shows the current state of the CorefView
```java
@Override
protected void initLayout(Composite parent) {
corefViewComposite = new CorefViewComposite(parent, SWT.NONE);
corefViewComposite.setInput(this);
// assert it the full space
GridData gd = new GridData(GridData.GRAB_VERTICAL | GridData.GRAB_HORIZONTAL | GridData.FILL_BOTH);
corefViewComposite.setLayoutData(gd);
corefViewComposite.refresh(annoList, overridesList);
}
```
All the code does, is to create a new widget (the corefViewComposite), and set its input. It is fine to assume that the ui element can hold a reference to the current object of the controller. This is done in this line:
```java
corefViewComposite.setInput(this);
```
So the view can store this reference of the controller and communicate with it.