cannot share data context between Swing events

my editor action show a DialogWarapper.

if i trigger action by short-cut, dialog on ok/cancel by key/mouse throws following exception

but if trigger it by mouse, all things is well.
=============
ERROR - ellij.ide.impl.DataManagerImpl - Assertion failed: cannot share data context between Swing events; initial event count = 1599; current event count = 1729
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.ide.impl.DataManagerImpl$MyDataContext.getData(DataManagerImpl.java:4)
at util.PluginUtil.getProject(PluginUtil.java:104)
at util.PluginUtil.getPsiFile(PluginUtil.java:108)
at sharghi.ali.orderlines.OrderLinesHandler.executeWriteAction(OrderLinesHandler.java:33)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java:52)
at com.intellij.openapi.application.impl.ApplicationImpl$9.compute(ApplicationImpl.java:2)
at com.intellij.psi.impl.source.PostprocessReformattingAspect.postponeFormattingInside(PostprocessReformattingAspect.java:115)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:355)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.execute(EditorWriteActionHandler.java:36)
at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:52)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:132)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:111)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:58)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:43)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:83)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:59)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:9)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:73)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:189)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
ERROR - ellij.ide.impl.DataManagerImpl - IntelliJ IDEA 6.0 Build #5766
ERROR - ellij.ide.impl.DataManagerImpl - JDK: 1.5.0_08
ERROR - ellij.ide.impl.DataManagerImpl - VM: Java HotSpot(TM) Client VM
ERROR - ellij.ide.impl.DataManagerImpl - Vendor: Sun Microsystems Inc.
ERROR - ellij.ide.impl.DataManagerImpl - OS: Windows XP
ERROR - ellij.ide.impl.DataManagerImpl - Last Action: OrderLinesPlugin.OrderLines
ERROR - ellij.ide.impl.DataManagerImpl - Current Command: Order lines....

5 comments

This means you save the DataContext from where it comes to a field, and later try to access it. This is not supported: you should save whatever information you need from data context, instead of context itself.

0

no, i sure do NOT this, my class no has field.

0

Do you store the data context in a final variable and access it later from within an anonymous inner class? Maybe it would be helpful to post the piece of code which is triggering the exception in the end.

0

no , but after refactoring , i NOT see this error.
i use power of IDEA in search usages, i sure that any palce store datacontext.
========
please i post a new thread .
please see it. very thanks

0

no, i not do this.

how i can access to current AnActoinEvent

i needed call a HighlightUsagesInFile actoin of IDEA in handler of my actions.
but actionPerformed(event) need to event and i am in handler so :

public abstract class AbstractEditorAction extends EditorAction {

public AbstractEditorAction(final EditorActionHandler handler) {
super(handler);
}

public void update(AnActionEvent e) {
((AbstractActionHandler) getHandler()).setActionEvent(e);
e.getPresentation().setEnabled(PluginUtil.getCurrentCodeBlock(e.getDataContext()) != null); //@Need Resolved : Ali Reza Sharghi , 5- fix enable/disable action on update if currentCodeBlock != null// it sometime is diable instead enable
}

}

only a my action' subclass that show a dialog for params of action , throw this exception. others use default params and neither show and thow
===========
public abstract class AbstractActionHandler extends EditorWriteActionHandler {
private ActionParams actionParams;

private AnActionEvent event;

public void executeWriteAction(Editor editor, DataContext dataContext) {
....
runHighLightInFilesAction(editor, dataContext, actionParams);
....
}

protected void runHighLightInFilesAction(final Editor editor, final DataContext dataContext, final ActionParams actionParams) {
AnAction anAction = ActionManager.getInstance().getAction("HighlightUsagesInFile");
anAction.actionPerformed(event);//@Need Resolved : Ali Reza Sharghi , want my str feeded on action instead of current selection
}

ex throw in above line
==========
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.ide.impl.DataManagerImpl$MyDataContext.getData(DataManagerImpl.java:4)
at com.intellij.codeInsight.highlighting.actions.HighlightUsagesAction.actionPerformed(HighlightUsagesAction.java:8)
at sharghi.ali.orderlines.action.handler.AbstractActionHandler.runHighLightInFilesAction(AbstractActionHandler.java:98)
at sharghi.ali.orderlines.action.handler.AbstractActionHandler.executeWriteAction(AbstractActionHandler.java:54)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler$1.run(EditorWriteActionHandler.java:52)
at com.intellij.openapi.application.impl.ApplicationImpl$9.compute(ApplicationImpl.java:2)
at com.intellij.psi.impl.source.PostprocessReformattingAspect.postponeFormattingInside(PostprocessReformattingAspect.java:115)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:355)
at com.intellij.openapi.editor.actionSystem.EditorWriteActionHandler.execute(EditorWriteActionHandler.java:36)
at com.intellij.openapi.editor.actionSystem.EditorAction$1.run(EditorAction.java:52)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:132)
at com.intellij.openapi.command.impl.CommandProcessorImpl.executeCommand(CommandProcessorImpl.java:111)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:58)
at com.intellij.openapi.editor.actionSystem.EditorAction.actionPerformed(EditorAction.java:43)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.a(IdeKeyEventDispatcher.java:83)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.b(IdeKeyEventDispatcher.java:59)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:9)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:73)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:189)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
ERROR - ellij.ide.impl.DataManagerImpl - Assertion failed: cannot share data context between Swing events; initial event count = 6495; current event count = 8919

0

Please sign in to leave a comment.