Share My Creation Menu Designer

The task of creating menu for b4j is not simple because you have to create a jason string.
I made a tool for creating the string based on this thread https://www.b4x.com/android/forum/threads/designer-menu-items.56602/
While doing that I exercised the new designer :)

For first level menu items only name, tag and event are relevant (I tried to disable but it does not work)
Make sure that an item is selected before doing update or remove.
After "create" you have the string in the clipboard, just paste it to the menu field in the application designer, or copy from the textarea or the log.
Please check and report any problems, it has not been tested too much.

Edit: Ver. 1.1 , logic of update and remove is changed completely.
Edit: Ver 2.0 includes save and load functions. A bug is corrected in submenu operation, now when you click it you can add a sub menu for the selected treeitem.
Edit: ver 2.1 correct a bug.
Edit: ver 2.2 corrected a bug in update.
Edit: ver 2.3 added menu with shortcuts (created by itself ! ) for load(open) and save files.
Edit: ver 2.4 corrects bugs in move and remove.
MenuDesigner_kvs uses KeyValueStore to keep the current "menu in work" ready even while exiting.
Edit: ver 2.5 and kvs_2.5 replace the previous after correction of bug.
Edit: ver 2.6 corrected the same problem in moving nodes.

Note: From version 2.0 the item's details are kept in a map by the item's name as the key. This means that an update cannot include change of the name. To do such update remove the item and add a new item instead.
 

Attachments

  • img.png
    img.png
    51.1 KB · Views: 7,151
  • MenuDesigner2.6.zip
    18.5 KB · Views: 1,181
  • MenuDesigner_kvs_2.6.zip
    20.7 KB · Views: 1,055
Last edited:

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Derez.

This is a wonderful contribution.

Early stages of testing....

Remove command - makes app exit
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Hello, Derez.

I was able to create a menu using your app (see zip).

A number of suggestions/issues:
1. Add Save and Get menus (no one gets the menu right the first time) to provide for Edit/Modify capability.
2. Update button - works on Event Names but not on Menu Text. I wanted to modify Edit to something else and it did not allow it.
3. Remove button kills the app.

Thank you.

Sandy

PS: Ideally, when your app is perfected, Erel could integrate it into the Open Designer to generate the subs for the Events....
his goes back to my wish to have a Menu Designer....
 

Attachments

  • example2.zip
    272.3 KB · Views: 751

rwblinn

Well-Known Member
Licensed User
Longtime User
Well Done.
Just minor one: It is possible to add menu items without text.
Suggestions: Add Seperator, Button to Copy Code to Clipboard.
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Derez for v1.1 - great job!

V 1.1 seems more robust also.

I was able to create the menu in the example attached in about 3 minutes (after testing the various features of your app). True RAD....

But, let's say now, I want to change the menu... I cannot bring the existing menu back to your app for modification.
WISH: The app needs a Save and Get - then it will be fantastic. Any possibility of getting this feature?

Best regards.

Sandy
 

Attachments

  • example2 (2).zip
    279.4 KB · Views: 644

derez

Expert
Licensed User
Longtime User
It is possible to add menu items without text
Never crossed my mind, why ?
Add Seperator,Button to Copy Code to Clipboard.
Separator should be done by "-"
It is automatically copied to the clipboard ! just paste it !
This is written in the first post:
After "create" you have the string in the clipboard, just paste it to the menu field in the application designer, or copy from the textarea or the log.
WISH: The app needs a Save and Get
I can't save the tree or the mainmap as objects because they include TreeItems. If someone has an idea how to save and load - let me know. I've tried my best today but to no avail, but still thinking on it !
 
Last edited:

LWGShane

Well-Known Member
Licensed User
Longtime User
Thanks for this!

Was planning on doing something similar, but ran into a road block. (I couldn't figure out how to store and generate the menus.)
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Derez.

WISH: The app needs a Save and Get
Click to expand...
I can't save the tree or the mainmap as objects because they include TreeItems. If someone has an idea how to save and load - let me know. I've tried my best today but to no avail, but still thinking on it !

Please remember this is a newbie asking...

Could the TreeItems be recreated from the JSON string?
Is
this relevant?

Thank you again.

Sandy
 
Last edited:

derez

Expert
Licensed User
Longtime User
I have tried that on the whole map and the reconstruction is not good enough but I think I know what to do to make it work, thanks for directing me :)
 
Last edited:

tdocs2

Well-Known Member
Licensed User
Longtime User
Derez,

You deserve a triple "Like":):):) This is great.

In my brief testing: On Save if Cancel - app exits....

Thank you,

Sandy
 

LWGShane

Well-Known Member
Licensed User
Longtime User
Bug: After clicking update, clicking "Create Code" crashes the app.

This is the debugger output ;)

B4X:
Program started.
Error occurred on line: 412 (main).
java.lang.RuntimeException: Object should first be initialized (Map).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32)
    at anywheresoftware.b4a.objects.collections.Map.Get(Map.java:67)
    at b4j.example.main._write_string(main.java:463)
    at b4j.example.main._write_string(main.java:481)
    at b4j.example.main._create_action(main.java:399)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:563)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:221)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:156)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:82)
    at anywheresoftware.b4a.BA$2.run(BA.java:165)
    at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295)
    at com.sun.javafx.application.PlatformImpl$$Lambda$48/701593.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294)
    at com.sun.javafx.application.PlatformImpl$$Lambda$47/2180324.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$145(WinApplication.java:101)
    at com.sun.glass.ui.win.WinApplication$$Lambda$36/3326003.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
 

derez

Expert
Licensed User
Longtime User
Have you selected an item before pressing update ?
can you give more details ? (what item were you updating and what is the update)
Can you please attach the saved file ?
 
Last edited:

derez

Expert
Licensed User
Longtime User
Ok found it, ver 2.2 corrects the bug.
Here is the created string (after doing update):
[{Text: "File",Children: [{Text: "Open Image",EventName: "Open",Shortcut: {Key: "O",Modifier: "CONTROL"}}]},{Text: "Export",Children: [{Text: "Export All",EventName: "ExportAll"},{Text: "Android",EventName: "Android_Export"},{Text: "iOS",EventName: "iOS_Export"},{Text: "Windows Phone",EventName: "WP_Export"}]},{Text: "Help",Children: [{Text: "About",EventName: "About"},{Text: "About",EventName: "About"}]}]
 

derez

Expert
Licensed User
Longtime User
Ver 2.3 , added menu with shortcuts for load(open) and save.
The fix in 2.2 was wrong, see in the post above "about" appears twice in the end because it was the updated item.
The correct string by 2.3 is:
[{Text: "File",Children: [{Text: "Open Image",EventName: "Open",Shortcut: {Key: "O",Modifier: "CONTROL"}}]},{Text: "Export",Children: [{Text: "Export All",EventName: "ExportAll"},{Text: "Android",EventName: "Android_Export"},{Text: "iOS",EventName: "iOS_Export"},{Text: "Windows Phone",EventName: "WP_Export"}]},{Text: "Help",Children: [{Text: "About",EventName: "About"}]}]
 

derez

Expert
Licensed User
Longtime User
Version 2.4 corrects bugs in handling of treeitems which are changed(removed or moved)
App MenuDesigner_kvs takes the issue of save and retrieve one step forward - it uses KVS so the menu you are working on is kept even if you exit and there is no need to save, only SaveAs if you want to keep the file when starting a new menu.
 
Top