Skip to content

Commit 22621de

Browse files
committed
ADAP-57: created RuntimeConfiguration
1 parent b3ae730 commit 22621de

File tree

7 files changed

+63
-49
lines changed

7 files changed

+63
-49
lines changed

RELEASENOTES-ADAPTER.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
* Added RuntimeConfiguration class to improve configurability of Runtime from Java programs.
66
* Added DesktopConnection.connect(RuntimeConfiguration)
7-
* Added add DesktopStateListener.onClose to notify connection to Runtime is closed.
7+
* Added DesktopStateListener.onClose to notify connection to Runtime is closed.
88
* Added Application.getGroups
99

1010
## Bug Fixes
2.79 KB
Binary file not shown.
189 Bytes
Binary file not shown.
361 Bytes
Binary file not shown.

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

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -124,38 +124,43 @@ private JPanel layoutDescriptionPanel() {
124124
public ApplicationOptions getApplicatonOptions() {
125125
ApplicationOptions options = null;
126126
if (createClicked) {
127-
String uuid = uuidText.getText();
128-
String name = nameText.getText();
129-
String url = urlText.getText();
130-
String applicationIcon = applicationIconText.getText();
131-
int defaultLeft = Integer.parseInt(defaultLeftText.getText());
132-
int defaultTop = Integer.parseInt(defaultTopText.getText());
133-
int defaultWidth = Integer.parseInt(defaultWidthText.getText());
134-
int defaultHeight = Integer.parseInt(defaultHeightText.getText());
135-
boolean resize = resizeCheck.isSelected();
136-
boolean frame = frameCheck.isSelected();
137-
boolean showTaskbarIcon = showTaskbarIconCheck.isSelected();
138-
boolean autoShow = autoShowCheck.isSelected();
139-
140-
options = new ApplicationOptions(name, uuid, url);
141-
options.setApplicationIcon(applicationIcon);
142-
143-
WindowOptions mainWindowOptions = new WindowOptions();
144-
145-
mainWindowOptions.setAutoShow(autoShow);
146-
mainWindowOptions.setDefaultHeight(defaultHeight);
147-
mainWindowOptions.setDefaultLeft(defaultLeft);
148-
mainWindowOptions.setDefaultTop(defaultTop);
149-
mainWindowOptions.setDefaultWidth(defaultWidth);
150-
mainWindowOptions.setResizable(resize);
151-
mainWindowOptions.setFrame(frame);
152-
mainWindowOptions.setShowTaskbarIcon(showTaskbarIcon);
153-
154-
options.setMainWindowOptions(mainWindowOptions);
127+
options = getApplicationOptionsFromUI();
155128
}
156129
return options;
157130
}
158131

132+
public ApplicationOptions getApplicationOptionsFromUI() {
133+
String uuid = uuidText.getText();
134+
String name = nameText.getText();
135+
String url = urlText.getText();
136+
String applicationIcon = applicationIconText.getText();
137+
int defaultLeft = Integer.parseInt(defaultLeftText.getText());
138+
int defaultTop = Integer.parseInt(defaultTopText.getText());
139+
int defaultWidth = Integer.parseInt(defaultWidthText.getText());
140+
int defaultHeight = Integer.parseInt(defaultHeightText.getText());
141+
boolean resize = resizeCheck.isSelected();
142+
boolean frame = frameCheck.isSelected();
143+
boolean showTaskbarIcon = showTaskbarIconCheck.isSelected();
144+
boolean autoShow = autoShowCheck.isSelected();
145+
146+
ApplicationOptions options = new ApplicationOptions(name, uuid, url);
147+
options.setApplicationIcon(applicationIcon);
148+
149+
WindowOptions mainWindowOptions = new WindowOptions();
150+
151+
mainWindowOptions.setAutoShow(autoShow);
152+
mainWindowOptions.setDefaultHeight(defaultHeight);
153+
mainWindowOptions.setDefaultLeft(defaultLeft);
154+
mainWindowOptions.setDefaultTop(defaultTop);
155+
mainWindowOptions.setDefaultWidth(defaultWidth);
156+
mainWindowOptions.setResizable(resize);
157+
mainWindowOptions.setFrame(frame);
158+
mainWindowOptions.setShowTaskbarIcon(showTaskbarIcon);
159+
160+
options.setMainWindowOptions(mainWindowOptions);
161+
return options;
162+
}
163+
159164
public void show(Component parent) {
160165
this.createClicked = false;
161166
uuidText.setText("OpenFinDesktopDemo");

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

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import java.awt.event.WindowListener;
1919
import java.util.ArrayList;
2020
import java.util.HashMap;
21+
22+
import org.json.JSONObject;
2123
import org.slf4j.Logger;
2224
import org.slf4j.LoggerFactory;
2325

@@ -72,6 +74,7 @@ public class OpenFinDesktopDemo extends JPanel implements ActionListener, Window
7274
InterApplicationBus bus;
7375

7476
protected DesktopConnection desktopConnection;
77+
protected RuntimeConfiguration runtimeConfiguration;
7578
protected int desktopPort = -1; // if set, assuming Runtime is already running on the port
7679
protected System openfinSystem;
7780
protected AppCreateDialog appCreateDialog;
@@ -95,6 +98,7 @@ public OpenFinDesktopDemo() {
9598
}
9699

97100
private void initDesktopConnection() throws DesktopException {
101+
this.runtimeConfiguration = new RuntimeConfiguration();
98102
if (java.lang.System.getProperty("com.openfin.demo.port") != null) {
99103
this.desktopPort = Integer.parseInt(java.lang.System.getProperty("com.openfin.demo.port"));
100104
}
@@ -109,10 +113,26 @@ private void initDesktopConnection() throws DesktopException {
109113
}
110114
if (securityRealm != null) {
111115
this.desktopConnection.setRuntimeSecurityRealm(securityRealm);
116+
this.runtimeConfiguration.setSecurityRealm(securityRealm);
117+
}
118+
String desktopVersion = java.lang.System.getProperty("com.openfin.demo.version");
119+
if (desktopVersion == null) {
120+
desktopVersion = "stable";
121+
}
122+
this.runtimeConfiguration.setRuntimeVersion(desktopVersion);
123+
String rvmArgs = java.lang.System.getProperty("com.openfin.demo.rvm.arguments");
124+
if (rvmArgs != null) {
125+
updateMessagePanel("Additional RVM arguments: " + rvmArgs);
126+
this.runtimeConfiguration.setAdditionalRvmArguments(rvmArgs);
112127
}
113-
this.desktopConnection.setRdmUrl(java.lang.System.getProperty("com.openfin.demo.rdmURL"));
114-
this.desktopConnection.setRuntimeAssetsUrl(java.lang.System.getProperty("com.openfin.demo.assetsURL"));
115-
this.desktopConnection.setAdditionalRuntimeArguments("--v=1"); // enable additional logging
128+
this.runtimeConfiguration.setRdmURL(java.lang.System.getProperty("com.openfin.demo.rdmURL"));
129+
this.runtimeConfiguration.setRuntimeAssetURL(java.lang.System.getProperty("com.openfin.demo.assetsURL"));
130+
this.runtimeConfiguration.setAdditionalRuntimeArguments("--v=1"); // enable additional logging
131+
this.runtimeConfiguration.setDevToolsPort(9090);
132+
JSONObject myconfig = new JSONObject();
133+
myconfig.put("key1", "value1");
134+
myconfig.put("PI", 3.14);
135+
this.runtimeConfiguration.addConfigurationItem("myconfig", myconfig);
116136
}
117137

118138
private JPanel layoutLeftPanel() {
@@ -381,7 +401,8 @@ public void run() {
381401
private void closeDesktop() {
382402
if (desktopConnection != null && desktopConnection.isConnected()) {
383403
try {
384-
new System(desktopConnection).exit();
404+
// new System(desktopConnection).exit();
405+
this.desktopConnection.disconnect();
385406
// Application app = Application.wrap(this.startupUUID, this.desktopConnection);
386407
// app.close();
387408
setMainButtonsEnabled(false);
@@ -495,22 +516,8 @@ public void onOutgoingMessage(String message) {
495516
updateMessagePanel("Connecting to Runtime already running at port " + this.desktopPort);
496517
desktopConnection.connect(listener);
497518
} else {
498-
String desktopVersion = java.lang.System.getProperty("com.openfin.demo.version");
499-
if (desktopVersion == null) {
500-
desktopVersion = "stable";
501-
}
502-
String rvmArgs = java.lang.System.getProperty("com.openfin.demo.rvm.arguments");
503-
if (rvmArgs != null) {
504-
updateMessagePanel("Additional RVM arguments: " + rvmArgs);
505-
desktopConnection.setAdditionalRvmArguments(rvmArgs);
506-
}
507-
String securityRealm = java.lang.System.getProperty("com.openfin.demo.securityRealm");
508-
if (securityRealm != null) {
509-
java.lang.System.out.println(String.format("Using security realm %s", securityRealm));
510-
desktopConnection.setRuntimeSecurityRealm(securityRealm);
511-
}
512-
updateMessagePanel("Connecting to version " + desktopVersion);
513-
desktopConnection.connectToVersion(desktopVersion, listener, 10000);
519+
updateMessagePanel("Connecting to version " + this.runtimeConfiguration.getRuntimeVersion());
520+
desktopConnection.connect(this.runtimeConfiguration, listener, 10000);
514521
}
515522
} catch (Exception ex) {
516523
ex.printStackTrace();
@@ -720,6 +727,7 @@ public void onError(Ack ack) {
720727

721728
@Override
722729
public void onError(Ack ack) {
730+
java.lang.System.out.println(String.format("Error creating application: %s", ack.getReason()));
723731
}
724732
});
725733
this.applicationList.put(options.getUUID(), app);

src/test/java/com/openfin/desktop/TestUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public static DesktopConnection setupConnection(String connectionUuid, String rd
110110

111111
DesktopConnection desktopConnection = new DesktopConnection(connectionUuid);
112112
desktopConnection.setAdditionalRuntimeArguments(" --v=1 "); // turn on Chromium debug log
113+
desktopConnection.setDevToolsPort(9090);
113114
desktopConnection.setRdmUrl(rdmUrl);
114115
desktopConnection.setRuntimeAssetsUrl(assetsUrl);
115116
desktopConnection.connectToVersion(runtimeVersion, new DesktopStateListener() {

0 commit comments

Comments
 (0)