Fork me on GitHub

User Interface Layer

Use a custom MVC pattern with a lot of convenient tricks

UI Roles

The User Interface layer is composed by three main components :

  • Model
  • View
  • Controller

Each of these must do predefined tasks to maintain a good Separation of Concerns (SoC).

Short UML Diagram:

Models

Models are directly synchronized with the UIFacade and can send & receive Waves, they can also use any other components.

The goal of Models is to retrieve data from other layers, and to define Business Logic (business rules, authorizations ...).

The Model automatically build its attached view.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
public class SampleModel extends AbstractModel<SampleModel, SampleView> {
 
    /** The class logger. */
    private static final Logger LOGGER = LoggerFactory.getLogger(SampleModel.class);
 
    /**
     * {@inheritDoc}
     */
    @Override
    protected void customInitialize() {
        // Put the code to initialize your model here
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    protected void customInitializeInnerModels() {
        // Put the code to initialize inner models here (if any)
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    protected void processAction(final Wave wave) {
        // Process a wave action, you must listen the wave type before
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    protected void customShowView() {
        // Custom code to process when the view is displayed
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    protected void customHideView() {
        // Custom code to process when the view is hidden
    }
 
}

InnerModels

Views

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package org.jrebirth.sample.ui;
 
import javafx.scene.control.LabelBuilder;
import javafx.scene.layout.BorderPane;
 
import org.jrebirth.core.exception.CoreException;
import org.jrebirth.core.ui.AbstractView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
/**
 * The class <strong>SampleView</strong>.
 *
 * @author
 */
public class SampleView extends AbstractView<SampleModel, BorderPane, SampleController> {
 
    /** The class logger. */
    private static final Logger LOGGER = LoggerFactory.getLogger(SampleView.class);
 
    /**
     * Default Constructor.
     *
     * @param model the controls view model
     *
     * @throws CoreException if build fails
     */
    public SampleView(final SampleModel model) throws CoreException {
        super(model);
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    protected void customInitializeComponents() {
        getRootNode().setCenter(
                LabelBuilder.create()
                        .text("JRebirth Sample")
                        .build()
                );
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    public void doStart() {
        // Custom code to process when the view is displayed the first time
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    public void doReload() {
        // Custom code to process when the view is displayed the 1+n time
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    public void doHide() {
        // Custom code to process when the view is hidden
    }
 
}

Controllers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.jrebirth.sample.ui;
 
import org.jrebirth.core.exception.CoreException;
import org.jrebirth.core.ui.AbstractController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
/**
 * The class <strong>SampleController</strong>.
 *
 * @author
 */
public class SampleController extends AbstractController<SampleModel, SampleView> {
 
    /** The class logger. */
    private static final Logger LOGGER = LoggerFactory.getLogger(SampleController.class);
 
    /**
     * Default Constructor.
     *
     * @param view the view to control
     *
     * @throws CoreException if an error occurred while creating event handlers
     */
    public SampleController(final SampleView view) throws CoreException {
        super(view);
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    protected void customInitializeEventAdapters() throws CoreException {
        // Attach event adapters
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    protected void customInitializeEventHandlers() throws CoreException {
        // Listen events
    }
 
}

Adapters & Handlers