import org.gjt.sp.jedit.jEdit; import java.awt.event.KeyEvent; void popupSVNMenu() { // find SVN plugin, get its context menu svn = jEdit.getPlugin("ise.plugin.svn.SVNPlugin"); menu = svn.createContextMenu(view); /* NOTE: from this moment on, SVNPlugin's original context menu (a submenu in the text area's right-click menu) is messed up, i.e. it won't show properly. To fix this, we drop it from there. */ popup = menu.getPopupMenu(); svn.removeContextMenu(view); // hack on it a little, add accelerators components = popup.getComponents(); components[0].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, 0)); components[1].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, 0)); components[2].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, 0)); components[3].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, 0)); components[4].setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_5, 0)); // calculate the caret (cursor) position, convert to x/y int pos = textArea.getCaretPosition(); textArea.goToStartOfLine(false); int left_pos = pos - textArea.getCaretPosition(); textArea.moveCaretPosition(pos); Point pt = new Point(0, 0); textArea.offsetToXY(textArea.getScreenLineOfOffset(pos), left_pos, pt); // finally, show the menu popup.show(view, (int) pt.getX(), (int) pt.getY()); } popupSVNMenu();