jtulach commented on code in PR #9771:
URL: https://github.com/apache/netbeans/pull/9771#discussion_r4434613761
##########
platform/openide.explorer/src/org/openide/explorer/DefaultEMLookup.java:
##########
@@ -136,9 +162,22 @@ protected synchronized void beforeLookup(Template<?> t) {
}
}
+ @Override
public void propertyChange(PropertyChangeEvent evt) {
- if (ExplorerManager.PROP_SELECTED_NODES == evt.getPropertyName()) {
- updateLookups((Node[]) evt.getNewValue());
+ if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName()))
{
+ scheduleUpdate();
+ }
+ }
+
+ /**
+ * Schedules an update of this lookup to the currently selected nodes
+ * on a background thread. Pending updates are postponed. The update reads
+ * the selection when it runs, so a superseded update can never leave a
stale
+ * state behind.
+ */
+ private void scheduleUpdate() {
Review Comment:
- As the [failing tests
indicate](https://github.com/apache/netbeans/actions/runs/41214064539/job/124577206308?pr=9771#step:12:761)
- just the `schedule(later)` fix can hardly be compatible with current
behavior
- the tests perform an action and expect to _see the result immediately_
- probably one would have to:
- immediately invalidate the state
- schedule the update in a background sliding task (as
a95adf8cf3102eba8dcfcbd5b1d38879a390c4da does)
- whenever someone queries the invalidated, not yet computed state ...
- ...await the computation with `task.waitFinished()`
- something like that has been attempted in
`ExplorerActionsImpl.ActionsStateUpdater`
- but yeah, when I see this code over all the years, I am wondering why we
haven't done a better job...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists