Editing two files simultaneously

Hi all!

I am developing a plugin for visual editing of state machine diagrams. There is a custom editor which displays my XML file as a graph. At the same time all the info about graph node positions are stored into a different XML file next to the first one.
I have the following problem when closing the tab with the state machine XML file:

2011-09-12 20:22:39,794 [  47669]  ERROR - .intellij.openapi.command.impl - -1

java.lang.ArrayIndexOutOfBoundsException: -1

 at com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite.getSelectedEditorWithProvider(EditorWithProviderComposite.java:70)

 at com.intellij.openapi.fileEditor.impl.EditorComposite.getSelectedEditor(EditorComposite.java:331)

 at com.intellij.openapi.fileEditor.impl.EditorComposite$MyComponent.getData(EditorComposite.java:396)

 at com.intellij.ide.impl.DataManagerImpl.getDataFromProvider(DataManagerImpl.java:88)

 at com.intellij.ide.impl.DataManagerImpl.getData(DataManagerImpl.java:72)

 at com.intellij.ide.impl.DataManagerImpl.access$100(DataManagerImpl.java:49)

 at com.intellij.ide.impl.DataManagerImpl$MyDataContext.getData(DataManagerImpl.java:348)

 at com.intellij.openapi.actionSystem.DataKey.getData(DataKey.java:75)

 at com.intellij.openapi.command.impl.FocusBasedCurrentEditorProvider.getCurrentEditor(FocusBasedCurrentEditorProvider.java:32)

 at com.intellij.openapi.command.impl.UndoManagerImpl.getCurrentState(UndoManagerImpl.java:246)

 at com.intellij.openapi.command.impl.UndoManagerImpl.commandFinished(UndoManagerImpl.java:239)

 at com.intellij.openapi.command.impl.UndoManagerImpl.onCommandFinished(UndoManagerImpl.java:214)

 at com.intellij.openapi.command.impl.UndoManagerImpl.access$200(UndoManagerImpl.java:53)

 at com.intellij.openapi.command.impl.UndoManagerImpl$2.commandFinished(UndoManagerImpl.java:161)

 at com.intellij.openapi.command.impl.CommandProcessorImpl.fireCommandFinished(CommandProcessorImpl.java:208)

 at com.intellij.openapi.command.impl.CommandProcessorImpl.finishCommand(CommandProcessorImpl.java:173)

 at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:121)

 at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:91)

 at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:79)

 at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.closeFile(FileEditorManagerImpl.java:492)

 at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.closeFile(FileEditorManagerImpl.java:510)

 at com.intellij.openapi.fileEditor.impl.EditorTabbedContainer$CloseTab.actionPerformed(EditorTabbedContainer.java:395)

 at com.intellij.ui.tabs.impl.ActionButton.actionPerformed(ActionButton.java:102)

 at com.intellij.ui.InplaceButton$1.execute(InplaceButton.java:67)

 at com.intellij.util.ui.BaseButtonBehavior$MyMouseListener.execute(BaseButtonBehavior.java:153)

 at com.intellij.util.ui.BaseButtonBehavior$MyMouseListener.mouseReleased(BaseButtonBehavior.java:136)

 at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)

 at java.awt.Component.processMouseEvent(Component.java:6288)

 at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)

 at java.awt.Component.processEvent(Component.java:6053)

 at java.awt.Container.processEvent(Container.java:2041)

 at java.awt.Component.dispatchEventImpl(Component.java:4651)

 at java.awt.Container.dispatchEventImpl(Container.java:2099)

 at java.awt.Component.dispatchEvent(Component.java:4481)

 at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)

 at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)

 at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)

 at java.awt.Container.dispatchEventImpl(Container.java:2085)

 at java.awt.Window.dispatchEventImpl(Window.java:2478)

 at java.awt.Component.dispatchEvent(Component.java:4481)

 at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)

 at java.awt.EventQueue.access$000(EventQueue.java:84)

 at java.awt.EventQueue$1.run(EventQueue.java:602)

 at java.awt.EventQueue$1.run(EventQueue.java:600)

 at java.security.AccessController.doPrivileged(Native Method)

 at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)

 at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)

 at java.awt.EventQueue$2.run(EventQueue.java:616)

 at java.awt.EventQueue$2.run(EventQueue.java:614)

 at java.security.AccessController.doPrivileged(Native Method)

 at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)

 at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)

 at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:662)

 at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:511)

 at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:411)

 at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:369)

 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)

 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)

 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)

 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)

 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

 at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


I suppose the problem is that I open the second file without any editor, but I'm not sure. Are there any rules how to close any opened resources (PSI files) properly?
2 comments
Comment actions Permalink

I forgot another execption that I see in the log:

2011-09-14 14:02:45,350 [  64295]  ERROR - pl.EditorWithProviderComposite - No selected editors for file://C:/Work/sources/research/sme-test/src/xml/agent-sm.xml
java.lang.Throwable
 at com.intellij.openapi.diagnostic.Logger.error(Logger.java:52)
 at com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite.getSelectedEditorWithProvider(EditorWithProviderComposite.java:66)
 at com.intellij.openapi.fileEditor.impl.EditorComposite.getSelectedEditor(EditorComposite.java:331)
 at com.intellij.openapi.fileEditor.impl.EditorComposite$MyComponent.getData(EditorComposite.java:396)
 at com.intellij.ide.impl.DataManagerImpl.getDataFromProvider(DataManagerImpl.java:88)
 at com.intellij.ide.impl.DataManagerImpl.getData(DataManagerImpl.java:72)
 at com.intellij.ide.impl.DataManagerImpl.access$100(DataManagerImpl.java:49)
 at com.intellij.ide.impl.DataManagerImpl$MyDataContext.getData(DataManagerImpl.java:348)
 at com.intellij.openapi.actionSystem.DataKey.getData(DataKey.java:75)
 at com.intellij.openapi.command.impl.FocusBasedCurrentEditorProvider.getCurrentEditor(FocusBasedCurrentEditorProvider.java:32)
 at com.intellij.openapi.command.impl.UndoManagerImpl.getCurrentState(UndoManagerImpl.java:246)
 at com.intellij.openapi.command.impl.UndoManagerImpl.commandFinished(UndoManagerImpl.java:239)
 at com.intellij.openapi.command.impl.UndoManagerImpl.onCommandFinished(UndoManagerImpl.java:214)
 at com.intellij.openapi.command.impl.UndoManagerImpl.access$200(UndoManagerImpl.java:53)
 at com.intellij.openapi.command.impl.UndoManagerImpl$2.commandFinished(UndoManagerImpl.java:161)
 at com.intellij.openapi.command.impl.CommandProcessorImpl.fireCommandFinished(CommandProcessorImpl.java:208)
 at com.intellij.openapi.command.impl.CommandProcessorImpl.finishCommand(CommandProcessorImpl.java:173)
 at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:121)
 at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:91)
 at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:79)
 at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.closeFile(FileEditorManagerImpl.java:492)
 at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.closeFile(FileEditorManagerImpl.java:510)
 at com.intellij.openapi.fileEditor.impl.EditorTabbedContainer$CloseTab.actionPerformed(EditorTabbedContainer.java:395)
 at com.intellij.ui.tabs.impl.ActionButton.actionPerformed(ActionButton.java:102)
 at com.intellij.ui.InplaceButton$1.execute(InplaceButton.java:67)
 at com.intellij.util.ui.BaseButtonBehavior$MyMouseListener.execute(BaseButtonBehavior.java:153)
 at com.intellij.util.ui.BaseButtonBehavior$MyMouseListener.mouseReleased(BaseButtonBehavior.java:136)
 at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
 at java.awt.Component.processMouseEvent(Component.java:6288)
 at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
 at java.awt.Component.processEvent(Component.java:6053)
 at java.awt.Container.processEvent(Container.java:2041)
 at java.awt.Component.dispatchEventImpl(Component.java:4651)
 at java.awt.Container.dispatchEventImpl(Container.java:2099)
 at java.awt.Component.dispatchEvent(Component.java:4481)
 at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
 at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
 at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
 at java.awt.Container.dispatchEventImpl(Container.java:2085)
 at java.awt.Window.dispatchEventImpl(Window.java:2478)
 at java.awt.Component.dispatchEvent(Component.java:4481)
 at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
 at java.awt.EventQueue.access$000(EventQueue.java:84)
 at java.awt.EventQueue$1.run(EventQueue.java:602)
 at java.awt.EventQueue$1.run(EventQueue.java:600)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
 at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
 at java.awt.EventQueue$2.run(EventQueue.java:616)
 at java.awt.EventQueue$2.run(EventQueue.java:614)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
 at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:662)
 at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:511)
 at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:411)
 at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:369)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

0
Comment actions Permalink

One more observation.
My editor is placed before the standard one, so there are two tabs in the bottom of the editor that allow me to switch from standard XML editor to my visual editor.
I have noticed that the abovementioned exceptions appear only when I close the editor and the tab with my visual editor is active.
Can somebody help me with this issue? There are no javadocs in the IDEA sources, so it is not easy to understand all the stuff, some sources are unavailable. I have tried to google something, but without success.

0

Please sign in to leave a comment.