Skip to content

Instantly share code, notes, and snippets.

@AndrewShitsko
Last active January 21, 2017 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewShitsko/158b36e79b48e41b9a1c2f3dbc68a44b to your computer and use it in GitHub Desktop.
Save AndrewShitsko/158b36e79b48e41b9a1c2f3dbc68a44b to your computer and use it in GitHub Desktop.
package com.example
import griffon.core.artifact.GriffonView
import griffon.inject.MVCMember
import griffon.metadata.ArtifactProviderFor
import javafx.collections.FXCollections
import javafx.fxml.FXML
import javafx.scene.control.Button
import javafx.scene.control.Label
import javafx.scene.control.TableView
import javafx.scene.web.WebView
import javax.annotation.Nonnull
import org.codehaus.griffon.runtime.javafx.artifact.AbstractJavaFXGriffonView
@ArtifactProviderFor(GriffonView)
class HomeView extends AbstractJavaFXGriffonView {
@MVCMember @Nonnull
FactoryBuilderSupport builder
@MVCMember @Nonnull
HomeModel model
@FXML private TableView tableView
@FXML private WebView webView
@FXML private Label clickLabel
@FXML private Button countButton
void initUI() {
builder.application(title: application.configuration['application.title'], name: "settingsWindow",
centerOnScreen: true, resizable: false) {
scene {
// Load fxml file by specified path 'griffon-app/resources/views/home.fxml'
def node = loadFromFXML("views/home.fxml")
// Link button actions with the controller actions
connectActions(node, controller)
// Set data to the table view
initTableViewData()
// Load site by url in web view
webView.engine.load("http://griffon-framework.org")
// Bidirectional binding of the label 'clickLabel' with the model property 'clickCount'
clickLabel.textProperty().bindBidirectional(model.clickCountProperty())
// Set custom text to the button, if you want, for example "Count"
countButton.text = application.messageSource.getMessage("home.count.button.label")
// Render fxml view
fxml node
}
}
}
private initTableViewData() {
def languages = ["JavaScript", "Java", "Python", "Ruby", "PHP", "C++", "CSS", "C#", "C", "Go", "Shell",
"Objective-C", "Scala", "Swift", "TypeScript"]
def items = []
languages.eachWithIndex{ String entry, int i ->
items << new Language(i + 1, entry)
}
// Set list to the table view items
tableView.items = FXCollections.observableArrayList(items)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment