Set Cuba main menu items from source code

Hi community,

I have a question,
when I start my application of cuba,
I get one tab with the name: Application and in this tab, I can find my “entity” Customer
but what I want are different kind of tab with different entity, means

“application” “customer” “orders”
As tabs…

how to make it from source code?

Thanks

Hello @spamhater.alex

Could you share a screenshot that describes what are you talking about?

Regards,
Daniil.

@tsarev

Hello,

yes, of course

example

Here you can see the “UseCase” tab with Project and Usecase-Status
I want to add such a tab like “UseCase” for Example Orders, where I have Customer and Products for example

So the question is, how to add such “tab” like Usecase with his entity and I want to know, how to make it from “scratch” means, only from source code

Thanks a lot

PS: I like cuba-platform

Okay, thank you. Now it is clear - you are talking about main menu and its items.

So to imperatively add new item to application menu you have to extend main window - it is the only way to get access to main menu.

Then you can use the com.haulmont.cuba.gui.components.mainwindow.AppMenu API to manage items.

1 Like

but how? :frowning:
I have to be honest no idea…

Could you clarify what do you mean by “but how”? I can’t help until you describe a problem.

Sorry,

I mean about how to “implementing” this,
that I can add a tab programmatically,

like, how to start or where I need exactly to make modifications, or do I need to create a class for this? Or where to create a class?

Thanks

As I said above first of all you have to extend main window (documentation). It can be done with CUBA Studio:

… click New on the GENERIC UI tab of the navigation panel and choose the template for the new main screen in the Generic UI templates visual designer.

And there is a field mainMenu that represents the menu - use it to add new items like this:

AppMenu.MenuItem newItem = mainMenu.createMenuItem(
        "menuItemId", 
        "menuItemCaption", 
        "menuItemIcon (nullable)", 
        menuItem -> 
                openWindow("screenId", WindowManager.OpenType.NEW_TAB));

mainMenu.addMenuItem(newItem);

Regards,
Daniil.

1 Like

ok,
sposiba

I will take a look :slight_smile:

1 Like