ClassCastException in AnAction.update(evt)

Hi, I'm trying to wrap all actions under the "NewGroup" group with my class
to be able to
find out when was a file created by the user (as opposed to file created
outside IDEA
or running Ant, or ... - as it is possible with the listener approach).

1. Perhaps that is not the best way. What is better?
2. When I implement AnAction.update(evt) as m_originalAction.update(evt) I
get
some ClassCastException (see below)

This work is for the Perforce plugin and I believe it might be useful for
others as well.




Here is the exception (one of them, this was fired after Alt-INS):

ERROR - intellij.plugins.PluginManager -
ERROR - intellij.plugins.PluginManager - IntelliJ IDEA 3.0.2
Build #695
ERROR - intellij.plugins.PluginManager - JDK: 1.4.1_01
ERROR - intellij.plugins.PluginManager - VM: Java HotSpot(TM)
Client VM
ERROR - intellij.plugins.PluginManager - Vendor: Sun Microsystems
Inc.
ERROR - intellij.plugins.PluginManager - OS: Windows 2000
ERROR - intellij.plugins.PluginManager - Last Action:
ERROR - intellij.plugins.PluginManager -
java.lang.ClassCastException
at com.intellij.ide.a.dj.a(dj.java:19)
at com.intellij.ide.a.dj.update(dj.java:3)
at com.rne.testplugin.ActionNew.update(ActionNew.java:16)
at com.intellij.openapi.a.c.e.a(e.java:102)
at com.intellij.openapi.a.c.e.b(e.java:2)
at com.intellij.openapi.a.c.e.a(e.java:3)
at com.intellij.ide.q.dispatchEvent(q.java:40)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


3 comments

More details just found after sent the message:
- it looks like the default action for "NewElement" looks up the "NewGroup"
and tries to
cast it to DefaultActionGroup (but having my ActionGroupWrap object
instead).
Will try to change just contents of the "NewGroup" action...


"Richard Nemec" <rndzank@attbi.com> wrote in message
news:b5ns70$dln$1@is.intellij.net...

Hi, I'm trying to wrap all actions under the "NewGroup" group with my

class

to be able to
find out when was a file created by the user (as opposed to file created
outside IDEA
or running Ant, or ... - as it is possible with the listener approach).

>

1. Perhaps that is not the best way. What is better?
2. When I implement AnAction.update(evt) as m_originalAction.update(evt) I
get
some ClassCastException (see below)

>

This work is for the Perforce plugin and I believe it might be useful for
others as well.

>
>
>
>

Here is the exception (one of them, this was fired after Alt-INS):

>

ERROR - intellij.plugins.PluginManager -
ERROR - intellij.plugins.PluginManager - IntelliJ IDEA 3.0.2
Build #695
ERROR - intellij.plugins.PluginManager - JDK: 1.4.1_01
ERROR - intellij.plugins.PluginManager - VM: Java HotSpot(TM)
Client VM
ERROR - intellij.plugins.PluginManager - Vendor: Sun

Microsystems

Inc.
ERROR - intellij.plugins.PluginManager - OS: Windows 2000
ERROR - intellij.plugins.PluginManager - Last Action:
ERROR - intellij.plugins.PluginManager -
java.lang.ClassCastException
at com.intellij.ide.a.dj.a(dj.java:19)
at com.intellij.ide.a.dj.update(dj.java:3)
at com.rne.testplugin.ActionNew.update(ActionNew.java:16)
at com.intellij.openapi.a.c.e.a(e.java:102)
at com.intellij.openapi.a.c.e.b(e.java:2)
at com.intellij.openapi.a.c.e.a(e.java:3)
at com.intellij.ide.q.dispatchEvent(q.java:40)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

>
>


0

Now I'm replacing items INSIDE the "NewGroup" group and things seem to be
better
but when I hit Alt-INS in the code I get the following stacktrace and cannot
finish
the action. Don't know, now...


ERROR - intellij.plugins.PluginManager -
ERROR - intellij.plugins.PluginManager - IntelliJ IDEA 3.0.2
Build #695
ERROR - intellij.plugins.PluginManager - JDK: 1.4.1_01
ERROR - intellij.plugins.PluginManager - VM: Java HotSpot(TM)
Client VM
ERROR - intellij.plugins.PluginManager - Vendor: Sun Microsystems
Inc.
ERROR - intellij.plugins.PluginManager - OS: Windows 2000
ERROR - intellij.plugins.PluginManager - Last Action: NewElement
ERROR - intellij.plugins.PluginManager -
java.lang.ClassCastException
at com.intellij.codeInsight.g.a.n.a(n.java:6)
at com.intellij.codeInsight.g.a.n.update(n.java:5)
at com.intellij.openapi.a.c.e.a(e.java:102)
at com.intellij.openapi.a.c.e.b(e.java:2)
at com.intellij.openapi.a.c.e.a(e.java:3)
at com.intellij.ide.q.dispatchEvent(q.java:40)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


0

I am curious. Why are you trying to find out this way?
Can you not use VirtualFileManager.addVirtualFileListener to detect file creation or better the full AbstractVcs?

Do you know that implementing AbstractVcs is the only way (please shoot me down if I am wrong) to be able to get a "mass" checkout menu items in the preview of refactoring. You can then select the preview top level node of the affected files tree and invoke your action and voila it will be invoked for all files.

You might want to peek at the ClearCasePlugin for code samples.

Jacques

0

Please sign in to leave a comment.