IUiSelectionManager - Current selection manager

IUiSelectionManager - interface to get or change current selection.

Possibilities

Usage example

import com.intechcore.scomponents.scell.api.IScellApiResolver;
import com.intechcore.scomponents.scell.api.ScellApiProvider;
import com.intechcore.scomponents.scell.api.spreadsheet.service.util.IRangeAddressBuilder;
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 com.intechcore.scomponents.scell.api.ui.fx.control.IUiContentManager;
import com.intechcore.scomponents.scell.api.ui.fx.control.IUiSelectionManager;
import javafx.application.Application;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.stage.Stage;

import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;

public class App extends Application {

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

    private Optional<IScellApiResolver> apiResolver;

    @Override
    public void start(Stage stage) {
        //...
        Pane someRootPane = new Pane();
        // ...
        this.apiResolver.ifPresent(resolver -> {
            // Resolve APIs providers
            ISpreadsheetApiProvider coreProvider = resolver.resolve(ISpreadsheetApiProvider.class);
            IScellUiApiProvider<Node> uiFxApiProvider = resolver.resolve(IScellUiFxApiProvider.class);

            IRangeAddressBuilder addressBuilder = resolver.resolve(IRangeAddressBuilder.class);

            CompletableFuture<IWorkbook> workbook = coreProvider.createNew(); // SCell core API entry point
            IScellUiApi<Node> uiApi = uiFxApiProvider.create(workbook);       // SCell UI API entry point
            Node scellJavaFxNode = uiApi.createControl();                     // SCell UI control
            someRootPane.getChildren().add(scellJavaFxNode);                  // Adding the SCell UI control

            IUiSelectionManager uiSelectionManager = uiApi.getSelectionManager();// Getting the selection manager

            // Set new selection example
            Button setSelectionButton = new Button();
            setSelectionButton.setOnAction(event -> {
                setSelectionButton.setDisable(true);

                uiSelectionManager.setSelection(addressBuilder.setBottomRight(4, 4).buildCell())  // Set new active selection area
                        .thenRun(() -> setSelectionButton.setDisable(false));
            });
            someRootPane.getChildren().add(setSelectionButton);
        });
        // ...
    }

    @Override
    public void init() throws Exception {
        this.apiResolver = apiResolverFuture.join();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Next (IUiControlSettings - Changing UI at runtime)

See also

IUiContentManager - Changing current UI content

IUiSelectionManager - Current selection manager

IRangeAddressBuilder