Skip to content

Commit b71936a

Browse files
committed
ADAP-56: fixed issues in embed demo
1 parent 1c63bdb commit b71936a

1 file changed

Lines changed: 39 additions & 3 deletions

File tree

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

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.openfin.desktop.win32.WinMessageHelper;
66
import com.sun.jna.Native;
77
import info.clearthought.layout.TableLayout;
8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
810

911
import javax.swing.*;
1012
import java.awt.*;
@@ -20,13 +22,16 @@
2022
*
2123
*/
2224
public class WindowEmbedDemo extends JPanel implements ActionListener, WindowListener {
25+
private final static Logger logger = LoggerFactory.getLogger(WindowEmbedDemo.class.getName());
2326

2427
private static JFrame jFrame;
2528
protected String appUuid = "JavaEmbedding";
2629
protected String startupUuid = "OpenFinHelloWorld";
2730
protected String desktopOption;
2831
protected DesktopConnection controller;
2932

33+
protected String openfin_app_url = "https://cdn.openfin.co/examples/junit/SimpleDockingExample.html"; // source is in release/SimpleDockingExample.html
34+
3035
protected JButton launch, close, embed;
3136
protected java.awt.Canvas embedCanvas;
3237
protected Long previousPrarentHwndId;
@@ -35,7 +40,7 @@ public WindowEmbedDemo(final String desktopOption, final String startupUuid) {
3540
this.startupUuid = startupUuid;
3641
this.desktopOption = desktopOption;
3742
try {
38-
this.controller = new DesktopConnection(appUuid, "localhost", 9696);
43+
this.controller = new DesktopConnection(appUuid);
3944
} catch (DesktopException desktopError) {
4045
desktopError.printStackTrace();
4146
}
@@ -203,6 +208,7 @@ private void runStartAction() {
203208
@Override
204209
public void onReady() {
205210
setMainButtonsEnabled(true);
211+
launchHtmlApp();
206212
}
207213

208214
@Override
@@ -220,14 +226,44 @@ public void onMessage(String message) {
220226
public void onOutgoingMessage(String message) {
221227
}
222228
};
223-
// desktopConnection.launchAndConnect(null, desktopOption, listener, 10000);
224-
controller.connect(listener);
229+
controller.connectToVersion("alpha", listener, 60);
225230

226231
} catch (Exception e) {
227232
e.printStackTrace();
228233
}
229234
}
230235

236+
private void launchHtmlApp() {
237+
// launch 5 instances of same example app
238+
int width = 300, height=200;
239+
try {
240+
ApplicationOptions options = new ApplicationOptions(startupUuid, startupUuid, openfin_app_url);
241+
options.setApplicationIcon("http://openfin.github.io/snap-and-dock/openfin.ico");
242+
WindowOptions mainWindowOptions = new WindowOptions();
243+
mainWindowOptions.setAutoShow(true);
244+
mainWindowOptions.setDefaultHeight(height);
245+
mainWindowOptions.setDefaultLeft(10);
246+
mainWindowOptions.setDefaultTop(50);
247+
mainWindowOptions.setDefaultWidth(width);
248+
mainWindowOptions.setShowTaskbarIcon(true);
249+
mainWindowOptions.setSaveWindowState(false); // set to false so all windows start at same initial positions for each run
250+
mainWindowOptions.setFrame(false);
251+
options.setMainWindowOptions(mainWindowOptions);
252+
DemoUtils.runApplication(options, this.controller, new AckListener() {
253+
@Override
254+
public void onSuccess(Ack ack) {
255+
Application app = (Application) ack.getSource();
256+
}
257+
@Override
258+
public void onError(Ack ack) {
259+
logger.error(String.format("Error launching %s %s", options.getUUID(), ack.getReason()));
260+
}
261+
});
262+
} catch (Exception e) {
263+
logger.error("Error launching app", e);
264+
}
265+
}
266+
231267
private boolean trayIconAdded = false;
232268
private Application startupHtml5app;
233269

0 commit comments

Comments
 (0)