From 5f26d058e6de57167debc2249450698ea854b757 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Mon, 1 Jun 2009 19:02:46 +0000 Subject: [PATCH] Fixing help menu links, integrating copy as html, and modifying EditorToolbar labels (Run -> Verify, Export -> Upload). --- app/src/processing/app/Base.java | 22 +++++++++-- app/src/processing/app/Editor.java | 39 +++++++++++++++---- app/src/processing/app/EditorToolbar.java | 2 +- .../processing/app/tools/DiscourseFormat.java | 25 ++++++------ 4 files changed, 65 insertions(+), 23 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 0668150bc..15c4c0531 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1636,7 +1636,16 @@ public class Base { File referenceFile = new File(referenceFolder, filename); openURL(referenceFile.getAbsolutePath()); } - + + static public void showGettingStarted() { + if (Base.isMacOS()) { + Base.showReference("Guide_MacOSX.html"); + } else if (Base.isWindows()) { + Base.showReference("Guide_Windows.html"); + } else { + Base.openURL("http://www.arduino.cc/playground/Learning/Linux"); + } + } static public void showReference() { showReference("index.html"); @@ -1644,7 +1653,7 @@ public class Base { static public void showEnvironment() { - showReference("environment" + File.separator + "index.html"); + showReference("Guide_Environment.html"); } @@ -1654,9 +1663,14 @@ public class Base { static public void showTroubleshooting() { - showReference("troubleshooting" + File.separator + "index.html"); + showReference("Guide_Troubleshooting.html"); } - + + + static public void showFAQ() { + showReference("faq.html"); + } + // ................................................................. diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 3ae7aa184..f0b4b9fd6 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -981,7 +981,7 @@ public class Editor extends JFrame implements RunnerListener { item = new JMenuItem("Getting Started"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - Base.openURL("http://processing.org/learning/gettingstarted/"); + Base.showGettingStarted(); } }); menu.add(item); @@ -1023,15 +1023,15 @@ public class Editor extends JFrame implements RunnerListener { item = new JMenuItem("Frequently Asked Questions"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - Base.openURL("http://processing.org/faq.html"); + Base.showFAQ(); } }); menu.add(item); - item = newJMenuItem("Visit Processing.org", '5'); + item = new JMenuItem("Visit Arduino.cc"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - Base.openURL("http://processing.org/"); + Base.openURL("http://arduino.cc/"); } }); menu.add(item); @@ -1039,7 +1039,7 @@ public class Editor extends JFrame implements RunnerListener { // macosx already has its own about menu if (!Base.isMacOS()) { menu.addSeparator(); - item = new JMenuItem("About Processing"); + item = new JMenuItem("About Arduino"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { base.handleAbout(); @@ -1089,7 +1089,19 @@ public class Editor extends JFrame implements RunnerListener { public void actionPerformed(ActionEvent e) { // SwingUtilities.invokeLater(new Runnable() { // public void run() { - new DiscourseFormat(Editor.this).show(); + new DiscourseFormat(Editor.this, false).show(); +// } +// }); + } + }); + menu.add(item); + + item = newJMenuItemAlt("Copy as HTML", 'C'); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { +// SwingUtilities.invokeLater(new Runnable() { +// public void run() { + new DiscourseFormat(Editor.this, true).show(); // } // }); } @@ -1560,7 +1572,12 @@ public class Editor extends JFrame implements RunnerListener { protected void handleDiscourseCopy() { - new DiscourseFormat(Editor.this).show(); + new DiscourseFormat(Editor.this, false).show(); + } + + + protected void handleHTMLCopy() { + new DiscourseFormat(Editor.this, true).show(); } @@ -2367,6 +2384,14 @@ public class Editor extends JFrame implements RunnerListener { }); this.add(discourseItem); + discourseItem = new JMenuItem("Copy as HTML"); + discourseItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + handleHTMLCopy(); + } + }); + this.add(discourseItem); + item = new JMenuItem("Paste"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { diff --git a/app/src/processing/app/EditorToolbar.java b/app/src/processing/app/EditorToolbar.java index e7b89475b..96a82bcb2 100644 --- a/app/src/processing/app/EditorToolbar.java +++ b/app/src/processing/app/EditorToolbar.java @@ -35,7 +35,7 @@ import javax.swing.event.*; public class EditorToolbar extends JComponent implements MouseInputListener { static final String title[] = { - "Run", "Stop", "New", "Open", "Save", "Export" + "Verify", "Stop", "New", "Open", "Save", "Upload" }; static final int BUTTON_COUNT = title.length; diff --git a/app/src/processing/app/tools/DiscourseFormat.java b/app/src/processing/app/tools/DiscourseFormat.java index 5de4c0074..a9a40d299 100644 --- a/app/src/processing/app/tools/DiscourseFormat.java +++ b/app/src/processing/app/tools/DiscourseFormat.java @@ -55,6 +55,7 @@ public class DiscourseFormat { Editor editor; // JTextArea of the actual Editor JEditTextArea textarea; + boolean html; /** @@ -62,9 +63,10 @@ public class DiscourseFormat { * from the actual Processing Tab ready to send to the processing discourse * web (copy & paste) */ - public DiscourseFormat(Editor editor) { + public DiscourseFormat(Editor editor, boolean html) { this.editor = editor; this.textarea = editor.getTextArea(); + this.html = html; } @@ -73,7 +75,7 @@ public class DiscourseFormat { */ public void show() { // [code] tag cancels other tags, using [quote] - StringBuffer cf = new StringBuffer("[quote]\n"); + StringBuffer cf = new StringBuffer(html ? "
\n" : "[quote]\n");
 
     int selStart = textarea.getSelectionStart();
     int selStop = textarea.getSelectionStop();
@@ -97,7 +99,7 @@ public class DiscourseFormat {
       appendFormattedLine(cf, i);
     }
 
-    cf.append("\n[/quote]");
+    cf.append(html ? "\n
" : "\n[/quote]"); StringSelection formatted = new StringSelection(cf.toString()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); @@ -107,8 +109,9 @@ public class DiscourseFormat { } }); - editor.statusNotice("Code formatted for processing.org/discourse " + - "has been copied to the clipboard."); + editor.statusNotice("Code formatted for " + + (html ? "HTML" : "the Arduino forum ") + + " has been copied to the clipboard."); } @@ -178,12 +181,12 @@ public class DiscourseFormat { // fm = painter.getFontMetrics(); } else { // Place open tags [] - cf.append("[color=#"); + cf.append(html ? "" : "]"); if (styles[id].isBold()) - cf.append("[b]"); + cf.append(html ? "" : "[b]"); // fm = styles[id].getFontMetrics(defaultFont); } @@ -193,7 +196,7 @@ public class DiscourseFormat { char c = segmentArray[segmentOffset + offset + j]; if (offset == 0 && c == ' ') { // Works on Safari but not Camino 1.6.3 or Firefox 2.x on OS X. - cf.append('\u00A0'); //   + cf.append(html ? " " : '\u00A0'); //   // if ((j % 2) == 1) { // cf.append("[b]\u00A0[/b]"); // } else { @@ -204,9 +207,9 @@ public class DiscourseFormat { } // Place close tags [/] if (j == (length - 1) && id != Token.NULL && styles[id].isBold()) - cf.append("[/b]"); + cf.append(html ? "" : "[/b]"); if (j == (length - 1) && id != Token.NULL) - cf.append("[/color]"); + cf.append(html ? "" : "[/color]"); // int charWidth; // if (c == '\t') { // charWidth = (int) painter