Tutorial Main View Controller

Main FXML File

The MainViewController in the /controller/MainViewController needs a valid FXML File. The bindings for Navigation, Workspace and StatusBar Controller uses the fx:id values.

source<BorderPane>
    <top>
        <AnchorPane fx:id="navigationPane"/>
    </top>
    <center>
        <AnchorPane fx:id="workspacePane"/>
    </center>
    <bottom>
        <AnchorPane fx:id="statusPane"/>
    </bottom>
</BorderPane>

MainViewController

For adding SubController and displaying their UI content following steps are needed:

  1. Prepare SubController
  2. Connect with FXML identifier
  3. Define ContentManager
  4. Load Controller in the MainViewController LifeCycle
  5. Optional Prepare Functions for Controller switching
  6. Optional CDI based Functions / Injection Points

Prepare SubController

sourcelazy val workspaceController: WorkspaceController =
  getController[WorkspaceController]()
lazy val barChartController: ChartPageController =
  getController[ChartPageController]()
lazy val personController: PersonPageController =
  getController[PersonPageController]()
lazy val navigationController: NavigationController =
  getController[NavigationController]()
lazy val statusBarController: StatusBarController =
  new StatusBarController()

Connect with FXML identifier

source@FXML
var workspacePane: Pane = _
@FXML
var statusPane: Pane = _
@FXML
var navigationPane: Pane = _

ContentManager

sourcevar workspaceManager: SFXContentManager = _
var navigationManager: SFXContentManager = _
var statusBarManager: SFXContentManager = _

Init Controller

sourceoverride def didGainVisibilityFirstTime() {
  super.didGainVisibility()
  navigationManager = SFXContentManager(navigationPane, this, navigationController)
  statusBarManager = SFXContentManager(statusPane, this, statusBarController)
  workspaceManager = SFXContentManager(workspacePane, this, workspaceController)
}