@@ -26,11 +26,12 @@ import prof7bit.bitcoin.wallettool.core.WalletKeyTool
26
26
import prof7bit.bitcoin.wallettool.fileformats.AbstractImportExportHandler
27
27
import prof7bit.bitcoin.wallettool.fileformats.MultibitHandler
28
28
import prof7bit.bitcoin.wallettool.fileformats.WalletDumpHandler
29
- import prof7bit.bitcoin.wallettool.ui.swing.listeners.MouseDownListener
30
29
import prof7bit.bitcoin.wallettool.ui.swing.listeners.ResizeListener
31
30
import prof7bit.bitcoin.wallettool.ui.swing.misc.TableColumnAdjuster
32
31
33
32
import static extension prof7bit.bitcoin.wallettool.core.Ext.*
33
+ import java.awt.event.MouseEvent
34
+ import prof7bit.bitcoin.wallettool.ui.swing.listeners.MousePressedOrReleasedListener
34
35
35
36
class WalletPanel extends JPanel {
36
37
val log = LoggerFactory . getLogger(this . class)
@@ -57,98 +58,110 @@ class WalletPanel extends JPanel{
57
58
]
58
59
]
59
60
61
+ var boolean table_clicked_inside
62
+
60
63
val JTable table = new JTable = > [
61
64
model = new WalletTableModel (keyTool)
62
65
autoResizeMode = JTable . AUTO_RESIZE_ALL_COLUMNS
63
66
addComponentListener(new ResizeListener [
64
67
columnAdjuster. adjustColumns
65
68
])
66
- addMouseListener(new MouseDownListener [evt|
67
- if (evt. popupTrigger) {
68
- val row = rowAtPoint(evt. point)
69
- val inside = (row >= 0 && row < model. rowCount)
70
- new JPopupMenu = > [popup|
71
- if (inside){
69
+ addMouseListener(new MousePressedOrReleasedListener [evt|
70
+ if (SwingUtilities . isRightMouseButton(evt)){
71
+
72
+ // select immediately on mouse down
73
+ // before we do anything else
74
+ if (evt. ID == MouseEvent . MOUSE_PRESSED ){
75
+ val row = rowAtPoint(evt. point)
76
+ if (row >= 0 && row < model. rowCount){
72
77
selectionModel. setSelectionInterval(row, row)
73
- new JMenuItem (" copy address to clipboard" ) = > [
74
- popup. add(it )
75
- addActionListener [
76
- copyToClipboard(row, 0 )
77
- ]
78
- ]
79
- new JMenuItem (" copy private key to clipboard" ) = > [
80
- popup. add(it )
81
- addActionListener [
82
- copyToClipboard(row, 1 )
78
+ table_clicked_inside = true
79
+ } else {
80
+ table_clicked_inside = false
81
+ }
82
+ }
83
+
84
+ // popup also on mouse down (some platforms)
85
+ // or on mouse up (some other platforms)
86
+ if (evt. popupTrigger) {
87
+ val row = selectedRow
88
+ new JPopupMenu = > [popup|
89
+ if (table_clicked_inside) {
90
+ new JMenuItem (" copy address to clipboard" ) = > [
91
+ popup. add(it )
92
+ addActionListener [
93
+ copyToClipboard(row, 0 )
94
+ ]
83
95
]
84
- ]
85
- new JMenuItem (" copy selected key to " + otherName) = > [
86
- popup. add(it )
87
- addActionListener [
88
- if (otherKeyTool. params == null ){
89
- otherKeyTool. params = keyTool. params
90
- }
91
- otherKeyTool. addKeyFromOtherInstance(keyTool, row)
96
+ new JMenuItem (" copy private key to clipboard" ) = > [
97
+ popup. add(it )
98
+ addActionListener [
99
+ copyToClipboard(row, 1 )
100
+ ]
92
101
]
93
- ]
94
- new JMenuItem (" move selected key to " + otherName) = > [
95
- popup. add(it )
96
- addActionListener [
97
- if (otherKeyTool. params == null ){
98
- otherKeyTool. params = keyTool. params
99
- }
100
- otherKeyTool. addKeyFromOtherInstance(keyTool, row)
101
- keyTool. remove(row)
102
+ new JMenuItem (" copy selected key to " + otherName) = > [
103
+ popup. add(it )
104
+ addActionListener [
105
+ if (otherKeyTool. params == null ){
106
+ otherKeyTool. params = keyTool. params
107
+ }
108
+ otherKeyTool. addKeyFromOtherInstance(keyTool, row)
109
+ ]
102
110
]
103
- ]
104
- new JMenuItem (" Remove selected key" ) = > [
105
- popup. add(it )
106
- addActionListener [
107
- keyTool. remove(row)
111
+ new JMenuItem (" move selected key to " + otherName) = > [
112
+ popup. add(it )
113
+ addActionListener [
114
+ if (otherKeyTool. params == null ){
115
+ otherKeyTool. params = keyTool. params
116
+ }
117
+ otherKeyTool. addKeyFromOtherInstance(keyTool, row)
118
+ keyTool. remove(row)
119
+ ]
108
120
]
109
- ]
110
- new JMenuItem (" Fetch balance and creation date from blockchain.info" ) = > [
111
- popup. add(it )
112
- addActionListener [
113
- keyTool. doRemoteFetchBalance(row)
114
- keyTool. doRemoteFetchCreationDate(row)
121
+ new JMenuItem (" Remove selected key" ) = > [
122
+ popup. add(it )
123
+ addActionListener [
124
+ keyTool. remove(row)
125
+ ]
115
126
]
116
- ]
117
- val key = keyTool. get(row)
118
- var compOtherTxt = " compressed"
119
- if (key. hasPrivKey){
120
- if (key. compressed){
121
- compOtherTxt = " uncompressed"
122
- }
123
- new JMenuItem (" Add " + compOtherTxt + " version of this key" ) = > [
127
+ new JMenuItem (" Fetch balance and creation date from blockchain.info" ) = > [
124
128
popup. add(it )
125
129
addActionListener [
126
- keyTool. addOtherCompressedVersion(row)
130
+ keyTool. doRemoteFetchBalance(row)
131
+ keyTool. doRemoteFetchCreationDate(row)
127
132
]
128
133
]
134
+ val key = keyTool. get(row)
135
+ var compOtherTxt = " compressed"
136
+ if (key. hasPrivKey){
137
+ if (key. compressed){
138
+ compOtherTxt = " uncompressed"
139
+ }
140
+ new JMenuItem (" Add " + compOtherTxt + " version of this key" ) = > [
141
+ popup. add(it )
142
+ addActionListener [
143
+ keyTool. addOtherCompressedVersion(row)
144
+ ]
145
+ ]
146
+ }
129
147
}
130
- // new JMenuItem("Fetch all data for all keys from blockchain.info") => [
131
- // popup.add(it)
132
- // addActionListener [
133
- // keyTool.doRemoteUpdateAll
134
- // ]
135
- // ]
136
- }
137
- new JMenuItem (" Add new key" ) = > [
138
- popup. add(it )
139
- addActionListener [
140
- new AddKeyDialog (parentFrame, keyTool)
148
+ new JMenuItem (" Add new key" ) = > [
149
+ popup. add(it )
150
+ addActionListener [
151
+ new AddKeyDialog (parentFrame, keyTool)
152
+ ]
141
153
]
142
- ]
143
- new JMenuItem ( " Clear list " ) = > [
144
- popup . add( it )
145
- addActionListener [
146
- keyTool . clear
154
+ new JMenuItem ( " Clear list " ) = > [
155
+ popup . add( it )
156
+ addActionListener [
157
+ keyTool . clear
158
+ ]
147
159
]
160
+ popup. show(table, evt. x, evt. y)
148
161
]
149
- popup. show(table, evt. x, evt. y)
150
- ]
162
+ }
151
163
}
164
+
152
165
])
153
166
]
154
167
0 commit comments