maxandersen/update.xam.dk — pull request #2 by gamerson (2012-09-10 10:04:08+00:00)
Title: Windows conflict and NPEs on e4

Hey Max,

I've been using this quite a bit lately and I've made a couple of changes to my fork that I wanted to share with you.

First commit is a change to the default key sequence from F4 to F5. When F4 is the default, this will activate the "Alt+F4" system keybinding on Windows which will close the workbench window, so I changed it to F5.

2nd commit is a fix for some NPEs I've been running into with e4 workbench. The problem was when I was capturing the ProjectExplorer part, this part renderer uses an anonymous class whose superclass is Composite. Anonymous classes don't have a canonical name, so the Balsamiq classes were getting NPEs like this one:

Caused by: java.lang.NullPointerException
at dk.xam.spy.handlers.BalsamiqControl.isUnknown(BalsamiqControl.java:165)
at dk.xam.spy.handlers.BalsamiqControl.isVisual(BalsamiqControl.java:141)
at dk.xam.spy.handlers.Balsamiq.process(Balsamiq.java:31)
at dk.xam.spy.handlers.SpyHandler.printChildren(SpyHandler.java:95)
at dk.xam.spy.handlers.SpyHandler.execute(SpyHandler.java:74)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
... 47 more

So I introduced a new "safeGetClass" method that will check canonicalName first and if it is 'null' like with an anonymous class, it will look up the hierarchy until it finds a valid canonicalName. This fixed the problems I was encountering on e4.

Thanks.