Skip to content

Commit 118db68

Browse files
committed
RUN-63: updated README
1 parent 7ccbf0c commit 118db68

1 file changed

Lines changed: 139 additions & 159 deletions

File tree

README.md

Lines changed: 139 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,139 @@
1-
# java-example
2-
Examples for OpenFin Java adapter
3-
4-
## Run the example of connecting to OpenFin and creating applications
5-
6-
1. Clone this repository
7-
8-
2. Go to release directory and start run.bat
9-
10-
3. Once the java app starts, click on Start button, which should start OpenFin Runtime and "Hello OpenFin" HTML5 demo app. The java app will wait and try to connect to OpenFin Runtime.
11-
12-
4. You can use buttons in Window Control section to move and re-size HTML5 window of Hello OpenFin app.
13-
14-
5. Click "Create Application" button, which should start a dialog with all the fields pre-populated for our Hello OpenFin demo HTML5 application. Just click on "Create" button.
15-
16-
6. After Hello OpenFin starts, you can use the buttons under Window Control of Java app to control Hello OpenFin window.
17-
18-
## Source Code Review
19-
20-
Source code for the example is located in /src/main/java/com/openfin/desktop/demo/OpenFinDesktopDemo.java. The followings overview of how it communicates with OpenFin Runtime with API calls supported by the Java adapter:
21-
22-
1. Create connection object:
23-
24-
this.desktopConnection = new DesktopConnection("OpenFinDesktopDemo");
25-
26-
This code just creates an instance and it does not try to connect to runtime.
27-
28-
2. Launch and connect to stable version of OpenFin runtime:
29-
30-
desktopConnection.connectToVersion("stable", listener, 60);
31-
32-
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime. desktopCommandLine is a string of arguments passed to OpenFinRVM.
33-
This example by default passes remote config file for Hello OpenFin app, which will be started as the first app in OpenFin Runtime.
34-
35-
3. Create new application when clicking on Create App:
36-
37-
Application app = new Application(options, desktopConnection, new AckListener() {
38-
@Override
39-
public void onSuccess(Ack ack) {
40-
Application application = (Application) ack.getSource();
41-
application.run(); // run the app
42-
}
43-
@Override
44-
public void onError(Ack ack) {
45-
}
46-
});
47-
48-
options is an instance of ApplicationOptions, which is populated from App Create dialog. AckListener interface provides callback for the operation.
49-
50-
Once the application is created successfully, you can take actions on its window:
51-
52-
4. Change opacity:
53-
54-
WindowOptions options = new WindowOptions();
55-
options.setOpacity(newOpacityValue);
56-
application.getWindow().updateOptions(options, null);
57-
58-
5. Change Window size
59-
60-
application.getWindow().resizeBy(10, 10, "top-left");
61-
62-
63-
6. Publishes messages to a topic with InterApplicationBus
64-
65-
org.json.JSONObject message = createSomeJsonMessage();
66-
desktopConnection.getInterApplicationBus().publish("someTopic", message);
67-
68-
7. Subscribes to a topic with InterApplicationBus
69-
70-
desktopConnection.getInterApplicationBus().subscribe("*", "someTopic", new BusListener() {
71-
public void onMessageReceived(String sourceUuid, String topic, Object payload) {
72-
JSONObject message = (JSONObject) payload;
73-
}
74-
});
75-
76-
## Run the example of docking Java Swing window with HTML5 application
77-
78-
1. Clone this repository
79-
80-
2. Go to release directory and start docking.bat
81-
82-
3. Once the java app starts, click on "Launch OpenFin" button, which should start OpenFin Runtime and "Hello OpenFin" HTML5 demo app. The java app will wait and try to connect to OpenFin Runtime.
83-
84-
4. After clicking "Dock to HTML5 app" button, you can move either window to see docking effect.
85-
86-
5. Click "Undock from HTML5 app" to undock 2 windows
87-
88-
## Source Code Review for docking windows
89-
90-
Source code for the example is located in /src/main/java/com/openfin/desktop/demo/OpenFinDockingDemo.java. This example uses Snap&Dock library from https://github.com/openfin/java-snap-and-dock
91-
92-
1. Create connection object:
93-
94-
this.desktopConnection = new DesktopConnection("OpenFinDockingDemo", "localhost", port);
95-
96-
This code just creates an instance and it does not try to connect to runtime.
97-
98-
2. Launch and connect to stable version of OpenFin runtime:
99-
100-
desktopConnection.connectToVersion("stable", listener, 60);
101-
102-
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime.
103-
104-
3. Once Runtime is running, an instance of DockingManager is create with
105-
106-
this.dockingManager = new DockingManager(this.desktopConnection, javaParentAppUuid);
107-
108-
4. Any OpenFin window can be registered with DockingManager with
109-
110-
dockingManager.registerWindow(openFinWindow);
111-
112-
5. Any Java window can be registered with DockingManager with
113-
114-
dockingManager.registerJavaWindow(javaWindowName, jFrame, AckListener);
115-
116-
6. An application can receive dock and undock events from DockingManger with
117-
118-
desktopConnection.getInterApplicationBus().subscribe("*", "window-docked", EventListener);
119-
desktopConnection.getInterApplicationBus().subscribe("*", "window-undocked", EventListener);
120-
121-
7. An application can request DockingManager to undock a window with:
122-
123-
JSONObject msg = new JSONObject();
124-
msg.put("applicationUuid", javaParentAppUuid);
125-
msg.put("windowName", javaWindowName);
126-
desktopConnection.getInterApplicationBus().publish("undock-window", msg);
127-
128-
129-
Once the demo is running, Windows snap while being draggted close to other windows. Snapped windows dock on mounse release.
130-
131-
132-
## Source Code Review for JNLP Example
133-
134-
Source code for the example is located in /src/main/java/com/openfin/desktop/demo/JNLPExample.java. The followings overview of how it communicates with OpenFin Runtime with API calls supported by the Java adapter:
135-
136-
1. Create connection object:
137-
138-
this.desktopConnection = new DesktopConnection("WebStartExample");
139-
140-
This code just creates an instance and it does not try to connect to runtime.
141-
142-
2. Launch and connect to OpenFin runtime:
143-
144-
desktopConnection.connectToVersion("stable", listener, 100000);
145-
146-
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime. connectToVersion connects to "stable" version of Runtime. If "stable" version is not running, this method will try to start it.
147-
148-
3. Once the Runtime is running, launchHTML5App method is called to start Hello OpenFin demo app.
149-
150-
4. To run the demo, please import webstart/OpenFinSigner.csr into Java Webstart as Signer CA first, and then load
151-
[Demo JNLP](http://openfin.github.io/java-example/webstart/JNLPExample.jnlp) to start the demo.
152-
153-
## More Info
154-
155-
More information and API documentation can be found at https://openfin.co/java-api/
156-
157-
## Getting help
158-
159-
Please contact [email protected]
1+
# java-example
2+
Examples for OpenFin Java adapter
3+
4+
## Run the example of connecting to OpenFin and creating applications
5+
6+
1. Clone this repository
7+
8+
2. Go to release directory and start run.bat
9+
10+
3. Once the java app starts, click on Start button, which should start OpenFin Runtime. The java app will wait and try to connect to OpenFin Runtime.
11+
12+
4. Once OpenFin Runtime is started and Java app connects successfully, "Create Application" button is enabled. You can click on the button to bring up a dialog for entering configuration of any HTML5 app. By default, the dialog is pre-populate with configuration for Hello OpenFin demo app.
13+
14+
5. You can use buttons in Window Control section to move and re-size HTML5 window of Hello OpenFin app.
15+
16+
6. Click "Create Application" button, which should start a dialog with all the fields pre-populated for our Hello OpenFin demo HTML5 application. Just click on "Create" button.
17+
18+
7. After Hello OpenFin starts, you can use the buttons under Window Control of Java app to control Hello OpenFin window.
19+
20+
## Source Code Review
21+
22+
Source code for the example is located in /src/main/java/com/openfin/desktop/demo/OpenFinDesktopDemo.java. The followings overview of how it communicates with OpenFin Runtime with API calls supported by the Java adapter:
23+
24+
1. Create connection object:
25+
26+
this.desktopConnection = new DesktopConnection("OpenFinDesktopDemo");
27+
28+
This code just creates an instance and it does not try to connect to runtime.
29+
30+
2. Launch and connect to stable version of OpenFin runtime:
31+
32+
desktopConnection.connectToVersion("stable", listener, 60);
33+
34+
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime. desktopCommandLine is a string of arguments passed to OpenFinRVM.
35+
This example by default passes remote config file for Hello OpenFin app, which will be started as the first app in OpenFin Runtime.
36+
37+
3. Create new application when clicking on Create App:
38+
39+
Application app = new Application(options, desktopConnection, new AckListener() {
40+
@Override
41+
public void onSuccess(Ack ack) {
42+
Application application = (Application) ack.getSource();
43+
application.run(); // run the app
44+
}
45+
@Override
46+
public void onError(Ack ack) {
47+
}
48+
});
49+
50+
options is an instance of ApplicationOptions, which is populated from App Create dialog. AckListener interface provides callback for the operation.
51+
52+
Once the application is created successfully, you can take actions on its window:
53+
54+
4. Change opacity:
55+
56+
WindowOptions options = new WindowOptions();
57+
options.setOpacity(newOpacityValue);
58+
application.getWindow().updateOptions(options, null);
59+
60+
5. Change Window size
61+
62+
application.getWindow().resizeBy(10, 10, "top-left");
63+
64+
65+
6. Publishes messages to a topic with InterApplicationBus
66+
67+
org.json.JSONObject message = createSomeJsonMessage();
68+
desktopConnection.getInterApplicationBus().publish("someTopic", message);
69+
70+
7. Subscribes to a topic with InterApplicationBus
71+
72+
desktopConnection.getInterApplicationBus().subscribe("*", "someTopic", new BusListener() {
73+
public void onMessageReceived(String sourceUuid, String topic, Object payload) {
74+
JSONObject message = (JSONObject) payload;
75+
}
76+
});
77+
78+
## Run the example of docking Java Swing window with HTML5 application
79+
80+
1. Clone this repository
81+
82+
2. Go to release directory and start docking.bat
83+
84+
3. Once the java app starts, click on "Launch OpenFin" button, which should start OpenFin Runtime and "Hello OpenFin" HTML5 demo app. The java app will wait and try to connect to OpenFin Runtime.
85+
86+
4. After clicking "Dock to HTML5 app" button, you can move either window to see docking effect.
87+
88+
5. Click "Undock from HTML5 app" to undock 2 windows
89+
90+
## Source Code Review for docking windows
91+
92+
Source code for the example is located in /src/main/java/com/openfin/desktop/demo/OpenFinDockingDemo.java. This example uses Snap&Dock library from https://github.com/openfin/java-snap-and-dock
93+
94+
1. Create connection object:
95+
96+
this.desktopConnection = new DesktopConnection("OpenFinDockingDemo", "localhost", port);
97+
98+
This code just creates an instance and it does not try to connect to runtime.
99+
100+
2. Launch and connect to stable version of OpenFin runtime:
101+
102+
desktopConnection.connectToVersion("stable", listener, 60);
103+
104+
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime.
105+
106+
3. Once Runtime is running, an instance of DockingManager is create with
107+
108+
this.dockingManager = new DockingManager(this.desktopConnection, javaParentAppUuid);
109+
110+
4. Any OpenFin window can be registered with DockingManager with
111+
112+
dockingManager.registerWindow(openFinWindow);
113+
114+
5. Any Java window can be registered with DockingManager with
115+
116+
dockingManager.registerJavaWindow(javaWindowName, jFrame, AckListener);
117+
118+
6. An application can receive dock and undock events from DockingManger with
119+
120+
desktopConnection.getInterApplicationBus().subscribe("*", "window-docked", EventListener);
121+
desktopConnection.getInterApplicationBus().subscribe("*", "window-undocked", EventListener);
122+
123+
7. An application can request DockingManager to undock a window with:
124+
125+
JSONObject msg = new JSONObject();
126+
msg.put("applicationUuid", javaParentAppUuid);
127+
msg.put("windowName", javaWindowName);
128+
desktopConnection.getInterApplicationBus().publish("undock-window", msg);
129+
130+
131+
Once the demo is running, Windows snap while being draggted close to other windows. Snapped windows dock on mounse release.
132+
133+
## More Info
134+
135+
More information and API documentation can be found at https://openfin.co/java-api/
136+
137+
## Getting help
138+
139+
Please contact [email protected]

0 commit comments

Comments
 (0)