JavaFX UI API Provider - IScellUiFxApiProvider (IScellUiApiProvider<Node>)

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

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

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

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

public interface IScellUiFxApiProvider extends IScellUiApiProvider<Node> {
}

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

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

public class CustomerExamples {
    private static final CompletableFuture<Optional<IScellApiResolver>> apiResolverFuture = ScellApiProvider.getApiResolverAsync();

    public static void main(String[] args) {
        apiResolverFuture.thenAccept(apiResolverOpt -> apiResolverOpt.ifPresent(apiResolver -> {

            IScellUiApiProvider<Node> uiApiProvider = apiResolver.resolve(IScellUiFxApiProvider.class);   // UI API entry point

        })).join();
    }
}

The IScellUiApiProvider 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)
  • enableContextMenu(boolean value) - if false, SCell UI component will be without context menu, by default - false
  • 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.ui.fx.IScellUiApi;
import com.intechcore.scomponents.scell.api.ui.fx.IScellUiApiProvider;
import com.intechcore.scomponents.scell.api.ui.fx.IScellUiFxApiProvider;
import com.intechcore.scomponents.scell.api.spreadsheet.ISpreadsheetApiProvider;

import javafx.scene.Node;

public class CustomerExamples {
    private static final CompletableFuture<Optional<IScellApiResolver>> apiResolverFuture = ScellApiProvider.getApiResolverAsync();

    public static void main(String[] args) {
        apiResolverFuture.thenAccept(apiResolverOpt -> apiResolverOpt.ifPresent(apiResolver -> {

            ISpreadsheetApiProvider coreApiProvider = apiResolver.resolve(ISpreadsheetApiProvider.class); // Core API entry point
            IScellUiApiProvider<Node> uiApiProvider = apiResolver.resolve(IScellUiFxApiProvider.class);   // UI API entry point

            CompletableFuture<IWorkbook> coreApi = coreApiProvider.createNew();                           // create a new spreadsheet (you can make load() here too)

            IScellUiApi<Node> uiApi = uiApiProvider
                    .enableContextMenu(false)                                                              // configure to turn off the context menu
                    .create(coreApi);                                                                      // build the UI entry point

        })).join();
    }
}

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

ISpreadsheetApiProvider - IWorkbook creation, getting API info