amondel2 commented on code in PR #441: URL: https://github.com/apache/grails-intellij-plugin/pull/441#discussion_r4290175428
########## plugin/src/main/java/org/apache/grails/intellij/plugin/actions/AddCustomFolderAction.java: ########## @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.grails.intellij.plugin.actions; + +import com.intellij.openapi.actionSystem.ActionUpdateThread; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.project.DumbAwareAction; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VfsUtilCore; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiManager; +import org.apache.grails.intellij.plugin.config.GrailsCustomFoldersProjectService; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class AddCustomFolderAction extends DumbAwareAction { + + @Override + public void update(@NotNull AnActionEvent e) { Review Comment: Agreed, and applied to all three rather than only this one. *Add* requires the selected directory to belong to a Grails application, which also supplies the base for the stored path, and is hidden for the application root. *Remove* is gated on `hasApplications()`. *Configure* additionally requires the Grails pane. The `hasApplications()` check you pointed at in `GrailsActionGroup` / `GrailsRunCommandAction` is the shape these follow. There is a second no-op case the review did not mention, which I folded into the same guard: *Add* is now hidden for a directory the Grails view already renders as a custom folder, comparing after normalization and against the effective (project plus global) list. Previously a right-click on a global default added it to the project list, promoting a default into an override. ########## plugin/src/main/java/org/apache/grails/intellij/plugin/actions/ConfigureCustomFoldersAction.java: ########## @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.grails.intellij.plugin.actions; + +import com.intellij.ide.projectView.ProjectView; +import com.intellij.ide.projectView.impl.AbstractProjectViewPane; +import com.intellij.openapi.actionSystem.ActionUpdateThread; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.options.ShowSettingsUtil; +import com.intellij.openapi.project.DumbAwareAction; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiManager; +import com.intellij.util.ui.tree.TreeUtil; +import org.apache.grails.intellij.plugin.config.GrailsCustomFoldersConfigurable; +import org.apache.grails.intellij.plugin.projectView.nodes.GrailsCustomFolderNode; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.tree.TreePath; + +public class ConfigureCustomFoldersAction extends DumbAwareAction { + + @Override + public void update(@NotNull AnActionEvent e) { + Project project = e.getProject(); + boolean visible = false; + if (project != null) { + AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane(); + if (pane != null) { + // Visible when a custom folder node is selected (same as Remove) + if (isCustomFolderSelected(pane)) { + visible = true; + } + // Also visible when a directory is selected (same as Add) + else if (getSelectedDirectory(e) != null) { Review Comment: Shown only in the Grails pane. `ProjectView.getInstance(project).getCurrentProjectViewPane()` is the one remaining pane lookup in these actions, reduced to a `getId()` comparison, because the settings page is about that pane specifically. -- 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]
