Namek Dev
a developer's log
NamekDev

The Console: deciding on tools, techs and workflow, then code

March 2, 2016

Continuing on my Retake on The Console.

Set up

Just installed Eclipse package which is named e(fx)clipse and contains plugins for some better JavaFX support and includes support for Xtend programming language - which is nice. Thanks to this configuration I decided to try Xtend instead of Java. Xtend’s main selling point for me is type inference which reduces verbosity. It’s a feature that I liked within TypeScript so I’ve already got good experience about it.

I’m committing using Angular Team’s Commit Message Guidelines. It doesn’t help when prototyping but it’s more than delightful when projects grow. If anyone would ask - I use Windows and babun, simply no GUI for git.

My so-called** task management** will be done using a simple Trello board. I don’t suppose to perform any Kanban here since it’s a more “play-and-see” project than strictly-3-months work plan of destroying the world which can’t cross the deadline. I do already have got some ideas but will prioritize them and note in there later.

First moment of JavaFX glory

Toggling window visibility was never simple. On the one hand all my twisted hacks around setting window on top after libgdx initialization and making them undecorated are now reduced to those lines with JavaFX:

stage.initStyle(StageStyle.UNDECORATED)
stage.setAlwaysOnTop(true);

So that’s cool. But in the other hand I’ve got a problem with simply hiding the window without destroying it.

def setVisible(boolean show) {
	Platform.runLater [
		if (!stage.showing && show) {
			stage.show()
		}
		else if (stage.showing && !show) {
			stage.hide()
		}
	]
}

Platform.runLater()  takes an anonymous function (in Java - through Runnable  interface) which is supposted to be executed in the UI thread. Without it I’m going to see

java.lang.IllegalStateException: Not on FX application thread

However, that function is not going to be executed after “hiding” primary Stage. After googling, debugging and few tries around various things and googling again I found this magic line which appeared to be valid in JavaFX version 2.2:

Platform.setImplicitExit(false)

Tada! Now CTRL+TILDE hotkey toggles visibility of the console. The Console. Two.

Daj Się Poznać, the-console
comments powered by Disqus