ActionGroup is disabled. Why?
Answered
I found that it's caused by this.
The actiongroup will check whether it's children visible. And the check called here.
Why is canceled?
Here's the code of my action group. It's a dynamic group. Source settings state is a PersistentStateComponent saving settings.
My temp workaround is implements the AlwaysVisibleActionGroup.
package net.kaiba.source.settings;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.actionSystem.AlwaysVisibleActionGroup;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class ServerActionGroup extends ActionGroup implements AlwaysVisibleActionGroup {
@NotNull
@Override
public AnAction[] getChildren(@Nullable AnActionEvent e) {
List<AnAction> anActionList = new ArrayList<>();
for (int i = 0; i < SourceSettingsState.getInstance().serverList.size(); i++) {
SourceSettingsState.Server server = SourceSettingsState.getInstance().serverList.get(i);
ServerAction serverAction = new ServerAction(server.name, i);
anActionList.add(serverAction);
}
return anActionList.toArray(new AnAction[0]);
}
}
Please sign in to leave a comment.
It's working after I make children actions implement DumbAware. What's it? No documentaiton for it.
Seto,
Thanks for pointing it out - we'll try improve the SDK Documentation regarding the DumbAware.