Skip to content

Commit

Permalink
Initial implementation of helper methods and Model-View-X pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsacha committed Dec 21, 2016
1 parent c529175 commit 258a590
Show file tree
Hide file tree
Showing 21 changed files with 1,039 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Set the default line separator behavior, in case people don't have core.autocrlf set.
* text=auto
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax: glob

*.class
build/
out/
lib/
.settings/
.cache
.metadata/
.idea/
.idea/*
.gradle/
.history
target
lib_managed
project/boot
project/target
*.iml
*.log
*.bak
.classpath
.project
*.orig
.worksheet/
*.sc
.externalToolBuilders/
5 changes: 5 additions & 0 deletions .jvmopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-Dfile.encoding=UTF8
-Xms512M
-Xmx1536M
-Xss2M
-XX:+CMSClassUnloadingEnabled
1 change: 1 addition & 0 deletions .sbtopts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Dfile.encoding=UTF-8
35 changes: 35 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
sudo: false

language: scala
scala:
- 2.10.6
- 2.11.8
- 2.12.1

before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"

jdk:
- oraclejdk8

install: true

script:
- java -version
- sbt test

branches:
only:
- master
- stable

notifications:
email:
- [email protected]

# Work around for default old version of Java provided by Travis CI
addons:
apt:
packages:
- oracle-java8-installer
18 changes: 17 additions & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
ScalaFX Extras
==============

Addition to ScalaFX to simplify use.
Additions to ScalaFX that do not have corresponding concepts in JavaFX. The key parts are helper methods in `org.scalafx.extras` and support for a working with Model-View and FXML.

Module `scalafx-extras-demos` has a demo StopWatch application that illustrates uses of the Model-View and FXML API.


ScalaFX Extras is still quite experimental and APIs may change significantly.


Discussion and Support
----------------------

Please use [ScalaFX Users Group](https://groups.google.com/forum/#!forum/scalafx-users). Please report issues using the projects Issue tracker.


License
-------

BSD-3-Clause ScalaFX license.
130 changes: 130 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import java.net.URL

import scala.xml._

// @formatter:off

//
// Environment variables used by the build:
// GRAPHVIZ_DOT_PATH - Full path to Graphviz dot utility. If not defined Scaladocs will be build without diagrams.
// JAR_BUILT_BY - Name to be added to Jar metadata field "Built-By" (defaults to System.getProperty("user.name")
//

val projectVersion = "0.1.0-SNAPSHOT"
val versionTagDir = if (projectVersion.endsWith("SNAPSHOT")) "master" else "v" + projectVersion

// ScalaFX project
lazy val scalaFXExtrasProject = Project(
id = "scalafx-extras",
base = file("scalafx-extras"),
settings = scalaFXExtrasSettings ++ Seq(
description := "The ScalaFX Extras",
fork in run := true,
scalacOptions in(Compile, doc) ++= Seq(
"-sourcepath", baseDirectory.value.toString,
"-doc-root-content", baseDirectory.value + "/src/main/scala/root-doc.creole",
"-doc-source-url", "https://github.com/SscalaFX-Extras/scalafx-extras/blob/" + versionTagDir + "/scalafx/€{FILE_PATH}.scala"
) ++ (Option(System.getenv("GRAPHVIZ_DOT_PATH")) match {
case Some(path) => Seq("-diagrams", "-diagrams-dot-path", path)
case None => Seq.empty[String]
})
)
)

// ScalaFX Demos project
lazy val scalaFXExtrasDemosProject = Project(
id = "scalafx-extras-demos",
base = file("scalafx-extras-demos"),
settings = scalaFXExtrasSettings ++ Seq(
description := "The ScalaFX Extras demonstrations",
fork in run := true,
javaOptions ++= Seq(
"-Xmx512M",
"-Djavafx.verbose"
),
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full),
publishArtifact := false
)
) dependsOn (scalaFXExtrasProject % "compile;test->test")

// Resolvers
lazy val sonatypeNexusSnapshots = "Sonatype Nexus Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
lazy val sonatypeNexusStaging = "Sonatype Nexus Staging" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"

// Add snapshots to root project to enable compilation with Scala SNAPSHOT compiler,
// e.g., 2.11.0-SNAPSHOT
resolvers += sonatypeNexusSnapshots

// Common settings
lazy val scalaFXExtrasSettings = Seq(
organization := "org.scalafx",
version := projectVersion,
crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.1"),
scalaVersion <<= crossScalaVersions { versions => versions.head },
scalacOptions ++= Seq("-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8", "-feature"),
scalacOptions in(Compile, doc) ++= Opts.doc.title("ScalaFX Extras API"),
scalacOptions in(Compile, doc) ++= Opts.doc.version(projectVersion),
scalacOptions in(Compile, doc) += s"-doc-external-doc:${scalaInstance.value.libraryJar}#http://www.scala-lang.org/api/${scalaVersion.value}/",
scalacOptions in(Compile, doc) ++= Seq("-doc-footer", s"ScalaFX Extras API v.$projectVersion"),
javacOptions ++= Seq(
"-target", "1.8",
"-source", "1.8",
"-Xlint:deprecation"),
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scalafx" %% "scalafx" % "8.0.102-R11",
"org.scalafx" %% "scalafxml-core-sfx8" % "0.2.2",
"org.scalatest" %% "scalatest" % "3.0.0" % "test",
"junit" % "junit" % "4.12" % "test"),
autoAPIMappings := true,
manifestSetting,
publishSetting,
fork in Test := true,
parallelExecution in Test := false,
resolvers += sonatypeNexusSnapshots,
// print junit-style XML for CI
testOptions in Test <+= (target in Test) map {
t => Tests.Argument(TestFrameworks.ScalaTest, "-u", "%s" format (t / "junitxmldir"))
},
shellPrompt in ThisBuild := { state => "sbt:" + Project.extract(state).currentRef.project + "> " }
) ++ mavenCentralSettings

lazy val manifestSetting = packageOptions <+= (name, version, organization) map {
(title, version, vendor) =>
Package.ManifestAttributes(
"Created-By" -> "Simple Build Tool",
"Built-By" -> Option(System.getenv("JAR_BUILT_BY")).getOrElse(System.getProperty("user.name")),
"Build-Jdk" -> System.getProperty("java.version"),
"Specification-Title" -> title,
"Specification-Version" -> version,
"Specification-Vendor" -> vendor,
"Implementation-Title" -> title,
"Implementation-Version" -> version,
"Implementation-Vendor-Id" -> vendor,
"Implementation-Vendor" -> vendor
)
}

lazy val publishSetting = publishTo <<= version {
version: String =>
if (version.trim.endsWith("SNAPSHOT"))
Some(sonatypeNexusSnapshots)
else
Some(sonatypeNexusStaging)
}

// Metadata needed by Maven Central
// See also http://maven.apache.org/pom.html#Developers
lazy val mavenCentralSettings = Seq(
homepage := Some(new URL("http://www.scalafx.org/")),
startYear := Some(2016),
licenses := Seq(("BSD", new URL("https://github.com/scalafx/scalafx-extras/blob/master/LICENSE.txt"))),
pomExtra <<= (pomExtra, name, description) {
(pom, name, desc) => pom ++ Group(
<scm>
<url>https://github.com/scalafx/scalafx-extras</url>
<connection>scm:git:https://github.com/scalafx/scalafx-extras.git</connection>
</scm>
)
}
)
29 changes: 29 additions & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Copyright (c) 2011-2016, ScalaFX Project
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the ScalaFX Project nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE SCALAFX PROJECT OR ITS CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

sbt.version=0.13.13

1 change: 1 addition & 0 deletions project/plugin.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scalacOptions ++= Seq("-unchecked", "-deprecation")
3 changes: 3 additions & 0 deletions project/sbt-sonatype.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// [https://github.com/xerial/sbt-sonatype]
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
1 change: 1 addition & 0 deletions scalafx-extras-demos/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2011-2016, ScalaFX Project
~ All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~ * Redistributions of source code must retain the above copyright
~ notice, this list of conditions and the following disclaimer.
~ * Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ * Neither the name of the ScalaFX Project nor the
~ names of its contributors may be used to endorse or promote products
~ derived from this software without specific prior written permission.
~
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
~ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
~ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
~ DISCLAIMED. IN NO EVENT SHALL THE SCALAFX PROJECT OR ITS CONTRIBUTORS BE LIABLE
~ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
~ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
~ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
~ AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
~ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
~ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.text.*?>
<BorderPane xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.scalafx.extras.modelview.stopwatch.StopWatchView">
<padding>
<Insets bottom="7.0" left="7.0" right="7.0" top="7.0"/>
</padding>
<bottom>
<ButtonBar BorderPane.alignment="CENTER">
<buttons>
<Button fx:id="startButton" mnemonicParsing="false" text="Start"/>
<Button fx:id="stopButton" mnemonicParsing="false" text="Stop"/>
<Button fx:id="resetButton" mnemonicParsing="false" text="Reset"/>
</buttons>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding>
</ButtonBar>
</bottom>
<center>
<HBox>
<children>
<Label fx:id="minutesLabel" alignment="CENTER" contentDisplay="CENTER" text="99" textAlignment="CENTER"
BorderPane.alignment="CENTER">
<font>
<Font name="Lucida Sans Typewriter Regular" size="96.0"/>
</font>
</Label>
<Label text=":">
<font>
<Font size="96.0"/>
</font>
</Label>
<Label fx:id="secondsLabel" alignment="CENTER" contentDisplay="CENTER" text="99" textAlignment="CENTER">
<font>
<Font name="Lucida Sans Typewriter Regular" size="96.0"/>
</font>
</Label>
<Label text=".">
<font>
<Font size="96.0"/>
</font>
</Label>
<Label fx:id="fractionLabel" alignment="CENTER" contentDisplay="CENTER" text="99"
textAlignment="CENTER">
<font>
<Font name="Lucida Sans Typewriter Regular" size="96.0"/>
</font>
</Label>
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding>
</HBox>
</center>
</BorderPane>
Loading

0 comments on commit 258a590

Please sign in to comment.