-
Notifications
You must be signed in to change notification settings - Fork 128
added date of disabled pvs to structural element #3880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,9 +26,7 @@ | |
|
|
||
| import java.time.LocalDateTime; | ||
| import java.time.format.DateTimeFormatter; | ||
| import java.util.LinkedList; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import java.util.*; | ||
|
|
||
| /** TreeCell for AlarmTreeItem | ||
| * @author Kay Kasemir | ||
|
|
@@ -127,22 +125,27 @@ protected void updateItem(final AlarmTreeItem<?> item, final boolean empty) | |
| else | ||
| { | ||
| final AlarmClientNode node = (AlarmClientNode) item; | ||
|
|
||
| Optional<Pair<LeavesDisabledStatus, Boolean>> maybeLeavesDisabledStatusBooleanPair = leavesDisabledStatus(node); | ||
| if (maybeLeavesDisabledStatusBooleanPair.isPresent() && !maybeLeavesDisabledStatusBooleanPair.get().getKey().equals(LeavesDisabledStatus.AllEnabled)) { | ||
| Pair<LeavesDisabledStatus, Boolean> leavesDisabledStatusBooleanPair = maybeLeavesDisabledStatusBooleanPair.get(); | ||
|
|
||
| if (leavesDisabledStatusBooleanPair.getKey().equals(LeavesDisabledStatus.AllDisabled)) { | ||
| if (leavesDisabledStatusBooleanPair.getValue()) { | ||
| disabledTimerIndicator.setText("(" + Messages.disabled + "; " + Messages.timer + ")"); | ||
| } | ||
| else { | ||
| Set<AlarmClientLeaf> withEnableDate = new HashSet<>(); | ||
| boolean test = DisableAction.checkEnableDates(node.getChildren(), new HashSet<>(), withEnableDate); | ||
| if (test){ | ||
| disabledTimerIndicator.setText("(" + Messages.disabled + "; " + Messages.timer + ": " + withEnableDate.iterator().next().getEnabledDate() + ")"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest to format the enabled date with second-precision only, i.e., to remove the milliseconds, etc. I don't know whether it would be a good idea to also implement logic to simplify the date depending on the current date: e.g., if the current date is
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, second precision is sufficient. But I prefer to always use the same format for the sake of consistency. |
||
| } else { | ||
| disabledTimerIndicator.setText("(" + Messages.disabled + "; " + Messages.timers + ")"); | ||
| } | ||
|
|
||
| } else { | ||
| disabledTimerIndicator.setText("(" + Messages.disabled + ")"); | ||
| } | ||
| } | ||
| else if (leavesDisabledStatusBooleanPair.getKey().equals(LeavesDisabledStatus.SomeEnabledSomeDisabled)) { | ||
| if (leavesDisabledStatusBooleanPair.getValue()) { | ||
| disabledTimerIndicator.setText("(" + Messages.partlyDisabled + "; " + Messages.timer + ")"); | ||
| disabledTimerIndicator.setText("(" + Messages.partlyDisabled + "; " + Messages.timers + ")"); | ||
| } | ||
| else { | ||
| disabledTimerIndicator.setText("(" + Messages.partlyDisabled + ")"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment describing
DisableAction.checkEnableDates()states:Therefore,
withEnableDate.iterator().next().getEnabledDate()not throwing an exception here (in the case that there are no enable dates) implicitly depends onleavesDisabledStatusBooleanPair.getValue()beingtruemeaning that there is at least one timer in the sub-tree.In practice, it seems that
DisableAction.checkEnableDates()is used to determine whether there exists one shared enable date for a sub-tree: I suggest to consider changing the signature ofDisableAction.checkEnableDates()to something like the following to reflect this:Returning:
Optional.empty()if there is no shared enabled date.Optional.of(sharedEnabledDate)if there is a shared enabled date.This would remove the implicit dependency, also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DisableAction.checkEnableDates()is actually used also for another purpose, which has been a bit lost in the refactoring done in this commit.I will update to split the required business logic a bit to improve readability.