private void createActions() {
		DockingAction action = new DockingAction("Create Sample Tree", getName()) {
			@Override
			public void actionPerformed(ActionContext context) {
				modularize();
			}

			@Override
			public boolean isEnabledForContext(ActionContext context) {
				return currentProgram != null;
			}
		};
		action.setMenuBarData(
			new MenuData(new String[] { "Misc", "Create Sample Tree" }, null, null));
		action.setDescription("Plugin to create a program tree and modularize accordingly");
		tool.addAction(action);

	}
create the action and call the subroutine that handles it
Ghidra/Extensions/sample/src/main/java/ghidra/examples/SampleProgramTreePlugin.java