Our Finsemble Java Repository contains four example Java applications:
Here is a sample configuration to use the Java Example project with the Finsemble seed project:
"Java Example (local)": {
"window": {
"id": "JavaExample",
"windowType": "native",
"path": "Path to FinsembleJavaFXExample.jar",
"url": "",
"arguments": "",
"defaultHeight": 600,
"autoShow": true,
"alwaysOnTop": false,
"resizable": true,
"showTaskbarIcon": false,
"addToWorkspace": true
},
"component": {
"spawnOnStartup": false
},
"foreign": {
"services": {
"workspaceService": {
"isArrangable": true
}
},
"components": {
"App Launcher": {
"launchableByUser": true
},
"Window Manager": {
"persistWindowState": false,
"FSBLHeader": true
},
"Toolbar": {
"iconURL": "$applicationRoot/assets/img/example.png"
}
}
}
},
The Finsemble window title bar has not been implemented in Java, but examples have been provided for implementing the linker and grouping functionality in Java. Java windows can participate in snapping and docking, linking and drag and drop data sharing.
When data to be shared in Finsemble is dragged, a scrim should displayed on top of all components denoting whether or
not the component can receive that data. You must create a control that occupies the entire space of the component, sits
on top of all other controls, and is hidden. This is the control that will accept the dragged data from other
components. In order to keep the implementation UI agnostic, the addWindowHighlight
and removeWindowHighlight
callbacks are provided to trigger when the scrim should be shown. Here is how to provide this control to Finsemble:
private void addWindowHighlight(JSONObject err, JSONObject res) {
Platform.runLater(() -> {
fxScrim = new HBox();
fxScrim.setId("scrim");
fxScrim.setMinWidth(window.getWidth());
fxScrim.setMinHeight(window.getHeight());
boolean canReceiveData = res.getBoolean("canReceiveData");
if (canReceiveData) {
fxScrim.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 99, 0.5), CornerRadii.EMPTY, Insets.EMPTY)));
fxScrim.setOnDragOver((DragEvent dragEvent) -> {
dragEvent.acceptTransferModes(TransferMode.COPY_OR_MOVE);
});
fxScrim.setOnDragDropped((DragEvent dragEvent) -> {
final Dragboard db = dragEvent.getDragboard();
final String dragDataStr = db.getString();
final JSONObject dragDataJson = new JSONObject(dragDataStr);
fsbl.getClients().getDragAndDropClient().drop(dragDataJson);
});
} else
fxScrim.setBackground(new Background(new BackgroundFill(Color.rgb(99, 0, 0, 0.5), CornerRadii.EMPTY, Insets.EMPTY)));
((Pane) window.getScene().getRoot()).getChildren().add(fxScrim);
});
}
private void removeWindowHighlight(JSONObject err, JSONObject res) {
Platform.runLater(() -> {
((Pane) window.getScene().getRoot()).getChildren().remove(fxScrim);
});
}
The main window of the
Authentication Example application
needs to be initialized. Once the user is authenticated, you need to call publishAuthorization
:
fsbl.getClients().getAuthenticationClient().publishAuthorization(userName, credentials);
If your application requires credentials from Finsemble, you can call getCurrentCredentials
:
fsbl.getClients().getAuthenticationClient().getCurrentCredentials((err, res) -> {});
You can also have Java applications that do not display a window to interoperate with other components via the Router. This allows for the integration of a Java application as a service within Finsemble. An example of such an integration is provided in the Headless Java Example.
Desktop services created from Java applications currently need to be added to the Finsemble component configuration and will always be started after all other services have been initialized. To add a Java service (i.e., windowless component) to Finsemble, add it to the appd.json file as normal and ensure that you set:
window.windowType
to "native"
window.name
field to help you identify the component in the Central Loggerwindow.autoShow
to false
as no window should be displayedwindow.addToWorkspace
to false
to disable any state capture and lifecycle eventscomponent.spawnOnStartup
to true
to ensure that the component is auto-startedforeign.components["App Launcher"].launchableByUser
to false
to stop the component appearing in the launcher menuThe component may be launched using a path
or alias
and can be passed arguments
in the same way as any other
native component.
For example:
"JavaHeadlessExample": {
"window": {
"id": "Windowless",
"name": "winlessSeed",
"windowType": "native",
"alias": "javaHeadlessExample",
"arguments": "arg1 arg2 arg3",
"autoShow": false,
"addToWorkspace": false
},
"component": {
"spawnOnStartup": true
},
"foreign": {
"components": {
"App Launcher": {
"launchableByUser": false
}
}
}
}
The basics of integrating native components is covered in this tutorial.
For information about authentication, check out the Authentication tutorial.
Understanding how the Linker Client and Drag and Drop Client work is important for understanding this tutorial.