def createMenuItems(self, invoker):
        global immediate_data, compuracer_communication_lock
        self.invoker = invoker

        if not (invoker.getInvocationContext()
                == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST
                or invoker.getInvocationContext()
                == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_REQUEST
                or invoker.getInvocationContext()
                == IContextMenuInvocation.CONTEXT_TARGET_SITE_MAP_TABLE
                or invoker.getInvocationContext()
                == IContextMenuInvocation.CONTEXT_PROXY_HISTORY):
            return None

        self.messages = self.invoker.getSelectedMessages()
        if self.messages is None:
            return None
        if len(self.messages) > 1:
            button_text = "Send {} requests to CompuRacer".format(
                len(self.messages))
        else:
            button_text = "Send request to CompuRacer"
        global racer_alive
        if not racer_alive:
            button_text += " (offline)"
        elif compuracer_communication_lock.locked():
            button_text += " (busy)"
        send_menu = JMenuItem(button_text,
                              actionPerformed=self.start_request_transmitter)
        option_menu = JCheckBoxMenuItem("Immediate mode",
                                        actionPerformed=self.mode_changed)
        option_menu.setSelected(immediate_data['mode'] == 'on')
        # self.set_icon(menu_send)
        send_menu.setEnabled(racer_alive
                             and not compuracer_communication_lock.locked())
        option_menu.setEnabled(racer_alive
                               and not compuracer_communication_lock.locked())
        return [send_menu, option_menu]
    def createMenuItems(self, invoker):

        self.invoker = invoker

        self.selection = self.invoker.getSelectionBounds()

        context = self.invoker.getInvocationContext()
        if not (context == self.invoker.CONTEXT_MESSAGE_EDITOR_REQUEST
                or context == self.invoker.CONTEXT_MESSAGE_VIEWER_REQUEST
                or context == self.invoker.CONTEXT_MESSAGE_EDITOR_RESPONSE
                or context == self.invoker.CONTEXT_MESSAGE_VIEWER_RESPONSE):
            return None

        menu_translate_sel = JMenuItem(self.src_menu_text,
                                       actionPerformed=self.translate)
        menu_translate_sel.setEnabled(False)
        menu_translate_clip = JMenuItem(self.dst_menu_text,
                                        actionPerformed=self.translate)
        menu_translate_clip.setEnabled(False)

        if self.selection is not None and self.selection[0] != self.selection[
                1]:
            menu_translate_sel.setEnabled(True)
        if self.get_clipboard_text() is not None:
            menu_translate_clip.setEnabled(True)

        menu_header = JMenu(
            '%s v%s' %
            (BurpExtender.extension_name, BurpExtender.extension_version))
        menu_src = JMenu('Source Language [%s]' % (self.src))
        menu_dst = JMenu('Destination Language [%s]' % (self.dst))
        menu_automatic = JCheckBoxMenuItem('Automatic',
                                           actionPerformed=self.select_src)
        menu_src.add(menu_automatic)
        if self.src == menu_automatic.getText():
            menu_automatic.setSelected(True)
        for lang in sorted(langs):
            menu_item = JCheckBoxMenuItem(lang,
                                          actionPerformed=self.select_src)
            if lang == self.src:
                menu_item.setSelected(True)
            menu_src.add(menu_item)
            menu_item = JCheckBoxMenuItem(lang,
                                          actionPerformed=self.select_dst)
            if lang == self.dst:
                menu_item.setSelected(True)
            menu_dst.add(menu_item)

        menu_header.add(menu_src)
        menu_header.add(menu_dst)
        menu_header.add(menu_translate_sel)
        menu_header.add(menu_translate_clip)

        return [menu_header]