6
6
import java .awt .Dimension ;
7
7
import java .awt .GridBagConstraints ;
8
8
import java .awt .GridBagLayout ;
9
+ import java .awt .Toolkit ;
10
+ import java .awt .datatransfer .Clipboard ;
11
+ import java .awt .datatransfer .StringSelection ;
9
12
import java .nio .file .Path ;
10
13
import java .util .List ;
11
14
@@ -141,15 +144,18 @@ private static String generateCommand(
141
144
142
145
private class CommandDisplayDialog extends JDialog {
143
146
147
+ private final String command ;
148
+
144
149
public CommandDisplayDialog (JDialog parent , String command ) {
145
150
super (parent );
151
+ this .command = command ;
146
152
setResizable (true );
147
153
setTitle ("EnrichmentMap: Command" );
148
154
setMinimumSize (new Dimension (500 , 300 ));
149
155
setDefaultCloseOperation (WindowConstants .DISPOSE_ON_CLOSE );
150
156
151
157
JPanel messagePanel = createMessagePanel ();
152
- JPanel commandPanel = createCommandPanel (command );
158
+ JPanel commandPanel = createCommandPanel ();
153
159
JPanel buttonPanel = createButtonPanel ();
154
160
155
161
messagePanel .setBorder (BorderFactory .createEmptyBorder (8 ,8 ,8 ,8 ));
@@ -185,7 +191,7 @@ private JPanel createMessagePanel() {
185
191
}
186
192
187
193
188
- private JPanel createCommandPanel (String command ) {
194
+ private JPanel createCommandPanel () {
189
195
JTextArea textArea = new JTextArea (command );
190
196
textArea .setEditable (false );
191
197
textArea .setLineWrap (true );
@@ -197,12 +203,20 @@ private JPanel createCommandPanel(String command) {
197
203
return panel ;
198
204
}
199
205
206
+
200
207
private JPanel createButtonPanel () {
201
208
JButton okButton = new JButton ("Close" );
202
209
okButton .addActionListener (e -> dispose ());
203
- return LookAndFeelUtil .createOkCancelPanel (okButton , null );
210
+
211
+ JButton clipboardButton = new JButton ("Copy to Clipboard" );
212
+ clipboardButton .addActionListener (e -> {
213
+ StringSelection stringSelection = new StringSelection (command );
214
+ Clipboard clipboard = Toolkit .getDefaultToolkit ().getSystemClipboard ();
215
+ clipboard .setContents (stringSelection , null );
216
+ });
217
+
218
+ return LookAndFeelUtil .createOkCancelPanel (okButton , null , clipboardButton );
204
219
}
205
220
}
206
221
207
-
208
222
}
0 commit comments