| author | wenzelm | 
| Tue, 24 Jun 2025 21:05:48 +0200 | |
| changeset 82747 | 00828818a607 | 
| parent 75393 | 87ebf5a50283 | 
| permissions | -rw-r--r-- | 
| 56585 | 1 | /* Title: Tools/jEdit/src/context_menu.scala | 
| 2 | Author: Makarius | |
| 3 | ||
| 4 | Common context menu for Isabelle/jEdit. | |
| 5 | */ | |
| 6 | ||
| 7 | package isabelle.jedit | |
| 8 | ||
| 9 | ||
| 10 | import isabelle._ | |
| 11 | ||
| 12 | ||
| 58548 | 13 | import java.awt.event.MouseEvent | 
| 14 | ||
| 15 | import javax.swing.JMenuItem | |
| 56585 | 16 | |
| 17 | import org.gjt.sp.jedit.gui.DynamicContextMenuService | |
| 58548 | 18 | import org.gjt.sp.jedit.textarea.JEditTextArea | 
| 56585 | 19 | |
| 20 | ||
| 75393 | 21 | class Context_Menu extends DynamicContextMenuService {
 | 
| 56585 | 22 | def createMenu(text_area: JEditTextArea, evt: MouseEvent): Array[JMenuItem] = | 
| 62229 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 23 | if (evt == null) null | 
| 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 24 |     else {
 | 
| 65240 | 25 | Isabelle.dismissed_popups(text_area.getView) | 
| 58524 | 26 | |
| 62229 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 27 | val items1 = | 
| 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 28 |         if (evt != null && evt.getSource == text_area.getPainter) {
 | 
| 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 29 | val offset = text_area.xyToOffset(evt.getX, evt.getY) | 
| 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 30 | if (offset >= 0) | 
| 65139 | 31 | JEdit_Spell_Checker.context_menu(text_area, offset) ::: | 
| 62229 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 32 | Debugger_Dockable.context_menu(text_area, offset) | 
| 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 33 | else Nil | 
| 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 34 | } | 
| 58524 | 35 | else Nil | 
| 62229 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 36 | |
| 66120 | 37 | val items2 = JEdit_Bibtex.context_menu(text_area) | 
| 58524 | 38 | |
| 62229 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 39 | val items = items1 ::: items2 | 
| 
027e6032977f
more robust initialization: createMenu(_, null) is called early (during EditPane creation), thus it precedes the startup_failure dialog and could crash if PIDE.options are uninitialized;
 wenzelm parents: 
60878diff
changeset | 40 | if (items.isEmpty) null else items.toArray | 
| 56585 | 41 | } | 
| 42 | } |