|
| 1 | +/* |
| 2 | + * Copyright (c) 2011-2021, ScalaFX Project |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions are met: |
| 7 | + * * Redistributions of source code must retain the above copyright |
| 8 | + * notice, this list of conditions and the following disclaimer. |
| 9 | + * * Redistributions in binary form must reproduce the above copyright |
| 10 | + * notice, this list of conditions and the following disclaimer in the |
| 11 | + * documentation and/or other materials provided with the distribution. |
| 12 | + * * Neither the name of the ScalaFX Project nor the |
| 13 | + * names of its contributors may be used to endorse or promote products |
| 14 | + * derived from this software without specific prior written permission. |
| 15 | + * |
| 16 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | + * DISCLAIMED. IN NO EVENT SHALL THE SCALAFX PROJECT OR ITS CONTRIBUTORS BE LIABLE |
| 20 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 21 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 22 | + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 23 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | + */ |
| 27 | + |
| 28 | +package org.scalafx.extras.mvcfx |
| 29 | + |
| 30 | +/** |
| 31 | + * The ControllerFX creates connection of the FXML to Scala code and underlying ModelFX for the application logic. |
| 32 | + * |
| 33 | + * Constructor argument names correspond to controls defined in FXML and the model. The constructor is used by ScalaFXML |
| 34 | + * macro to automatically expose FXML controls in Scala code of the view class. |
| 35 | + * |
| 36 | + * See more details in the [[org.scalafx.extras.mvcfx `org.scalafx.extras.mvcfx`]] documentation. |
| 37 | + * |
| 38 | + * Example: |
| 39 | + * {{{ |
| 40 | + * import org.scalafx.extras.mvcfx.ControllerFX |
| 41 | + * |
| 42 | + * import scalafx.Includes.* |
| 43 | + * import scalafx.scene.control.{Button, Label} |
| 44 | + * import scalafxml.core.macros.sfxml |
| 45 | + * |
| 46 | + * import javafx.scene.control as jfxsc |
| 47 | + * import javafx.fxml as jfxf |
| 48 | + * |
| 49 | + * class StopWatchController(model: StopWatchModel) extends ControllerFX { |
| 50 | + * |
| 51 | + * @jfxf.FXML |
| 52 | + * private var startButton: jfxsc.Button = _ |
| 53 | + * @jfxf.FXML |
| 54 | + * private var stopButton: jfxsc.Button = _ |
| 55 | + * @jfxf.FXML |
| 56 | + * private var resetButton: jfxsc.Button = _ |
| 57 | + * ... |
| 58 | + * |
| 59 | + * @jfxf.FXML |
| 60 | + * def initialize(): Unit = { |
| 61 | + * startButton.disable <== model.running |
| 62 | + * stopButton.disable <== !model.running |
| 63 | + * resetButton.disable <== model.running |
| 64 | + * ... |
| 65 | + * } |
| 66 | + * } |
| 67 | + * }}} |
| 68 | + */ |
| 69 | +trait ControllerFX |
0 commit comments