IntelliJ IDEA Messaging infrastructure with return Value

Hi, how can i use the IntelliJ IDEA Messaging infrastructure with return Value?

When i try to pass some value thru it ends up with:

[   9980]  ERROR - com.intellij.ide.IdeEventQueue - Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(86,506),absolute(2531,655),button=1,modifiers=Button1,clickCount=1] on win0 java.lang.ClassCastException: java.lang.Object cannot be cast to [Ljavax.swing.tree.TreePath;      at com.sun.proxy.$Proxy82.getTreePath(Unknown Source)      at TFS.actions.SetPropertyAction.actionPerformed(SetPropertyAction.java:54)      at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter$1.run(ActionMenuItem.java:256)      at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:892)      at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:114)      at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:227)      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)      at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:101)      at com.intellij.ui.plaf.beg.BegMenuItemUI.a(BegMenuItemUI.java:512)      at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:44)      at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:532)      at java.awt.Component.processMouseEvent(Component.java:6505)      at javax.swing.JComponent.processMouseEvent(JComponent.java:3312)      at java.awt.Component.processEvent(Component.java:6270)      at java.awt.Container.processEvent(Container.java:2229)      at java.awt.Component.dispatchEventImpl(Component.java:4861)      at java.awt.Container.dispatchEventImpl(Container.java:2287)      at java.awt.Component.dispatchEvent(Component.java:4687)      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)      at java.awt.Container.dispatchEventImpl(Container.java:2273)      at java.awt.Window.dispatchEventImpl(Window.java:2719)      at java.awt.Component.dispatchEvent(Component.java:4687)      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)      at java.awt.EventQueue.access$200(EventQueue.java:103)      at java.awt.EventQueue$3.run(EventQueue.java:688)      at java.awt.EventQueue$3.run(EventQueue.java:686)      at java.security.AccessController.doPrivileged(Native Method)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)      at java.awt.EventQueue$4.run(EventQueue.java:702)      at java.awt.EventQueue$4.run(EventQueue.java:700)      at java.security.AccessController.doPrivileged(Native Method)      at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)      at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)      at com.intellij.ide.IdeEventQueue.d(IdeEventQueue.java:685)      at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:506)      at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:333)      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)      at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) [   9982]  ERROR - com.intellij.ide.IdeEventQueue - PyCharm 2.7.1  Build #PY-125.92 [   9982]  ERROR - com.intellij.ide.IdeEventQueue - JDK: 1.7.0_21 [   9982]  ERROR - com.intellij.ide.IdeEventQueue - VM: OpenJDK 64-Bit Server VM [   9982]  ERROR - com.intellij.ide.IdeEventQueue - Vendor: Oracle Corporation [   9982]  ERROR - com.intellij.ide.IdeEventQueue - OS: Linux




Here my code, everything is compileable and seems legit for me:

public interface GetTreePathNotifier {   Topic<GetTreePathNotifier> GET_TREE_PATH_NOTIFIER_TOPIC = Topic.create("GetTreePath", GetTreePathNotifier.class);   TreePath[] getTreePath(); }



    MessageBus bus =  ProjectManager.getInstance().getDefaultProject().getMessageBus();     final GetTreePathNotifier c = bus.syncPublisher(GetTreePathNotifier.GET_TREE_PATH_NOTIFIER_TOPIC);     for(TreePath p :(TreePath[])c.getTreePath())     {       DefaultMutableTreeNode DMTN = (DefaultMutableTreeNode) p.getLastPathComponent();       System.out.println(DMTN.getUserObject().toString());     }



    connection.subscribe(GetTreePathNotifier.GET_TREE_PATH_NOTIFIER_TOPIC,new GetTreePathNotifier() {       @Override       public TreePath[] getTreePath()       {         return myTree.getCheckingPaths();       }     });

0
1 comment
Avatar
Permanently deleted user

Hello,

What are you trying to achieve?

The whole idea of that MessageBus, publisher and subscriber stuff is to provide messages delivery infrastructure. E.g. lets look into ModuleRootListener: it allows to notify interested listeners that module roots are being changed, i.e. a publisher provides a ModuleRootEvent and all subscribers are called with it. As far as I understand your intetion, GetTreePathNotifier.getTreePath() should be re-written as 'GetTreePathNotifier.onTreePathChange(TreePath[])' - a publisher calls that method with new tree path and all subscribers receive it.

Denis

0

Please sign in to leave a comment.