Skip to content

Commit 1694cfd

Browse files
weitehowenjunche
andcommitted
ADAP-175 corresponding change for java adapter fdc3 change. (openfin#31)
* ADAP-175 updated example code and tests per java-adapter change. * ADAP-175 restored channel api connect name alias option * ADAP-175: updated FDC3 example Co-authored-by: Wenjun Che <[email protected]>
1 parent 0ed5246 commit 1694cfd

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

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

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.awt.event.WindowEvent;
1414
import java.io.IOException;
1515
import java.lang.System;
16+
import java.util.List;
1617
import java.util.UUID;
1718

1819
public class FDC3Example implements DesktopStateListener {
@@ -220,41 +221,38 @@ private void sendTickerToReds() {
220221
JSONObject id = new JSONObject();
221222
id.put("ticker", ticker.toLowerCase());
222223
context.setId(id);
223-
fdc3Client.raiseIntent("fdc3.ViewChart", context, "fdc3-charts-red", new AsyncCallback<IntentResolution>() {
224+
fdc3Client.raiseIntent("ViewChart", context, "fdc3-charts-red", new AsyncCallback<IntentResolution>() {
224225
@Override
225226
public void onSuccess(IntentResolution result) {
227+
output.setText(String.format("IntentResolution source=%s, version=%s", result.getSource(), result.getVersion()));
226228
}
227229
});
228230
}
229231

230232
private void findIntent() {
231-
fdc3Client.findIntent("fdc3.ViewChart", null, new AckListener() {
232-
@Override
233-
public void onSuccess(Ack ack) {
234-
if (ack.isSuccessful()) {
235-
output.setText(String.format("Intent found: %s", ack.getJsonObject().getJSONObject("data").getJSONObject("result")));
236-
}
237-
}
238-
@Override
239-
public void onError(Ack ack) {
240-
}
233+
fdc3Client.findIntent("ViewChart", null, new AsyncCallback<AppIntent>() {
234+
@Override
235+
public void onSuccess(AppIntent result) {
236+
output.setText(result.toString());
237+
238+
}
241239
});
242240
}
243241

244-
private void findContextIntent() {
245-
String ticker = getTicker();
246-
Context context = new Context("fdc3.instrument", ticker);
242+
private void findContextIntent() {
243+
String ticker = getTicker();
244+
Context context = new Context("fdc3.instrument", ticker);
247245

248-
fdc3Client.findIntentsByContext(context, new AckListener() {
249-
@Override
250-
public void onSuccess(Ack ack) {
251-
output.setText(String.format("Intent found: %s", ack.getJsonObject().getJSONObject("data").getJSONArray("result")));
252-
}
253-
@Override
254-
public void onError(Ack ack) {
255-
}
256-
});
257-
}
246+
fdc3Client.findIntentsByContext(context, new AsyncCallback<List<AppIntent>>() {
247+
248+
@Override
249+
public void onSuccess(List<AppIntent> result) {
250+
for (int i=0; i<result.size(); i++) {
251+
output.setText(i + ":" + result.get(i).toString());
252+
}
253+
}
254+
});
255+
}
258256

259257
private void broadcast() {
260258
String ticker = getTicker();
@@ -300,7 +298,7 @@ public void onError(Ack ack) {
300298
}
301299

302300
private void addIntentListener() {
303-
fdc3Client.addIntentListener("fdc3.ViewChart", new IntentListener() {
301+
fdc3Client.addIntentListener("ViewChartByJava", new IntentListener() {
304302
@Override
305303
public JSONObject onIntent(Context context) {
306304
output.setText(String.format("Received Intent: %s", context.toString()));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public void onChannelDisconnect(ConnectionEvent connectionEvent) {
232232
desktopConnection.getChannel(channelName).connect(channelName, new AsyncCallback<ChannelClient>() {
233233
@Override
234234
public void onSuccess(ChannelClient client) {
235-
desktopConnection.getChannel(channelName).disconnect(client, null);
235+
client.disconnect(null);
236236
}
237237

238238
});

0 commit comments

Comments
 (0)