Refreshing the Project panel after changing module grouping

I've got a plugin that, among other features, allows modules to be grouped and ungrouped easily and graphically. The grouping and ungrouping work fine, but after commiting the changes the project panel never gets updated, and starts throwing endless errors until IDEA must be restarted. Here's a sample exception:

java.lang.ArrayIndexOutOfBoundsException: 0
at com.intellij.ide.projectView.impl.nodes.AbstractProjectNode.modulesAndGroups(
at com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode.getChildren(
at com.intellij.ide.util.treeView.AbstractTreeStructureBase.getChildElements(
at com.intellij.ide.commander.AbstractListBuilder.b(
at com.intellij.ide.commander.AbstractListBuilder.updateList(
at com.intellij.ide.commander.ProjectListBuilder$
at com.intellij.util.Alarm$
at com.intellij.util.Alarm$MyThread$
at com.intellij.openapi.application.impl.LaterInvocator$
at java.awt.event.InvocationEvent.dispatch(
at java.awt.EventQueue.dispatchEvent(
at com.intellij.ide.IdeEventQueue.b(
at com.intellij.ide.IdeEventQueue.a(
at com.intellij.ide.IdeEventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(

Is there some magic incantation I need to make in order to get the Project Panel to be appropriately updated? This is a showstopper for some otherwise quite nice functionality.

--Dave Griffith

1 comment
Comment actions Permalink

Never mind, I've figured it out. It turns out that to remove a module from all groups, you need to call

ModifiableModuleModel.setModuleGroupPath(module, null);

rather than

ModifiableModuleModel.setModuleGroupPath(module, new String[0]);

which makes more sense. I'd class this as an OpenAPI bug, but would put it's priority somewhere below low.

--Dave Griffith


Please sign in to leave a comment.