IScellUiFxApiBuilder<Node>

To create SCell spreadsheet UI component, there is an interface IScellUiApiBuilder<TControl>.

The IScellUiApiBuilder designed as generic interface to have a possibility to have identical implementations for different UI frameworks - JavaFX, Swing, etc.

Now SCell API supports only JavaFX component - IScellUiApiBuilder<Node> where Node - the JavaFX abstract parent for all the UI controls.

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

public interface IScellUiFxApiBuilder extends IScellUiApiBuilder<Node> {
}

With it, we can resolve implementation of IScellUiApiBuilder<Node> by our dependency container.

Other words, the IScellUiApiBuilder<Node> can be consumed by the following way:

import com.intechcore.scomponents.scell.api.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 pattern Builder and can be configured by known way with the following calls:

  • readOnly(boolean value) - if true, SCell UI component will be read only, without possibility to change the content, by default - false (business license)
  • enableUndoRedo(boolean value) - if false, SCell UI component will be without undo/redo last command functionality, by default - true (business license)
  • enableContextMenu(ContextMenuOwner target, boolean value) - if false, SCell UI component will be without corresponding context menu (grid, tabs or editing cell), by default - false (business license)
  • setForegroundAccentColor(IColor value) - possibility to adjust colors ot the spreadsheet controls to be more consistent with the host UI application
  • inputBarVisible(boolean value) - if false, SCell UI component will be without the top input formula bar, by default - true (business license)
  • gridVisible(boolean value) - if false, SCell UI component will be without gray grid lines, by default - true (business license)
  • verticalScrollbarVisible(boolean value) - if false, SCell UI component will be without vertical scroll bar, by default - true (business license)
  • horizontalScrollbarVisible(boolean value) - if false, SCell UI component will be without horizontal scroll bar, by default - true (business license)

After any number of configure calls it should be called the create(CompletableFuture<IWorkbook> coreApi) to get the main purpose - IScellUiApi<TControl> (only with JavaFX's Node as generic parameter):

import com.intechcore.scomponents.scell.api.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.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));
            return uiApi.createControl();
        }, 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 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