Example usage for javafx.beans.property ObjectProperty addListener

List of usage examples for javafx.beans.property ObjectProperty addListener

Introduction

In this page you can find the example usage for javafx.beans.property ObjectProperty addListener.

Prototype

void addListener(ChangeListener<? super T> listener);

Source Link

Document

Adds a ChangeListener which will be notified whenever the value of the ObservableValue changes.

Usage

From source file:cz.lbenda.dataman.rc.DatamanApp.java

/** Add node to center pane */
public Tab addToCenter(ObjectProperty<String> title, Node node, boolean closable) {
    Tab tab = addToCenter(title.getValue(), node, closable);
    title.addListener((observable, oldValue, newValue) -> tab.setText(newValue));
    return tab;//from  ww  w  . j a v  a2s.  c  o m
}

From source file:cz.lbenda.dataman.rc.DatamanApp.java

@SuppressWarnings("unchecked")
@Override/* www  . ja  v a 2s.co m*/
public void start(Stage primaryStage) throws Exception {
    StatusHelper.getInstance().setStatusBar(statusBar);
    Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> ExceptionMessageFrmController
            .showException(MessageFactory.getInstance().getMessage("UncaughtException"), throwable));

    ribbon = new Ribbon(MessageFactory.getInstance().getMessage("app.name"),
            IconFactory.getInstance().image(this, "dataman.png", IconFactory.IconLocation.APP_ICON));

    primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("dataman16.png")));
    primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("dataman32.png")));
    primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("dataman48.png")));
    primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("dataman64.png")));
    primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("dataman128.png")));
    primaryStage.setTitle(MessageFactory.getInstance().getMessage("app.name"));

    DbConfigFactory.reloadConfiguration();
    ObjectProperty<DbConfig> currentDbProperty = new SimpleObjectProperty<>();
    ObjectProperty<TableDesc> selectedTableDescProperty = new SimpleObjectProperty<>();

    prepareMainPane();
    ribbon.itemsProperty().addAll(new AddDatabaseHandler(), new ImportDatabaseHandler(),
            new ExportDatabaseHandler(currentDbProperty), new DbConfigMenuOptions(currentDbProperty),
            new ConnectDatabaseHandler(currentDbProperty), new EditDatabaseHandler(currentDbProperty),
            new CopyDatabaseHandler(currentDbProperty), new RemoveDatabaseHandler(currentDbProperty),
            new ReloadDatabaseHandler(currentDbProperty), new RemoveRowsHandler(tableViewObjectProperty),
            new AddRowHandler(tableViewObjectProperty), new ReloadTableHandler(tableViewObjectProperty),
            new SaveTableHandler(tableViewObjectProperty), new SaveAllTableHandler(currentDbProperty),
            new OpenConnectedTablesHandler(tableViewObjectProperty,
                    detailDescriptor -> addRemoveToDetail(detailDescriptor.getTitle(),
                            detailDescriptor.getNode(), detailDescriptor.getClosable())),
            new ExportTableHandler(sqlQueryRowsObjectProperty),
            new ExportTableWithTemplateHandler(sqlQueryRowsObjectProperty), new AboutApplicationHandler());

    Scene scene = new Scene(mainPane);
    te = new SQLEditorController(ribbon::addItem, scene, currentDbProperty, nodeShower);

    addToCenter(SQLEditorController.WINDOW_TITLE, te.getNode(), false);

    Tuple2<Parent, DbTableStructureFrmController> dbTableStructureFrmController = DbTableStructureFrmController
            .createNewInstance();
    addToCenter(DbTableStructureFrmController.WINDOW_TITLE, dbTableStructureFrmController.get1(), false);
    selectedTableDescProperty.addListener(
            (observable, oldValue, newValue) -> dbTableStructureFrmController.get2().setTableDesc(newValue));

    DbStructureFrmController dfc = new DbStructureFrmController(currentDbProperty, td -> new Thread(() -> {
        StatusHelper.getInstance().progressStart(td, DataTableFrmController.TASK_NAME, 2);
        StatusHelper.getInstance().progressNextStep(td, td.getName(), 0);
        DataTableFrmController controller = new DataTableFrmController(td);
        StatusHelper.getInstance().progressNextStep(td, td.getName(), 0);
        Platform.runLater(() -> addToCenter(controller.titleProperty(), controller.getTabView(), true));
        StatusHelper.getInstance().progressFinish(td, DataTableFrmController.STEP_FINISH);
    }).start(), selectedTableDescProperty);
    leftPane.getChildren().add(dfc.getControlledNode());

    RowEditorFrmController rowEditorFrmController = new RowEditorFrmController(tableViewObjectProperty);
    addToRight(RowEditorFrmController.WINDOW_TITLE, rowEditorFrmController.getPane());

    // Scene scene = te.createScene();
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(event -> {
        if (!DialogHelper.getInstance().showUnsavedObjectDialog(SavableRegistry.getInstance())) {
            event.consume();
        }
    });
    primaryStage.show();
    /*
    try {
      // AquaFx.style();
      // FlatterFX.style();
      //AeroFX.style();
    } catch (Exception e) {
      LOG.error("Problem with switch to AquaFx style", e);
    }
    */
}