diff --git a/src/main/scala/org/gerweck/scalafx/akka/AkkaFX.scala b/src/main/scala/org/gerweck/scalafx/akka/AkkaFX.scala index 3d22f69..f494fd6 100644 --- a/src/main/scala/org/gerweck/scalafx/akka/AkkaFX.scala +++ b/src/main/scala/org/gerweck/scalafx/akka/AkkaFX.scala @@ -1,6 +1,5 @@ package org.gerweck.scalafx.akka -import scala.collection.mutable import scala.concurrent._ import akka.Done diff --git a/src/main/scala/org/gerweck/scalafx/akka/AkkaFXCollections.scala b/src/main/scala/org/gerweck/scalafx/akka/AkkaFXCollections.scala index 4882539..c2223c9 100644 --- a/src/main/scala/org/gerweck/scalafx/akka/AkkaFXCollections.scala +++ b/src/main/scala/org/gerweck/scalafx/akka/AkkaFXCollections.scala @@ -15,8 +15,6 @@ import scalafx.application.Platform.runLater import scalafx.beans.Observable import scalafx.beans.property._ -import org.log4s._ - import org.gerweck.scalafx.util.FutureObservable trait AkkaFXCollections extends Any { @@ -28,7 +26,6 @@ object AkkaFXCollections { (buffer: Observable with Growable[A] with Clearable, clearFirst: Boolean, groupingSize: Int = 50, groupingTimeout: FiniteDuration = 100.milliseconds) - (implicit ec: ExecutionContext) : Sink[A, Future[Done]] = { sealed trait PopulateAction case class InsertRows(data: Seq[A]) extends PopulateAction diff --git a/src/main/scala/org/gerweck/scalafx/util/ObservableTupler.scala b/src/main/scala/org/gerweck/scalafx/util/ObservableTupler.scala index a9b2672..1d486ea 100644 --- a/src/main/scala/org/gerweck/scalafx/util/ObservableTupler.scala +++ b/src/main/scala/org/gerweck/scalafx/util/ObservableTupler.scala @@ -1,10 +1,5 @@ package org.gerweck.scalafx.util -import language.existentials - -import scalaz._ -import Scalaz._ - import shapeless._ import shapeless.ops.hlist._ import shapeless.ops.function._ @@ -19,18 +14,20 @@ import scalafx.beans.value.ObservableValue class ObservableTupler [HLObs <: HList, HLParams <: HList, TParams <: Product] private (hlist: HLObs) - (implicit unwrapper: Mapper.Aux[ObservableUnwrapper.type, HLObs, HLParams], - tupler: Tupler.Aux[HLParams, TParams], - lister: ToList[HLObs, Observable[_]]) { + (implicit + unwrapper: Mapper.Aux[ObservableUnwrapper.type, HLObs, HLParams], + tupler: Tupler.Aux[HLParams, TParams], + lister: ToList[HLObs, Observable[_]]) { - def |@|[O, P, Appended <: HList, Unwrapped <: HList, Tupled <: Product, ApList] + def |@|[O, P, Appended <: HList, Unwrap <: HList, Tupled <: Product, ApList] (f: ObservableValue[O, P]) - (implicit prepend: Prepend.Aux[HLObs, ObservableValue[O, P]::HNil, Appended], - uw: Mapper.Aux[ObservableUnwrapper.type, Appended, Unwrapped], - tplr: Tupler.Aux[Unwrapped, Tupled], - lst: ToList[Appended, Observable[_]]): ObservableTupler[Appended, Unwrapped, Tupled] = { + (implicit + prepend: Prepend.Aux[HLObs, ObservableValue[O, P]::HNil, Appended], + uw: Mapper.Aux[ObservableUnwrapper.type, Appended, Unwrap], + tplr: Tupler.Aux[Unwrap, Tupled], + lst: ToList[Appended, Observable[_]]): ObservableTupler[Appended, Unwrap, Tupled] = { val newHL: Appended = hlist :+ f - new ObservableTupler[Appended, Unwrapped, Tupled](newHL) + new ObservableTupler[Appended, Unwrap, Tupled](newHL) } def hlisted: ObservableValue[HLParams, HLParams] = { @@ -64,7 +61,10 @@ class ObservableTupler prop } - def apply[Func, Result](f: Func)(implicit ffp: FnFromProduct.Aux[HLParams => Result, Func], ftp: FnToProduct.Aux[Func, HLParams => Result]): ObservableValue[Result, Result] = { + def apply[Func, Result] + (f: Func) + (implicit ftp: FnToProduct.Aux[Func, HLParams => Result]) + : ObservableValue[Result, Result] = { hlisted map ftp(f) } } diff --git a/src/main/scala/org/gerweck/scalafx/util/observable.scala b/src/main/scala/org/gerweck/scalafx/util/observable.scala index 3b8d631..663231b 100644 --- a/src/main/scala/org/gerweck/scalafx/util/observable.scala +++ b/src/main/scala/org/gerweck/scalafx/util/observable.scala @@ -172,29 +172,24 @@ final class RichTuple[A <: Product](val self: A) extends AnyVal { * Shapeless's `tuple` package, but it can't infer the exact output type, * which is far less useful. */ - def observe - [L <: HList, Unwrapped <: HList, Tupled <: Product] - (implicit tohl: Generic.Aux[A, L], - lister: ToTraversable.Aux[L, List, Observable[_]], - uw: Mapper.Aux[ObservableUnwrapper.type, L, Unwrapped], - tplr: Tupler.Aux[Unwrapped, Tupled]): ObservableValue[Tupled, Tupled] = { + def observe[L <: HList, Unwrap <: HList, Tupled <: Product] + (implicit tohl: Generic.Aux[A, L], + lister: ToTraversable.Aux[L, List, Observable[_]], + uw: Mapper.Aux[ObservableUnwrapper.type, L, Unwrap], + tplr: Tupler.Aux[Unwrap, Tupled]): ObservableValue[Tupled, Tupled] = { val asHList: L = tohl.to(self) def calculate(): Tupled = uw(asHList).tupled val original = calculate() val prop = ObjectProperty[Tupled](original) - for { - component <- asHList.to[List] - } { + for (component <- asHList.to[List]) { component onChange { prop.value = calculate() } } prop } - - // def omap[B] } final class RichObservable[A, C](val self: ObservableValue[A, C]) extends AnyVal { @@ -247,9 +242,9 @@ final class ObservableOfMapLike[A, B, C](val self: ObservableValue[C, C])(implic } final class RichProperty[A, B](val inner: Property[A, B]) extends AnyVal { - def biMap[B <: AnyRef](push: A => B, pull: B => A): ObjectProperty[B] = { + def biMap[A1 <: AnyRef](push: A => A1, pull: A1 => A): ObjectProperty[A1] = { val original = push(inner.value) - val op = ObjectProperty[B](original) + val op = ObjectProperty[A1](original) inner onChange { val oldVal = op.value val newVal = push(inner.value) diff --git a/src/main/scala/org/gerweck/scalafx/util/observableCollection.scala b/src/main/scala/org/gerweck/scalafx/util/observableCollection.scala index 2069b9a..0430e91 100644 --- a/src/main/scala/org/gerweck/scalafx/util/observableCollection.scala +++ b/src/main/scala/org/gerweck/scalafx/util/observableCollection.scala @@ -1,7 +1,5 @@ package org.gerweck.scalafx.util -import language.implicitConversions - import scala.compat.java8.FunctionConverters._ import java.util.function.{ Predicate => JPredicate } diff --git a/src/main/scala/org/gerweck/scalafx/util/package.scala b/src/main/scala/org/gerweck/scalafx/util/package.scala index 0e119ac..3b4dc8d 100644 --- a/src/main/scala/org/gerweck/scalafx/util/package.scala +++ b/src/main/scala/org/gerweck/scalafx/util/package.scala @@ -1,18 +1,12 @@ package org.gerweck.scalafx -import language.implicitConversions -import language.existentials - -import scalafx.Includes._ import scalafx.beans.property._ import scalafx.beans.value._ -import scalafx.event.subscriptions.Subscription import scalafx.scene.Node import scalafx.scene.control._ import scalafx.scene.input._ import scalafx.scene.layout.GridPane import scalafx.scene.text.Text -import scalafx.util.StringConverter import scalaz._ @@ -25,8 +19,8 @@ package object util extends ObservableImplicits with LowPriorityImplicits { type SimpleProperty[A] = Property[A, _] object TextDisplay { - def apply(text: ObservableValue[String,String]) = { - val t = new scalafx.scene.text.Text + def apply(text: ObservableValue[String,String]): Text = { + val t = new Text t.text <== text t }