Skip to content

Commit a20e871

Browse files
authored
Merge develop to master (openfin#22)
* ADAP-114: adapter 6.0.1.3 * ADAP-115: Igore registerUser test for now * ADAP-115: added Application.registerUser * ADAP-120: Upgrade JNA to 4.5.1 * ADAP-120: updateed embed exampled * ADAP-122 Upgrade adapter to 6.0.2.2-SNAPSHOT * ADAP-125: update RELEASENOTES-ADAPTER.md * ADAP-126: update adapter to 7.0.1 * RUN-3975 added unit test case for IAB with reconnection. (openfin#19) * ADAP-130: adapter updates * ADAP-130: update docs * ADAP-134 fixed sample code that doesn't build with Java 10 * ADAP-136: Adapter 7.0.1 release * ADAP-139 updated embedded code and script, added description in readme * Update README.md * Update README.md * ADAP-138: updated RELEASENOTES for 7.0.2
1 parent 4aca66d commit a20e871

24 files changed

+663
-323
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ hs_err_pid*
1313
# IDEA
1414
*.iml
1515
.idea/**
16-
target/**
16+
target/**
17+
/target/

README.md

Lines changed: 136 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -26,59 +26,69 @@ Source code for the example is located in /src/main/java/com/openfin/desktop/dem
2626

2727
1. Create connection object:
2828

29-
this.desktopConnection = new DesktopConnection("OpenFinDesktopDemo");
30-
31-
This code just creates an instance of DesktopConnection and it does not try to connect to runtime.
29+
```java
30+
this.desktopConnection = new DesktopConnection("OpenFinDesktopDemo");
31+
```
32+
This code just creates an instance of DesktopConnection and it does not try to connect to runtime.
3233

3334
2. Launch and connect to stable version of OpenFin runtime:
3435

35-
// create an instance of RuntimeConfiguration and configure Runtime by setting properties in RuntimeConfiguration
36-
this.runtimeConfiguration = new RuntimeConfiguration();
37-
// launch and connect to OpenFin Runtime
38-
desktopConnection.connect(this.runtimeConfiguration, listener, 10000);
39-
36+
```java
37+
// create an instance of RuntimeConfiguration and configure Runtime by setting properties in RuntimeConfiguration
38+
this.runtimeConfiguration = new RuntimeConfiguration();
39+
// launch and connect to OpenFin Runtime
40+
desktopConnection.connect(this.runtimeConfiguration, listener, 10000);
41+
```
4042
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime.
4143

4244
3. Create new application when clicking on Create App:
4345

44-
Application app = new Application(options, desktopConnection, new AckListener() {
45-
@Override
46-
public void onSuccess(Ack ack) {
47-
Application application = (Application) ack.getSource();
48-
application.run(); // run the app
49-
}
50-
@Override
51-
public void onError(Ack ack) {
52-
}
53-
});
54-
46+
```java
47+
Application app = new Application(options, desktopConnection, new AckListener() {
48+
@Override
49+
public void onSuccess(Ack ack) {
50+
Application application = (Application) ack.getSource();
51+
application.run(); // run the app
52+
}
53+
@Override
54+
public void onError(Ack ack) {
55+
}
56+
});
57+
```
5558
options is an instance of ApplicationOptions, which is populated from App Create dialog. AckListener interface provides callback for the operation.
5659

5760
Once the application is created successfully, you can take actions on its window:
5861

5962
4. Change opacity:
6063

61-
WindowOptions options = new WindowOptions();
62-
options.setOpacity(newOpacityValue);
63-
application.getWindow().updateOptions(options, null);
64+
```java
65+
WindowOptions options = new WindowOptions();
66+
options.setOpacity(newOpacityValue);
67+
application.getWindow().updateOptions(options, null);
68+
```
6469

6570
5. Change Window size
6671

67-
application.getWindow().resizeBy(10, 10, "top-left");
68-
72+
```java
73+
application.getWindow().resizeBy(10, 10, "top-left");
74+
```
6975

7076
6. Publishes messages to a topic with InterApplicationBus
7177

72-
org.json.JSONObject message = createSomeJsonMessage();
73-
desktopConnection.getInterApplicationBus().publish("someTopic", message);
78+
```java
79+
org.json.JSONObject message = createSomeJsonMessage();
80+
desktopConnection.getInterApplicationBus().publish("someTopic", message);
81+
```
7482

7583
7. Subscribes to a topic with InterApplicationBus
7684

77-
desktopConnection.getInterApplicationBus().subscribe("*", "someTopic", new BusListener() {
78-
public void onMessageReceived(String sourceUuid, String topic, Object payload) {
79-
JSONObject message = (JSONObject) payload;
80-
}
81-
});
85+
```java
86+
desktopConnection.getInterApplicationBus().subscribe("*", "someTopic", new BusListener() {
87+
public void onMessageReceived(String sourceUuid, String topic, Object payload) {
88+
JSONObject message = (JSONObject) payload;
89+
}
90+
});
91+
```
8292

8393
## Run the example of docking Java Swing window with HTML5 application
8494

@@ -98,43 +108,124 @@ Source code for the example is located in /src/main/java/com/openfin/desktop/dem
98108

99109
1. Create connection object:
100110

101-
this.desktopConnection = new DesktopConnection("OpenFinDockingDemo", "localhost", port);
111+
```java
112+
this.desktopConnection = new DesktopConnection("OpenFinDockingDemo", "localhost", port);
113+
```
102114

103-
This code just creates an instance and it does not try to connect to runtime.
115+
This code just creates an instance and it does not try to connect to runtime.
104116

105117
2. Launch and connect to stable version of OpenFin runtime:
106118

107-
desktopConnection.connectToVersion("stable", listener, 60);
119+
```java
120+
desktopConnection.connectToVersion("stable", listener, 60);
121+
```
108122

109123
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime.
110124

111125
3. Once Runtime is running, an instance of DockingManager is create with
112126

113-
this.dockingManager = new DockingManager(this.desktopConnection, javaParentAppUuid);
127+
```java
128+
this.dockingManager = new DockingManager(this.desktopConnection, javaParentAppUuid);
129+
```
114130

115131
4. Any OpenFin window can be registered with DockingManager with
116132

117-
dockingManager.registerWindow(openFinWindow);
133+
```java
134+
dockingManager.registerWindow(openFinWindow);
135+
```
118136

119137
5. Any Java window can be registered with DockingManager with
120138

121-
dockingManager.registerJavaWindow(javaWindowName, jFrame, AckListener);
122-
139+
```java
140+
dockingManager.registerJavaWindow(javaWindowName, jFrame, AckListener);
141+
```
142+
123143
6. An application can receive dock and undock events from DockingManger with
124144

125-
desktopConnection.getInterApplicationBus().subscribe("*", "window-docked", EventListener);
126-
desktopConnection.getInterApplicationBus().subscribe("*", "window-undocked", EventListener);
145+
```java
146+
desktopConnection.getInterApplicationBus().subscribe("*", "window-docked", EventListener);
147+
desktopConnection.getInterApplicationBus().subscribe("*", "window-undocked", EventListener);
148+
```
127149

128150
7. An application can request DockingManager to undock a window with:
129151

130-
JSONObject msg = new JSONObject();
131-
msg.put("applicationUuid", javaParentAppUuid);
132-
msg.put("windowName", javaWindowName);
133-
desktopConnection.getInterApplicationBus().publish("undock-window", msg);
134-
152+
```java
153+
JSONObject msg = new JSONObject();
154+
msg.put("applicationUuid", javaParentAppUuid);
155+
msg.put("windowName", javaWindowName);
156+
desktopConnection.getInterApplicationBus().publish("undock-window", msg);
157+
```
135158

136159
Once the demo is running, Windows snap while being draggted close to other windows. Snapped windows dock on mounse release.
137160

161+
## Run the example of embedding HTML5 application into a Java Swing window
162+
163+
1. Clone this repository
164+
165+
2. Go to release directory and start embed.bat
166+
167+
3. Once the java app starts, click on "Launch OpenFin" button, which should start OpenFin Runtime and embed the OpenFin application that points to https://openfin.co
168+
169+
4. Click "Shutdown OpenFin" button to close HTML5 application and the Java Swing window
170+
171+
## Source Code Review for embedded OpenFin application
172+
173+
Source code for the example is located in /src/main/java/com/openfin/desktop/demo/WindowEmbedDemo.java
174+
175+
1. create a canvas and place it where the HTML5 application should be embedded.
176+
177+
```java
178+
embedCanvas = new java.awt.Canvas();
179+
panel.add(embedCanvas, BorderLayout.CENTER);
180+
```
181+
182+
2. listen to the canvas resize event, and resize embedded HTML5 application accordingly.
183+
184+
```java
185+
embedCanvas.addComponentListener(new ComponentAdapter() {
186+
@Override
187+
public void componentResized(ComponentEvent event) {
188+
super.componentResized(event);
189+
Dimension newSize = event.getComponent().getSize();
190+
try {
191+
if (startupHtml5app != null) {
192+
startupHtml5app.getWindow().embedComponentSizeChange((int)newSize.getWidth(), (int)newSize.getHeight());
193+
}
194+
} catch (Exception e) {
195+
e.printStackTrace();
196+
}
197+
}
198+
});
199+
```
200+
201+
3. launch and connect to OpenFin runtime
202+
203+
```java
204+
this.desktopConnection = new DesktopConnection(appUuid);
205+
DesktopStateListener listener = new DesktopStateListener() {...};
206+
RuntimeConfiguration configuration = new RuntimeConfiguration();
207+
configuration.setRuntimeVersion(desktopVersion);
208+
desktopConnection.connect(configuration, listener, 60);
209+
```
210+
211+
4. create HTML5 application
212+
213+
```java
214+
ApplicationOptions options = new ApplicationOptions(startupUuid, startupUuid, openfin_app_url);
215+
WindowOptions mainWindowOptions = new WindowOptions();
216+
options.setMainWindowOptions(mainWindowOptions);
217+
DemoUtils.runApplication(options, this.desktopConnection, new AckListener() {...});
218+
```
219+
220+
5. embed HTML5 application into the canvas
221+
222+
```java
223+
startupHtml5app = Application.wrap(this.startupUuid, this.desktopConnection);
224+
Window html5Wnd = startupHtml5app.getWindow();
225+
long parentHWndId = Native.getComponentID(this.embedCanvas);
226+
html5Wnd.embedInto(parentHWndId, this.embedCanvas.getWidth(), this.embedCanvas.getHeight(), new AckListener() {...});
227+
```
228+
138229
## More Info
139230
More information and API documentation can be found at https://openfin.co/java-api/
140231

RELEASENOTES-ADAPTER.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
# Version 7.0.2
12

2-
# Version 6.0.2.2-SNAPSHOT
3+
## Bug Fixes
4+
* Fixed an issue with setting timeout if RuntimeConfiguration.setRuntimePort is called.
5+
6+
# Version 7.0.1
37

48
## New Features
59
* Improved thread safety with concurrent collection classes.
10+
* Added error message to DesktopStateListener.onClose (breaking change)
11+
* Added OpenFinRuntime.getRuntimeInfo
12+
* Added OpenFinRuntime.getRvmInfo
13+
* Improved thread safety with concurrent collection classes.
614

715
## Bug Fixes
816
* Fixed an issue with passing arguments in System.launchExternalProcess
@@ -31,7 +39,7 @@
3139
* Add browser-style navigation to Window class
3240
* Add support for fallbackVersion of Runtime
3341
* Add support for non-persistent connections to Runtime
34-
* Improve suppot for app assets
42+
* Improve support for app assets
3543

3644
## Bug Fixes
3745
* Fixed an issue with loop of re-connecting to Runtime

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>co.openfin</groupId>
88
<artifactId>openfin-desktop-java-example</artifactId>
9-
<version>6.0.1.2</version>
9+
<version>6.0.1.3-SNAPSHOT</version>
1010
<packaging>jar</packaging>
1111

1212
<name>openfin-desktop-java-example</name>
@@ -58,7 +58,7 @@
5858
<dependency>
5959
<groupId>co.openfin</groupId>
6060
<artifactId>openfin-desktop-java-adapter</artifactId>
61-
<version>6.0.2.2-SNAPSHOT</version>
61+
<version>7.0.1</version>
6262
</dependency>
6363
<dependency>
6464
<groupId>co.openfin</groupId>

release/embed.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
java -cp openfin-desktop-java-example-6.0.1.2.jar;openfin-desktop-java-adapter-6.0.2.1-SNAPSHOT.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 -Dcom.openfin.demo.embed.URL=https://openfin.co -Dcom.openfin.demo.version=stable com.openfin.desktop.demo.WindowEmbedDemo
1+
java -cp openfin-desktop-java-example-6.0.1.3-SNAPSHOT.jar;openfin-desktop-java-adapter-7.0.1.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 -Dcom.openfin.demo.embed.URL=https://openfin.co -Dcom.openfin.demo.version=stable com.openfin.desktop.demo.WindowEmbedDemo
337 KB
Binary file not shown.
171 KB
Binary file not shown.

src/main/java/com/openfin/desktop/demo/DemoUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public static void ackError(AckListener ackListener, String reason) {
141141
if (ackListener != null) {
142142
JSONObject obj = new JSONObject();
143143
obj.put("reason", reason);
144-
ackListener.onError(new Ack(obj, null));
144+
ackListener.onError(new Ack(obj, ackListener));
145145
}
146146
}
147147

src/main/java/com/openfin/desktop/demo/DockingDemo2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void onReady() {
106106
}
107107

108108
@Override
109-
public void onClose() {
109+
public void onClose(String error) {
110110
}
111111
@Override
112112
public void onError(String reason) {

src/main/java/com/openfin/desktop/demo/ExternalMessageDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void onReady() {
3131
}
3232

3333
@Override
34-
public void onClose() {
34+
public void onClose(String error) {
3535
System.out.println("Connection closed");
3636
}
3737

0 commit comments

Comments
 (0)