0 followers Follow

How do I create more than one submenu item?

This is a locked post that has been migrated from our previous forum. Please start a new post if you would like to continue the discussion.

Geneious User:

A simplified version of the code I'm working on is pasted below. It is derived from the Blast options example given for the createSubmenuActionOptions method of GeneiousActionOptions in the api. The plugin I'm working on has a menu item that has several submenus items. Ideally, it would be like the primer design bundled plugin, in this regard. The code below creates a menu item with a single submenu item available. I'm having trouble figureing out how to add additional submenu items rather than simply replacing them, as the code below does.
Thanks for your help,

public class Setup extends DocumentOperation {

public GeneiousActionOptions getActionOptions() {

GeneiousActionOptions parent = new GeneiousActionOptions("Name","Description").setMainMenuLocation(GeneiousActionOptions.MainMenu.Tools);
GeneiousActionOptions submenuItem1 = new GeneiousActionOptions("Item1", "Description");
GeneiousActionOptions submenuItem2 = new GeneiousActionOptions("Item2", "Description");
GeneiousActionOptions sub1 = parent.createSubmenuActionOptions(parent, submenuItem1);
GeneiousActionOptions sub2 = parent.createSubmenuActionOptions(parent, submenuItem2);

return sub2;

Geneious Support:

I'm sure one of the devs can give you a better answer, but I had this same problem with the Glimmer plugin when I was writing it. As it turns out, in my GeneiousPlugin class I have two different operations, a SequenceAnnotationGenerator which runs Glimmer to annotate the ORFs, and a DocumentOperation which creates the glimmer model. These two are both in the GeneiousPlugin implementation and then they're essentially written as separate plugins all within the GlimmerPlugin so I have the GlimmerAnnnotationGenerator which has its GeneiousActionOptions and the GlimmerModelOperation which has another GeneiousActionOptions so when you install the Glimmer plugin you get two menu items.

If you just want you can return multiple DocumentOperations since it is a list whereas my example has a mixture but you could do something like this instead:

public DocumentOperation[] getDocumentOperations() {
return new DocumentOperation[] {
new MyFirstDocumentOperation(),
new MySecondDocumentOperation()

Now just implement each of these operations with their own ActionOptions to get separate menu items.


Geneious User:

Thanks for the quick response Shane. I've looked into doing exactly what you describe, and that might be a reasonable option...however, I would still prefer to use a submenu in order to save space on the menu dropdown, if that is possible. Crossing my fingers!

Geneious Support:

Shane is on the right track. You also need to do something like this in each document operation:

public GeneiousActionOptions getActionOptions() {
//the parent options need to be shared between the two document operations so you should create a method to get the same options from both places.
GeneiousActionOptions parent = MyPlugin.getParentActionOptions();
GeneiousActionOptions submenuItem1 = new GeneiousActionOptions("Item1", "Description");
GeneiousActionOptions sub1 = parent.createSubmenuActionOptions(parent, submenuItem1);
return sub1;
Web admin

Post is closed for comments.