27
27
import java .awt .event .*;
28
28
import javax .swing .*;
29
29
30
+ import java .awt .datatransfer .*;
31
+ import static processing .app .I18n ._ ;
32
+
30
33
31
34
/**
32
35
* Panel just below the editing area that contains status messages.
@@ -68,6 +71,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
68
71
JButton okButton ;
69
72
JTextField editField ;
70
73
JProgressBar progressBar ;
74
+ JButton copyErrorButton ;
71
75
72
76
//Thread promptThread;
73
77
int response ;
@@ -109,6 +113,7 @@ public void empty() {
109
113
public void notice (String message ) {
110
114
mode = NOTICE ;
111
115
this .message = message ;
116
+ copyErrorButton .setVisible (false );
112
117
//update();
113
118
repaint ();
114
119
}
@@ -121,6 +126,7 @@ public void unnotice(String unmessage) {
121
126
public void error (String message ) {
122
127
mode = ERR ;
123
128
this .message = message ;
129
+ copyErrorButton .setVisible (true );
124
130
repaint ();
125
131
}
126
132
@@ -178,6 +184,7 @@ public void progress(String message)
178
184
this .message = message ;
179
185
progressBar .setIndeterminate (false );
180
186
progressBar .setVisible (true );
187
+ copyErrorButton .setVisible (false );
181
188
setCursor (Cursor .getPredefinedCursor (Cursor .WAIT_CURSOR ));
182
189
repaint ();
183
190
}
@@ -190,6 +197,7 @@ public void progressIndeterminate(String message)
190
197
progressBar .setIndeterminate (true );
191
198
progressBar .setValue (50 );
192
199
progressBar .setVisible (true );
200
+ copyErrorButton .setVisible (false );
193
201
setCursor (Cursor .getPredefinedCursor (Cursor .WAIT_CURSOR ));
194
202
repaint ();
195
203
}
@@ -208,6 +216,7 @@ public void unprogress()
208
216
if (Preferences .getBoolean ("editor.beep.compile" )) {
209
217
Toolkit .getDefaultToolkit ().beep ();
210
218
}
219
+ if (progressBar == null ) return ;
211
220
progressBar .setVisible (false );
212
221
progressBar .setValue (0 );
213
222
setCursor (null );
@@ -217,6 +226,7 @@ public void unprogress()
217
226
218
227
public void progressUpdate (int value )
219
228
{
229
+ if (progressBar == null ) return ;
220
230
progressBar .setValue (value );
221
231
repaint ();
222
232
}
@@ -442,6 +452,32 @@ public void keyTyped(KeyEvent event) {
442
452
add (progressBar );
443
453
progressBar .setVisible (false );
444
454
455
+ copyErrorButton = new JButton (
456
+ "<html>" + _ ("Copy error" ) + "<br>" + _ ("to clipboard" ) + "</html>" );
457
+ Font font = copyErrorButton .getFont ();
458
+ font = new Font (font .getName (), font .getStyle (), (int ) (font .getSize ()*0.7 ));
459
+ copyErrorButton .setFont (font );
460
+ copyErrorButton .setHorizontalAlignment (JLabel .CENTER );
461
+ add (copyErrorButton );
462
+ copyErrorButton .setVisible (false );
463
+ copyErrorButton .addActionListener (new ActionListener () {
464
+ public void actionPerformed (ActionEvent e ) {
465
+ String message ="" ;
466
+ if ((Preferences .getBoolean ("build.verbose" )) == false ) {
467
+ message = " " + _ ("This report would have more information with" ) + "\n " ;
468
+ message += " \" " + _ ("Show verbose output during compilation" ) + "\" \n " ;
469
+ message += " " + _ ("enabled in File > Preferences." ) + "\n " ;
470
+ }
471
+ message += _ ("Arduino: " ) + Base .VERSION_NAME + " (" + System .getProperty ("os.name" ) + "), " ;
472
+ message += _ ("Board: " ) + "\" " + Base .getBoardPreferences ().get ("name" ) + "\" \n " ;
473
+ message += editor .console .consoleTextPane .getText ().trim ();
474
+ Clipboard clipboard = Toolkit .getDefaultToolkit ().getSystemClipboard ();
475
+ StringSelection data = new StringSelection (message );
476
+ clipboard .setContents (data , null );
477
+ Clipboard unixclipboard = Toolkit .getDefaultToolkit ().getSystemSelection ();
478
+ if (unixclipboard != null ) unixclipboard .setContents (data , null );
479
+ }
480
+ });
445
481
}
446
482
}
447
483
@@ -474,6 +510,10 @@ protected void setButtonBounds() {
474
510
editField .setBounds (yesLeft - Preferences .BUTTON_WIDTH , editTop ,
475
511
editWidth , editHeight );
476
512
progressBar .setBounds (noLeft , editTop , editWidth , editHeight );
513
+
514
+ Dimension copyErrorButtonSize = copyErrorButton .getPreferredSize ();
515
+ copyErrorButton .setLocation (sizeW - copyErrorButtonSize .width - 5 , top );
516
+ copyErrorButton .setSize (copyErrorButtonSize .width , Preferences .BUTTON_HEIGHT );
477
517
}
478
518
479
519
0 commit comments