Skip to content

Commit

Permalink
Add "Copy To Clipboard" button for compile errors (Paul Stoffregen)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulStoffregen committed Apr 22, 2013
1 parent d66930f commit f913517
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions app/src/processing/app/EditorStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.datatransfer.*;
import static processing.app.I18n._;


/**
Expand Down Expand Up @@ -68,6 +70,7 @@ public class EditorStatus extends JPanel /*implements ActionListener*/ {
JButton okButton;
JTextField editField;
JProgressBar progressBar;
JButton copyErrorButton;

//Thread promptThread;
int response;
Expand Down Expand Up @@ -108,6 +111,7 @@ public void empty() {
public void notice(String message) {
mode = NOTICE;
this.message = message;
copyErrorButton.setVisible(false);
//update();
repaint();
}
Expand All @@ -120,6 +124,7 @@ public void unnotice(String unmessage) {
public void error(String message) {
mode = ERR;
this.message = message;
copyErrorButton.setVisible(true);
repaint();
}

Expand Down Expand Up @@ -177,6 +182,7 @@ public void progress(String message)
this.message = message;
progressBar.setIndeterminate(false);
progressBar.setVisible(true);
copyErrorButton.setVisible(false);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
repaint();
}
Expand All @@ -189,6 +195,7 @@ public void progressIndeterminate(String message)
progressBar.setIndeterminate(true);
progressBar.setValue(50);
progressBar.setVisible(true);
copyErrorButton.setVisible(false);
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
repaint();
}
Expand All @@ -207,6 +214,7 @@ public void unprogress()
if (Preferences.getBoolean("editor.beep.compile")) {
Toolkit.getDefaultToolkit().beep();
}
if (progressBar == null) return;
progressBar.setVisible(false);
progressBar.setValue(0);
setCursor(null);
Expand All @@ -216,6 +224,7 @@ public void unprogress()

public void progressUpdate(int value)
{
if (progressBar == null) return;
progressBar.setValue(value);
repaint();
}
Expand Down Expand Up @@ -438,6 +447,29 @@ public void keyTyped(KeyEvent event) {
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);
}
});
}
}

Expand Down Expand Up @@ -470,6 +502,10 @@ protected void setButtonBounds() {
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);
}


Expand Down

0 comments on commit f913517

Please sign in to comment.