| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | 22 | package processing.app.ui; | |
| 23 | 23 | ||
| 24 | + import java.awt.Container; | ||
| 24 | 25 | import java.awt.Dimension; | |
| 25 | 26 | import java.awt.event.ActionEvent; | |
| 26 | 27 | import java.awt.event.ActionListener; | |
@@ -46,10 +47,10 @@ public class WebFrame extends JFrame { | |||
| 46 | 47 | boolean ready; | |
| 47 | 48 | ||
| 48 | 49 | ||
| 49 | - public WebFrame(File file, int width) throws IOException { | ||
| 50 | + public WebFrame(File file, int width, Container panel) throws IOException { | ||
| 50 | 51 | // Need to use the URL version so that relative paths work for images | |
| 51 | 52 | // https://github.com/processing/processing/issues/3494 | |
| 52 | - URL fileUrl = file.toURI().toURL(); //.toExternalForm(); | ||
| 53 | + URL fileUrl = file.toURI().toURL(); | ||
| 53 | 54 | requestContentHeight(width, fileUrl); | |
| 54 | 55 | ||
| 55 | 56 | editorPane = new JEditorPane(); | |
@@ -68,7 +69,14 @@ public void propertyChange(PropertyChangeEvent evt) { | |||
| 68 | 69 | editorPane.setEditable(false); | |
| 69 | 70 | // set height to something generic | |
| 70 | 71 | editorPane.setPreferredSize(new Dimension(width, width)); | |
| 71 | - getContentPane().add(editorPane); | ||
| 72 | + | ||
| 73 | + //getContentPane().add(editorPane); | ||
| 74 | + Container pain = getContentPane(); | ||
| 75 | + pain.setLayout(new BoxLayout(pain, BoxLayout.Y_AXIS)); | ||
| 76 | + pain.add(editorPane); | ||
| 77 | + if (panel != null) { | ||
| 78 | + pain.add(panel); | ||
| 79 | + } | ||
| 72 | 80 | ||
| 73 | 81 | Toolkit.registerWindowCloseKeys(getRootPane(), new ActionListener() { | |
| 74 | 82 | @Override | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,54 +21,114 @@ | |||
| 21 | 21 | ||
| 22 | 22 | package processing.app.ui; | |
| 23 | 23 | ||
| 24 | + import java.awt.Color; | ||
| 24 | 25 | import java.awt.EventQueue; | |
| 26 | + import java.awt.Font; | ||
| 27 | + import java.awt.event.ActionEvent; | ||
| 28 | + import java.awt.event.ActionListener; | ||
| 29 | + import java.awt.event.ItemEvent; | ||
| 30 | + import java.awt.event.ItemListener; | ||
| 25 | 31 | import java.io.File; | |
| 26 | 32 | import java.io.IOException; | |
| 27 | 33 | ||
| 34 | + import javax.swing.Box; | ||
| 35 | + import javax.swing.JButton; | ||
| 36 | + import javax.swing.JCheckBox; | ||
| 37 | + import javax.swing.JComponent; | ||
| 38 | + | ||
| 28 | 39 | import processing.app.Base; | |
| 29 | 40 | import processing.app.Language; | |
| 30 | 41 | import processing.app.Platform; | |
| 31 | 42 | import processing.app.Preferences; | |
| 32 | 43 | import processing.core.PApplet; | |
| 33 | - import processing.data.StringDict; | ||
| 34 | 44 | ||
| 35 | 45 | ||
| 36 | - public class Welcome extends WebFrame { | ||
| 46 | + public class Welcome { | ||
| 37 | 47 | Base base; | |
| 48 | + WebFrame view; | ||
| 38 | 49 | ||
| 39 | 50 | ||
| 40 | 51 | public Welcome(Base base, boolean sketchbook) throws IOException { | |
| 41 | - super(getIndexFile(sketchbook), 400); | ||
| 42 | 52 | this.base = base; | |
| 43 | - //addStyle("#new_sketchbook { background-color: rgb(0, 255, 0); }"); | ||
| 44 | - setVisible(true); | ||
| 45 | - } | ||
| 46 | 53 | ||
| 54 | + // TODO this should live inside theme or somewhere modifiable | ||
| 55 | + Font dialogFont = Toolkit.getSansFont(14, Font.PLAIN); | ||
| 56 | + | ||
| 57 | + JComponent panel = Box.createHorizontalBox(); | ||
| 58 | + panel.setBackground(new Color(245, 245, 245)); | ||
| 59 | + Toolkit.setBorder(panel, 15, 20, 15, 20); | ||
| 60 | + | ||
| 61 | + //panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); | ||
| 62 | + //panel.add(Box.createHorizontalStrut(20)); | ||
| 63 | + JCheckBox checkbox = new JCheckBox("Show this message on startup"); | ||
| 64 | + checkbox.setFont(dialogFont); | ||
| 65 | + // handles the Help menu invocation, and also the pref not existing | ||
| 66 | + checkbox.setSelected("true".equals(Preferences.get("welcome.show"))); | ||
| 67 | + checkbox.addItemListener(new ItemListener() { | ||
| 68 | + @Override | ||
| 69 | + public void itemStateChanged(ItemEvent e) { | ||
| 70 | + if (e.getStateChange() == ItemEvent.SELECTED) { | ||
| 71 | + Preferences.setBoolean("welcome.show", true); | ||
| 72 | + } else if (e.getStateChange() == ItemEvent.DESELECTED) { | ||
| 73 | + Preferences.setBoolean("welcome.show", false); | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + }); | ||
| 77 | + panel.add(checkbox); | ||
| 47 | 78 | ||
| 48 | - public void handleSubmit(StringDict dict) { | ||
| 49 | - // sketchbook = "create_new" or "use_existing" | ||
| 50 | - // show_each_time = "on" or <not param> | ||
| 51 | - //dict.print(); | ||
| 52 | - | ||
| 53 | - String sketchbookAction = dict.get("sketchbook", null); | ||
| 54 | - if ("create_new".equals(sketchbookAction)) { | ||
| 55 | - // open file dialog | ||
| 56 | - // on affirmative selection, update sketchbook folder | ||
| 57 | - // String path = Preferences.getSketchbookPath() + "3"; | ||
| 58 | - // File folder = new File(path); | ||
| 59 | - // folder.mkdirs(); | ||
| 60 | - File folder = new File(Preferences.getSketchbookPath()).getParentFile(); | ||
| 61 | - PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"), | ||
| 62 | - "sketchbookCallback", folder, | ||
| 63 | - this, this); | ||
| 64 | - } | ||
| 79 | + panel.add(Box.createHorizontalGlue()); | ||
| 65 | 80 | ||
| 66 | - // If un-checked, the key won't be in the dict, so null will be passed | ||
| 67 | - boolean keepShowing = "on".equals(dict.get("show_each_time", null)); | ||
| 68 | - Preferences.setBoolean("welcome.show", keepShowing); | ||
| 69 | - Preferences.save(); | ||
| 81 | + JButton button = new JButton("Get Started"); | ||
| 82 | + button.setFont(Toolkit.getSansFont(14, Font.PLAIN)); | ||
| 83 | + button.addActionListener(new ActionListener() { | ||
| 84 | + public void actionPerformed(ActionEvent e) { | ||
| 85 | + view.handleClose(); | ||
| 86 | + } | ||
| 87 | + }); | ||
| 88 | + panel.add(button); | ||
| 89 | + //panel.add(Box.createHorizontalGlue()); | ||
| 90 | + | ||
| 91 | + view = new WebFrame(getIndexFile(sketchbook), 425, panel) { | ||
| 92 | + /* | ||
| 93 | + @Override | ||
| 94 | + public void handleSubmit(StringDict dict) { | ||
| 95 | + String sketchbookAction = dict.get("sketchbook", null); | ||
| 96 | + if ("create_new".equals(sketchbookAction)) { | ||
| 97 | + File folder = new File(Preferences.getSketchbookPath()).getParentFile(); | ||
| 98 | + PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"), | ||
| 99 | + "sketchbookCallback", folder, | ||
| 100 | + this, this); | ||
| 101 | + } | ||
| 70 | 102 | ||
| 71 | - handleClose(); | ||
| 103 | + // // If un-checked, the key won't be in the dict, so null will be passed | ||
| 104 | + // boolean keepShowing = "on".equals(dict.get("show_each_time", null)); | ||
| 105 | + // Preferences.setBoolean("welcome.show", keepShowing); | ||
| 106 | + // Preferences.save(); | ||
| 107 | + handleClose(); | ||
| 108 | + } | ||
| 109 | + */ | ||
| 110 | + | ||
| 111 | + @Override | ||
| 112 | + public void handleLink(String link) { | ||
| 113 | + // The link will already have the full URL prefix | ||
| 114 | + if (link.endsWith("#sketchbook")) { | ||
| 115 | + File folder = new File(Preferences.getSketchbookPath()).getParentFile(); | ||
| 116 | + PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"), | ||
| 117 | + "sketchbookCallback", folder, | ||
| 118 | + this, this); | ||
| 119 | + } else { | ||
| 120 | + super.handleLink(link); | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + @Override | ||
| 125 | + public void handleClose() { | ||
| 126 | + Preferences.setBoolean("welcome.seen", true); | ||
| 127 | + Preferences.save(); | ||
| 128 | + super.handleClose(); | ||
| 129 | + } | ||
| 130 | + }; | ||
| 131 | + view.setVisible(true); | ||
| 72 | 132 | } | |
| 73 | 133 | ||
| 74 | 134 | ||
@@ -77,16 +137,17 @@ public void sketchbookCallback(File folder) { | |||
| 77 | 137 | if (folder != null) { | |
| 78 | 138 | if (base != null) { | |
| 79 | 139 | base.setSketchbookFolder(folder); | |
| 80 | - } else { | ||
| 81 | - System.out.println("user selected " + folder); | ||
| 140 | + // } else { | ||
| 141 | + // System.out.println("user selected " + folder); | ||
| 82 | 142 | } | |
| 83 | 143 | } | |
| 84 | 144 | } | |
| 85 | 145 | ||
| 86 | 146 | ||
| 87 | - public void handleClose() { | ||
| 88 | - dispose(); | ||
| 89 | - } | ||
| 147 | + // @Override | ||
| 148 | + // public void handleClose() { | ||
| 149 | + // dispose(); | ||
| 150 | + // } | ||
| 90 | 151 | ||
| 91 | 152 | ||
| 92 | 153 | static private File getIndexFile(boolean sketchbook) { | |
@@ -120,11 +181,7 @@ static public void main(String[] args) { | |||
| 120 | 181 | EventQueue.invokeLater(new Runnable() { | |
| 121 | 182 | public void run() { | |
| 122 | 183 | try { | |
| 123 | - new Welcome(null, true) { | ||
| 124 | - public void handleClose() { | ||
| 125 | - System.exit(0); | ||
| 126 | - } | ||
| 127 | - }; | ||
| 184 | + new Welcome(null, true); | ||
| 128 | 185 | } catch (IOException e) { | |
| 129 | 186 | e.printStackTrace(); | |
| 130 | 187 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,46 +5,27 @@ | |||
| 5 | 5 | </head> | |
| 6 | 6 | <body> | |
| 7 | 7 | ||
| 8 | - <!-- action needs to exist (even though blank), otherwise causes NPE --> | ||
| 9 | - <form action=""> | ||
| 8 | + <!-- Using a table here as a layout hack, as CSS "vertical-align: middle;" | ||
| 9 | + is not supported by the Java HTML renderer. --> | ||
| 10 | + <table> | ||
| 11 | + <tr> | ||
| 12 | + <td valign="top"> | ||
| 13 | + <img src="../icons/pde-64.png" width="64" height="64"> | ||
| 14 | + </td> | ||
| 15 | + <td valign="middle"> | ||
| 16 | + <h1>Welcome to Processing 3</h1> | ||
| 17 | + </td> | ||
| 18 | + </tr> | ||
| 19 | + </table> | ||
| 20 | + | ||
| 21 | + <p> | ||
| 22 | + <a href="https://github.com/processing/processing/wiki/Changes-in-3.0">Read about what’s new in 3.0 →</a> | ||
| 23 | + </p> | ||
| 10 | 24 | ||
| 11 | - <!-- Using a table here as a layout hack, as CSS "vertical-align: middle;" | ||
| 12 | - is not supported by the Java HTML renderer. --> | ||
| 13 | - <table> | ||
| 14 | - <tr> | ||
| 15 | - <td valign="top"> | ||
| 16 | - <img src="../icons/pde-64.png" width="64" height="64"> | ||
| 17 | - </td> | ||
| 18 | - <td valign="middle"> | ||
| 19 | - <h1>Welcome to Processing 3</h1> | ||
| 20 | - </td> | ||
| 21 | - </tr> | ||
| 22 | - </table> | ||
| 23 | - | ||
| 24 | - <p> | ||
| 25 | - <a href="https://github.com/processing/processing/wiki/Changes-in-3.0">Read about what’s new in 3.0 →</a> | ||
| 26 | - </p> | ||
| 27 | - | ||
| 28 | - <p class="inset"> | ||
| 29 | - Note that some sketches from Processing 2 may not be compatible. | ||
| 30 | - <a href="https://github.com/processing/processing/wiki/Changes-in-3.0">What has changed?</a> | ||
| 31 | - </p> | ||
| 32 | - | ||
| 33 | - <table> | ||
| 34 | - <tr> | ||
| 35 | - <td> | ||
| 36 | - <input type="checkbox" name="show_each_time" checked /> | ||
| 37 | - </td> | ||
| 38 | - <td> | ||
| 39 | - Show this welcome<br/>message each time | ||
| 40 | - </td> | ||
| 41 | - <td> | ||
| 42 | - <input id="startButton" type="submit" value="Get Started" /> | ||
| 43 | - </td> | ||
| 44 | - </tr> | ||
| 45 | - </table> | ||
| 46 | - | ||
| 47 | - </form> | ||
| 25 | + <p class="inset"> | ||
| 26 | + Note that some sketches from Processing 2 may not be compatible. | ||
| 27 | + <a href="https://github.com/processing/processing/wiki/Changes-in-3.0">What has changed?</a> | ||
| 28 | + </p> | ||
| 48 | 29 | ||
| 49 | 30 | </body> | |
| 50 | 31 | </html> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,72 +5,46 @@ | |||
| 5 | 5 | </head> | |
| 6 | 6 | <body> | |
| 7 | 7 | ||
| 8 | - <!-- action needs to exist (even though blank), otherwise causes NPE --> | ||
| 9 | - <form action=""> | ||
| 10 | - | ||
| 11 | - <!-- Using a table here as a layout hack, as CSS "vertical-align: middle;" | ||
| 12 | - is not supported by the Java HTML renderer. --> | ||
| 13 | - <table> | ||
| 14 | - <tr> | ||
| 15 | - <td valign="top"> | ||
| 16 | - <img src="../icons/pde-64.png" width="64" height="64"> | ||
| 17 | - </td> | ||
| 18 | - <td valign="middle"> | ||
| 19 | - <h1>Welcome to Processing 3</h1> | ||
| 20 | - </td> | ||
| 21 | - </tr> | ||
| 22 | - </table> | ||
| 23 | - | ||
| 8 | + <!-- Using a table here as a layout hack, as CSS "vertical-align: middle;" | ||
| 9 | + is not supported by the Java HTML renderer. --> | ||
| 10 | + <table> | ||
| 11 | + <tr> | ||
| 12 | + <td valign="top"> | ||
| 13 | + <img src="../icons/pde-64.png" width="64" height="64"> | ||
| 14 | + </td> | ||
| 15 | + <td valign="middle"> | ||
| 16 | + <h1>Welcome to Processing 3</h1> | ||
| 17 | + </td> | ||
| 18 | + </tr> | ||
| 19 | + </table> | ||
| 20 | + | ||
| 21 | + <p> | ||
| 22 | + <a href="https://github.com/processing/processing/wiki/Changes-in-3.0">Read about what’s new in 3.0 →</a> | ||
| 23 | + </p> | ||
| 24 | + | ||
| 25 | + <p class="inset"> | ||
| 26 | + Note that some sketches from Processing 2 may not be compatible. | ||
| 27 | + <a href="https://github.com/processing/processing/wiki/Changes-in-3.0">What has changed?</a> | ||
| 28 | + </p> | ||
| 29 | + | ||
| 30 | + <div id="new_sketchbook"> | ||
| 24 | 31 | <p> | |
| 25 | - <a href="https://github.com/processing/processing/wiki/Changes-in-3.0">Read about what’s new in 3.0 →</a> | ||
| 32 | + Since older sketches may not be compatible, we recommend creating a new sketchbook folder, so Processing 2 and 3 can happily coexist. This is a one-time process. <a href="https://github.com/processing/processing/wiki/Multiple-Sketchbooks">Read more about it.</a> | ||
| 26 | 33 | </p> | |
| 27 | 34 | ||
| 28 | - <p class="inset"> | ||
| 29 | - Note that some sketches from Processing 2 may not be compatible. | ||
| 30 | - <a href="https://github.com/processing/processing/wiki/Changes-in-3.0">What has changed?</a> | ||
| 31 | - </p> | ||
| 32 | - | ||
| 33 | - <div id="new_sketchbook"> | ||
| 34 | - <p> | ||
| 35 | - Since older sketches may not be compatible, we recommend creating a new sketchbook folder, so Processing 2 and 3 can happily coexist. This is a one-time process. <a href="https://github.com/processing/processing/wiki/Multiple-Sketchbooks">Read more about it.</a> | ||
| 36 | - </p> | ||
| 37 | - | ||
| 38 | - <table class="inset"> | ||
| 39 | - <tr> | ||
| 40 | - <td> | ||
| 41 | - <input type="radio" name="sketchbook" value="create_new" checked /> | ||
| 42 | - </td> | ||
| 43 | - <td> | ||
| 44 | - Create a new sketchbook folder for use with Processing 3 sketches <em>(recommended!)</em> | ||
| 45 | - </td> | ||
| 46 | - </tr> | ||
| 47 | - <tr> | ||
| 48 | - <td> | ||
| 49 | - <input type="radio" name="sketchbook" value="use_existing" /> | ||
| 50 | - </td> | ||
| 51 | - <td> | ||
| 52 | - Use the existing sketchbook folder for both old and new sketches (may cause conflicts with installed libraries) | ||
| 53 | - </td> | ||
| 54 | - </tr> | ||
| 55 | - </table> | ||
| 56 | - | ||
| 57 | - </div> | ||
| 58 | - | ||
| 59 | - <table> | ||
| 35 | + <table class="inset"> | ||
| 60 | 36 | <tr> | |
| 61 | 37 | <td> | |
| 62 | - <input type="checkbox" name="show_each_time" checked /> | ||
| 63 | - </td> | ||
| 64 | - <td> | ||
| 65 | - Show this welcome<br/>message each time | ||
| 38 | + <a href="#sketchbook">Click here</a> to create a new sketchbook folder for Processing 3 <em>(recommended!)</em> | ||
| 66 | 39 | </td> | |
| 40 | + </tr> | ||
| 41 | + <tr> | ||
| 67 | 42 | <td> | |
| 68 | - <input id="startButton" type="submit" value="Get Started" /> | ||
| 43 | + Otherwise, your existing sketchbook folder will be used for both old and new sketches (may cause conflicts with installed libraries) | ||
| 69 | 44 | </td> | |
| 70 | 45 | </tr> | |
| 71 | 46 | </table> | |
| 72 | - | ||
| 73 | - </form> | ||
| 74 | - | ||
| 47 | + </div> | ||
| 48 | + | ||
| 75 | 49 | </body> | |
| 76 | 50 | </html> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments