Re: Some visual issues with a test application

2018-10-15 Thread Mark Raynsford
Hello!

On 2018-10-14T23:36:37 -0500
Ty Young  wrote:
>
> but I digress, JDK 11 switched to GTK3 by default which has caused some 
> bugs. Try setting:
> 
> 
> -Djdk.gtk.version=2

This fixes the menu issue (thanks!) but it doesn't fix the issue with
the icons in the table. Is there an open bug for the menu issue that I
can track?

Is there anything I can do about the table icons? I mean, not having
them at all is one option, but I'm mildly concerned that that's a
band-aid on a more serious problem (although you seem to be suggesting
that I've not made any obvious mistakes in the code).

> >   "YOU ARE NOT USING THE API CORRECTLY"
> > criticism is also welcome.
> >  
> 
> If I may ask, why are you sidestepping constructors and using static 
> everywhere? It works all the same, just never seen anyone write code the 
> way you did.

It's a couple of things: One is that I prefer to keep constructors as
side-effect free as possible. The other is that I approached this code
as I would have done with Swing. In Swing, it's more typical to extend
existing API classes like JFrame and so on than it is to aggregate
them. Doing so inevitably leads to rather large constructors that do
all sorts of work like instantiating other components, setting up
layouts and the like. This almost inevitably leads to the code leaking
the "this" reference to other code within the constructor, and this is
rather bad practice (passing a not-yet-completely-constructed value to
other code is a recipe for bugs). As such, I tended to write Swing code
where all of the complex initialization happens in static factory
methods. I agree it looks rather odd. There's actually a "bug" in the
OBBrowserWindow code in the sense that I don't pass any references to
the constructor. This whole project is very much a sketch pad for
getting to grips with how to write a real application with JavaFX, so
I'm not too bothered.

-- 
Mark Raynsford | http://www.io7m.com



Re: Some visual issues with a test application

2018-10-14 Thread Ty Young

On 10/14/18 3:22 PM, Mark Raynsford wrote:


Hello!

I've been developing with Swing for many years, and I'm just now giving
JavaFX a serious look now that the distribution issues are fixed
(packages on Maven Central and the like).

I've run into a couple of odd issues and I'm not sure that either of
them are my fault.

I've been putting together a little API and GUI application for
browsing OSGi repositories:

   https://github.com/io7m/osgibrowse

I've recorded the issues here:

   http://ataxia.io7m.com/2018/10/14/javafx.mp4

You may notice that things look a little odd in that all windows appear
to be fullscreen. This is because I'm using a tiling window manager
(i3). Historically, Swing had a bit of trouble with this sort of window
manager. I'm not sure if JavaFX also does.

The first issue: The menu bar I created seems to behave erratically.
Sometimes I can click on the menu to open it, other times it flashes
open and then immediately closes. In both cases, the menu seems to be
detached from the menu bar (there's a gap between the menu and the bar).

The menu is created here and added to a BorderPane:

   
https://github.com/io7m/osgibrowse/blob/develop/com.io7m.osgibrowse.gui.javafx/src/main/java/com/io7m/osgibrowse/gui/javafx/OBBrowserWindow.java#L30

The second issue: Icons set on TreeItem values seem to be corrupted
when the TreeTableView containing them is scrolled. You can see this
happen in the video. The table in question is populated from an
immutable snapshot of data returned by the underlying repository API.
Once a repository is added, the table is populated once and then does
not change until the user adds another repository.

Double clicking on a row "selects" a bundle from the repository
and this triggers a refresh of the table view. When I scroll up and
down, it seems like icon views are incorrectly reused from other rows.

The entirety of the table configuration happens here:

   
https://github.com/io7m/osgibrowse/blob/develop/com.io7m.osgibrowse.gui.javafx/src/main/java/com/io7m/osgibrowse/gui/javafx/OBTableView.java#L188

Icons are set on the tree table nodes here:

   
https://github.com/io7m/osgibrowse/blob/develop/com.io7m.osgibrowse.gui.javafx/src/main/java/com/io7m/osgibrowse/gui/javafx/OBTableView.java#L92

Any advice would be appreciated.



The code ultimately does everything correctly. Some JavaFX components 
expose a getChildren() method which doesn't actually do anything because 
your supposed to use getItems() or something like that and it causes odd 
behavior but you're using the right methods...



but I digress, JDK 11 switched to GTK3 by default which has caused some 
bugs. Try setting:



-Djdk.gtk.version=2


wherever you add run args in your Maven project(I use Ant and have no 
experience with Maven). It will force GTK2. I tried to run your program 
myself but there doesn't seem to be a way to add local dependencies like 
you can with Ant in Netbeans 9, causing a build fail and Netbeans 9 
can't find a main class.




  "YOU ARE NOT USING THE API CORRECTLY"
criticism is also welcome.



If I may ask, why are you sidestepping constructors and using static 
everywhere? It works all the same, just never seen anyone write code the 
way you did.




Re: Some visual issues with a test application

2018-10-14 Thread Mark Raynsford
On 2018-10-14T21:22:23 +0100
Mark Raynsford  wrote:

> Hello!
> 
> I've been developing with Swing for many years, and I'm just now giving
> JavaFX a serious look now that the distribution issues are fixed
> (packages on Maven Central and the like).

Forgot to mention:

$ uname -a
Linux almond.int.arc7.info 4.18.12-arch1-1-ARCH #1 SMP PREEMPT Thu Oct
4 01:01:27 UTC 2018 x86_64 GNU/Linux

$ java -version
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

-- 
Mark Raynsford | http://www.io7m.com



Some visual issues with a test application

2018-10-14 Thread Mark Raynsford
Hello!

I've been developing with Swing for many years, and I'm just now giving
JavaFX a serious look now that the distribution issues are fixed
(packages on Maven Central and the like).

I've run into a couple of odd issues and I'm not sure that either of
them are my fault.

I've been putting together a little API and GUI application for
browsing OSGi repositories:

  https://github.com/io7m/osgibrowse

I've recorded the issues here:

  http://ataxia.io7m.com/2018/10/14/javafx.mp4

You may notice that things look a little odd in that all windows appear
to be fullscreen. This is because I'm using a tiling window manager
(i3). Historically, Swing had a bit of trouble with this sort of window
manager. I'm not sure if JavaFX also does.

The first issue: The menu bar I created seems to behave erratically.
Sometimes I can click on the menu to open it, other times it flashes
open and then immediately closes. In both cases, the menu seems to be
detached from the menu bar (there's a gap between the menu and the bar).

The menu is created here and added to a BorderPane:

  
https://github.com/io7m/osgibrowse/blob/develop/com.io7m.osgibrowse.gui.javafx/src/main/java/com/io7m/osgibrowse/gui/javafx/OBBrowserWindow.java#L30

The second issue: Icons set on TreeItem values seem to be corrupted
when the TreeTableView containing them is scrolled. You can see this
happen in the video. The table in question is populated from an
immutable snapshot of data returned by the underlying repository API.
Once a repository is added, the table is populated once and then does
not change until the user adds another repository.

Double clicking on a row "selects" a bundle from the repository
and this triggers a refresh of the table view. When I scroll up and
down, it seems like icon views are incorrectly reused from other rows.

The entirety of the table configuration happens here:

  
https://github.com/io7m/osgibrowse/blob/develop/com.io7m.osgibrowse.gui.javafx/src/main/java/com/io7m/osgibrowse/gui/javafx/OBTableView.java#L188

Icons are set on the tree table nodes here:

  
https://github.com/io7m/osgibrowse/blob/develop/com.io7m.osgibrowse.gui.javafx/src/main/java/com/io7m/osgibrowse/gui/javafx/OBTableView.java#L92

Any advice would be appreciated. "YOU ARE NOT USING THE API CORRECTLY"
criticism is also welcome.

-- 
Mark Raynsford | http://www.io7m.com