-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathEditorApplication.java
More file actions
61 lines (51 loc) · 2.01 KB
/
EditorApplication.java
File metadata and controls
61 lines (51 loc) · 2.01 KB
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
package nodebox.client;
import org.python.core.Py;
import org.python.core.PyString;
import org.python.core.PySystemState;
import javax.swing.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
/**
* The NodeBox "classic" version.
* <p/>
* Eventually both Application and EditorApplication will be merge, whereby the classic version will become a
* set of panel settings.
*/
public class EditorApplication {
public static final String NAME = "NodeBox";
private static EditorApplication instance;
private List<EditorDocument> documents = new ArrayList<EditorDocument>();
private EditorDocument currentDocument;
public static EditorApplication getInstance() {
return instance;
}
private EditorApplication() {
System.setProperty("apple.laf.useScreenMenuBar", "true");
// Initialize Jython
Properties jythonProperties = new Properties();
File jythonCacheDir = new File(PlatformUtils.getUserDataDirectory(), "_jythoncache");
jythonProperties.put("python.cachedir", jythonCacheDir.getAbsolutePath());
PySystemState.initialize(System.getProperties(), jythonProperties, new String[]{""});
String workingDirectory = System.getProperty("user.dir");
File pythonLibraries = new File(workingDirectory, "lib" + PlatformUtils.SEP + "python.zip");
Py.getSystemState().path.add(new PyString(pythonLibraries.getAbsolutePath()));
Py.getSystemState().path.add(new PyString(PlatformUtils.getUserDataDirectory().getAbsolutePath()));
createNewDocument();
}
public EditorDocument createNewDocument() {
EditorDocument doc = new EditorDocument();
doc.setVisible(true);
documents.add(doc);
currentDocument = doc;
return doc;
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
instance = new EditorApplication();
}
});
}
}