Commit Graph

62 Commits

Author SHA1 Message Date
Sarah Gerweck
5f1db873be
Refactor observable instances 2018-01-10 22:15:58 -08:00
Sarah Gerweck
c1fafcfc8f
Switch from Scalaz to Cats 2018-01-10 22:15:58 -08:00
Sarah Gerweck
f7bd816b79
Fix ObservablePref Scala 2.11 compatibility
Scala 2.11 doesn't automatically lift functions into implementations
of single-method interfaces, so we have to be a bit more explicit when
creating the callback object.
2017-12-19 23:00:06 -08:00
Sarah Gerweck
bce5a0d39e New ObservablePref mechanism
This inherits from the `Pref` system in `scala-utils`, extending it so
that preferences can be ScalaFX bound variables. This is the easiest way
to store things like the preferred window size and other per-user local
configuration.
2017-11-05 21:45:40 -08:00
Sarah Gerweck
d882c1a784 Misc code beautification 2017-10-08 01:52:49 -07:00
Sarah Gerweck
488fc08cd6 Rewrite SingletonStage for safety & power
Also, add more documentation so this is actually a usable piece of code.
2017-10-08 01:52:11 -07:00
Sarah Gerweck
5b6ad07a08 Add new automatic conversion to BooleanProperty
There are a number of signatures in ScalaFX that won't accept an
observable of a Scala Boolean and that require you to convert it to a
Java Boolean. This adds an automatic conversion to resolve that.
2016-07-30 15:26:18 -07:00
Sarah Gerweck
e50159b82e Add new mechanism for streaming to a collection 2016-07-30 15:05:45 -07:00
Sarah Gerweck
d3296748f2 Add a new FutureObservable.ofTryOption
This is the lowest-level observer you could make on a `Future`, but it's
pretty useful. All the others _could_ be derived from this one, but it's
better to use as few JavaFX callbacks as possible since they have to be
executed in the main UI thread.
2016-07-29 20:58:55 -07:00
Sarah Gerweck
ef1216a821 Rename apply to withDefault 2016-07-29 20:58:55 -07:00
Sarah Gerweck
8df96ed076 Minor improvements to FutureObservable 2016-07-29 20:58:55 -07:00
Sarah Gerweck
60828f3aad Minor fixups to type signatures 2016-07-15 22:27:31 -07:00
Sarah Gerweck
58ea91e3a3 (Breaking) improvement to SingletonStage 2016-07-14 02:00:48 -07:00
Sarah Gerweck
0660143ae4 Start adding standard StringConverters 2016-07-14 01:57:33 -07:00
Sarah Gerweck
bd1201ca28 New Anchored constructor for top stage panes 2016-07-14 01:07:27 -07:00
Sarah Gerweck
ad7118c0fe Add a new DebugTools object for debugging methods 2016-06-17 18:41:48 -07:00
Sarah Gerweck
b962c62209 Add control-panel builders
I've used these in a few projects now, so might as well put them in a
common library where they can get properly enhanced.
2016-06-15 05:42:35 -07:00
Sarah Gerweck
c525330b08 Add observeFiltered methods on ObserableBuffer
These are convenience methods for constructing a `FilteredBuffer` with
either a static or dynamic filter.
2016-06-12 08:11:24 -07:00
Sarah Gerweck
99ed345be5 Add observableSize operation to collections
Also, bump the version to 0.9 since this change is definitely not binary
compatible: class names and structures have changed. Most clients should
be fine though if they just recompile: the changes are to things that
will generally be used through the implicits system, so most shoudln't
notice the changes.
2016-06-12 04:11:07 -07:00
Sarah Gerweck
96fd69b323 New readOnly method for broadening observables 2016-06-08 18:56:48 -07:00
Sarah Gerweck
dc763de5f4 Simplify DialogButtons behavior
The custom region doesn't quite work yet, so just expose the underling
bar so we can still get the shared behavior. Maybe the region will get
fixed later on.
2016-06-04 01:02:48 -07:00
Sarah Gerweck
768fba21b0 Make sure to unset the singleton instance on close 2016-06-04 00:40:43 -07:00
Sarah Gerweck
e050f07692 A helper for making dialog button bars
JavaFX & ScalaFX already have one of these, but this handles padding
and automatically set up the apply, ok, cancel trilogy (though you can
disable any of these).
2016-06-04 00:34:16 -07:00
Sarah Gerweck
0f3361017d A couple of classes for making custom table cells 2016-06-04 00:34:06 -07:00
Sarah Gerweck
fd040af74f New class for making singleton windows
This ensures there will be at most one copy of the stage, which will be
created and destroyed as needed. Trying to create a second just brings
the first into focus. This is good for things like preferences windows.
2016-06-04 00:32:00 -07:00
Sarah Gerweck
ccc644f9d4 New method to observe an Option[A] from a future
This makes it much easier to mix in an observable from a future. I'd
also like to do a `Try[Option[A]]` method.
2016-06-04 00:30:04 -07:00
Sarah Gerweck
cea337a5fd Reduce logging verbosity 2016-05-31 02:24:11 -07:00
Sarah Gerweck
f0ced5fd66 Add HostOS utility
This currently calls out to a private JavaFX utility from Sun. If that
changes, I'll modify the code to use the system properties directly.
2016-05-23 22:05:38 -07:00
Sarah Gerweck
1fb1d5db1f Update to ScalaFX for Java 1.8.0u92
Also, update the version number of Gerweck Utils.
2016-05-04 22:26:28 -07:00
Sarah Gerweck
941d0c7cb7 Update FutureObservable to perform much better 2016-05-04 22:26:28 -07:00
Sarah Gerweck
83d7f5f009 Add observableSource converter 2016-04-18 21:15:14 -07:00
Sarah Gerweck
eb00380441 Add documentation to observableSink 2016-04-18 21:14:03 -07:00
Sarah Gerweck
fb2dac9b3f Code to make an Observable from a Future 2016-04-18 20:18:45 -07:00
Sarah Gerweck
b26e2cecc0 Add ReadOnlyObjectProperty instances for 0.7.0 2016-04-18 01:12:39 -07:00
Sarah Gerweck
6956bd05da Add operations to flatten arrays, lists and sets
This makes it really convenient to take a data structure like a
`ObservableBuffer`, which normally has special operations to watch for
different CRUD operations on its individual members, and treat the whole
thing as a solid value. This lets you turn it into an `ObservableValue`
where you get a notice of changes and then you can use the normal
operations like `map` and `flatMap` to react to changes.

Because this requires reprocessing the entirety of the contained values,
this may not perform as well as if you subscribe to more granular update
messages.

It is possible to round-trip these collections back to the ScalaFX
native collections using the other utilities available. This will be
required if you want to use the output to back something like a table.
2016-04-16 20:42:37 -07:00
Sarah Gerweck
d9ffc45d69 Slight performance & correctness improvement 2016-04-16 17:21:04 -07:00
Sarah Gerweck
05d4a4f8aa Remove deprecated view-bound syntax 2015-10-05 11:39:54 -07:00
Sarah Gerweck
b366a810f7 ScalaFX App wrapper 2015-09-15 01:33:05 -07:00
Sarah Gerweck
907c83da52 Remove erroneous copyright notice 2015-08-15 16:30:56 -07:00
Sarah Gerweck
6d37cc4373 More support for observing collections 2015-08-15 03:48:14 -07:00
Sarah Gerweck
4bc515b73f Finalize classes 2015-08-15 02:18:37 -07:00
Sarah Gerweck
777f6bda28 Add conversion to ObservableBuffer 2015-08-15 02:09:45 -07:00
Sarah Gerweck
f1044d2b5a Clean up unneeded imports 2015-08-12 18:29:32 -07:00
Sarah Gerweck
13e841d613 Synchronize the change handlers
I'm pretty confident that this isn't actually required by the JavaFX
threading model, but it makes the code more obviously correct and
uncontended synchronization has a negligible cost when we're talking
about UI-level changes.
2015-08-11 11:10:23 -07:00
Sarah Gerweck
3f30eb32c2 Fix Observable.map to suppress nil changes
If the new output is equal to the old output, we'll suppress the change
message altogether, so as not to do unnecessary recalculations.

E.g., imagine you have a property `isOdd`. If you go from 27 to 319,
there's no need to trigger all the downstream objects to recalculate.
(Most of the other functional primitives I've created already have this
behavior.)
2015-08-10 19:05:54 -07:00
Sarah Gerweck
8166b9be3f Improved return type 2015-08-10 04:49:42 -07:00
Sarah Gerweck
f769fffeb2 Make Observable an instance of Monad
This is not yet tested, and it requires a lot of testing. A previous
helper that attempted to support `bind` never quite worked correctly,
but I believe that the new approach of implementing `join` and `map`
instead of `bind` makes the code more resilient.

Even though `map` and `ap` can be derived from `point` and `bind`, I'm
keeping both of them, as `bind` requires quite a bit of subscription
manipulation. Those methods have much simpler implementations.
2015-08-09 22:51:11 -07:00
Sarah Gerweck
914e168771 Fix a bug in the ap function
This could prevent it from updating values if you returned to
the original value. E.g., if your values went 1, 2, 1, 2, you'd
get notifications for 1, 2, 2. This would also cause some extra
notifications to go when the logical value didn't actually change.
2015-08-09 22:41:01 -07:00
Sarah Gerweck
8e7a5a35a6 Simple withKey to bind a keyboard shortcut 2015-08-08 21:21:15 -07:00
Sarah Gerweck
6c2b73f4d6 Remove not-so-useful observe2 method. 2015-05-04 11:48:28 -07:00