Search in sources :

Example 71 with FXMLLoader

use of javafx.fxml.FXMLLoader in project TrayNotification by PlusHaze.

the class TrayNotification method initTrayNotification.

private void initTrayNotification(String title, String message, NotificationType type) {
    try {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/tray/views/TrayNotification.fxml"));
        fxmlLoader.setController(this);
        fxmlLoader.load();
        initStage();
        initAnimations();
        setTray(title, message, type);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader)

Example 72 with FXMLLoader

use of javafx.fxml.FXMLLoader in project Smartcity-Smarthouse by TechnionYP5777.

the class SensorConfigurationController method initialize.

@Override
public void initialize(final URL location, final ResourceBundle __) {
    nameColumn.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().getName()));
    typeColumn.setCellValueFactory(cellData -> new ReadOnlyStringWrapper(cellData.getValue().getType().getFieldDescription()));
    deleteColumn.setCellValueFactory(param -> new SimpleBooleanProperty(param.getValue() != null));
    deleteColumn.setCellFactory(p -> {
        final ButtonCell $ = new ButtonCell();
        $.setAlignment(Pos.CENTER);
        return $;
    });
    backButton.setOnAction(__1 -> mainController.loadSensorList());
    HBox.setHgrow(addNameField, Priority.ALWAYS);
    HBox.setHgrow(addTypeField, Priority.ALWAYS);
    HBox.setHgrow(saveButton, Priority.ALWAYS);
    addTypeField.setPromptText("Sensor Type");
    addTypeField.getItems().addAll(Types.values());
    final int btnCount = buttonBox.getChildren().size();
    addNameField.prefWidthProperty().bind(buttonBox.widthProperty().divide(btnCount));
    addTypeField.prefWidthProperty().bind(buttonBox.widthProperty().divide(btnCount));
    saveButton.prefWidthProperty().bind(buttonBox.widthProperty().divide(btnCount));
    saveButton.setOnAction(__1 -> addField());
    deleteButton.setOnAction(__1 -> {
        mainController.removeSensor(currentSensor);
        mainController.loadSensorList();
    });
    messageButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(final ActionEvent __1) {
            try {
                final FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("message_ui.fxml"));
                final Parent root1 = (Parent) fxmlLoader.load();
                ((MessageViewController) fxmlLoader.getController()).setCurrentSensor(currentSensor);
                final Stage stage = new Stage();
                stage.setScene(new Scene(root1));
                stage.show();
            } catch (final Exception $) {
                System.out.println($);
            }
        }
    });
}
Also used : SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) ReadOnlyStringWrapper(javafx.beans.property.ReadOnlyStringWrapper) Parent(javafx.scene.Parent) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader)

Example 73 with FXMLLoader

use of javafx.fxml.FXMLLoader in project Smartcity-Smarthouse by TechnionYP5777.

the class SensorListViewController method enterSensorConfig.

private void enterSensorConfig(final SensorData d) {
    if (d == null)
        return;
    final FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("sensor_configuration_ui.fxml"));
    try {
        JavaFxHelper.placeNodeInPane(fxmlLoader.load(), mainController.sidePane);
    } catch (final IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    final SensorConfigurationController controller = fxmlLoader.getController();
    controller.setSensor(d).setMainController(mainController);
}
Also used : IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader)

Example 74 with FXMLLoader

use of javafx.fxml.FXMLLoader in project Smartcity-Smarthouse by TechnionYP5777.

the class SimulatorController method loadSensorList.

public void loadSensorList() {
    final FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("sensors_list_ui.fxml"));
    try {
        JavaFxHelper.placeNodeInPane(fxmlLoader.load(), sidePane);
    } catch (final IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    tableController = fxmlLoader.getController();
    tableController.setMainController(this).setData(sensors);
}
Also used : IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader)

Example 75 with FXMLLoader

use of javafx.fxml.FXMLLoader in project Smartcity-Smarthouse by TechnionYP5777.

the class SystemPresenter method createChildPresenter.

private PresenterInfo createChildPresenter(final URL fxmlLocation) throws Exception {
    final FXMLLoader loader = new FXMLLoader(fxmlLocation);
    loader.setControllerFactory(param -> {
        try {
            final SystemPresenter p = (SystemPresenter) param.newInstance();
            p.systemCore = getModel();
            p.parent = this;
            return p;
        } catch (final Exception e) {
            log.error("Couldn't start child controller", e);
        }
        return null;
    });
    return loadPresenter(loader);
}
Also used : FXMLLoader(javafx.fxml.FXMLLoader)

Aggregations

FXMLLoader (javafx.fxml.FXMLLoader)113 IOException (java.io.IOException)67 Scene (javafx.scene.Scene)37 Parent (javafx.scene.Parent)33 Stage (javafx.stage.Stage)28 URL (java.net.URL)24 FXML (javafx.fxml.FXML)24 Pane (javafx.scene.layout.Pane)24 ActionEvent (javafx.event.ActionEvent)18 AnchorPane (javafx.scene.layout.AnchorPane)18 ResourceBundle (java.util.ResourceBundle)16 BorderPane (javafx.scene.layout.BorderPane)16 Initializable (javafx.fxml.Initializable)14 JFXButton (com.jfoenix.controls.JFXButton)13 StackPane (javafx.scene.layout.StackPane)13 KeyFrame (javafx.animation.KeyFrame)12 Timeline (javafx.animation.Timeline)12 Duration (javafx.util.Duration)12 Level (java.util.logging.Level)11 Logger (java.util.logging.Logger)11