UX: for all lists, automagically show `Updating...` message
...if updates take more than 200ms. The number is arbitrary and
hard-coded - may need some tuning.
--- a/VDBAbstractListApplication.st Sat Jun 08 16:36:18 2019 +0100
+++ b/VDBAbstractListApplication.st Sun Jun 09 11:19:45 2019 +0100
@@ -12,7 +12,7 @@
VDBAbstractContentsApplication subclass:#VDBAbstractListApplication
instanceVariableNames:'internalListHolder internalListView internalSelectionHolder
- internalMessageView'
+ internalMessageView internalMessageTimeoutID'
classVariableNames:''
poolDictionaries:''
category:'VDB-UI-Abstract'
@@ -397,10 +397,12 @@
"/ For internal use, do not override!!"
contentsValid := false.
windowVisible ifTrue:[
+ self showMessage: (resources string: 'Updating...') after: 200.
self delayedUpdateContents.
].
"Created: / 14-02-2019 / 16:43:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-06-2019 / 14:09:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
delayedUpdateInternalList
@@ -411,9 +413,11 @@
delayedUpdateInternalListInternal
self delayedUpdateInternalList.
+ self hideMessage.
contentsValid := true.
"Created: / 14-02-2019 / 16:44:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-06-2019 / 14:09:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
delayedUpdateSelection
@@ -710,26 +714,67 @@
hideMessage
"Hide any message previously shown by #showMessage:"
+ | timeoutId |
+
internalMessageView notNil ifTrue:[
- internalMessageView label: ''.
internalMessageView beInvisible.
+ internalMessageTimeoutID notNil ifTrue:[
+ timeoutId := internalMessageTimeoutID.
+ Processor removeTimeoutWithID: timeoutId.
+ internalMessageTimeoutID := nil.
+ ].
]
"Created: / 08-06-2019 / 10:09:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-06-2019 / 14:07:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-showMessage: text
- "Show given message `text` instead of list contents.
- Message `text` is not localized, the caller is responsible
- for localization."
+showMessage: message
+ "Show given `message` instead of list contents. To hide
+ the message and show the list again, call #hideMessage.
+ The caller is responsible for localizing `message` text."
+
+ self showMessage: message after: 0
+
+ "Created: / 08-06-2019 / 10:07:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-06-2019 / 11:12:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+showMessage: text after: milliseconds
+ "Show given `message` instead of list contents.
+
+ If `milliseconds` is non zero, the message is shown after
+ given time. and if NO OTHER call to #showMessage:after or
+ #hideMessage is made meanwhile.
+
+ If `milliseconds` is zero, `message` is shown immediately.
+ "
+ | timeoutId |
internalMessageView isNil ifTrue:[
self initializeMessageView.
].
+ internalMessageTimeoutID notNil ifTrue:[
+ timeoutId := internalMessageTimeoutID.
+ Processor removeTimeoutWithID: timeoutId.
+ internalMessageTimeoutID := nil.
+ ].
+
internalMessageView label: text.
- internalMessageView beVisible.
- "Created: / 08-06-2019 / 10:07:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ milliseconds == 0 ifTrue:[
+ internalMessageView beVisible.
+ ] ifFalse:[
+ internalMessageTimeoutID :=
+ Processor
+ addTimedBlock: [
+ internalMessageTimeoutID := nil.
+ internalMessageView beVisible.
+ ] afterMilliseconds: milliseconds
+ ].
+
+ "Created: / 09-06-2019 / 11:00:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 10-06-2019 / 14:08:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBAbstractListApplication class methodsFor:'documentation'!