Skip to content

Commit b407431

Browse files
authored
Planned/6.1.0 (#33)
merge planned/6.1.0 into master
1 parent 202a0c4 commit b407431

File tree

6 files changed

+101
-31
lines changed

6 files changed

+101
-31
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ You can build the JAR files and the launch4j executable file using the `mvn pack
1111
**Note:** The executable generated by launch4j is experimental and may not work correctly. Reach out to <a href="mailto:[email protected]">[email protected]</a> to receive Client Success support if you encounter difficulties.
1212

1313
## Examples provided
14+
1415
- JavaExample - Example JavaFX application
1516
- JavaSwingExample - Example Java Swing application
1617
- JavaHeadlessExample - Example of a window-less Java application
1718
- AuthenticationExample - Example component that performs authentication from within Java
1819
- MultiWindow - JavaSwingExample - Same as JavaSwingExample but running in multi-window (several windows running under the same
1920
process)
2021
- MultiWindow - AuthenticationExample - Same as AuthenticationExample but running in multi-window (several windows running under the same
21-
process)
22+
process)
2223
- InteropServiceExample - Example of JavaFX FDC3 Desktop Agent client
2324

24-
## Configuring the Java examples
25+
## Configuring the Java examples
26+
2527
Copy the _java-example.json_ included in the project to _src/components/java-example/java-example.json_. Update the application manifest to include:
26-
``` JSON
28+
29+
```JSON
2730
"finsemble": {
2831
...,
2932
"custom": {
@@ -37,11 +40,10 @@ Copy the _java-example.json_ included in the project to _src/components/java-exa
3740
```
3841

3942
**NOTE:**
40-
- The _java-example.json_ file includes two copies of the JavaFX example:
43+
44+
- The _java-example.json_ file includes two copies of the JavaFX example:
4145
- Java Example (local)
42-
- Java Example (asset).
46+
- Java Example (asset).
4347

4448
The "local" component uses `javaExampleRoot` to specify the path to the JAR file on the local system. The "asset" component uses the `appAsset` to download and run the application - Please refer to our tutorial
4549
on [integrating native applications](https://documentation.finsemble.com/tutorial-integratingNativeApplications.html) for more details.
46-
47-

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>ChartIQ</groupId>
88
<artifactId>finesmble-java-example</artifactId>
9-
<version>6.2.0-SNAPSHOT</version>
9+
<version>6.1.0</version>
1010

1111
<repositories>
1212
<repository>
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.chartiq.finsemble</groupId>
2828
<artifactId>finsemble</artifactId>
29-
<version>6.2.0</version>
29+
<version>6.1.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>it.sauronsoftware</groupId>

src/main/java/com/chartiq/finsemble/example/JavaSwingExample.java

Lines changed: 80 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.chartiq.finsemble.Finsemble;
88
import com.chartiq.finsemble.interfaces.ConnectionEventGenerator;
99
import com.chartiq.finsemble.interfaces.ConnectionListener;
10+
import org.json.JSONArray;
1011
import org.json.JSONObject;
1112

1213
import javax.swing.*;
@@ -19,6 +20,7 @@
1920
import java.io.*;
2021
import java.util.ArrayList;
2122
import java.util.Arrays;
23+
import java.util.HashMap;
2224
import java.util.List;
2325
import java.util.logging.*;
2426
import java.util.stream.Collectors;
@@ -46,6 +48,8 @@ public class JavaSwingExample extends JFrame implements WindowListener {
4648
private JButton group5Button;
4749
private JButton group6Button;
4850

51+
private HashMap<String, JButton> linkerButtons = new HashMap<>();
52+
4953
private Finsemble fsbl;
5054

5155
/**
@@ -89,82 +93,88 @@ private void createForm() {
8993
contentPane = getContentPane();
9094
contentPane.setLayout(new GridBagLayout());
9195
final GridBagConstraints constraints = new GridBagConstraints();
92-
constraints.insets= new Insets(10,10,0,10);
96+
constraints.insets = new Insets(10, 10, 0, 10);
9397

9498
// region Linker buttons
9599
group1Button = new JButton();
96-
group1Button.setBackground(new Color(135,129,189));
97-
group1Button.setForeground(new Color(187,187,187));
100+
group1Button.setBackground(new Color(135, 129, 189));
101+
group1Button.setForeground(new Color(187, 187, 187));
98102
group1Button.setName("group1");
99-
constraints.insets= new Insets(10,10,0,0);
103+
constraints.insets = new Insets(10, 10, 0, 0);
100104
constraints.ipady = 40;
101105
constraints.weightx = 0.5;
102106
constraints.fill = GridBagConstraints.HORIZONTAL;
103107
constraints.gridx = 0;
104108
constraints.gridy = 0;
105109
contentPane.add(group1Button, constraints);
110+
linkerButtons.put("group1", group1Button);
106111

107112
group2Button = new JButton();
108-
group2Button.setBackground(new Color(255,224,53));
109-
group2Button.setForeground(new Color(187,187,187));
113+
group2Button.setBackground(new Color(255, 224, 53));
114+
group2Button.setForeground(new Color(187, 187, 187));
110115
group2Button.setName("group2");
111-
constraints.insets= new Insets(10,0,0,0);
116+
constraints.insets = new Insets(10, 0, 0, 0);
112117
constraints.weightx = 0.5;
113118
constraints.fill = GridBagConstraints.HORIZONTAL;
114119
constraints.gridx = 1;
115120
constraints.gridy = 0;
116121
contentPane.add(group2Button, constraints);
122+
linkerButtons.put("group2", group2Button);
117123

118124
group3Button = new JButton();
119-
group3Button.setBackground(new Color(137,216,3));
120-
group3Button.setForeground(new Color(187,187,187));
125+
group3Button.setBackground(new Color(137, 216, 3));
126+
group3Button.setForeground(new Color(187, 187, 187));
121127
group3Button.setName("group3");
122-
constraints.insets= new Insets(10,0,0,0);
128+
constraints.insets = new Insets(10, 0, 0, 0);
123129
constraints.weightx = 0.5;
124130
constraints.fill = GridBagConstraints.HORIZONTAL;
125131
constraints.gridx = 2;
126132
constraints.gridy = 0;
127133
contentPane.add(group3Button, constraints);
134+
linkerButtons.put("group3", group3Button);
128135

129136
group4Button = new JButton();
130-
group4Button.setBackground(new Color(254,98,98));
131-
group4Button.setForeground(new Color(187,187,187));
137+
group4Button.setBackground(new Color(254, 98, 98));
138+
group4Button.setForeground(new Color(187, 187, 187));
132139
group4Button.setName("group4");
133-
constraints.insets= new Insets(10,0,0,0);
140+
constraints.insets = new Insets(10, 0, 0, 0);
134141
constraints.weightx = 0.5;
135142
constraints.fill = GridBagConstraints.HORIZONTAL;
136143
constraints.gridx = 3;
137144
constraints.gridy = 0;
138145
contentPane.add(group4Button, constraints);
146+
linkerButtons.put("group4", group4Button);
139147

140148
group5Button = new JButton();
141-
group5Button.setBackground(new Color(45,172,255));
142-
group5Button.setForeground(new Color(187,187,187));
149+
group5Button.setBackground(new Color(45, 172, 255));
150+
group5Button.setForeground(new Color(187, 187, 187));
143151
group5Button.setName("group5");
144-
constraints.insets= new Insets(10,0,0,0);
152+
constraints.insets = new Insets(10, 0, 0, 0);
145153
constraints.weightx = 0.5;
146154
constraints.fill = GridBagConstraints.HORIZONTAL;
147155
constraints.gridx = 4;
148156
constraints.gridy = 0;
149157
contentPane.add(group5Button, constraints);
158+
linkerButtons.put("group5", group5Button);
150159

151160
group6Button = new JButton();
152-
group6Button.setBackground(new Color(255,162,0));
153-
group6Button.setForeground(new Color(187,187,187));
161+
group6Button.setBackground(new Color(255, 162, 0));
162+
group6Button.setForeground(new Color(187, 187, 187));
154163
group6Button.setName("group6");
155-
constraints.insets= new Insets(10,0,0,10);
164+
constraints.insets = new Insets(10, 0, 0, 10);
156165
constraints.weightx = 0.5;
157166
constraints.fill = GridBagConstraints.HORIZONTAL;
158167
constraints.gridx = 5;
159168
constraints.gridy = 0;
160169
contentPane.add(group6Button, constraints);
170+
linkerButtons.put("group6", group6Button);
161171
// endregion
162172

163173
// region Symbol
164174
symbolTextField = new JTextField("MSFT");
165175
symbolTextField.setEditable(true);
166176
symbolTextField.setEnabled(false);
167-
constraints.insets= new Insets(10,10,0,10);
177+
constraints.insets = new Insets(10, 10, 0, 10);
168178
constraints.fill = GridBagConstraints.HORIZONTAL;
169179
constraints.ipady = 10;
170180
constraints.gridx = 0;
@@ -219,7 +229,7 @@ private void createForm() {
219229

220230
messages = new JTextArea();
221231
messages.setVisible(false);
222-
constraints.insets= new Insets(10,10,10,10);
232+
constraints.insets = new Insets(10, 10, 10, 10);
223233
constraints.fill = GridBagConstraints.BOTH;
224234
constraints.weighty = 1;
225235
constraints.gridx = 0;
@@ -331,6 +341,55 @@ private void initForm() {
331341
group4Button.addActionListener(this::toggleLinker);
332342
group5Button.addActionListener(this::toggleLinker);
333343
group6Button.addActionListener(this::toggleLinker);
344+
345+
//GetComponentState
346+
final JSONArray componentStateFields = new JSONArray() {{
347+
put("Finsemble_Linker");
348+
put("symbol");
349+
}};
350+
final JSONObject getComponentStateParam = new JSONObject() {{
351+
put("fields", componentStateFields);
352+
}};
353+
fsbl.getClients().getWindowClient().getComponentState(getComponentStateParam, this::handleGetComponentStateCb);
354+
}
355+
356+
private void handleGetComponentStateCb(JSONObject err, JSONObject res) {
357+
if (err != null) {
358+
LOGGER.log(Level.SEVERE, "Error in handleGetComponentStateCb", err);
359+
} else {
360+
//Set subscribe linker channel
361+
if (res.has("Finsemble_Linker")) {
362+
final JSONArray channelToLink = res.getJSONArray("Finsemble_Linker");
363+
final JSONObject windowIdentifier = fsbl.getClients().getWindowClient().getWindowIdentifier();
364+
for (int i = 0; i < channelToLink.length(); i++) {
365+
try {
366+
String currentChannel = channelToLink.getString(i);
367+
JButton lkrBtn = linkerButtons.get(currentChannel);
368+
fsbl.getClients().getLinkerClient().linkToChannel(currentChannel, windowIdentifier, (error, response) -> {
369+
if (error != null) {
370+
LOGGER.log(Level.SEVERE, String.format("Error linking to channel: %s", currentChannel), err);
371+
} else {
372+
LOGGER.info((String.format("Linked to channel: %s", currentChannel)));
373+
}
374+
});
375+
lkrBtn.setText("X");
376+
lkrBtn.updateUI();
377+
} catch (Exception ex) {
378+
String errorMsg = String.format("Error linking channel %s to group", channelToLink);
379+
LOGGER.log(Level.SEVERE, errorMsg, ex.getMessage());
380+
fsbl.getClients().getLoggerClient().system().error(errorMsg + " cause: " + ex.getMessage());
381+
}
382+
}
383+
}
384+
385+
//Set symbol value
386+
if (res.has("symbol")) {
387+
final String symbol = res.getString("symbol");
388+
if (!symbol.equals("")) {
389+
symbolLabel.setText(symbol);
390+
}
391+
}
392+
}
334393
}
335394

336395
private void handleSymbol(JSONObject err, JSONObject res) {

src/main/java/com/chartiq/finsemble/example/fdc3/InteropServiceExample.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ public void onWindowStateReady(ConnectionEventGenerator from) {
420420
appendMessage("Window window state: READY");
421421
try {
422422
appendMessage("Registering with InteropService...");
423+
// Added this to allow for Finsemble to send the correct active descriptors.
424+
// Seems that we have a bug that the onReady event gets fired before the
425+
// activeDescriptors object gets updated
426+
Thread.sleep(200);
423427
registerWithInteropService();
424428
} catch (Exception e) {
425429
e.printStackTrace();

src/main/java/com/chartiq/finsemble/example/fdc3/InteropServiceExampleApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void start(Stage primaryStage) {
9595
final VBox anchorPane = loader.load();
9696
LOGGER.info("Parent loaded from resource");
9797
primaryStage.setTitle("InteropServiceExampleApplication");
98-
primaryStage.setResizable(false);
98+
primaryStage.setResizable(true);
9999
final Scene scene = new Scene(anchorPane, 265, 400);
100100

101101
LOGGER.info("Scene created");

src/main/resources/com/chartiq/finsemble/example/InteropService.fxml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
<?import javafx.scene.shape.Circle?>
1414
<?import javafx.scene.text.Font?>
1515

16+
<?import javafx.scene.control.ScrollPane?>
1617
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.chartiq.finsemble.example.fdc3.InteropServiceExample">
1718
<children>
19+
<ScrollPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
20+
<content>
1821
<SplitPane dividerPositions="0.6" prefHeight="803.0" prefWidth="1280.0">
1922
<items>
2023
<AnchorPane fx:id="controlsPanel" minHeight="0.0" minWidth="0.0" prefHeight="798.0" prefWidth="454.0" style="-fx-background-color: #22262f;">
@@ -163,5 +166,7 @@
163166
</AnchorPane>
164167
</items>
165168
</SplitPane>
169+
</content>
170+
</ScrollPane>
166171
</children>
167172
</VBox>

0 commit comments

Comments
 (0)