Skip to content

Commit

Permalink
Added a new "hidden" property to Entry.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemmermann committed Sep 27, 2022
1 parent e4df1c7 commit 0b285d2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
43 changes: 35 additions & 8 deletions CalendarFXView/src/main/java/com/calendarfx/model/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
*
*
* <h2>Recurrence</h2>
*
* <p>
* This class supports the industry standard for defining recurring events (RFC
* 2445). For recurring events the method {@link #setRecurrenceRule(String)}
* must be fed with a valid RRULE string, for example "RRULE:FREQ=DAILY" for an
Expand Down Expand Up @@ -698,7 +698,8 @@ private void updateRecurrenceEndProperty(String newRecurrence) {
try {
Recur<LocalDate> recur = new Recur<>(newRecurrence.replaceFirst("^RRULE:", ""));
setRecurrenceEnd(Objects.requireNonNullElse(recur.getUntil(), LocalDate.MAX));
} catch (IllegalArgumentException | DateTimeParseException e) {
} catch (IllegalArgumentException |
DateTimeParseException e) {
e.printStackTrace();
}
} else {
Expand Down Expand Up @@ -1496,6 +1497,25 @@ private boolean isShowing(Entry<?> entry, LocalDate startDate, LocalDate endDate
return Util.intersect(interval.getStartZonedDateTime(), interval.getEndZonedDateTime(), st, et);
}

private final BooleanProperty hidden = new SimpleBooleanProperty(this, "hidden", false);

public final boolean isHidden() {
return hidden.get();
}

public final BooleanProperty hiddenProperty() {
return hidden;
}

/**
* An entry can be made explicityl hidden.
*
* @param hidden true if the entry should not be visible in the calendar
*/
public final void setHidden(boolean hidden) {
this.hidden.set(hidden);
}

private boolean isRecurrenceShowing(Entry<?> entry, ZonedDateTime st, ZonedDateTime et, ZoneId zoneId) {
String recurrenceRule = entry.getRecurrenceRule().replaceFirst("^RRULE:", "");

Expand Down Expand Up @@ -1580,25 +1600,32 @@ public int hashCode() {
@SuppressWarnings("rawtypes")
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
Entry other = (Entry) obj;
if (id == null) {
if (other.id != null)
if (other.id != null) {
return false;
} else if (!id.equals(other.id))
}
} else if (!id.equals(other.id)) {
return false;
}

String recId = getRecurrenceId();
String otherRecId = other.getRecurrenceId();

if (recId == null) {
return otherRecId == null;
} else return recId.equals(otherRecId);
}

return recId.equals(otherRecId);
}

private static final String ENTRY_CATEGORY = "Entry";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,24 @@ private void bindEntry(Entry<?> entry) {
private void bindVisibility() {
Entry<?> entry = getEntry();
T dateControl = getDateControl();

if (entry != null && dateControl != null) {
Calendar calendar = entry.getCalendar();

if (calendar != null) {
BooleanBinding binding = Bindings.and(dateControl.getCalendarVisibilityProperty(calendar), Bindings.not(hiddenProperty()));

binding = binding.and(entry.hiddenProperty().not());

if (getLayer() != null) {
binding = binding.and(Bindings.createBooleanBinding(this::isAssignedLayerVisible, dateControl.visibleLayersProperty()));
}

if (dateControl instanceof DayViewBase) {
/*
* Day views support editing of an availability calendar. During editing the
* entries might be shown, hidden, or become somewhat transparent.
*/
DayViewBase dayView = (DayViewBase) dateControl;

binding = binding.and(dayView.editAvailabilityProperty().not().or(dayView.entryViewAvailabilityEditingBehaviourProperty().isEqualTo(AvailabilityEditingEntryBehaviour.HIDE).not()));
Expand Down

0 comments on commit 0b285d2

Please sign in to comment.