FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/app/src/processing/app/ui/Welcome.java at master · hayscoding/processing · GitHub
hayscoding
processing
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
ui
/
Welcome.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
191 lines (158 loc) · 5.71 KB
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
ui
/
Welcome.java
Copy path
File metadata and controls
191 lines (158 loc) · 5.71 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2015-19 The Processing Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
processing
.
app
.
ui
;
import
java
.
awt
.
Color
;
import
java
.
awt
.
EventQueue
;
import
java
.
awt
.
Font
;
import
java
.
awt
.
event
.
ActionEvent
;
import
java
.
awt
.
event
.
ActionListener
;
import
java
.
awt
.
event
.
ItemEvent
;
import
java
.
awt
.
event
.
ItemListener
;
import
java
.
io
.
File
;
import
java
.
io
.
IOException
;
import
javax
.
swing
.
Box
;
import
javax
.
swing
.
JButton
;
import
javax
.
swing
.
JCheckBox
;
import
javax
.
swing
.
JComponent
;
import
processing
.
app
.
Base
;
import
processing
.
app
.
Language
;
import
processing
.
app
.
Platform
;
import
processing
.
app
.
Preferences
;
import
processing
.
core
.
PApplet
;
public
class
Welcome
{
Base
base
;
WebFrame
view
;
public
Welcome
(
Base
base
,
boolean
sketchbook
)
throws
IOException
{
this
.
base
=
base
;
// TODO this should live inside theme or somewhere modifiable
Font
dialogFont
=
Toolkit
.
getSansFont
(
14
,
Font
.
PLAIN
);
JComponent
panel
=
Box
.
createHorizontalBox
();
panel
.
setBackground
(
new
Color
(
245
,
245
,
245
));
Toolkit
.
setBorder
(
panel
,
15
,
20
,
15
,
20
);
//panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
//panel.add(Box.createHorizontalStrut(20));
JCheckBox
checkbox
=
new
JCheckBox
(
"Show this message on startup"
);
checkbox
.
setFont
(
dialogFont
);
// handles the Help menu invocation, and also the pref not existing
checkbox
.
setSelected
(
"true"
.
equals
(
Preferences
.
get
(
"welcome.show"
)));
checkbox
.
addItemListener
(
new
ItemListener
() {
@
Override
public
void
itemStateChanged
(
ItemEvent
e
) {
if
(
e
.
getStateChange
() ==
ItemEvent
.
SELECTED
) {
Preferences
.
setBoolean
(
"welcome.show"
,
true
);
}
else
if
(
e
.
getStateChange
() ==
ItemEvent
.
DESELECTED
) {
Preferences
.
setBoolean
(
"welcome.show"
,
false
);
}
}
});
panel
.
add
(
checkbox
);
panel
.
add
(
Box
.
createHorizontalGlue
());
JButton
button
=
new
JButton
(
"Get Started"
);
button
.
setFont
(
Toolkit
.
getSansFont
(
14
,
Font
.
PLAIN
));
button
.
addActionListener
(
new
ActionListener
() {
public
void
actionPerformed
(
ActionEvent
e
) {
view
.
handleClose
();
}
});
panel
.
add
(
button
);
//panel.add(Box.createHorizontalGlue());
view
=
new
WebFrame
(
getIndexFile
(
sketchbook
),
425
,
panel
) {
/*
@Override
public void handleSubmit(StringDict dict) {
String sketchbookAction = dict.get("sketchbook", null);
if ("create_new".equals(sketchbookAction)) {
File folder = new File(Preferences.getSketchbookPath()).getParentFile();
PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"),
"sketchbookCallback", folder,
this, this);
}
// // If un-checked, the key won't be in the dict, so null will be passed
// boolean keepShowing = "on".equals(dict.get("show_each_time", null));
// Preferences.setBoolean("welcome.show", keepShowing);
// Preferences.save();
handleClose();
}
*/
@
Override
public
void
handleLink
(
String
link
) {
// The link will already have the full URL prefix
if
(
link
.
endsWith
(
"#sketchbook"
)) {
File
folder
=
new
File
(
Preferences
.
getSketchbookPath
()).
getParentFile
();
PApplet
.
selectFolder
(
Language
.
text
(
"preferences.sketchbook_location.popup"
),
"sketchbookCallback"
,
folder
,
this
,
this
);
}
else
{
super
.
handleLink
(
link
);
}
}
@
Override
public
void
handleClose
() {
Preferences
.
setBoolean
(
"welcome.seen"
,
true
);
Preferences
.
save
();
super
.
handleClose
();
}
};
view
.
setVisible
(
true
);
}
/** Callback for the folder selector. */
public
void
sketchbookCallback
(
File
folder
) {
if
(
folder
!=
null
) {
if
(
base
!=
null
) {
base
.
setSketchbookFolder
(
folder
);
// } else {
// System.out.println("user selected " + folder);
}
}
}
// @Override
// public void handleClose() {
// dispose();
// }
static
private
File
getIndexFile
(
boolean
sketchbook
) {
String
filename
=
"welcome/"
+ (
sketchbook
?
"sketchbook.html"
:
"generic.html"
);
// version when running from command line for editing
File
htmlFile
=
new
File
(
"../build/shared/lib/"
+
filename
);
if
(
htmlFile
.
exists
()) {
return
htmlFile
;
}
// processing/build/macosx/work/Processing.app/Contents/Java
// version for Scott to use for OS X debugging
htmlFile
=
Platform
.
getContentFile
(
"../../../../../shared/lib/"
+
filename
);
if
(
htmlFile
.
exists
()) {
return
htmlFile
;
}
try
{
return
Base
.
getLibFile
(
filename
);
}
catch
(
Exception
e
) {
e
.
printStackTrace
();
return
null
;
}
}
static
public
void
main
(
String
[]
args
) {
Platform
.
init
();
EventQueue
.
invokeLater
(
new
Runnable
() {
public
void
run
() {
try
{
new
Welcome
(
null
,
true
);
}
catch
(
IOException
e
) {
e
.
printStackTrace
();
}
}
});
}
}
Back
|
FazBrowse Home
|
New Git URL