Skip to content

Commit e73a38f

Browse files
author
Wenjun Che
committed
ADAP-43: Add more test code
1 parent c284c86 commit e73a38f

1 file changed

Lines changed: 42 additions & 28 deletions

File tree

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

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,7 @@ public class OpenFinDesktopDemo extends JPanel implements ActionListener, Window
7777
private JLabel uuidLabel, nameLabel, versionLabel, urlLabel, resizeLabel, autoShowLabel, frameLabel;
7878

7979

80-
public OpenFinDesktopDemo(final String securityRealm) {
81-
try {
82-
83-
if (java.lang.System.getProperty("com.openfin.demo.port") != null) {
84-
this.desktopPort = Integer.parseInt(java.lang.System.getProperty("com.openfin.demo.port"));
85-
}
86-
if (this.desktopPort > 0) {
87-
this.desktopConnection = new DesktopConnection("OpenFinDesktopDemoJava", "localhost", this.desktopPort);
88-
} else {
89-
this.desktopConnection = new DesktopConnection("OpenFinDesktopDemoJava");
90-
}
91-
if (securityRealm != null) {
92-
this.desktopConnection.setRuntimeSecurityRealm(securityRealm);
93-
}
94-
this.desktopConnection.setAdditionalRuntimeArguments("--v=1"); // enable additional logging
95-
} catch (DesktopException desktopError) {
96-
desktopError.printStackTrace();
97-
}
80+
public OpenFinDesktopDemo() {
9881
this.appCreateDialog = new AppCreateDialog();
9982
this.loadAppsDialog = new LoadAppsDialog();
10083

@@ -106,6 +89,25 @@ public OpenFinDesktopDemo(final String securityRealm) {
10689
setAppButtonsEnabled(false);
10790
}
10891

92+
private void initDesktopConnection() throws DesktopException {
93+
if (java.lang.System.getProperty("com.openfin.demo.port") != null) {
94+
this.desktopPort = Integer.parseInt(java.lang.System.getProperty("com.openfin.demo.port"));
95+
}
96+
if (this.desktopPort > 0) {
97+
this.desktopConnection = new DesktopConnection("OpenFinDesktopDemoJava", "localhost", this.desktopPort);
98+
} else {
99+
this.desktopConnection = new DesktopConnection("OpenFinDesktopDemoJava");
100+
}
101+
String securityRealm = null;
102+
if (java.lang.System.getProperty("com.openfin.demo.security.realm") != null) {
103+
securityRealm = java.lang.System.getProperty("com.openfin.demo.security.realm");
104+
}
105+
if (securityRealm != null) {
106+
this.desktopConnection.setRuntimeSecurityRealm(securityRealm);
107+
}
108+
this.desktopConnection.setAdditionalRuntimeArguments("--v=1"); // enable additional logging
109+
}
110+
109111
private JPanel layoutLeftPanel() {
110112
JPanel panel = new JPanel();
111113
double size[][] = {{TableLayout.FILL}, {160, 30, TableLayout.FILL}};
@@ -429,6 +431,12 @@ public void init() {
429431
}
430432

431433
private void runStartAction() {
434+
try {
435+
initDesktopConnection();
436+
} catch (DesktopException desktopError) {
437+
desktopError.printStackTrace();
438+
}
439+
432440
final DesktopStateListener listener = new DesktopStateListener() {
433441
@Override
434442
public void onReady() {
@@ -631,7 +639,19 @@ private void createApplication(final ApplicationOptions options) {
631639
public void onSuccess(Ack ack) {
632640
Application application = (Application) ack.getSource();
633641
try {
634-
application.run();
642+
application.run(new AckListener() {
643+
public void onSuccess(Ack ack) {
644+
java.lang.System.out.println("Intalling minimized event listener");
645+
Application application = (Application) ack.getSource();
646+
application.getWindow().addEventListener("minimized", new EventListener() {
647+
public void eventReceived(com.openfin.desktop.ActionEvent actionEvent) {
648+
java.lang.System.out.println("eventReceived " + actionEvent.getType());
649+
}
650+
}, null);
651+
}
652+
public void onError(Ack ack) {
653+
}
654+
});
635655
} catch (Exception e) {
636656
e.printStackTrace();
637657
}
@@ -676,14 +696,14 @@ private String getBooleanString(boolean value) {
676696
return value ? "Y" : "N";
677697
}
678698

679-
private static void createAndShowGUI(final String securityRealm) {
699+
private static void createAndShowGUI() {
680700

681701
//Create and set up the window.
682702
jFrame = new JFrame("Java Login Demo");
683703
jFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
684704

685705
//Create and set up the content pane.
686-
OpenFinDesktopDemo newContentPane = new OpenFinDesktopDemo(securityRealm);
706+
OpenFinDesktopDemo newContentPane = new OpenFinDesktopDemo();
687707
newContentPane.setOpaque(true); //content panes must be opaque
688708
jFrame.setContentPane(newContentPane);
689709
jFrame.addWindowListener(newContentPane);
@@ -708,16 +728,10 @@ private static void createAndShowGUI(final String securityRealm) {
708728
*/
709729
public static void main(String[] args) throws Exception {
710730

711-
final String securityRealm;
712-
if (java.lang.System.getProperty("com.openfin.demo.security.realm") != null) {
713-
securityRealm = java.lang.System.getProperty("com.openfin.demo.security.realm");
714-
} else {
715-
securityRealm = null;
716-
}
717731

718732
javax.swing.SwingUtilities.invokeLater(new Runnable() {
719733
public void run() {
720-
createAndShowGUI(securityRealm);
734+
createAndShowGUI();
721735
}
722736
});
723737
}

0 commit comments

Comments
 (0)