/**
  * Execute the code in example
  *
  * @param pre the preformatted Element containing Scilab's code
  */
 public void execExample(Element pre) {
   String code = getCode(pre);
   try {
     ScilabConsole.getConsole()
         .getAsSimpleConsole()
         .sendCommandsToScilab(code, true /* display */, false /* store in history */);
   } catch (NoClassDefFoundError e) {
     ScilabModalDialog.show(
         (SimpleTab) SwingUtilities.getAncestorOfClass(SimpleTab.class, x),
         Messages.gettext("Feature not available in this mode..."));
   }
 }
  /**
   * Create the popup menu on the help
   *
   * @param c The graphic component
   */
  private void createPopupMenu(JComponent c) {
    final JPopupMenu popup = new JPopupMenu();

    JMenuItem menuItem;

    /* Execute into Scilab */
    ActionListener actionListenerExecuteIntoScilab =
        (ActionEvent actionEvent) -> {
          String selection = accessibleHtml.getSelectedText();
          if (selection == null) {
            ScilabHelpBrowser.getHelpBrowser()
                .getInfoBar()
                .setText(Messages.gettext("No text selected"));
          } else {
            ScilabConsole.getConsole()
                .getAsSimpleConsole()
                .sendCommandsToScilab(selection, true /* display */, true /* store in history */);
          }
        };
    menuItem = new JMenuItem(Messages.gettext("Execute into Scilab"));
    menuItem.addActionListener(actionListenerExecuteIntoScilab);
    if (!ScilabConsole.isExistingConsole()) {
      /* Only available in STD mode */
      menuItem.setEnabled(false);
    }
    popup.add(menuItem);

    /* Edit in the Scilab Text Editor */
    ActionListener actionListenerLoadIntoTextEditor =
        (ActionEvent actionEvent) -> {
          String selection = accessibleHtml.getSelectedText();
          if (selection == null) {
            ScilabHelpBrowser.getHelpBrowser()
                .getInfoBar()
                .setText(Messages.gettext("No text selected"));
          } else {
            edit(selection);
          }
        };

    menuItem = new JMenuItem(Messages.gettext("Edit in the Scilab Text Editor"));
    try {
      Class scinotesClass = Class.forName("org.scilab.modules.scinotes.SciNotes");
    } catch (ClassNotFoundException e) {
      /* SciNotes not available */
      menuItem.setEnabled(false);
    }
    menuItem.addActionListener(actionListenerLoadIntoTextEditor);
    popup.add(menuItem);
    popup.addSeparator();

    /* Back in the history*/
    ActionListener actionListenerBackHistory =
        (ActionEvent actionEvent) -> {
          DefaultHelpHistoryModel history = SwingScilabHelpBrowser.getHelpHistory();
          /* Not at the first position */
          if (history.getIndex() > 0) {
            SwingScilabHelpBrowser.getHelpHistory().goBack();
          }
        };

    menuItem = new JMenuItem(Messages.gettext("Back"));
    menuItem.addActionListener(actionListenerBackHistory);
    popup.add(menuItem);

    /* Forward in the history*/
    ActionListener actionListenerForwardHistory =
        (ActionEvent actionEvent) -> {
          DefaultHelpHistoryModel history = SwingScilabHelpBrowser.getHelpHistory();
          /* Not at the last position */
          if (history.getHistory().size() != (history.getIndex() + 1)) {
            SwingScilabHelpBrowser.getHelpHistory().goForward();
          }
        };

    menuItem = new JMenuItem(Messages.gettext("Forward"));
    menuItem.addActionListener(actionListenerForwardHistory);
    popup.add(menuItem);
    popup.addSeparator();

    /* Copy */
    menuItem = new JMenuItem(new DefaultEditorKit.CopyAction());
    menuItem.setText(Messages.gettext("Copy"));
    popup.add(menuItem);
    popup.addSeparator();

    /* Select all */
    ActionListener actionListenerSelectAll =
        (ActionEvent actionEvent) -> {
          accessibleHtml.selectAll();
        };
    menuItem = new JMenuItem(Messages.gettext("Select All"));
    menuItem.addActionListener(actionListenerSelectAll);
    popup.add(menuItem);

    /* Edit in the Scilab Text Editor */
    final JMenuItem helpMenuItem = new JMenuItem("Help on the selected text");

    ActionListener actionListenerHelpOnKeyword =
        (ActionEvent actionEvent) -> {
          String selection = accessibleHtml.getSelectedText();
          if (selection == null) {
            ScilabHelpBrowser.getHelpBrowser()
                .getInfoBar()
                .setText(Messages.gettext("No text selected"));
          } else {
            ScilabHelpBrowser.getHelpBrowser().searchKeywork(selection);
          }
        };
    PropertyChangeListener listenerTextItem =
        (PropertyChangeEvent arg0) -> {
          String keyword = accessibleHtml.getSelectedText();
          if (keyword == null) {
            helpMenuItem.setText(Messages.gettext("Help about a selected text"));
          } else {
            int nbOfDisplayedOnlyXChar = 10;
            if (keyword.length() > nbOfDisplayedOnlyXChar) {
              keyword = keyword.substring(0, nbOfDisplayedOnlyXChar) + "...";
            }
            helpMenuItem.setText(Messages.gettext("Help about '") + keyword + "'");
          }
        };
    helpMenuItem.addPropertyChangeListener(listenerTextItem);
    helpMenuItem.addActionListener(actionListenerHelpOnKeyword);
    popup.add(helpMenuItem);

    /* Creates the Popupmenu on the component */
    accessibleHtml.setComponentPopupMenu(popup);
  }