26
26
import java .awt .*;
27
27
import java .awt .event .*;
28
28
import javax .swing .*;
29
+ import java .awt .datatransfer .*;
30
+ import static processing .app .I18n ._ ;
29
31
30
32
31
33
/**
@@ -68,6 +70,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
68
70
JButton okButton ;
69
71
JTextField editField ;
70
72
JProgressBar progressBar ;
73
+ JButton copyErrorButton ;
71
74
72
75
//Thread promptThread;
73
76
int response ;
@@ -108,6 +111,7 @@ public void empty() {
108
111
public void notice (String message ) {
109
112
mode = NOTICE ;
110
113
this .message = message ;
114
+ copyErrorButton .setVisible (false );
111
115
//update();
112
116
repaint ();
113
117
}
@@ -120,6 +124,7 @@ public void unnotice(String unmessage) {
120
124
public void error (String message ) {
121
125
mode = ERR ;
122
126
this .message = message ;
127
+ copyErrorButton .setVisible (true );
123
128
repaint ();
124
129
}
125
130
@@ -177,6 +182,7 @@ public void progress(String message)
177
182
this .message = message ;
178
183
progressBar .setIndeterminate (false );
179
184
progressBar .setVisible (true );
185
+ copyErrorButton .setVisible (false );
180
186
setCursor (Cursor .getPredefinedCursor (Cursor .WAIT_CURSOR ));
181
187
repaint ();
182
188
}
@@ -189,6 +195,7 @@ public void progressIndeterminate(String message)
189
195
progressBar .setIndeterminate (true );
190
196
progressBar .setValue (50 );
191
197
progressBar .setVisible (true );
198
+ copyErrorButton .setVisible (false );
192
199
setCursor (Cursor .getPredefinedCursor (Cursor .WAIT_CURSOR ));
193
200
repaint ();
194
201
}
@@ -207,6 +214,7 @@ public void unprogress()
207
214
if (Preferences .getBoolean ("editor.beep.compile" )) {
208
215
Toolkit .getDefaultToolkit ().beep ();
209
216
}
217
+ if (progressBar == null ) return ;
210
218
progressBar .setVisible (false );
211
219
progressBar .setValue (0 );
212
220
setCursor (null );
@@ -216,6 +224,7 @@ public void unprogress()
216
224
217
225
public void progressUpdate (int value )
218
226
{
227
+ if (progressBar == null ) return ;
219
228
progressBar .setValue (value );
220
229
repaint ();
221
230
}
@@ -438,6 +447,29 @@ public void keyTyped(KeyEvent event) {
438
447
add (progressBar );
439
448
progressBar .setVisible (false );
440
449
450
+ copyErrorButton = new JButton (_ ("Copy To Clipboard" ));
451
+ add (copyErrorButton );
452
+ //copyErrorButton.setVisible(true);
453
+ copyErrorButton .setVisible (false );
454
+ System .out .println ("create copyErrorButton" );
455
+ copyErrorButton .addActionListener (new ActionListener () {
456
+ public void actionPerformed (ActionEvent e ) {
457
+ String message ="" ;
458
+ if ((Preferences .getBoolean ("build.verbose" )) == false ) {
459
+ message = " " + _ ("This report would have more information with" ) + "\n " ;
460
+ message += " \" " + _ ("Show verbose output during compilation" ) + "\" \n " ;
461
+ message += " " + _ ("enabled in File > Preferences." ) + "\n " ;
462
+ }
463
+ message += _ ("Arduino: " ) + Base .VERSION_NAME + " (" + System .getProperty ("os.name" ) + "), " ;
464
+ message += _ ("Board: " ) + "\" " + Base .getBoardPreferences ().get ("name" ) + "\" \n " ;
465
+ message += editor .console .consoleTextPane .getText ().trim ();
466
+ Clipboard clipboard = Toolkit .getDefaultToolkit ().getSystemClipboard ();
467
+ StringSelection data = new StringSelection (message );
468
+ clipboard .setContents (data , null );
469
+ Clipboard unixclipboard = Toolkit .getDefaultToolkit ().getSystemSelection ();
470
+ if (unixclipboard != null ) unixclipboard .setContents (data , null );
471
+ }
472
+ });
441
473
}
442
474
}
443
475
@@ -470,6 +502,10 @@ protected void setButtonBounds() {
470
502
editField .setBounds (yesLeft - Preferences .BUTTON_WIDTH , editTop ,
471
503
editWidth , editHeight );
472
504
progressBar .setBounds (noLeft , editTop , editWidth , editHeight );
505
+
506
+ Dimension copyErrorButtonSize = copyErrorButton .getPreferredSize ();
507
+ copyErrorButton .setLocation (sizeW - copyErrorButtonSize .width - 5 , top );
508
+ copyErrorButton .setSize (copyErrorButtonSize .width , Preferences .BUTTON_HEIGHT );
473
509
}
474
510
475
511
0 commit comments