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,338
  • MenuDesigner2.6.zip
    18.5 KB · Views: 1,288
  • MenuDesigner_kvs_2.6.zip
    20.7 KB · Views: 1,159
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Hi @derez

First of all, thanks for this useful tool.

I'm trying your Menu Designer 2.4. If I remove an Item the program crashes:

Error occurred on line: 294 (main).
java.lang.RuntimeException: Object should first be initialized (Map).


B4X:
Sub Update_Children_List(t As TreeItem) ' t is the parent item of the item that is changed (deleted or moved)
    Dim L As List
    Dim m As Map
    L.Initialize
    For Each ti As TreeItem In t.Children
        L.Add(ti.Text)
    Next
    m = mainmap.Get(t.Text)
    m.Put("Children",L)    '  <--- Line 294
    mainmap.Put(t.text,m)
End Sub

I added a first Main Menu with one sub menu, a second Main (no sub menues) and a third Main; I tried to remove this third Main menu.


Thank you
 
Last edited:

derez

Expert
Licensed User
Longtime User
Thank you LucaMs for the report. The bug was in trying to update the children list of root in the main map while it is not stored there at all.
The corrected versions were uploaded.
 

Cableguy

Expert
Licensed User
Longtime User
Hi @derez

First of all, thanks for this useful tool.

I'm trying your Menu Designer 2.4. If I remove an Item the program crashes:

Error occurred on line: 294 (main).
java.lang.RuntimeException: Object should first be initialized (Map).


B4X:
Sub Update_Children_List(t As TreeItem) ' t is the parent item of the item that is changed (deleted or moved)
    Dim L As List
    Dim m As Map
    L.Initialize
    For Each ti As TreeItem In t.Children
        L.Add(ti.Text)
    Next
    m = mainmap.Get(t.Text)
    m.Put("Children",L)    '  <--- Line 294
    mainmap.Put(t.text,m)
End Sub

I added a first Main Menu with one sub menu, a second Main (no sub menues) and a third Main; I tried to remove this third Main menu.


Thank you

I report this same issue, removing an item crashes the app with the above message, but in line 175 in the "non kvs" version
 

LWGShane

Well-Known Member
Licensed User
Longtime User
Hi @derez

First of all, thanks for this useful tool.

I'm trying your Menu Designer 2.4. If I remove an Item the program crashes:

Error occurred on line: 294 (main).
java.lang.RuntimeException: Object should first be initialized (Map).


B4X:
Sub Update_Children_List(t As TreeItem) ' t is the parent item of the item that is changed (deleted or moved)
    Dim L As List
    Dim m As Map
    L.Initialize
    For Each ti As TreeItem In t.Children
        L.Add(ti.Text)
    Next
    m = mainmap.Get(t.Text)
    m.Put("Children",L)    '  <--- Line 294
    mainmap.Put(t.text,m)
End Sub

I added a first Main Menu with one sub menu, a second Main (no sub menues) and a third Main; I tried to remove this third Main menu.


Thank you

Having the same problem, but with moving a menu item.
 

derez

Expert
Licensed User
Longtime User
ColdBlueLava wrote:
Having the same problem, but with moving a menu item.
Can you please tell me the exact menu and which item was moved that caused the crash ?
Cableguy - sorry I missed your post.
I'll check it.
 

LWGShane

Well-Known Member
Licensed User
Longtime User
@derez: It occurs on any menu item. (with or without Sub-Items.)
 

derez

Expert
Licensed User
Longtime User
The same problem that appeared in deletion was corrected in up and down as well.
Uploaded in the first post, ver 2.6
 
Last edited:

LWGShane

Well-Known Member
Licensed User
Longtime User
Bug: Updating Tag on main menu deletes all child menus.
 

derez

Expert
Licensed User
Longtime User
Bug: Updating Tag on main menu deletes all child menus.
I checked and it works fine. Is it possible that you just need to open the node by click on the triangle on the left ?
 

derez

Expert
Licensed User
Longtime User
Upload the text, I'll do it for you
Or, if you have the result you can put it in an application and see the menu, create with the tool a new one just like the one you have and sava it.
 
Last edited:

LWGShane

Well-Known Member
Licensed User
Longtime User
@derez

1: I think it was 'operator error'. I'm unable to reproduce it.

2: The Separator item is just a "-" and not "{Text:"-"}".

B4X:
[
   {Text: "_File", Children:
     ["_New", "_Save",
     {Text: "_Export", Children: ["Zip File", "Tar File"]},
     "-",
     "_Close"]
   }
]
 

Mashiane

Expert
Licensed User
Longtime User

LWGShane

Well-Known Member
Licensed User
Longtime User
Last edited:

LWGShane

Well-Known Member
Licensed User
Longtime User
New update:

- Finalized my GUI modifications.
- Modify Button Text "Create Code" to "Compile Menu".
- Add @Mashiane's code with the button titled "Decompile Menu".
- Added the ability to hit "enter" or "return" to add a menu item to each text field.

(Download Removed. Latest is attached.)

This is the first open source project I've contributed code to.

Hotfix Release 3.0.1:
- Forgot to add the ShortcutText_Action event.

2016 Release 1:
- Fix separator code. By mistake, it was adding the {} to the "-", which resulted in wrong JSON code. (I have no idea why as it wasn't before.)
- Change versioning to YEAR, RELEASE #

ZIP is attached.
 

Attachments

  • MenuDesigner_2016_R1.zip
    57.1 KB · Views: 456
Last edited:

DavideV

Active Member
Licensed User
Longtime User
Hi all contributors :)
this tool really useful and using it i found that crashes while cancel the open file dialog without choosing a file.
Just added my contribution too fixing it. I saw some other crashes in some cases but i haven't investigated more...
Thanks to Derez for starting this app (and other of course to keep it updated) !
 

Attachments

  • MenuDesigner_2016_R1_1.zip
    22.3 KB · Views: 438

LWGShane

Well-Known Member
Licensed User
Longtime User
I finally figured out why the separator code wasn't working. I also had to copy my separator code to where the the app's code appended the string with a "}".

B4X:
  If t_text.Contains("separator") Or t_text.Contains("Separator") Then
    'If the word is separator or Separator, then don't appened with a "}".
Else
    sb.Append("}")
End If

Menu Designer 2016 Release 2 is now available. It should fix the problem where the app would append the separator symbol with an "}". Project is attached.


@DavideV - This is why I love open source projects: they're powered by the community.
 

Attachments

  • MenuDesigner Release 2.zip
    21.6 KB · Views: 454
Last edited:

TorontoJim

Member
Licensed User
Longtime User
Just downloaded this. It would have stopped me from beating my head on the desk if I'd seen it earlier. Thank you for providing this great tool.
 

Mashiane

Expert
Licensed User
Longtime User
Hi there, I have updated the app for the following:

1. Used splitpane to make the screen bigger, there are three sections to the app, the tree, the buttons and the output, see screen dumps below. You can maximise the screen for full effect.
2. When creating a "New" menu, you are prompted for the project name. This enables one to differentiate between different menus they will create, see the screen dumps below.
3. Each time you Add, Update, Down, Up and item, the current state of the menu is Saved using the projject Name specified in 2. above. This ensures you never loose your menu.
4. Thanks to TorontoJim on post #38, I've added a recent files functionality to the designer. This means selecting your recent file will open that project. Each time you "Open" a project or "Save As", the recent file list is updated automatically.

This uses the JRDialog8 library available here.
 

Attachments

  • mdRecentFiles.png
    mdRecentFiles.png
    13.2 KB · Views: 471
  • mdFileNew.png
    mdFileNew.png
    16 KB · Views: 458
  • menuDesigner.png
    menuDesigner.png
    29.1 KB · Views: 450
  • jMenuDesigner.zip
    31.3 KB · Views: 463
Top