Exemplo n.º 1
0
  /**
   * Show popup menu in response to a mouse event.
   * 
   * @param e Event.
   */
  @Override
  protected void showPopup(MouseEvent e) {

    // Retrieve information
    if (!(e.getComponent() instanceof MWPane)) {
      return;
    }
    MWPane textPane = (MWPane) e.getComponent();
    showPopup(textPane, textPane.viewToModel(e.getPoint()), e.getX(), e.getY());
  }
Exemplo n.º 2
0
  /**
   * Show popup menu in response to a key event.
   * 
   * @param e Event.
   */
  @Override
  protected void showPopup(KeyEvent e) {

    // Retrieve information
    if (!(e.getComponent() instanceof MWPane)) {
      return;
    }
    MWPane textPane = (MWPane) e.getComponent();
    try {
      Rectangle rect = textPane.modelToView(textPane.getCaretPosition());
      showPopup(textPane, textPane.getSelectionStart(), rect.x, rect.y);
    } catch (BadLocationException e1) {
      //
    }
  }
Exemplo n.º 3
0
  /**
   * Construct and show popup menu.
   * 
   * @param textPane Text pane.
   * @param position Position in text.
   * @param x Position.
   * @param y Position.
   */
  private void showPopup(MWPane textPane, int position, int x, int y) {

    // Basic checks
    if (textPane == null) {
      return;
    }

    // Create popup menu
    Page originalPage = textPane.getWikiPage();
    PageAnalysis pageAnalysis = originalPage.getAnalysis(textPane.getText(), true);
    JPopupMenu popup = createPopup(textPane, position, pageAnalysis);
    if (popup == null) {
      popup = createDefaultPopup(textPane, position, pageAnalysis);
    }

    // Display popup menu
    if (popup != null) {
      popup.show(textPane, x, y);
    }
  }