Skip to content

Commit 1f81736

Browse files
committed
ADAP-74: updated embedding example to accept any URL
1 parent 582070c commit 1f81736

File tree

4 files changed

+15
-25
lines changed

4 files changed

+15
-25
lines changed

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.0.3</version>
9+
<version>6.0.1.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>openfin-desktop-java-example</name>
@@ -47,7 +47,7 @@
4747
<dependency>
4848
<groupId>co.openfin</groupId>
4949
<artifactId>openfin-desktop-java-adapter</artifactId>
50-
<version>6.0.1.0</version>
50+
<version>6.0.1.1-SNAPSHOT</version>
5151
</dependency>
5252
<dependency>
5353
<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.0.3.jar;openfin-desktop-java-adapter-6.0.0.3-SNAPSHOT.jar;TableLayout-20050920.jar;jna-4.1.0.jar;jna-platform-4.1.0.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 -Dcom.openfin.demo.embedWaitTime=1000 -Dcom.openfin.demo.version=stable com.openfin.desktop.demo.WindowEmbedDemo
1+
java -cp openfin-desktop-java-example-6.0.1.1.jar;openfin-desktop-java-adapter-6.0.1.0.jar;TableLayout-20050920.jar;jna-4.1.0.jar;jna-platform-4.1.0.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 -Dcom.openfin.demo.embed.URL=https://openfin.co -Dcom.openfin.demo.version=stable com.openfin.desktop.demo.WindowEmbedDemo
146 KB
Binary file not shown.

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

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public class WindowEmbedDemo extends JPanel implements ActionListener, WindowLis
2525
private static JFrame jFrame;
2626
protected String appUuid = "JavaEmbedding";
2727
protected String startupUuid = "OpenFinHelloWorld";
28-
protected String desktopOption;
2928
protected DesktopConnection desktopConnection;
3029

3130
protected String openfin_app_url = "https://cdn.openfin.co/examples/junit/SimpleDockingExample.html"; // source is in release/SimpleDockingExample.html
@@ -34,9 +33,8 @@ public class WindowEmbedDemo extends JPanel implements ActionListener, WindowLis
3433
protected java.awt.Canvas embedCanvas;
3534
protected Long previousPrarentHwndId;
3635

37-
public WindowEmbedDemo(final String desktopOption, final String startupUuid) {
36+
public WindowEmbedDemo(final String startupUuid) {
3837
this.startupUuid = startupUuid;
39-
this.desktopOption = desktopOption;
4038
try {
4139
this.desktopConnection = new DesktopConnection(appUuid);
4240
} catch (DesktopException desktopError) {
@@ -126,12 +124,12 @@ public void unsubscribed(String uuid, String topic) {
126124
}
127125
}
128126

129-
private static void createAndShowGUI(final String desktopOption, final String startupUuid) {
127+
private static void createAndShowGUI(final String startupUuid) {
130128
//Create and set up the window.
131-
jFrame = new JFrame("Java Docking Demo");
132-
jFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
129+
jFrame = new JFrame("Java Embedding Demo");
130+
// jFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
133131
//Create and set up the content pane.
134-
WindowEmbedDemo newContentPane = new WindowEmbedDemo(desktopOption, startupUuid);
132+
WindowEmbedDemo newContentPane = new WindowEmbedDemo(startupUuid);
135133
newContentPane.setOpaque(true); //content panes must be opaque
136134
jFrame.setContentPane(newContentPane);
137135
jFrame.addWindowListener(newContentPane);
@@ -233,7 +231,7 @@ public void onOutgoingMessage(String message) {
233231
}
234232
};
235233
RuntimeConfiguration configuration = new RuntimeConfiguration();
236-
desktopConnection.setAdditionalRuntimeArguments(" --v=1 "); // enable additional logging from Runtime
234+
configuration.setAdditionalRuntimeArguments(" --v=1 "); // enable additional logging from Runtime
237235
String desktopVersion = java.lang.System.getProperty("com.openfin.demo.version");
238236
if (desktopVersion == null) {
239237
desktopVersion = "stable";
@@ -250,6 +248,10 @@ private void launchHtmlApp() {
250248
// launch 5 instances of same example app
251249
int width = 500, height=500;
252250
try {
251+
String url = java.lang.System.getProperty("com.openfin.demo.embed.URL");
252+
if (url != null) {
253+
openfin_app_url = url;
254+
}
253255
ApplicationOptions options = new ApplicationOptions(startupUuid, startupUuid, openfin_app_url);
254256
options.setApplicationIcon("http://openfin.github.io/snap-and-dock/openfin.ico");
255257
WindowOptions mainWindowOptions = new WindowOptions();
@@ -307,7 +309,7 @@ public void eventReceived(ActionEvent actionEvent) {
307309
Window html5Wnd = startupHtml5app.getWindow();
308310
long parentHWndId = Native.getComponentID(this.embedCanvas);
309311
System.out.println("Canvas HWND " + Long.toHexString(parentHWndId));
310-
html5Wnd.embedInto(parentHWndId, 1920, 1000, new AckListener() {
312+
html5Wnd.embedInto(parentHWndId, this.embedCanvas.getWidth(), this.embedCanvas.getHeight(), new AckListener() {
311313
@Override
312314
public void onSuccess(Ack ack) {
313315
if (ack.isSuccessful()) {
@@ -326,26 +328,14 @@ public void onError(Ack ack) {
326328
}
327329

328330
/**
329-
* To start OpenFin Desktop and Connect, pass full path of OpenFin with*
330-
* -DOpenFinOption=--config=\"RemoteConfigUrl\"
331-
*
332-
* Set UUID of startup HTML5 app to dock to
333-
* -DStartupUUID="550e8400-e29b-41d4-a716-4466333333000"
334331
*
335332
* @param args
336333
*/
337334
public static void main(String[] args) {
338-
final String desktop_option = java.lang.System.getProperty("OpenFinOption");
339-
final String startupUUID;
340-
if (java.lang.System.getProperty("StartupUUID") != null) {
341-
startupUUID = java.lang.System.getProperty("StartupUUID");
342-
} else {
343-
startupUUID = "OpenFinHelloWorld";
344-
}
345335
java.lang.System.out.println("starting: ");
346336
javax.swing.SwingUtilities.invokeLater(new Runnable() {
347337
public void run() {
348-
createAndShowGUI(desktop_option, startupUUID);
338+
createAndShowGUI("OpenFin Embed Example");
349339
}
350340
});
351341
}

0 commit comments

Comments
 (0)