mbien commented on code in PR #9776:
URL: https://github.com/apache/netbeans/pull/9776#discussion_r4494694867


##########
ide/projectui/src/org/netbeans/modules/project/ui/actions/LookupSensitiveAction.java:
##########
@@ -164,28 +174,50 @@ private void doRefresh(boolean immediate) {
                 
r.setResourceBundle(NbBundle.getBundle(LookupSensitiveAction.class));
                 r.setParameters(new Object[]{
                     getClass(),
-                    lookup
+                    context
                 });
                 r.setLoggerName(LOG.getName());
                 LOG.log(r);
             }
-            refresh(lookup, immediate);
+            refresh(context);
         } finally {
             refreshing = false;
         }
         needsRefresh = false;
     }
 
-    // Abstract methods 
--------------------------------------------------------
-
     /** Called when the action is performed
      */
     protected abstract void actionPerformed( Lookup context );
 
-    /** Place where to change properties (enablement/name) when
-     *  the set of current projects changes.
+    /**
+     * Place where to change properties (enablement/name) when
+     * the set of current projects changes.
+     *
+     * <p>Invoked on a background (request processor) thread for
+     * scheduled refreshes, or synchronously on the calling thread
+     * (usually the EDT) when {@link #isEnabled()} or
+     * {@link #getValue(String)} forces a refresh of stale state.
      */
-    protected abstract void refresh(Lookup context, boolean immediate);
+    protected abstract void refresh(Lookup context);
+
+    /**
+     * Schedules a refresh of this action's state. Invoked automatically when
+     * the watched lookup changes; a subclass may also invoke it when state
+     * observed outside the lookup (e.g. the open projects list) changes.
+     *
+     * <p>The refresh is debounced so that a burst of changes coalesces
+     * into a single one; a state query ({@link #isEnabled()},
+     * {@link #getValue(String)}) that finds stale state refreshes
+     * immediately instead.
+     *
+     * @param context the lookup to refresh against
+     */
+    protected final void scheduleRefresh(Lookup context) {
+        needsRefresh = true;
+        pendingContext = context;

Review Comment:
   i checked but this wouldn't cover all states. One action does also call this 
method with null. So it would require more adjustments.
   
   the name `needsRefresh` is also self-documenting. A null context isn't, 
which would need more explaining.



-- 
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

Reply via email to