|
@ -1,19 +1,65 @@ |
|
|
package com.sothr.imagetools.ui.controller |
|
|
package com.sothr.imagetools.ui.controller |
|
|
|
|
|
|
|
|
import javafx.fxml.Initializable |
|
|
import javafx.fxml.FXML |
|
|
|
|
|
import javafx.event.ActionEvent |
|
|
|
|
|
import org.slf4j.LoggerFactory |
|
|
|
|
|
import org.slf4j.Logger |
|
|
|
|
|
import javafx.stage.{StageStyle, Stage} |
|
|
|
|
|
import javafx.scene.Scene |
|
|
|
|
|
import javafx.scene.Group |
|
|
|
|
|
import javafx.scene.text.Text |
|
|
|
|
|
import java.io.{IOException, File} |
|
|
import java.net.URL |
|
|
import java.net.URL |
|
|
import java.util.ResourceBundle |
|
|
import java.util.Scanner |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Created by drew on 12/31/13. |
|
|
* Created by drew on 12/31/13. |
|
|
*/ |
|
|
*/ |
|
|
class AppController extends Initializable { |
|
|
class AppController { |
|
|
|
|
|
|
|
|
def print():String = { |
|
|
val logger:Logger = LoggerFactory.getLogger(this.getClass) |
|
|
return "This method works"; |
|
|
//Define controls |
|
|
|
|
|
@FXML var rootMenuBar : javafx.scene.control.MenuBar = null |
|
|
|
|
|
|
|
|
|
|
|
//region MenuItem Actions |
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
|
def aboutAction(event:ActionEvent) = { |
|
|
|
|
|
logger.debug("Displaying about screen") |
|
|
|
|
|
var aboutMessage = "Simple About Message" |
|
|
|
|
|
try { |
|
|
|
|
|
val cl = this.getClass.getClassLoader |
|
|
|
|
|
val url = cl.getResource("documents/about") |
|
|
|
|
|
val uri = url.toURI |
|
|
|
|
|
aboutMessage = new Scanner(new File(uri)).useDelimiter("\\A").next() |
|
|
|
|
|
} catch { |
|
|
|
|
|
case ioe:IOException => |
|
|
|
|
|
logger.error("Unable to read about file") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val dialog:Stage = new Stage() |
|
|
|
|
|
dialog.initStyle(StageStyle.UTILITY) |
|
|
|
|
|
val parent:Group = new Group(); |
|
|
|
|
|
parent.getChildren.add(new Text(25, 25, aboutMessage)) |
|
|
|
|
|
val scene:Scene = new Scene(parent) |
|
|
|
|
|
dialog.setScene(scene) |
|
|
|
|
|
dialog.setResizable(false) |
|
|
|
|
|
dialog.setMinHeight(400.0) |
|
|
|
|
|
dialog.setMinWidth(400.0) |
|
|
|
|
|
dialog.show() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@FXML |
|
|
|
|
|
def closeAction(event:ActionEvent ) = { |
|
|
|
|
|
logger.debug("Closing application from the menu bar") |
|
|
|
|
|
val stage:Stage = this.rootMenuBar.getScene.getWindow.asInstanceOf[Stage] |
|
|
|
|
|
stage.close() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
def initialize(p1: URL, p2: ResourceBundle): Unit = { |
|
|
//endregion |
|
|
|
|
|
|
|
|
|
|
|
def print():String = { |
|
|
|
|
|
return "This method works" |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
xxxxxxxxxx