Example usage for javafx.scene.control SplitPane setMaxWidth

List of usage examples for javafx.scene.control SplitPane setMaxWidth

Introduction

In this page you can find the example usage for javafx.scene.control SplitPane setMaxWidth.

Prototype

public final void setMaxWidth(double value) 

Source Link

Usage

From source file:poe.trade.assist.Main.java

@Override
public void start(Stage stage) {
    //      try {
    //         fh = new FileHandler("D:\\MxDownload\\POE\\poe.trade.assist\\assist.log");
    //      } catch (IOException e) {
    //         e.printStackTrace();
    //      }/*from  w  w w. jav a  2s .c o m*/
    //      logger.addHandler(fh);
    //      SimpleFormatter formatter = new SimpleFormatter();
    //      fh.setFormatter(formatter);
    //      logger.info("Init application.");

    BorderPane root = new BorderPane();

    config = Config.load();
    config.get(Config.SEARCH_FILE).ifPresent(searchFileTextField::setText);

    searchFileTextField.setPromptText("Search CSV File URL or blank");
    searchFileTextField.setTooltip(new Tooltip(
            "Any url to a valid poe.trade.assist CSV search file. Can be googlespreadsheet URL. If left blank, will load search.csv file instead"));
    searchFileTextField.setMinWidth(330);
    HBox.setHgrow(searchFileTextField, Priority.ALWAYS);

    List<Search> searchList = loadSearchListFromFile();

    AutoSearchService autoSearchService = new AutoSearchService(
            Boolean.parseBoolean(config.get(Config.AUTO_ENABLE).get()),
            Float.parseFloat(config.get(Config.SEARCH_MINUTES).get()));
    searchPane = new SearchPane(searchList);
    resultPane = new ResultPane(searchFileTextField, this);

    autoSearchService.searchesProperty().bind(searchPane.dataProperty());

    EventHandler<ActionEvent> reloadAction = e -> {
        System.out.println("Loading search file: " + searchFileTextField.getText());
        List<Search> newList = loadSearchListFromFile();
        searchPane.dataProperty().clear();
        searchPane.dataProperty().addAll(newList);
        autoSearchService.restart();
        if (searchPane.dataProperty().size() > 0)
            searchPane.searchTable.getSelectionModel().select(0);
    };

    searchFileTextField.setOnAction(reloadAction);
    resultPane.loadButton.setOnAction(reloadAction);
    resultPane.defaultButton.setOnAction(e -> {
        searchFileTextField.setText(DEFAULT_SEARCH_CSV_FILE);
        resultPane.loadButton.fire();
    });

    resultPane.runNowButton.setOnAction(e -> autoSearchService.restart());
    //        autoSearchService.minsToSleepProperty().bind(resultPane.noOfMinsTextField.textProperty());
    setupResultPaneBinding(searchPane, resultPane, autoSearchService);
    if (searchList.size() > 0)
        searchPane.searchTable.getSelectionModel().select(0);

    stage.setOnCloseRequest(we -> {
        saveSearchList(searchPane);
        config.setProperty(Config.SEARCH_FILE, searchFileTextField.getText());
        config.setProperty(Config.SOUND_FILE, resultPane.soundButton.getUserData().toString());
        config.save();
    });

    config.get(Config.SOUND_FILE).ifPresent(resultPane.soundButton::setUserData);

    autoSearchService.restart();

    //        HBox container = new HBox(5, searchPane, resultPane);
    SplitPane container = new SplitPane(searchPane, resultPane);
    container.setDividerPositions(0.1);
    HBox.setHgrow(searchPane, Priority.ALWAYS);
    HBox.setHgrow(resultPane, Priority.ALWAYS);
    container.setMaxWidth(Double.MAX_VALUE);
    //        root.getChildren().addAll(container);
    root.setCenter(container);
    Scene scene = new Scene(root);
    stage.getIcons().add(new Image("/48px-Durian.png"));
    stage.titleProperty().bind(new SimpleStringProperty("poe.trade.assist v5 (Durian) - ")
            .concat(autoSearchService.messageProperty()));
    //        stage.setWidth(1200);
    //        stage.setHeight(550);
    stage.setMaximized(true);
    stage.setScene(scene);
    stage.show();
    searchPane.searchTable.requestFocus();
}