16
16
import java .util .Collection ;
17
17
import java .util .Collections ;
18
18
import java .util .Enumeration ;
19
+ import java .util .HashSet ;
19
20
import java .util .List ;
21
+ import java .util .Set ;
20
22
21
23
import javax .swing .AbstractAction ;
22
24
import javax .swing .BorderFactory ;
@@ -178,6 +180,18 @@ protected void initCommon() {
178
180
UiUtils .addEscapeShortCutToDispose (this );
179
181
}
180
182
183
+ protected void copyAllSearchResults () {
184
+ StringBuilder sb = new StringBuilder ();
185
+ Set <String > uniqueRefs = new HashSet <>();
186
+ for (JNode node : resultsModel .rows ) {
187
+ String codeNodeRef = node .getJavaNode ().getCodeNodeRef ().toString ();
188
+ if (uniqueRefs .add (codeNodeRef )) {
189
+ sb .append (codeNodeRef ).append ("\n " );
190
+ }
191
+ }
192
+ UiUtils .copyToClipboard (sb .toString ());
193
+ }
194
+
181
195
@ NotNull
182
196
protected JPanel initButtonsPanel () {
183
197
progressPane = new ProgressPanel (mainWindow , false );
@@ -187,6 +201,8 @@ protected JPanel initButtonsPanel() {
187
201
JButton openBtn = new JButton (NLS .str ("search_dialog.open" ));
188
202
openBtn .addActionListener (event -> openSelectedItem ());
189
203
getRootPane ().setDefaultButton (openBtn );
204
+ JButton copyBtn = new JButton (NLS .str ("search_dialog.copy" ));
205
+ copyBtn .addActionListener (event -> copyAllSearchResults ());
190
206
191
207
JCheckBox cbKeepOpen = new JCheckBox (NLS .str ("search_dialog.keep_open" ));
192
208
cbKeepOpen .setSelected (mainWindow .getSettings ().getKeepCommonDialogOpen ());
@@ -203,6 +219,8 @@ protected JPanel initButtonsPanel() {
203
219
buttonPane .add (progressPane );
204
220
buttonPane .add (Box .createRigidArea (new Dimension (5 , 0 )));
205
221
buttonPane .add (Box .createHorizontalGlue ());
222
+ buttonPane .add (copyBtn );
223
+ buttonPane .add (Box .createRigidArea (new Dimension (10 , 0 )));
206
224
buttonPane .add (openBtn );
207
225
buttonPane .add (Box .createRigidArea (new Dimension (10 , 0 )));
208
226
buttonPane .add (cancelButton );
@@ -440,8 +458,8 @@ public ResultsTableCellRenderer() {
440
458
}
441
459
442
460
@ Override
443
- public Component getTableCellRendererComponent (JTable table , Object obj ,
444
- boolean isSelected , boolean hasFocus , int row , int column ) {
461
+ public Component getTableCellRendererComponent (JTable table , Object obj , boolean isSelected , boolean hasFocus , int row ,
462
+ int column ) {
445
463
if (obj == null || table == null ) {
446
464
return emptyLabel ;
447
465
}
0 commit comments