MCPcopy Index your code
hub / github.com/benfry/processing4 / init

Method init

app/src/processing/app/Preferences.java:63–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61// /** @return true if the sketchbook file did not exist */
62// static public boolean init() {
63 static public void init() {
64 initialized = true;
65 // start by loading the defaults, in case something
66 // important was deleted from the user prefs
67 try {
68 // Name changed for 2.1b2 to avoid problems with users modifying or
69 // replacing the file after doing a search for "preferences.txt".
70 load(Base.getLibStream(DEFAULTS_FILE));
71 } catch (Exception e) {
72 Messages.showError(null, "Could not read default settings.\n" +
73 "You'll need to reinstall Processing.", e);
74 }
75
76 // Clone the defaults, then override any them with the user's preferences.
77 // This ensures that any new/added preference will be present.
78 defaults = new HashMap<>(table);
79
80 // other things that have to be set explicitly for the defaults
81 setColor("run.window.bgcolor", SystemColor.control); //$NON-NLS-1$
82
83 // For CJK users, enable IM support by default
84 if (Language.useInputMethod()) {
85 setBoolean("editor.input_method_support", true);
86 }
87
88 // next load user preferences file
89 preferencesFile = Base.getSettingsFile(PREFS_FILE);
90 boolean firstRun = !preferencesFile.exists();
91 if (!firstRun) {
92 try {
93 load(new FileInputStream(preferencesFile));
94
95 } catch (Exception ex) {
96 Messages.showError("Error reading preferences",
97 "Error reading the preferences file. " +
98 "Please delete (or move)\n" +
99 preferencesFile.getAbsolutePath() +
100 " and restart Processing.", ex);
101 }
102 }
103
104 if (checkSketchbookPref() || firstRun) {
105// if (firstRun) {
106 // create a new preferences file if none exists
107 // saves the defaults out to the file
108 save();
109 }
110
111 PApplet.useNativeSelect =
112 Preferences.getBoolean("chooser.files.native"); //$NON-NLS-1$
113
114 // Adding option to disable this in case it's getting in the way
115 if (get("proxy.system").equals("true")) {
116 // Use the system proxy settings by default
117 // https://github.com/processing/processing/issues/2643
118 System.setProperty("java.net.useSystemProxies", "true");
119 }
120

Callers 4

createAndShowGUIMethod · 0.95
mainMethod · 0.95
CommanderMethod · 0.95
initMethod · 0.95

Calls 14

loadMethod · 0.95
getLibStreamMethod · 0.95
showErrorMethod · 0.95
setColorMethod · 0.95
useInputMethodMethod · 0.95
setBooleanMethod · 0.95
getSettingsFileMethod · 0.95
checkSketchbookPrefMethod · 0.95
saveMethod · 0.95
getBooleanMethod · 0.95
getMethod · 0.95
handleProxyMethod · 0.95

Tested by

no test coverage detected