Skip to content

Commit f8788da

Browse files
authored
Update README.md
1 parent 3b59fa4 commit f8788da

File tree

1 file changed

+68
-45
lines changed

1 file changed

+68
-45
lines changed

README.md

Lines changed: 68 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,59 +23,69 @@ Source code for the example is located in /src/main/java/com/openfin/desktop/dem
2323

2424
1. Create connection object:
2525

26-
this.desktopConnection = new DesktopConnection("OpenFinDesktopDemo");
27-
28-
This code just creates an instance of DesktopConnection and it does not try to connect to runtime.
26+
```java
27+
this.desktopConnection = new DesktopConnection("OpenFinDesktopDemo");
28+
```
29+
This code just creates an instance of DesktopConnection and it does not try to connect to runtime.
2930

3031
2. Launch and connect to stable version of OpenFin runtime:
3132

32-
// create an instance of RuntimeConfiguration and configure Runtime by setting properties in RuntimeConfiguration
33-
this.runtimeConfiguration = new RuntimeConfiguration();
34-
// launch and connect to OpenFin Runtime
35-
desktopConnection.connect(this.runtimeConfiguration, listener, 10000);
36-
33+
```java
34+
// create an instance of RuntimeConfiguration and configure Runtime by setting properties in RuntimeConfiguration
35+
this.runtimeConfiguration = new RuntimeConfiguration();
36+
// launch and connect to OpenFin Runtime
37+
desktopConnection.connect(this.runtimeConfiguration, listener, 10000);
38+
```
3739
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime.
3840

3941
3. Create new application when clicking on Create App:
4042

41-
Application app = new Application(options, desktopConnection, new AckListener() {
42-
@Override
43-
public void onSuccess(Ack ack) {
44-
Application application = (Application) ack.getSource();
45-
application.run(); // run the app
46-
}
47-
@Override
48-
public void onError(Ack ack) {
49-
}
50-
});
51-
43+
```java
44+
Application app = new Application(options, desktopConnection, new AckListener() {
45+
@Override
46+
public void onSuccess(Ack ack) {
47+
Application application = (Application) ack.getSource();
48+
application.run(); // run the app
49+
}
50+
@Override
51+
public void onError(Ack ack) {
52+
}
53+
});
54+
```
5255
options is an instance of ApplicationOptions, which is populated from App Create dialog. AckListener interface provides callback for the operation.
5356

5457
Once the application is created successfully, you can take actions on its window:
5558

5659
4. Change opacity:
5760

58-
WindowOptions options = new WindowOptions();
59-
options.setOpacity(newOpacityValue);
60-
application.getWindow().updateOptions(options, null);
61+
```java
62+
WindowOptions options = new WindowOptions();
63+
options.setOpacity(newOpacityValue);
64+
application.getWindow().updateOptions(options, null);
65+
```
6166

6267
5. Change Window size
6368

64-
application.getWindow().resizeBy(10, 10, "top-left");
65-
69+
```java
70+
application.getWindow().resizeBy(10, 10, "top-left");
71+
```
6672

6773
6. Publishes messages to a topic with InterApplicationBus
6874

69-
org.json.JSONObject message = createSomeJsonMessage();
70-
desktopConnection.getInterApplicationBus().publish("someTopic", message);
75+
```java
76+
org.json.JSONObject message = createSomeJsonMessage();
77+
desktopConnection.getInterApplicationBus().publish("someTopic", message);
78+
```
7179

7280
7. Subscribes to a topic with InterApplicationBus
7381

74-
desktopConnection.getInterApplicationBus().subscribe("*", "someTopic", new BusListener() {
75-
public void onMessageReceived(String sourceUuid, String topic, Object payload) {
76-
JSONObject message = (JSONObject) payload;
77-
}
78-
});
82+
```java
83+
desktopConnection.getInterApplicationBus().subscribe("*", "someTopic", new BusListener() {
84+
public void onMessageReceived(String sourceUuid, String topic, Object payload) {
85+
JSONObject message = (JSONObject) payload;
86+
}
87+
});
88+
```
7989

8090
## Run the example of docking Java Swing window with HTML5 application
8191

@@ -95,40 +105,53 @@ Source code for the example is located in /src/main/java/com/openfin/desktop/dem
95105

96106
1. Create connection object:
97107

98-
this.desktopConnection = new DesktopConnection("OpenFinDockingDemo", "localhost", port);
108+
```java
109+
this.desktopConnection = new DesktopConnection("OpenFinDockingDemo", "localhost", port);
110+
```
99111

100-
This code just creates an instance and it does not try to connect to runtime.
112+
This code just creates an instance and it does not try to connect to runtime.
101113

102114
2. Launch and connect to stable version of OpenFin runtime:
103115

104-
desktopConnection.connectToVersion("stable", listener, 60);
116+
```java
117+
desktopConnection.connectToVersion("stable", listener, 60);
118+
```
105119

106120
listener is an instance of DesktopStateListener which provides callback on status of connections to runtime.
107121

108122
3. Once Runtime is running, an instance of DockingManager is create with
109123

110-
this.dockingManager = new DockingManager(this.desktopConnection, javaParentAppUuid);
124+
```java
125+
this.dockingManager = new DockingManager(this.desktopConnection, javaParentAppUuid);
126+
```
111127

112128
4. Any OpenFin window can be registered with DockingManager with
113129

114-
dockingManager.registerWindow(openFinWindow);
130+
```java
131+
dockingManager.registerWindow(openFinWindow);
132+
```
115133

116134
5. Any Java window can be registered with DockingManager with
117135

118-
dockingManager.registerJavaWindow(javaWindowName, jFrame, AckListener);
119-
136+
```java
137+
dockingManager.registerJavaWindow(javaWindowName, jFrame, AckListener);
138+
```
139+
120140
6. An application can receive dock and undock events from DockingManger with
121141

122-
desktopConnection.getInterApplicationBus().subscribe("*", "window-docked", EventListener);
123-
desktopConnection.getInterApplicationBus().subscribe("*", "window-undocked", EventListener);
142+
```java
143+
desktopConnection.getInterApplicationBus().subscribe("*", "window-docked", EventListener);
144+
desktopConnection.getInterApplicationBus().subscribe("*", "window-undocked", EventListener);
145+
```
124146

125147
7. An application can request DockingManager to undock a window with:
126148

127-
JSONObject msg = new JSONObject();
128-
msg.put("applicationUuid", javaParentAppUuid);
129-
msg.put("windowName", javaWindowName);
130-
desktopConnection.getInterApplicationBus().publish("undock-window", msg);
131-
149+
```java
150+
JSONObject msg = new JSONObject();
151+
msg.put("applicationUuid", javaParentAppUuid);
152+
msg.put("windowName", javaWindowName);
153+
desktopConnection.getInterApplicationBus().publish("undock-window", msg);
154+
```
132155

133156
Once the demo is running, Windows snap while being draggted close to other windows. Snapped windows dock on mounse release.
134157

0 commit comments

Comments
 (0)