Search in sources :

Example 1 with CleaningEntry

use of com.github.drbookings.ui.CleaningEntry in project drbookings by DrBookings.

the class BookingDetailsController method addRowFees.

private void addRowFees(final Pane content, final BookingBean be) {
    final HBox box = new HBox();
    // configure box
    box.setSpacing(8);
    box.setPadding(boxPadding);
    box.setAlignment(Pos.CENTER);
    box.setFillHeight(true);
    // add cleaning fees
    final TextField cleaningFeesTextField = new TextField();
    Bindings.bindBidirectional(cleaningFeesTextField.textProperty(), be.cleaningFeesProperty(), new NumberStringConverter(decimalFormat));
    cleaningFeesTextField.setPrefWidth(prefTextInputFieldWidth);
    final TextFlow cleaningFeesTextFlow = new TextFlow(new Text("Cleaning Fees: "), cleaningFeesTextField, new Text(" €"));
    box.getChildren().add(cleaningFeesTextFlow);
    // add cleaning costs
    final CleaningEntry ce = be.getCleaning();
    if (ce != null) {
        final TextField cleaningCostsTextField = new TextField();
        Bindings.bindBidirectional(cleaningCostsTextField.textProperty(), ce.cleaningCostsProperty(), new NumberStringConverter(decimalFormat));
        cleaningCostsTextField.setPrefWidth(prefTextInputFieldWidth);
        final TextFlow cleaningCostsTextFlow = new TextFlow(new Text("Cleaning Costs: "), cleaningCostsTextField, new Text(" €"));
        box.getChildren().add(cleaningCostsTextFlow);
    } else {
        final TextField cleaningCostsTextField = new TextField("No Cleaning");
        cleaningCostsTextField.setEditable(false);
        cleaningCostsTextField.setPrefWidth(prefTextInputFieldWidth);
        final TextFlow cleaningCostsTextFlow = new TextFlow(new Text("Cleaning Costs: "), cleaningCostsTextField);
        cleaningCostsTextField.getStyleClass().add("warning");
        box.getChildren().add(cleaningCostsTextFlow);
    }
    // add service fees
    final TextField serviceFeesTextField = new TextField();
    Bindings.bindBidirectional(serviceFeesTextField.textProperty(), be.serviceFeeProperty(), new NumberStringConverter(decimalFormat));
    serviceFeesTextField.setPrefWidth(prefTextInputFieldWidth);
    final TextFlow serviceFeesAbsTextFlow = new TextFlow(new Text("Service Fees: "), serviceFeesTextField, new Text(" €"));
    box.getChildren().add(serviceFeesAbsTextFlow);
    // add service fees percent
    final TextField serviceFeesPercentTextField = new TextField();
    Bindings.bindBidirectional(serviceFeesPercentTextField.textProperty(), be.serviceFeesPercentProperty(), new NumberStringConverter(decimalFormat));
    serviceFeesPercentTextField.setPrefWidth(prefTextInputFieldWidth);
    final TextFlow serviceFeesPercentTextFlow = new TextFlow(new Text("Service Fees: "), serviceFeesPercentTextField, new Text(" %"));
    box.getChildren().add(serviceFeesPercentTextFlow);
    // add box to parent
    content.getChildren().add(box);
}
Also used : HBox(javafx.scene.layout.HBox) NumberStringConverter(javafx.util.converter.NumberStringConverter) CleaningEntry(com.github.drbookings.ui.CleaningEntry) TextFlow(javafx.scene.text.TextFlow) Text(javafx.scene.text.Text)

Example 2 with CleaningEntry

use of com.github.drbookings.ui.CleaningEntry in project drbookings by DrBookings.

the class CleaningPlanController method handleActionCopySelected.

@FXML
private void handleActionCopySelected(final ActionEvent event) {
    final List<CleaningEntry> selection = content.getSelectionModel().getSelectedItems();
    final StringBuilder sb = new StringBuilder();
    final String roomNamePrefix = SettingsManager.getInstance().getRoomNamePrefix();
    for (final Iterator<CleaningEntry> it = selection.iterator(); it.hasNext(); ) {
        final CleaningEntry ce = it.next();
        sb.append(CleaningPlanController.DATE_FORMATTER.format(ce.getDate()));
        sb.append("\t");
        sb.append(roomNamePrefix);
        sb.append(ce.getRoom().getName());
        if (ce.isShortTime()) {
            sb.append("\t");
            sb.append("bis 1600");
        }
        if (it.hasNext()) {
            sb.append("\n");
        }
    }
    final ClipboardContent content = new ClipboardContent();
    content.putString(sb.toString());
    Clipboard.getSystemClipboard().setContent(content);
    final Tooltip t = new Tooltip("Content copied.");
    t.setAutoHide(true);
    t.setX(this.content.getScene().getWindow().getX() + this.content.getScene().getWindow().getWidth() - this.content.getScene().getWindow().getWidth() / 2);
    t.setY(this.content.getScene().getWindow().getY() + this.content.getScene().getWindow().getHeight() - this.content.getScene().getWindow().getHeight() / 2);
    t.show(this.content.getScene().getWindow());
}
Also used : ClipboardContent(javafx.scene.input.ClipboardContent) CleaningEntry(com.github.drbookings.ui.CleaningEntry) Tooltip(javafx.scene.control.Tooltip) FXML(javafx.fxml.FXML)

Example 3 with CleaningEntry

use of com.github.drbookings.ui.CleaningEntry in project drbookings by DrBookings.

the class UpcomingController method addEvents.

private void addEvents(final LocalDate date, final Collection<BookingEntry> upcomingBookings, final Collection<CleaningEntry> upcomingCleanings) {
    final VBox box = new VBox(4);
    if (date.equals(LocalDate.now())) {
        box.getStyleClass().add("first-day");
    } else if (date.equals(LocalDate.now().plusDays(1))) {
        box.getStyleClass().add("second-day");
    } else if (date.isAfter(LocalDate.now().plusDays(1))) {
        box.getStyleClass().add("later");
    }
    if (upcomingBookings.stream().filter(b -> b.isCheckIn() || b.isCheckOut()).collect(Collectors.toList()).isEmpty() && upcomingCleanings.isEmpty()) {
        final Text t0 = new Text(getDateString(date));
        final Text t1 = new Text(" there are no events.");
        t0.getStyleClass().add("emphasis");
        final TextFlow tf = new TextFlow();
        tf.getChildren().addAll(t0, t1);
        box.getChildren().addAll(tf);
    } else {
        final List<CheckInOutDetails> checkInNotes = Collections.synchronizedList(new ArrayList<>());
        final List<CheckInOutDetails> checkOutNotes = Collections.synchronizedList(new ArrayList<>());
        upcomingBookings.forEach(b -> {
            if (b.isCheckIn()) {
                String note = "";
                if (b.getElement().getCheckInNote() != null) {
                    note = b.getElement().getCheckInNote();
                }
                if (b.getElement().getSpecialRequestNote() != null) {
                    note = note + "\n" + b.getElement().getSpecialRequestNote();
                }
                checkInNotes.add(new CheckInOutDetails(b.getRoom().getName(), b.getElement().getBookingOrigin().getName(), note));
            } else if (b.isCheckOut()) {
                checkOutNotes.add(new CheckInOutDetails(b.getRoom().getName(), b.getElement().getBookingOrigin().getName(), b.getElement().getCheckOutNote()));
            }
        });
        Collections.sort(checkInNotes);
        Collections.sort(checkOutNotes);
        addGeneralSummary(date, box, checkInNotes);
        addCheckOutSummary(date, box, checkOutNotes);
        addCheckOutNotes(date, box, checkOutNotes);
        addCheckInSummary(date, box, checkInNotes);
        addCheckInNotes(date, box, checkInNotes);
        addCleaningSummary(date, box, upcomingCleanings);
        addCleanings(date, box, upcomingCleanings);
    }
    this.box.getChildren().add(box);
}
Also used : Initializable(javafx.fxml.Initializable) Logger(org.slf4j.Logger) URL(java.net.URL) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) MainManager(com.github.drbookings.model.data.manager.MainManager) TextFlow(javafx.scene.text.TextFlow) VBox(javafx.scene.layout.VBox) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) DateBean(com.github.drbookings.ui.beans.DateBean) ArrayList(java.util.ArrayList) SettingsManager(com.github.drbookings.model.settings.SettingsManager) FXML(javafx.fxml.FXML) Separator(javafx.scene.control.Separator) Text(javafx.scene.text.Text) List(java.util.List) ResourceBundle(java.util.ResourceBundle) ListChangeListener(javafx.collections.ListChangeListener) LocalDate(java.time.LocalDate) CleaningEntry(com.github.drbookings.ui.CleaningEntry) BookingEntry(com.github.drbookings.ui.BookingEntry) Collections(java.util.Collections) Text(javafx.scene.text.Text) TextFlow(javafx.scene.text.TextFlow) VBox(javafx.scene.layout.VBox)

Example 4 with CleaningEntry

use of com.github.drbookings.ui.CleaningEntry in project drbookings by DrBookings.

the class CleaningEntryTest method testEqualsHashCode01.

@Test
public void testEqualsHashCode01() {
    final CleaningEntry ce1 = new CleaningEntry(LocalDate.now(), TestUtils.getTestBooking("tt"), new Cleaning("testCleaning"), null);
    final CleaningEntry ce2 = new CleaningEntry(LocalDate.now(), TestUtils.getTestBooking("tt"), new Cleaning("testCleaning"), null);
    assertEquals(ce1.hashCode(), ce2.hashCode());
    assertEquals(ce1, ce2);
}
Also used : CleaningEntry(com.github.drbookings.ui.CleaningEntry) Cleaning(com.github.drbookings.model.data.Cleaning) Test(org.junit.Test)

Example 5 with CleaningEntry

use of com.github.drbookings.ui.CleaningEntry in project drbookings by DrBookings.

the class UpcomingController method addCleanings.

private static void addCleanings(final LocalDate date, final VBox box, final Collection<CleaningEntry> upcomingBookings) {
    for (final CleaningEntry c : upcomingBookings) {
        final TextFlow tf = new TextFlow();
        final Text t0 = new Text("Room " + c.getRoom() + ": ");
        t0.getStyleClass().add("emphasis");
        final Text t1 = new Text(c.getName());
        tf.getChildren().addAll(t0, t1);
        box.getChildren().add(tf);
    }
}
Also used : CleaningEntry(com.github.drbookings.ui.CleaningEntry) TextFlow(javafx.scene.text.TextFlow) Text(javafx.scene.text.Text)

Aggregations

CleaningEntry (com.github.drbookings.ui.CleaningEntry)9 Text (javafx.scene.text.Text)4 TextFlow (javafx.scene.text.TextFlow)4 Cleaning (com.github.drbookings.model.data.Cleaning)3 FXML (javafx.fxml.FXML)3 MainManager (com.github.drbookings.model.data.manager.MainManager)2 SettingsManager (com.github.drbookings.model.settings.SettingsManager)2 BookingEntry (com.github.drbookings.ui.BookingEntry)2 DateBean (com.github.drbookings.ui.beans.DateBean)2 URL (java.net.URL)2 LocalDate (java.time.LocalDate)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 List (java.util.List)2 ResourceBundle (java.util.ResourceBundle)2 Collectors (java.util.stream.Collectors)2 ListChangeListener (javafx.collections.ListChangeListener)2 Initializable (javafx.fxml.Initializable)2 Separator (javafx.scene.control.Separator)2