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(AbstractProjectNode.java:5)
at com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode.getChildren(ProjectViewProjectNode.java:0)
at com.intellij.ide.util.treeView.AbstractTreeStructureBase.getChildElements(AbstractTreeStructureBase.java:2)
at com.intellij.ide.commander.AbstractListBuilder.b(AbstractListBuilder.java:161)
at com.intellij.ide.commander.AbstractListBuilder.updateList(AbstractListBuilder.java:206)
at com.intellij.ide.commander.ProjectListBuilder$1.run(ProjectListBuilder.java:2)
at com.intellij.util.Alarm$1.run(Alarm.java:106)
at com.intellij.util.Alarm$MyThread$1.run(Alarm.java:250)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:5)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:182)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:138)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:142)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

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

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

0

Please sign in to leave a comment.