3535import javax .swing .border .EmptyBorder ;
3636
3737import processing .app .Base ;
38- import processing .app .Language ;
3938import processing .app .Platform ;
4039import processing .app .Preferences ;
41- import processing .awt .ShimAWT ;
4240
4341
4442public class Welcome {
@@ -74,6 +72,9 @@ public Welcome(Base base) throws IOException {
7472 button .addActionListener (e -> view .handleClose ());
7573 panel .add (button );
7674
75+ File indexFile = getIndexFile ();
76+ if (indexFile == null ) return ; // giving up; error already printed
77+
7778 view = new WebFrame (getIndexFile (), 420 , panel ) {
7879 /*
7980 @Override
@@ -97,15 +98,40 @@ public void handleSubmit(StringDict dict) {
9798 @ Override
9899 public void handleLink (String link ) {
99100 // The link will already have the full URL prefix
101+ /*
100102 if (link.endsWith("#sketchbook")) {
101103 File folder = new File(Preferences.getSketchbookPath()).getParentFile();
102104 ShimAWT.selectFolder(Language.text("preferences.sketchbook_location.popup"),
103105 "sketchbookCallback", folder, this);
106+ */
107+
108+ if (link .endsWith ("#examples" )) {
109+ base .getDefaultMode ().showExamplesFrame ();
110+
111+ } else if (link .endsWith ("#mouse" )) {
112+ openExample ("Basics/Input/Mouse2D/Mouse2D.pde" );
113+
114+ } else if (link .endsWith ("#arctan" )) {
115+ openExample ("Basics/Math/Arctangent/Arctangent.pde" );
116+
117+ } else if (link .endsWith ("#flocking" )) {
118+ openExample ("Topics/Simulate/Flocking/Flocking.pde" );
119+
120+ } else if (link .endsWith ("#rotating" )) {
121+ openExample ("Demos/Graphics/RotatingArcs/RotatingArcs.pde" );
122+
104123 } else {
105124 super .handleLink (link );
106125 }
107126 }
108127
128+ private void openExample (String examplePath ) {
129+ File examplesFolder =
130+ Platform .getContentFile ("modes/java/examples" );
131+ File pdeFile = new File (examplesFolder , examplePath );
132+ base .handleOpen (pdeFile .getAbsolutePath ());
133+ }
134+
109135 @ Override
110136 public void handleClose () {
111137 Preferences .setBoolean ("welcome.four.seen" , true );
@@ -117,14 +143,14 @@ public void handleClose() {
117143 }
118144
119145
120- /** Callback for the folder selector. */
121- public void sketchbookCallback (File folder ) {
122- if (folder != null ) {
123- if (base != null ) {
124- base .setSketchbookFolder (folder );
125- }
126- }
127- }
146+ // /** Callback for the folder selector. */
147+ // public void sketchbookCallback(File folder) {
148+ // if (folder != null) {
149+ // if (base != null) {
150+ // base.setSketchbookFolder(folder);
151+ // }
152+ // }
153+ // }
128154
129155
130156 static private File getIndexFile () {
@@ -163,13 +189,11 @@ static public void main(String[] args) {
163189 }
164190 Preferences .init ();
165191
166- EventQueue .invokeLater (new Runnable () {
167- public void run () {
168- try {
169- new Welcome (null );
170- } catch (IOException e ) {
171- e .printStackTrace ();
172- }
192+ EventQueue .invokeLater (() -> {
193+ try {
194+ new Welcome (null );
195+ } catch (IOException e ) {
196+ e .printStackTrace ();
173197 }
174198 });
175199 }
0 commit comments