You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/06/21 13:39:11 UTC

[GitHub] [netbeans] lkishalmi commented on a change in pull request #3004: Gradle Action Providers can disable an action.

lkishalmi commented on a change in pull request #3004:
URL: https://github.com/apache/netbeans/pull/3004#discussion_r655384392



##########
File path: extide/gradle/src/org/netbeans/modules/gradle/actions/DefaultActionMapping.java
##########
@@ -145,5 +145,10 @@ public boolean equals(Object obj) {
         }
         return Objects.equals(this.withPlugins, other.withPlugins);
     }
+
+    public static DefaultActionMapping DISABLED = new DefaultActionMapping();

Review comment:
       Wouldn't it be better to have a static final member in ActionMapping interface as a specific instance?

##########
File path: extide/gradle/src/org/netbeans/modules/gradle/api/execute/RunUtils.java
##########
@@ -539,6 +541,39 @@ public static ReplaceTokenProvider simpleReplaceTokenProvider(final String token
             }
         };
     }
+    
+    /**
+     * Returns an action mapping provider for the specified project and context. Specifically 
+     * supports {@link ProjectConfiguration}s, so the returned provider will 
+     * @param p the project
+     * @param context the action invocation context
+     * @return action provider suitable for the project/context.
+     * @since 2.14
+     */
+    public static ProjectActionMappingProvider findActionProvider(Project p, Lookup context) {
+        ConfigurableActionProvider cap = p.getLookup().lookup(ConfigurableActionProvider.class);
+        if (cap == null) {
+            return p.getLookup().lookup(ProjectActionMappingProvider.class);
+        }
+        GradleExecConfiguration cfg = ProjectConfigurationSupport.getEffectiveConfiguration(p, context);
+        return cap.findActionProvider(cfg.getId());
+    }
+
+    /**
+     * Checks if the action is disabled. Use in preference to plain <code>actionMapping == null</code>
+     * as it also handles a mapping that forcefully deconfigures an action.
+     * 
+     * @param am action mapping to check
+     * @return true, if the action is <b>disabled</b>
+     * @since 2.14
+     */
+    public static boolean isActionDisabled(ActionMapping am) {

Review comment:
       Would be better as a static method in ActionMapping.isDisabled(ActionMapping)




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists