-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.js
69 lines (57 loc) · 1.56 KB
/
application.js
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
var javaInit = require('./javainit');
var java = javaInit.getJavaInstance();
var fs = require("fs");
/**
* swing application
*/
class Application {
/**
* @param {string} name
* @param {string} applicationClass
* @param {string} Args
*/
constructor(name,applicationClass,Args=""){
this.name = name;
this.applicationClass = applicationClass;
this.Args = Args;
}
/**
* Add files from Directory to class path
* @param {string} dir
*/
addDirToClassPath(dir){
var dependencies = fs.readdirSync(dir);
dependencies.forEach(function(dependency){
java.classpath.push(dir + "/" + dependency);
})
}
/**
* add jar with full path on classpath
* @param {string} jar
*/
addJarToClassPath(jar){
java.classpath.push(jar);
}
/**
* add Java options for application
* @param {string} option
*/
addJavaOptions(option){
java.options.push(option);
}
/**
* Start Application
*/
start(){
this.BasicRobot = java.import("org.assertj.swing.core.BasicRobot");
this.Robot=this.BasicRobot.robotWithNewAwtHierarchySync();
this.instance = java.callStaticMethodSync("org.assertj.swing.launcher.ApplicationLauncher","application",this.applicationClass);
if(this.Args!="")
this.instance = this.instance.withArgsSync(this.Args);
this.instance.startSync();
}
getRobot(){
return this.Robot;
}
}
module.exports = Application;