amondel2 commented on code in PR #441: URL: https://github.com/apache/grails-intellij-plugin/pull/441#discussion_r4290185364
########## plugin/src/main/java/org/apache/grails/intellij/plugin/config/GrailsCustomFoldersProjectService.java: ########## @@ -0,0 +1,138 @@ +/* + * 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.config; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.ModalityState; +import com.intellij.openapi.components.PersistentStateComponent; +import com.intellij.openapi.components.State; +import com.intellij.openapi.components.Storage; +import com.intellij.openapi.components.StoragePathMacros; +import com.intellij.openapi.project.Project; +import com.intellij.util.messages.Topic; +import org.apache.grails.intellij.plugin.projectView.GrailsProjectViewPanes; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +@State(name = "GrailsCustomFolders", storages = @Storage(StoragePathMacros.WORKSPACE_FILE)) +public final class GrailsCustomFoldersProjectService implements PersistentStateComponent<GrailsCustomFoldersProjectService.StateHolder> { + public static final int MAX_FOLDERS = 3; Review Comment: Done as specified. `maxFolders` is persisted global state with a default of **6** and a range of **1โ20**, edited with a `JSpinner`. The cap is applied only in `combine`/`getEffectiveFolders`, when the view is built; `clean()` in both services and the row reader no longer truncate, so lowering the setting cannot delete a stored folder. The live preview and the over-cap warning both read the spinner value being edited, as does the "maximum reached" state in `AddCustomFolderAction.update`, which counts the effective (project plus global) folders. The four normalize/dedupe/cap loops collapsed into one `FolderPaths.dedupe`, and both `MAX_FOLDERS` constants are gone. On the other places you listed: - the labels no longer say "up to 3 folders"; they are keyed in `GrailsBundle` and the cap sentence in the description is interpolated from the spinner; - the README and IMPROVEMENT-PLAN ยง2.8 say six by default and name the setting; - the tests that asserted 3 now assert against a passed-in cap. Two deliberate limits worth flagging. `restore()` treats anything outside 1โ20 as "unset" and falls back to 6 rather than clamping, because a state file written before this field existed deserializes to 0. And nothing caps on save, which means a list can legitimately hold more folders than the cap renders โ the over-cap warning and the truncated preview are the two places that show it. -- 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]
