At the moment i am working with JavaFX building a little Application that has a lot of configurable parameters. For the reason of not getting lost on a dialog with thousand of different checkboxes, textfields and so on, the parameter controls should be grouped with the JavaFX control TabPane. A TabPane was quickly done but soon i realized that it is not so easy to prevent the user from changing the current tab if the parameters grouped in this tab have invalid values. Instead of switching to the selected tab i rather like to show a validation error message. So i did some reading on the JavaFX API but there is no way out of the box to achieve this behavior. You can do some work if the tab has changed but not before it is changed. If you have a similar issue with the TabPane maybe my solution will work for you :-)
class StateAwareChangeListener implements ChangeListener<Tab>
{
/**
* go to previous tab if validation fails and this flag is true.
*/
private boolean roleback;
/**
* If validation is ok change the tab.
*
* {@inheritDoc}
*
*/
@Override
public void changed(ObservableValue<? extends Tab> arg0, Tab arg1, Tab arg2)
{
if (roleback) {
roleback = false;
return;
}
boolean validateConfig = validateIfChangeIsPossible();
if (validateConfig == false) {
roleback = true;
tabPane.getSelectionModel().select(arg1);
}
}
}
This listener calls the method validateIfChangeIsPossible that you have to implement by yourself. If changing the tab is possible return true. If false the old tab is selected again. You can also parse the new tab as a parameter into validateIfChangeIsPossible, if you need the information.
Finally add this class as a ChangeListener to the selectedItemProperty of the TabPane:
tabPane.getSelectionModel().selectedItemProperty().addListener(new StateAwareChangeListener());
Saturday, November 15, 2014
Friday, October 31, 2014
Execute Groovy as a Shell-Script
A colleague of me told me today that it is possible to run Scala Scripts directly in a shell. Because i am more familiar with Groovy i started some research if it is possible to do this with Groovy as well. To do it short: Yes we can :-) Take a look: http://groovy.codehaus.org/Running
Tuesday, October 28, 2014
JavaFX SceneBuilder or how to add more Cols and Rows to a GridPane
Yeah, i know it sounds simple: add some additional columns and / or rows to a GridPane with the SceneBuilder. Minute over minute i looked at the Properties-View of the GridPane but no way to add columns or rows.
Solution: right click on the GridPane in the hierachy view and simply select what you want to do ;-)
Solution: right click on the GridPane in the hierachy view and simply select what you want to do ;-)
Sunday, October 19, 2014
Android Dependencies in local maven repo
After my last blog you may ask: "what about android dependencies that are not part of public maven repositories? I like to have 4.4.2 but everthing i found was 4.1.1!" Don't worry :-) There is a nice tool to install all android dependencies in your local repository. So take a look:
https://github.com/mosabua/maven-android-sdk-deployer
https://github.com/mosabua/maven-android-sdk-deployer
Saturday, October 18, 2014
Maven for Android
For all of you who won't miss Maven Support in your Android Projects:
https://code.google.com/p/maven-android-plugin/
This Maven-Plugin helps you building an Android Application (apk) and manage necessary Dependencies. Nice one :-)
https://code.google.com/p/maven-android-plugin/
This Maven-Plugin helps you building an Android Application (apk) and manage necessary Dependencies. Nice one :-)
Tuesday, October 7, 2014
Wohooo! Didn't know that i already have a blog :-). But good too know. So lets start with some Java Stuff.
Yesterday i installed the latestet version of the Android Development Toolkit. Most of my projects make use of Maven so i also tried to install the M2E Maven Eclipse integration. But i had no luck. The installation quit with a missing dependency (com.google.guave). The solution came to me in form of a two year old stackoverflow thread: http://stackoverflow.com/questions/11391297/maven-android-and-eclipse-coexistence-problems
Install the M2E from the following update site: http://rgladwell.github.com/m2e-android/updates/master/
That worked for me :-) Happy Coding
Yesterday i installed the latestet version of the Android Development Toolkit. Most of my projects make use of Maven so i also tried to install the M2E Maven Eclipse integration. But i had no luck. The installation quit with a missing dependency (com.google.guave). The solution came to me in form of a two year old stackoverflow thread: http://stackoverflow.com/questions/11391297/maven-android-and-eclipse-coexistence-problems
Install the M2E from the following update site: http://rgladwell.github.com/m2e-android/updates/master/
That worked for me :-) Happy Coding
Subscribe to:
Posts (Atom)
