B4J Question B4J Create designer files at runtime...

Magma

Expert
Licensed User
Longtime User
Hi there...

Well I know that what I am asking may be is a "direct" question (hate to do that - not right) to Erel but may be someone already searched it or tried it.

Well we all know Balconverter (that convert bal/bjl/bil to json and json to bal/bjl/bil)...

Well i have a different question on that-logic... what if create some controls/customviews at runtime (yes reading right)... how possible is to create json and then convert it to bal/bjl... Is there a quick.. to create the "kids" / controls / data need the bal/bjl fast...

B4X:
    For Each i As B4XView In myb4xform.GetAllViewsRecursive
...................magic_creating_json that need bal/bjl/bil.......
    next
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

PaulMeuris

Active Member
Licensed User
In the Using source code templates tutorial i use the Balconverter code to transform a layout file into a JSON file.
Then in the get_vars_from_json_layout(fname As String) method i extract information from the JSON file to draw a layout.
The structure of the JSON file is rather complicated...
Maybe you can find some inspiration from this code...
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
In the Using source code templates tutorial i use the Balconverter code to transform a layout file into a JSON file.
Then in the get_vars_from_json_layout(fname As String) method i extract information from the JSON file to draw a layout.
The structure of the JSON file is rather complicated...
Maybe you can find some inspiration from this code...
Yes it is too complicated..
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
That´1 100% the wrong try.
:) May be... may be not

I know when someone come to a Question thread must said all the "logic" behind of what sharing and waiting answer...

I am already building a Designer (old try: was my RAD Designer... now i am trying something different with other members) and I want to eliminate the writing of code of the end user-developer (of designer... so will be a mix Generating code/Designer)

@PaulMeuris already shared a Designer... and may be understanding the reason asking that...

1) compatibility with Internal Designer
2) different approach of designing (see the same time the control like old vb6)
3) May be some Intergration like DataBase/Table/Field... to create easy business forms/apps

...And the biggest reason... need that... is that i want to create b4x code, that will also create events of customview controls designed... (and i want all events to be in different sub... like someone used internal designer)

Well... will be a tool for lazy people (like me)... :)
 
Last edited:
Upvote 0

Magma

Expert
Licensed User
Longtime User
Well...

I am watching William Lancee Helper App... and the code using... seems... that is in right path...

So will search it little more...
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Well...

I am watching William Lancee Helper App... and the code using... seems... that is in right path...

So will search it little more...
ofcourse will be better if had WilBalWriter class :) @William Lancee
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
ok if do some reverse engineering with json... may be is simple... gonna share my thoughts an give food, but also expect ideas how to manage some "things"

well the big difference is the "key" named ":kids" that has all controls designed and is under Data (amap - a map in json have other maps inside :) )
also in same time have in ControlHeaders the name of controls (other map)... into LayoutHeader map

B4X:
    Dim Design As Map
    Design.Initialize
    
    Design.Put("LayoutHeader", layoutheader) 'ok...
    Design.Put("Variants", variants) 'ok understandable...
    Design.Put("Data", amap) 'amap holding other maps KIDS
    Design.Put("FontAwesome", False)
    Design.Put("MaterialIcons", False)

the IDEA:
So if just save any empty layout, then convert it to json... we have to add at ControlHeaders some extra keys: 1: , 2: (our controls) with their JavaType,DesignerType,Name

And create a ":kids:" key that will include a map with all the settings of every control....

It is possible to "assign" (find) the names just adding one one the controls from designer... but will be better to know java-names-type someway automatically to have better compatibility...

what do you think ?
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
this is a customview. It has to be loaded via Layout. You can not add such view just-by-code.
I am adding it... but want to save my design-layout from designer with my code... as explaining... It is not easy but i am trying it...
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
I am adding it... but want to save my design-layout from designer with my code... as explaining... It is not easy but i am trying it...
to be more specific:

- Adding it with code and using loadlayout (to be more specific)... but as you know no different event... has to use sender and etc...

- So i will create b4x layout from my designer (our) that will set different eventnames..... and also create the needed code for .bas file to be used...
 
Upvote 0

PaulMeuris

Active Member
Licensed User
When i was writing the pmtemplates application i used the JSON Tree application to visualize the JSON structure.
An example:
1695816702129.png

If you designed a layout like this: tf1 = Text Field, btn1 = Button and clv1 = Custom List View.
Then the converted .bjl layout file will have this JSON structure (provided you use only 1 variant):
1695816927130.png

Drilling down in this structure give these details:
1695817095616.png

And for the data:
1695817165461.png

And then you can look at the :kids map:
1695817279438.png

For the first kid:
1695817389669.png

1695817438797.png

And so on for the other kids...
The JSON tree application also provides the B4X code to build the tree structure.
Some questions about this structure:
- are all the attributes required?
- (as you mentioned already) where can you find the correct javaType?
- what will be the structure if you use Designer Script?
- ...
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
Hi there...

Well I know that what I am asking may be is a "direct" question (hate to do that - not right) to Erel but may be someone already searched it or tried it.

Well we all know Balconverter (that convert bal/bjl/bil to json and json to bal/bjl/bil)...

Well i have a different question on that-logic... what if create some controls/customviews at runtime (yes reading right)... how possible is to create json and then convert it to bal/bjl... Is there a quick.. to create the "kids" / controls / data need the bal/bjl fast...

B4X:
    For Each i As B4XView In myb4xform.GetAllViewsRecursive
...................magic_creating_json that need bal/bjl/bil.......
    next
Kinda funny, i have been asking myself the same thing. I still think if something like this could be possible it will be the bomb!
 
Upvote 0
Top