Fwd: JRebirth - Help/Sample for UI navigation

56 views
Skip to first unread message

Seb

unread,
Aug 12, 2015, 8:48:54 AM8/12/15
to jrebirth-users
Message received privately but the answer can help incoming all newcomers (pending better documentation for this topic)

---------- Forwarded message ----------



Hi Andreas,

Welcome aboard ! I know that documentation is sometimes poor but you can find a lot of code sample from all JRebirth repositories, there are 3 showcase applications, 1 game and several presentations using the prez engine.

There are several ways to attach a View somewhere. The one you mention was just fixed within 8.0.3-SNAPSHOT.

So which method to choose ? It depends on how you want to build your UI.

Seemingly you have chosen to use fxml file so you can:


=> Build your own DisplayModelWaveBean and call ShowModelCommand callCommand(ShowModelCommand.class, displayModelWaveBean); into your Model or a any Command or Service


=> call attachUi from the parent Model (short cut of the previous way) like this :
 attachUi(TaskModel.class, Builders.buildUiData(getView().yourPlaceHolder()).toArray(new WaveData[0]));

Builders.buildUiData allow to customize the wave bean and the command called.


=> Grab the view/rootNode of the TaskModel:
model.getRootNode()
getModel(TaskModel.class).getRootNode() // Warning this code will be run into the current thread so it't not adviced.

=> Build yourself the wave that does the job (longest method)

=> use fx:include if your view hierarchy is composed by several fxml files aggregated.

=> manage them by using InnerComponent, if the TaskModel is always used inside its parent. InnerComponent lifecycle rely on their parents lifecycle.


To conclude, you can use a MainModel<BorderPane> loaded by the Application (public Class<? extends Model> getFirstModelClass() {  return MainModel.class;}), in this model you can add code into showView, to attach your TaslModel to the centerproperty of the BorderPane.
 (use ShowmodelCommand before 8.0.3,
otherwise attachUi)

You can find an example here for your MainModel : https://github.com/JRebirth/MasteringTables/blob/master/org.jrebirth.demo.masteringtables/src/main/java/org/jrebirth/demo/masteringtables/ui/page/PageModel.java
This is a small and simple game from which you can get inspiration.

If you want to use StackModel you have a sample here : https://github.com/JRebirth/JRebirth/blob/master/org.jrebirth.af/showcase/fxml/src/main/java/org/jrebirth/af/showcase/fxml/ui/main/FXMLShowCaseModel.java

Let me know if you have any question

Seb


2015-08-12 14:01 GMT+02:00 <is...@gmx.de>:
Hello Sébastien
 
I'm using JRebirth first time and want to create an application which shows several modules (tasks, notifications, etc.).
 
But I'm stucking with adding an (for instance Task.fxml) view into the existent tree. I don't know how to instanciate the model (FXML, Model, Controller) and
how to insert it into the tree at a specific pane with JRebirth. FXMLoader failes.
 
I found the class StackModel - but seams this is for a main screen switch, not for an particular location.
 
Do you have an sample, how to navigate between views with JRebirth? The documentation announce something about in wave chapter.

Wave Group

There are 4 main group of waves :

  1. Call Command : used to trigger a command action
  2. Call Service : used to call a service, later another wave will be used
  3. Attach Ui : used to link two JavaFX nodes
  4. Undefined : to handle all other waves, the wave type must be defined
 
Thanks a lot in advance
 
Kind Regards
Andreas


Andreas

unread,
Aug 13, 2015, 6:25:48 PM8/13/15
to JRebirth Users, s...@jrebirth.org
Hi Seb

thanks a lot for your fast reply. I could solve the issue with the DisplayModelWaveBean.

But something else: It seams you prefer to create the UI inside a java class, not in FXML.

So I was searching for an CSS/Font usage sample with FXML, because if I create one, add it to the scene as in your sample app MasteringTables and run the application, nothing changed. But you don't use FXML in this MTApplication.
Default style will be used.

Here some excerpts of my code:

simple CSS in "src/main/resources/styles/main.css"
.button {
    -fx-text-fill: white;
    -fx-font-family: "TEXT";
    -fx-font-weight: bold;
    -fx-background-color: linear-gradient(#61a2b1, #2A5058);
    -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );
}

Define StyleItem
StyleSheetItem MAIN = create(new StyleSheet("styles/main"));

Load to scene
addCSS(scene, ApplicationStyles.MAIN);

Preload fonts
return Arrays.asList(new FontItem[] {
                FontResources.TEXT, FontResources.TABS, FontResources.HEADLINE, FontResources.PIANO
        });

Use a simple AbstractFXMLController, DefaultFXMLModel, FXML for the use case.

Add following to the FXML file
<?scenebuilder-stylesheet ../../../../../../main.css?>

But no style and font used :(.

Is something special to do in case of using FXML with JRebirth?


Thanks a lot in advance

Greetings
Andreas

Seb

unread,
Aug 14, 2015, 2:41:47 AM8/14/15
to Andreas, JRebirth Users
Hi Andreas,

the path<?scenebuilder-stylesheet ../../../../../../main.css?> looks very stange, there is perhaps an extra '..' , you shouldn't take into account the src/main/java and src/main/resources to calculate the relative path.

Other piece of code look good (you can try to load a font programatialy to check the corespondance with the real ttf name)

Seb

Andreas

unread,
Aug 14, 2015, 4:55:51 AM8/14/15
to JRebirth Users, adommes.o...@gmail.com, s...@jrebirth.org
Moin Seb,

I'm sorry, my fault. I did a mistake in following:

StyleSheetItem MAIN = create(new StyleSheet("styles/appstyles"));

The sub folder "styles" will be consider implicit, so this is correct:

StyleSheetItem MAIN = create(new StyleSheet("appstyles"));

Regards
Andreas

Seb

unread,
Aug 14, 2015, 11:46:17 AM8/14/15
to jrebirth-users, adommes.o...@gmail.com

I should improve documentation and javadoc to explicitly mention that default folders of fonts, styles and images are configurable (and have a default value) using a JRebirth parameter.

Best Regards

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "JRebirth Users".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jrebirth-user...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

Sebastien Bordes

unread,
Aug 16, 2015, 5:11:28 PM8/16/15
to JRebirth Users, adommes.o...@gmail.com, s...@jrebirth.org
I have added some lines into Javadoc, but I think that you have been warned by a log message like this:

2015-08-16 22:52:10,081  ERROR [JTP Slot 2] o.j.a.c.r.i.ImageBuilder [ImageBuilder.java:153] - Image : images/PoweredBy.png not found into base folder: [images]

==> images has been duplicated into the full path

Perhaps the log message is not self-explicit, let me know if something is not clear enough. Even log wording is important

Regards.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jrebirth-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages