mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
activate the welcome screens
This commit is contained in:
@@ -48,6 +48,7 @@ import processing.app.ui.EditorConsole;
|
||||
import processing.app.ui.EditorState;
|
||||
import processing.app.ui.PreferencesFrame;
|
||||
import processing.app.ui.Recent;
|
||||
import processing.app.ui.Welcome;
|
||||
import processing.core.*;
|
||||
import processing.data.StringDict;
|
||||
import processing.data.StringList;
|
||||
@@ -193,23 +194,39 @@ public class Base {
|
||||
// run static initialization that grabs all the prefs
|
||||
Preferences.init();
|
||||
|
||||
// Get the sketchbook path, and make sure it's set properly
|
||||
locateSketchbookFolder();
|
||||
|
||||
// String filename = args.length > 1 ? args[0] : null;
|
||||
if (!SingleInstance.alreadyRunning(args)) {
|
||||
// SingleInstance.startServer(platform);
|
||||
|
||||
// Set the look and feel before opening the window
|
||||
try {
|
||||
platform.setLookAndFeel();
|
||||
} catch (Exception e) {
|
||||
// String mess = e.getMessage();
|
||||
// if (!mess.contains("ch.randelshofer.quaqua.QuaquaLookAndFeel")) {
|
||||
loge("Could not set the Look & Feel", e); //$NON-NLS-1$
|
||||
// }
|
||||
}
|
||||
|
||||
boolean sketchbookPrompt = false;
|
||||
if (Preferences.getBoolean("welcome.show")) {
|
||||
if (!Preferences.getBoolean("welcome.seen")) {
|
||||
// Check if there's a 2.0 sketchbook present
|
||||
String oldPath = Preferences.getOldSketchbookPath();
|
||||
if (oldPath != null) {
|
||||
String newPath = Preferences.getSketchbookPath();
|
||||
// If newPath is null, this is the first run of any 3.x version
|
||||
if (newPath == null) {
|
||||
sketchbookPrompt = true;
|
||||
|
||||
} else if (oldPath.equals(newPath)) {
|
||||
// If both exist and are identical, then the user has been using
|
||||
// alpha releases of 3.x and needs to be warned about the larger
|
||||
// changes in this release.
|
||||
sketchbookPrompt = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the sketchbook path, and make sure it's set properly
|
||||
locateSketchbookFolder();
|
||||
|
||||
|
||||
// Create a location for untitled sketches
|
||||
try {
|
||||
untitledFolder = Base.createTempFolder("untitled", "sketches", null);
|
||||
@@ -222,10 +239,21 @@ public class Base {
|
||||
|
||||
log("about to create base..."); //$NON-NLS-1$
|
||||
try {
|
||||
Base base = new Base(args);
|
||||
final Base base = new Base(args);
|
||||
// Prevent more than one copy of the PDE from running.
|
||||
SingleInstance.startServer(base);
|
||||
|
||||
// Needs to be shown after the first editor window opens, so that it
|
||||
// shows up on top, and doesn't prevent an editor window from opening.
|
||||
if (Preferences.getBoolean("welcome.show")) {
|
||||
final boolean prompt = sketchbookPrompt;
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new Welcome(base, prompt);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
// Catch-all to pick up badness during startup.
|
||||
if (t.getCause() != null) {
|
||||
|
||||
@@ -52,11 +52,13 @@ public class Preferences {
|
||||
static final String DEFAULTS_FILE = "defaults.txt"; //$NON-NLS-1$
|
||||
static final String PREFS_FILE = "preferences.txt"; //$NON-NLS-1$
|
||||
|
||||
static HashMap<String, String> defaults;
|
||||
static HashMap<String, String> table = new HashMap<String, String>();
|
||||
static Map<String, String> defaults;
|
||||
static Map<String, String> table = new HashMap<String, String>();
|
||||
static File preferencesFile;
|
||||
|
||||
|
||||
// /** @return true if the sketchbook file did not exist */
|
||||
// static public boolean init() {
|
||||
static public void init() {
|
||||
// start by loading the defaults, in case something
|
||||
// important was deleted from the user prefs
|
||||
@@ -101,7 +103,8 @@ public class Preferences {
|
||||
|
||||
// next load user preferences file
|
||||
preferencesFile = Base.getSettingsFile(PREFS_FILE);
|
||||
if (preferencesFile.exists()) {
|
||||
boolean firstRun = !preferencesFile.exists();
|
||||
if (!firstRun) {
|
||||
try {
|
||||
load(new FileInputStream(preferencesFile));
|
||||
|
||||
@@ -114,7 +117,8 @@ public class Preferences {
|
||||
}
|
||||
}
|
||||
|
||||
if (checkSketchbookPref() || !preferencesFile.exists()) {
|
||||
if (checkSketchbookPref() || firstRun) {
|
||||
// if (firstRun) {
|
||||
// create a new preferences file if none exists
|
||||
// saves the defaults out to the file
|
||||
save();
|
||||
@@ -135,30 +139,6 @@ public class Preferences {
|
||||
handleProxy("http", "http.proxyHost", "http.proxyPort");
|
||||
handleProxy("https", "https.proxyHost", "https.proxyPort");
|
||||
handleProxy("socks", "socksProxyHost", "socksProxyPort");
|
||||
|
||||
/*
|
||||
String httpProxyHost = get("proxy.http.host");
|
||||
String httpProxyPort = get("proxy.http.port");
|
||||
if (httpProxyHost != null && httpProxyHost.length() != 0 &&
|
||||
httpProxyPort != null && httpProxyPort.length() != 0) {
|
||||
System.setProperty("http.proxyHost", httpProxyHost);
|
||||
System.setProperty("http.proxyPort", httpProxyPort);
|
||||
}
|
||||
String httpsProxyHost = get("proxy.https.host");
|
||||
String httpsProxyPort = get("proxy.https.port");
|
||||
if (httpsProxyHost != null && httpsProxyHost.length() != 0 &&
|
||||
httpsProxyPort != null && httpsProxyPort.length() != 0) {
|
||||
System.setProperty("https.proxyHost", httpsProxyHost);
|
||||
System.setProperty("https.proxyPort", httpsProxyPort);
|
||||
}
|
||||
String socksProxyHost = get("proxy.socks.host");
|
||||
String socksProxyPort = get("proxy.socks.port");
|
||||
if (socksProxyHost != null && socksProxyHost.length() != 0 &&
|
||||
socksProxyPort != null && socksProxyPort.length() != 0) {
|
||||
System.setProperty("socksProxyHost", socksProxyHost);
|
||||
System.setProperty("socksProxyPort", socksProxyPort);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -434,6 +414,11 @@ public class Preferences {
|
||||
}
|
||||
|
||||
|
||||
static public String getOldSketchbookPath() {
|
||||
return get("sketchbook.path");
|
||||
}
|
||||
|
||||
|
||||
static public String getSketchbookPath() {
|
||||
return get("sketchbook.path.three"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@@ -25,50 +25,94 @@ import java.awt.EventQueue;
|
||||
import java.io.File;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Language;
|
||||
import processing.app.Preferences;
|
||||
import processing.core.PApplet;
|
||||
import processing.data.StringDict;
|
||||
|
||||
|
||||
public class Welcome {
|
||||
public class Welcome extends WebFrame {
|
||||
Base base;
|
||||
|
||||
public Welcome() {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
// eventually this will be correct
|
||||
//File indexFile = Base.getLibFile("welcome/index.html");
|
||||
// version when running from command line for editing
|
||||
File indexFile = new File("../build/shared/lib/welcome/index.html");
|
||||
if (!indexFile.exists()) {
|
||||
// System.out.println("user dir is " + System.getProperty("user.dir"));
|
||||
// System.out.println(new File("").getAbsolutePath());
|
||||
// processing/build/macosx/work/Processing.app/Contents/Java
|
||||
// version for Scott to use for OS X debugging
|
||||
indexFile = Base.getContentFile("../../../../../shared/lib/welcome/index.html");
|
||||
// try {
|
||||
// System.out.println(indexFile.getCanonicalPath());
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
WebFrame frame = new WebFrame(indexFile, 400) {
|
||||
public void handleSubmit(StringDict dict) {
|
||||
dict.print();
|
||||
handleClose();
|
||||
}
|
||||
public Welcome(Base base, boolean sketchbook) {
|
||||
super(getIndexFile(sketchbook), 400);
|
||||
this.base = base;
|
||||
//addStyle("#new_sketchbook { background-color: rgb(0, 255, 0); }");
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public void handleClose() {
|
||||
//System.exit(0);
|
||||
dispose();
|
||||
}
|
||||
};
|
||||
frame.setVisible(true);
|
||||
|
||||
public void handleSubmit(StringDict dict) {
|
||||
// sketchbook = "create_new" or "use_existing"
|
||||
// show_each_time = "on" or <not param>
|
||||
//dict.print();
|
||||
|
||||
String sketchbookAction = dict.get("sketchbook", null);
|
||||
if ("create_new".equals(sketchbookAction)) {
|
||||
// open file dialog
|
||||
// on affirmative selection, update sketchbook folder
|
||||
// String path = Preferences.getSketchbookPath() + "3";
|
||||
// File folder = new File(path);
|
||||
// folder.mkdirs();
|
||||
File folder = new File(Preferences.getSketchbookPath()).getParentFile();
|
||||
PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"),
|
||||
"sketchbookCallback", folder,
|
||||
this, this);
|
||||
}
|
||||
|
||||
boolean keepShowing = "on".equals(dict.get("show_each_time", null));
|
||||
Preferences.setBoolean("welcome.show", keepShowing);
|
||||
Preferences.save();
|
||||
|
||||
handleClose();
|
||||
}
|
||||
|
||||
|
||||
/** 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void handleClose() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
|
||||
static private File getIndexFile(boolean sketchbook) {
|
||||
String filename =
|
||||
"welcome/" + (sketchbook ? "sketchbook.html" : "generic.html");
|
||||
// eventually this will be correct
|
||||
//File indexFile = Base.getLibFile(filename);
|
||||
// version when running from command line for editing
|
||||
File htmlFile = new File("../build/shared/lib/" + filename);
|
||||
if (!htmlFile.exists()) {
|
||||
// processing/build/macosx/work/Processing.app/Contents/Java
|
||||
// version for Scott to use for OS X debugging
|
||||
htmlFile = Base.getContentFile("../../../../../shared/lib/" + filename);
|
||||
}
|
||||
return htmlFile;
|
||||
}
|
||||
|
||||
|
||||
static public void main(String[] args) {
|
||||
Base.initPlatform();
|
||||
new Welcome();
|
||||
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new Welcome(null, true) {
|
||||
public void handleClose() {
|
||||
System.exit(0);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,13 +46,16 @@
|
||||
# Note that this path must exist already otherwise it won't see
|
||||
# the sketchbook folder, and will instead assume the sketchbook
|
||||
# has gone missing, and that it should instead use the default.
|
||||
#sketchbook.path=
|
||||
# In 3.0, the location has changed.
|
||||
#sketchbook.path.three=
|
||||
|
||||
welcome.show = true
|
||||
welcome.seen = false
|
||||
|
||||
# By default, no sketches currently open
|
||||
last.sketch.count=0
|
||||
|
||||
last.sketch.count = 0
|
||||
# true if you want sketches to re-open when you next run processing
|
||||
last.sketch.restore=true
|
||||
last.sketch.restore = true
|
||||
|
||||
# by default, contributions are moved to backup folders when
|
||||
# they are removed or replaced. The locations of the backup
|
||||
|
||||
@@ -6337,6 +6337,7 @@ public class PApplet implements PConstants {
|
||||
if (platform == MACOSX && useNativeSelect != false) {
|
||||
FileDialog fileDialog =
|
||||
new FileDialog(parentFrame, prompt, FileDialog.LOAD);
|
||||
fileDialog.setDirectory(defaultSelection.getAbsolutePath());
|
||||
System.setProperty("apple.awt.fileDialogForDirectories", "true");
|
||||
fileDialog.setVisible(true);
|
||||
System.setProperty("apple.awt.fileDialogForDirectories", "false");
|
||||
|
||||
@@ -353,7 +353,7 @@ public class JavaEditor extends Editor {
|
||||
item = new JMenuItem("Welcome to Processing 3");
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new Welcome();
|
||||
new Welcome(base, Preferences.getSketchbookPath().equals(Preferences.getOldSketchbookPath()));
|
||||
}
|
||||
});
|
||||
menu.add(item);
|
||||
|
||||
@@ -77,6 +77,8 @@ X allow modes to import other modes
|
||||
X https://github.com/processing/processing/pull/3444
|
||||
X CM list converted into table
|
||||
X https://github.com/processing/processing/pull/3454
|
||||
X more CM updates to fix #3465
|
||||
X https://github.com/processing/processing/pull/3465
|
||||
|
||||
cleaning
|
||||
o libraries in java tabs (separate .java files) are reported missing
|
||||
|
||||
Reference in New Issue
Block a user