IUiControlSettings - Changing UI at runtime

IUiControlSettings - interface to change some UI control settings at runtime.

Possibilities

  • boolean isContextMenuEnabled() - return true if SCell UI currently has context menus
  • void setContextMenuEnabled(boolean value) - enable/disable all SCell UI context menus
  • boolean isReadOnly() - return true if SCell UI currently is read-only (business license)
  • void setReadOnly(boolean value) - set SCell UI read-only at runtime (business license)
  • boolean isInputBarVisible() - return true if SCell UI formula input bar is visible (business license)
  • void setInputBarVisibility(boolean value) - show/hide the formula input bar of the SCell UI (business license)
  • boolean isGridVisible() - return true if SCell UI currently displays grid lines (business license)
  • void setGridVisibility(boolean value) - show/hide grid lines (business license)
  • boolean isVerticalScrollbarVisible() - return true if SCell UI currently show vertical scroll bar (business license)
  • void setVerticalScrollbarVisibility(boolean value) - show/hide vertical scroll bar (business license)
  • boolean isHorizontalScrollbarVisible() - return true if SCell UI currently show horizontal scroll bar (business license)
  • void setHorizontalScrollbarVisibility(boolean value) - show/hide horizontal scroll bar (business license)

Usage example

import com.intechcore.scomponents.scell.api.IScellApiResolver;
import com.intechcore.scomponents.scell.api.ScellApiProvider;
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.IUiControlSettings;
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);

            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

            IUiControlSettings uiControlSettings = uiApi.getSettingsService();// Getting the selection manager

            // Enable/disable context menus example
            Button disableContextMenusButton = new Button();
            disableContextMenusButton.setOnAction(event -> {
                disableContextMenusButton.setDisable(true);
                
                boolean isContextMenusEnabled = uiControlSettings.isContextMenuEnabled(); // Reads context menu state

                uiControlSettings.setContextMenuEnabled(!isContextMenusEnabled)           // Enable/disable context menus of the SCell UI control
                        .thenRun(() -> disableContextMenusButton.setDisable(false));
            });
            someRootPane.getChildren().add(disableContextMenusButton);
        });
        // ...
    }

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

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

See also

IUiContentManager - Changing current UI content

IUiSelectionManager - Current selection manager