Add "Copy To Clipboard" button for compile errors (Paul Stoffregen)

This commit is contained in:
PaulStoffregen 2013-04-22 14:17:38 -07:00
parent d66930fd6a
commit f9135178d1
1 changed files with 36 additions and 0 deletions

View File

@ -26,6 +26,8 @@ package processing.app;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.datatransfer.*;
import static processing.app.I18n._;
/**
@ -68,6 +70,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
JButton okButton;
JTextField editField;
JProgressBar progressBar;
JButton copyErrorButton;
//Thread promptThread;
int response;
@ -108,6 +111,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
public void notice(String message) {
mode = NOTICE;
this.message = message;
copyErrorButton.setVisible(false);
//update();
repaint();
}
@ -120,6 +124,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
public void error(String message) {
mode = ERR;
this.message = message;
copyErrorButton.setVisible(true);
repaint();
}
@ -177,6 +182,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
this.message = message;
progressBar.setIndeterminate(false);
progressBar.setVisible(true);
copyErrorButton.setVisible(false);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
repaint();
}
@ -189,6 +195,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
progressBar.setIndeterminate(true);
progressBar.setValue(50);
progressBar.setVisible(true);
copyErrorButton.setVisible(false);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
repaint();
}
@ -207,6 +214,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
if (Preferences.getBoolean("editor.beep.compile")) {
Toolkit.getDefaultToolkit().beep();
}
if (progressBar == null) return;
progressBar.setVisible(false);
progressBar.setValue(0);
setCursor(null);
@ -216,6 +224,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
public void progressUpdate(int value)
{
if (progressBar == null) return;
progressBar.setValue(value);
repaint();
}
@ -438,6 +447,29 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
add(progressBar);
progressBar.setVisible(false);
copyErrorButton = new JButton(_("Copy To Clipboard"));
add(copyErrorButton);
//copyErrorButton.setVisible(true);
copyErrorButton.setVisible(false);
System.out.println("create copyErrorButton");
copyErrorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String message="";
if ((Preferences.getBoolean("build.verbose")) == false) {
message = " " + _("This report would have more information with") + "\n";
message += " \"" + _("Show verbose output during compilation") + "\"\n";
message += " " + _("enabled in File > Preferences.") + "\n";
}
message += _("Arduino: ") + Base.VERSION_NAME + " (" + System.getProperty("os.name") + "), ";
message += _("Board: ") + "\"" + Base.getBoardPreferences().get("name") + "\"\n";
message += editor.console.consoleTextPane.getText().trim();
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection data = new StringSelection(message);
clipboard.setContents(data, null);
Clipboard unixclipboard = Toolkit.getDefaultToolkit().getSystemSelection();
if (unixclipboard != null) unixclipboard.setContents(data, null);
}
});
}
}
@ -470,6 +502,10 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
editField.setBounds(yesLeft - Preferences.BUTTON_WIDTH, editTop,
editWidth, editHeight);
progressBar.setBounds(noLeft, editTop, editWidth, editHeight);
Dimension copyErrorButtonSize = copyErrorButton.getPreferredSize();
copyErrorButton.setLocation(sizeW - copyErrorButtonSize.width - 5, top);
copyErrorButton.setSize(copyErrorButtonSize.width, Preferences.BUTTON_HEIGHT);
}