public void change(String userinput, Scene s) {
    String colorName = userinput.substring(userinput.indexOf(" ") + 1);
    if (!ApplicationColor.hasColor(colorName)) return;

    ApplicationColor selectedColor = ApplicationColor.valueOf(colorName.toUpperCase());
    JFXDecorator decorator = (JFXDecorator) s.lookup(".jfx-decorator");
    JFXToolbar toolbar = (JFXToolbar) s.lookup(".jfx-tool-bar");
    Label label = (Label) s.lookup(".icons-badge Label");
    label.setStyle("-fx-text-fill:" + selectedColor.getColorValue() + ";");
    decorator.setStyle("-fx-decorator-color: derive(" + selectedColor.getColorValue() + ",-20%);");
    toolbar.setStyle("-fx-background-color: " + selectedColor.getColorValue() + ";");
  }
 @Test
 public void launchApplication() throws Exception {
   WaitForAsyncUtils.waitForFxEvents();
   ScrollPane scrollPane = (ScrollPane) scene.lookup("#historyScrollPane");
   Parent container = scrollPane.getParent();
   // ScrollPane below a VBox causes the accordion not to scroll correctly
   Assert.assertFalse("ScrollPane inside VBox", (container instanceof VBox) ? true : false);
 }
Example #3
0
  @Override
  public void start(Stage primaryStage) {
    try {
      TabPane page = (TabPane) FXMLLoader.load(Main.class.getResource("simple.fxml"));
      Scene scene = new Scene(page);
      primaryStage.setScene(scene);
      primaryStage.setTitle("Hotels");
      primaryStage.show();

      textf = (TextField) scene.lookup("#HotelNameTextb");
      Button create = (Button) scene.lookup("#CreateButton");
      create.setOnAction(this::handleButtonAction);

    } catch (Exception ex) {
      Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
  @Before
  public final void setUp() {
    scene = stage.getScene();

    controller = (AlarmEditDialogController) getController();
    alarmEnabledCheckbox = (CheckBox) scene.lookup("#alarmEnabledCheckbox");
    alarmDatePicker = (DatePicker) scene.lookup("#alarmDatePicker");
    alarmTimePicker = (TimePicker) scene.lookup("#alarmTimePicker");
    alarmDescriptionTextField = (TextField) scene.lookup("#alarmDescriptionTextField");
    alarmSelectSoundButton = (Button) scene.lookup("#alarmSelectSoundButton");
    alarmNoSoundButton = (Button) scene.lookup("#alarmNoSoundButton");
    alarmPlaySoundButton = (Button) scene.lookup("#alarmPlaySoundButton");
    alarmSaveButton = (Button) scene.lookup("#alarmSaveButton");
  }
  /** Testet das Verwerfen der Änderungen. */
  @Test
  public final void testCancel() {
    controller.setDialogStage(mockedDialogStage);

    // Alarm vorgeben
    final LocalDateTime now = LocalDateTime.now();
    final Alarm alarm = new Alarm(now, "bla");
    controller.setAlarm(alarm);
    FXTestUtils.awaitEvents();

    // deaktivieren
    click(alarmEnabledCheckbox);
    waitForThreads();

    Platform.runLater(
        new Runnable() {
          public void run() {
            // Datum setzen
            alarmDatePicker.setValue(DateTimeUtil.getLocalDateForString("24.12.2014"));

            // Zeit setzen
            alarmTimePicker.setValue(DateTimeUtil.getLocalTimeForString("12:00:00"));

            // Beschreibung setzen
            alarmDescriptionTextField.setText("Test");
          }
        });
    FXTestUtils.awaitEvents();

    // Sound setzen
    controller.setRingtone("Sound");
    FXTestUtils.awaitEvents();

    // Abbrechen-Schaltfläche betätigen
    final Button alarmCancelButton = (Button) scene.lookup("#alarmCancelButton");
    click(alarmCancelButton);
    waitForThreads();

    // sicherstellen, dass Dialog geschlossen worden wäre
    verify(mockedDialogStage, timeout(WAIT_FOR_EVENT)).close();

    // sicherstellen, dass Alarm ursprüngliche Werte hat
    assertTrue(alarm.isEnabled());
    assertEquals(now, alarm.getDateTime());
    assertEquals("bla", alarm.getDescription());
    assertEquals(null, alarm.getSound());
  }
  /** Testet den Zustand der Steuerelemente nach Öffnen des Dialogs. */
  @Test
  public final void testInitialState() {
    final TextField hoursTextField = (TextField) scene.lookup("#hoursTextField");

    // Alarm vorgeben
    controller.setAlarm(
        new Alarm(DateTimeUtil.getLocalDateTimeForString("24.12.2014 12:00:00"), "Test"));
    FXTestUtils.awaitEvents();

    // sicherstellen, dass Formularfelder korrekt gefüllt sind
    assertTrue(alarmEnabledCheckbox.isSelected());
    assertEquals(DateTimeUtil.getLocalDateForString("24.12.2014"), alarmDatePicker.getValue());
    assertEquals(DateTimeUtil.getLocalTimeForString("12:00:00"), alarmTimePicker.getValue());
    assertEquals("12", hoursTextField.getText());
    assertEquals("Test", alarmDescriptionTextField.getText());

    assertEquals("kein Klingelton gewählt", alarmSelectSoundButton.getText());
    assertTrue(alarmNoSoundButton.isDisabled());
    assertTrue(alarmPlaySoundButton.isDisabled());
  }