1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.devaki.nextobjects.ui.menus;
21 import javax.swing.JPopupMenu;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import org.devaki.nextobjects.constants.CstImages;
25 import org.devaki.nextobjects.ui.components.CustomMenuItem;
26 import org.devaki.nextobjects.util.NOClipboard;
27 import java.awt.event.KeyEvent;
28 import javax.swing.JTextPane;
29 /***
30 * This class provide a popup menu for the SQL panel
31 */
32 public class EditorPopupMenu extends JPopupMenu
33 {
34 /***
35 * Copy menu item
36 */
37 private static CustomMenuItem jMenuItemCopy =
38 new CustomMenuItem(
39 "Copy",
40 CstImages.ICN_COPY,
41 KeyEvent.VK_C,
42 false);
43 /***
44 * Select all menu item
45 */
46 private CustomMenuItem jMenuItemSelectAll =
47 new CustomMenuItem("Select All", null, KeyEvent.VK_A, false);
48 /***
49 * Reference to the SQL editor
50 */
51 private static JTextPane textpane;
52 /***
53 * Create a new 'EditorPopupMenu' object
54 * @param theTextPane reference to the sql editor
55 */
56 public EditorPopupMenu()
57 {
58
59 EditorPopupMenu
60 .jMenuItemCopy
61 .addActionListener(new ActionListener()
62 {
63 public void actionPerformed(ActionEvent e)
64 {
65
66 NOClipboard.copy(textpane.getSelectedText());
67 }
68 });
69 this.jMenuItemSelectAll.addActionListener(new ActionListener()
70 {
71 public void actionPerformed(ActionEvent e)
72 {
73 textpane.selectAll();
74 }
75 });
76 jMenuItemCopy.setEnabled(true);
77 jMenuItemSelectAll.setEnabled(true);
78 this.add(this.jMenuItemSelectAll);
79 this.addSeparator();
80 add(jMenuItemCopy);
81 }
82 /***
83 * @param pane
84 */
85 public void setTextpane(JTextPane pane)
86 {
87 textpane = pane;
88 }
89 }