@@ -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