Skip to content

Commit 2512a27

Browse files
committed
ADAP-155: added LaunchManifestDemo
1 parent b3e3dab commit 2512a27

File tree

4 files changed

+152
-0
lines changed

4 files changed

+152
-0
lines changed

release/manifest.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
java -cp openfin-desktop-java-example-7.1.1.jar;openfin-desktop-java-adapter-7.1.2.jar;TableLayout-20050920.jar;jna-4.5.1.jar;jna-platform-4.5.1.jar;json-20140107.jar;slf4j-api-1.7.5.jar;slf4j-jdk14-1.6.1.jar;websocket-api-9.3.12.v20160915.jar;websocket-client-9.3.12.v20160915.jar;websocket-common-9.3.12.v20160915.jar;jetty-io-9.3.12.v20160915.jar;jetty-util-9.3.12.v20160915.jar -Djava.util.logging.config.file=logging.properties com.openfin.desktop.demo.LaunchManifestDemo
1.33 MB
Binary file not shown.
-42.6 KB
Binary file not shown.
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
package com.openfin.desktop.demo;
2+
3+
import com.openfin.desktop.*;
4+
import javafx.application.Application;
5+
import javafx.collections.ObservableList;
6+
import javafx.event.ActionEvent;
7+
import javafx.event.EventHandler;
8+
import javafx.scene.Group;
9+
import javafx.scene.Scene;
10+
import javafx.scene.control.Button;
11+
import javafx.scene.layout.AnchorPane;
12+
import javafx.stage.Stage;
13+
import org.slf4j.Logger;
14+
import org.slf4j.LoggerFactory;
15+
16+
17+
public class LaunchManifestDemo extends Application {
18+
19+
private final static Logger logger = LoggerFactory.getLogger(LaunchManifestDemo.class.getName());
20+
private final static String WINDOW_TITLE = "Launch Manifest Demo";
21+
22+
private DesktopConnection desktopConnectionGM; // connection to Watchlist by Giant Machines
23+
private DesktopConnection desktopConnectionSL; // connection to StockFlux by Scott Logic
24+
private Button btnGiantMachine, btnScottLogic;
25+
26+
private String startupUuid = LaunchManifestDemo.class.getName();
27+
private com.openfin.desktop.Application startupHtml5app;
28+
29+
@Override
30+
public void start(Stage stage) {
31+
btnGiantMachine = new Button();
32+
btnGiantMachine.setText("Launch Watchlist by Giant Machines");
33+
btnGiantMachine.setLayoutX(10);
34+
btnGiantMachine.setLayoutY(10);
35+
btnGiantMachine.setOnAction(new EventHandler<ActionEvent>() {
36+
@Override
37+
public void handle(ActionEvent event) {
38+
launchGiantMachine();
39+
}
40+
});
41+
42+
btnScottLogic = new Button();
43+
btnScottLogic.setText("Launch StockFlux by Scott Logic");
44+
btnScottLogic.setLayoutX(10);
45+
btnScottLogic.setLayoutY(50);
46+
btnScottLogic.setOnAction(new EventHandler<ActionEvent>() {
47+
@Override
48+
public void handle(ActionEvent event) {
49+
launchScottLogic();
50+
}
51+
});
52+
53+
AnchorPane anchorPane = new AnchorPane();
54+
anchorPane.getChildren().add(btnGiantMachine);
55+
anchorPane.getChildren().add(btnScottLogic);
56+
57+
//Creating a Group object
58+
Group root = new Group();
59+
60+
//Retrieving the observable list object
61+
ObservableList list = root.getChildren();
62+
63+
//Creating a scene object
64+
Scene scene = new Scene(anchorPane, 800, 800);
65+
66+
//Setting title to the Stage
67+
stage.setTitle(WINDOW_TITLE);
68+
69+
//Adding scene to the stage
70+
stage.setScene(scene);
71+
72+
//Displaying the contents of the stage
73+
stage.show();
74+
75+
}
76+
77+
private void launchGiantMachine() {
78+
if (desktopConnectionGM == null) {
79+
RuntimeConfiguration cfg = new RuntimeConfiguration();
80+
cfg.setManifestLocation("https://openfin.giantmachines.com/public/app.json");
81+
try {
82+
desktopConnectionGM = new DesktopConnection(startupUuid);
83+
desktopConnectionGM.connect(cfg, new DesktopStateListener() {
84+
@Override
85+
public void onReady() {
86+
logger.info("Connected to OpenFin Runtime hosting Watchlist by Giant Machines");
87+
}
88+
89+
@Override
90+
public void onClose(String error) {
91+
}
92+
93+
@Override
94+
public void onError(String reason) {
95+
}
96+
97+
@Override
98+
public void onMessage(String message) {
99+
}
100+
101+
@Override
102+
public void onOutgoingMessage(String message) {
103+
}
104+
}, 60);
105+
} catch (Exception e) {
106+
e.printStackTrace();
107+
}
108+
}
109+
}
110+
111+
private void launchScottLogic() {
112+
if (desktopConnectionSL == null) {
113+
RuntimeConfiguration cfg = new RuntimeConfiguration();
114+
cfg.setManifestLocation("http://scottlogic.github.io/StockFlux/master/app.json");
115+
try {
116+
desktopConnectionSL = new DesktopConnection(startupUuid);
117+
desktopConnectionSL.connect(cfg, new DesktopStateListener() {
118+
@Override
119+
public void onReady() {
120+
logger.info("Connected to OpenFin Runtime hosting StockFlux by Scott Logic");
121+
}
122+
123+
@Override
124+
public void onClose(String error) {
125+
}
126+
127+
@Override
128+
public void onError(String reason) {
129+
}
130+
131+
@Override
132+
public void onMessage(String message) {
133+
}
134+
135+
@Override
136+
public void onOutgoingMessage(String message) {
137+
}
138+
}, 60);
139+
} catch (Exception e) {
140+
e.printStackTrace();
141+
}
142+
}
143+
}
144+
145+
public static void main(String args[]) {
146+
launch(args);
147+
}
148+
149+
150+
151+
}

0 commit comments

Comments
 (0)