IUiContentManager - changing current UI content

IUiContentManager - an interface to change the current UI-displayed spreadsheet.

Possibilities

Usage example

import com.intechcore.scomponents.scell.api.init.ScellApiEntryPoint;
import com.intechcore.scomponents.scell.api.spreadsheet.IScellCoreApiFactory;
import com.intechcore.scomponents.scell.api.fx.IScellUiApi;
import com.intechcore.scomponents.scell.api.fx.IScellUiApiBuilder;
import com.intechcore.scomponents.scell.api.fx.IScellUiFxApiBuilder;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

import java.util.concurrent.CompletableFuture;

public class TestAppUi extends Application {
    @Override
    public void start(Stage primaryStage) {
        BorderPane root = new BorderPane(new Label("Initializing ..."));

        ScellApiEntryPoint.getApiResolverAsync().thenApplyAsync(resolver -> {

            IScellCoreApiFactory apiFactory = resolver.resolve(IScellCoreApiFactory.class);

            IScellUiApiBuilder<Node> uiBuilder = resolver.resolve(IScellUiFxApiBuilder.class);

            IScellUiApi<Node> uiApi = uiBuilder.create(CompletableFuture.supplyAsync(apiFactory::createNew));

            // Clear all content example (it is similar to creation a new spreadsheet)
            Button createNewButton = new Button("Create new spreadsheet");
            createNewButton.setOnAction(event -> {
                createNewButton.setDisable(true);

                uiApi.getContentManager().clear() // Clears all the existing content of the SCell UI control
                        .thenRun(() -> createNewButton.setDisable(false));
            });

            root.setTop(createNewButton);
            return uiApi.getControl();
        }, Platform::runLater).whenCompleteAsync((node, throwable) -> {
            if (throwable != null) {
                node = new Label("Failed to init: " + throwable.getCause().getMessage());
            }
            root.setCenter(node);
        }, Platform::runLater);

        primaryStage.setScene(new Scene(root, 800, 600));
        primaryStage.show();
    }
}

Next (IUiSelectionManager - Current selection manager)

See also

IUiControlSettings - Changing UI at runtime

IUiContentManager - Changing current UI content