35
35
import javax .swing .border .EmptyBorder ;
36
36
37
37
import processing .app .Base ;
38
- import processing .app .Language ;
39
38
import processing .app .Platform ;
40
39
import processing .app .Preferences ;
41
- import processing .awt .ShimAWT ;
42
40
43
41
44
42
public class Welcome {
@@ -74,6 +72,9 @@ public Welcome(Base base) throws IOException {
74
72
button .addActionListener (e -> view .handleClose ());
75
73
panel .add (button );
76
74
75
+ File indexFile = getIndexFile ();
76
+ if (indexFile == null ) return ; // giving up; error already printed
77
+
77
78
view = new WebFrame (getIndexFile (), 420 , panel ) {
78
79
/*
79
80
@Override
@@ -97,15 +98,40 @@ public void handleSubmit(StringDict dict) {
97
98
@ Override
98
99
public void handleLink (String link ) {
99
100
// The link will already have the full URL prefix
101
+ /*
100
102
if (link.endsWith("#sketchbook")) {
101
103
File folder = new File(Preferences.getSketchbookPath()).getParentFile();
102
104
ShimAWT.selectFolder(Language.text("preferences.sketchbook_location.popup"),
103
105
"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
+
104
123
} else {
105
124
super .handleLink (link );
106
125
}
107
126
}
108
127
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
+
109
135
@ Override
110
136
public void handleClose () {
111
137
Preferences .setBoolean ("welcome.four.seen" , true );
@@ -117,14 +143,14 @@ public void handleClose() {
117
143
}
118
144
119
145
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
+ // }
128
154
129
155
130
156
static private File getIndexFile () {
@@ -163,13 +189,11 @@ static public void main(String[] args) {
163
189
}
164
190
Preferences .init ();
165
191
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 ();
173
197
}
174
198
});
175
199
}
0 commit comments