IScellUiFxApiBuilder<Node>

The interface IScellUiApiBuilder<TControl> is used to create SCell spreadsheet UI component.

The IScellUiApiBuilder is designed as generic interface, which makes it possible to have identical implementations for different UI frameworks - JavaFX, Swing, etc.

At the moment SCell API supports only JavaFX component - IScellUiApiBuilder<Node> where Node is the JavaFX abstract parent of all the UI controls.

Due to the limits of Java, we had to create an empty non-generic child interface IScellUiFxApiBuilder to resolve the IScellUiApiBuilder<Node>:

public interface IScellUiFxApiBuilder extends IScellUiApiBuilder<Node> {
}

This interface helps to resolve the implementation of IScellUiApiBuilder<Node> by our dependency container.

In other words, the IScellUiApiBuilder<Node> can be consumed in the following way:

import com.intechcore.scomponents.scell.api.init.ScellApiEntryPoint;
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.stage.Stage;

public class TestAppUi extends Application {
    @Override
    public void start(Stage primaryStage) {
        ScellApiEntryPoint.getApiResolverAsync().thenAcceptAsync(resolver -> {

            IScellUiApiBuilder<Node> uiBuilder = resolver.resolve(IScellUiFxApiBuilder.class);
            // ...
        }, Platform::runLater);
    }
}

The IScellUiApiBuilder implements the pattern Builder and can be configured in the common way with the following calls:

  • readOnly(boolean value) - sets the SCell UI component to read-only mode, forbidding the changes of the content, by default - false (business license)
  • enableUndoRedo(boolean value) - enables/disables the undo/redo function of the SCell UI component, by default - true (business license)
  • enableContextMenu(ContextMenuOwner target, boolean value) - enables/disables the SCell UI component corresponding context menu (grids, tabs or editing cells), by default - false (business license)
  • setForegroundAccentColor(IColor value) - adjusts the colors of the spreadsheet controls to match the host UI application
  • inputBarVisible(boolean value) - sets the visibility of the top input formula bar, by default - true (business license)
  • gridVisible(boolean value) - sets the visibility of the gray grid lines, by default - true (business license)
  • verticalScrollbarVisible(boolean value) - sets the visibility of the vertical scroll bar, by default - true (business license)
  • horizontalScrollbarVisible(boolean value) - sets the visibility of the horizontal scroll bar, by default - true (business license)

After calling any number of configurations the create(IWorkbook coreApi) must be called to get the main purpose - IScellUiApi<TControl> (only with JavaFX's Node as generic parameter):

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 com.intechcore.scomponents.scell.api.init.ScellApiEntryPoint;
import com.intechcore.scomponents.scell.api.spreadsheet.IScellCoreApiFactory;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

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
                    .readOnly(false)
                    .create(apiFactory.createNew());
            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();
    }
}

Also, there is possibility to change the above-described settings (enable context menu, hide input bar, etc.) at runtime. To do this, use the IUiControlSettings interface.

Next (IScellUiApi<TControl> - Spreadsheet UI entry point)

See also

IUiControlSettings - changing UI control at runtime

IScellCoreApiFactory - IWorkbook creation, getting API info