File Exchange

image thumbnail

UIINSPECT - display methods, properties & callbacks of an object

version 1.28 (130 KB) by

Inspect an object handle (Java/COM/HG); display its methods/properties/callbacks in a unified window

50 Downloads

Updated

View License

Syntax:
hFig = uiinspect(obj)

Description:
UIINSPECT inspects an object handle (e.g., Java, COM, Handle Graphics, Matlab class, Dot-Net etc.) and displays the inspection results in a unified Matlab window. UIINSPECT displays a unified window with all relevant object methods (as can be displayed via Matlab's methodsview function), properties (as can be displayed via Matlab's inspect function), static fields, and callbacks. UIINSPECT also displays properties and fields that are not normally displayed with Matlab's inspect function. Property meta-data such as type, accessibility, visibility and default value are also displayed.

Unlike Matlab's inspect function, multiple UIINSPECT windows can be opened simultaneously.

Object properties and callbacks may be modified interactively within the UIINSPECT window.

hFig = UIINSPECT returns a handle to the created figure window. UIINSPECT opens a regular Matlab figure window which may be accessed via hFig (unlike Matlab's methodsview function which opens a Java frame that is not easily accessible from Matlab).

Examples:
hFig = uiinspect(0); % Matlab root (desktop) handle
hFig = uiinspect(handle(0));
hFig = uiinspect(gcf); % Figure handle
hFig = uiinspect(handle(gcf));
uiinspect(get(gcf,'JavaFrame'));
uiinspect(classhandle(handle(gcf))); % UDD handle
uiinspect(findprop(handle(gcf),'MenuBar')); % Meta-data handle
uiinspect('java.lang.String'); % Java class name
uiinspect(java.lang.String('yes')); % Java class object reference
uiinspect(actxserver('Excel.Application')); % COM/ActiveX object
uiinspect(Employee) % Matlab class object
uiinspect(?handle) % Matlab metaclass object
uiinspect('meta.class') % Matlab class name
uiinspect(System.Diagnostics.Process.GetCurrentProcess) % Dot-Net object

Warning:
This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7.1 and later releases, but use at your own risk!
Technical explanation and details:
http://undocumentedmatlab.com/blog/uiinspect

Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)

Comments and Ratings (36)

Yair Altman

Yair Altman (view profile)

@Mark - I just uploaded a fix that should solve this problem for R2014a and earlier Matlab releases (it was already ok for R2014b and later).

Yair Altman

Yair Altman (view profile)

@Mark - I just uploaded a fix that should solve this problem for R2014a and earlier Matlab releases (it was already ok for R2014b and later).

Mark Dow

Hi,

I'm having the same problem that David had on 23 Oct 2014:

>> uiinspect(0)
uiinspect: Error using setappdata
Invalid object handle

Error in uiinspect>getHandleTree (line 1384)
setappdata(tree_h, 'userdata',userdata);

Error in uiinspect>getMethodsPane (line 1315)
paneContents = getHandleTree(obj, hFig);

Error in uiinspect>displayObj (line 361)
[methodsPane, hgFlag] = getMethodsPane(objMethods, obj, hFig);

Error in uiinspect (line 139)
fig = displayObj(obj, objMethods, objProps, objCallbacks, objChildren,
inputname(1), fig);

Version info:

----------------------------------------------------------------------------------------------------
MATLAB Version: 8.3.0.532 (R2014a)
MATLAB License Number: 981453
Operating System: Mac OS X Version: 10.9.4 Build: 13E28
Java Version: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB Version 8.3 (R2014a)
>>

Yair Altman

Yair Altman (view profile)

@Daniel - please download the latest version of UIINSPECT and retry. I think that it should solve your problem. If it doesn't then let me know.

Daniel

Daniel (view profile)

Hi Yair,

This is a really great tool, but I am having trouble getting it to run in 2014b for Mac. The issue seems to be a property of uitree you are accessing that has disappeared in this version. Here is the error:

SNIP
>> uiinspect(0)
uiinspect: Error using javahandle.com.mathworks.hg.peer.UITreePeer/set
The name 'NodeExpandedCallback' is not an accessible property for an instance of class 'com.mathworks.hg.peer.UITreePeer'.

Error in uiinspect>getHandleTree (line 1384)
set(tree_hh, 'NodeExpandedCallback', {@nodeExpanded, tree_h});

Error in uiinspect>getMethodsPane (line 1311)
paneContents = getHandleTree(obj, hFig);

Error in uiinspect>displayObj (line 360)
[methodsPane, hgFlag] = getMethodsPane(objMethods, obj, hFig);

Error in uiinspect (line 138)
fig = displayObj(obj, objMethods, objProps, objCallbacks, objChildren, inputname(1), fig);
/SNIP

And my version information
SNIP
ver
----------------------------------------------------------------------------------------------------
MATLAB Version: 8.4.0.150421 (R2014b)
MATLAB License Number: 900355
Operating System: Mac OS X Version: 10.9.5 Build: 13F34
Java Version: Java 1.7.0_67-b01 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
/SNIP

Yair Altman

Yair Altman (view profile)

@David - this is fixed in the latest version that I have just uploaded. Enjoy!

David

David (view profile)

Hi Yair,

Great tool...I've used it many times in the past with no problems. I tried running it today but got the error message,

uiinspect: Error using setappdata
Invalid object handle

Error in uiinspect>getHandleTree (line 1376)
setappdata(tree_h,
'userdata',userdata);

Error in uiinspect>getMethodsPane (line 1308)
paneContents = getHandleTree(obj,
hFig);

Error in uiinspect>displayObj (line 358)
[methodsPane, hgFlag] =
getMethodsPane(objMethods, obj, hFig);

Error in uiinspect (line 136)
fig = displayObj(obj, objMethods,
objProps, objCallbacks, objChildren,
inputname(1), fig);

My version info is

----------------------------------------------------------------------------------------------------
MATLAB Version: 8.3.0.532 (R2014a)
MATLAB License Number: ******
Operating System: Microsoft Windows 7 Enterprise Version 6.1 (Build 7601: Service Pack 1)
Java Version: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------

Thanks so much,
David

Great tool. I couldn't live without it.

Lorenzo

Jon Griffiths

Amazing work, which complements the built-in Matlab editor, but can also be used in compiled Matlab applications (mcc). Many thanks.

Yair Altman

Yair Altman (view profile)

@Jonathan - you can simply click the arrow on the top of the split-pane divider.

Or you can modify line #378:
hsplitPane.setResizeWeight(0.6);
to some other value (e.g., 0.1) to make a permanent change.

Jonathan Lister

Yair,
Is there a command/feature to cause the split panes to collapse such that the inspectable object properties pane is the only one immediately visible?

Thanks in advance.
Jonathan

Pablo Tacconi

Mike

Mike (view profile)

So far, I'm having just one problem. It keeps asking to update to most recent version (25-Jan-2013), even though it has already been updated. The actual file "modified" date is 22-Jan-2013.

Andrew

Andrew (view profile)

I finally got around to downloading it after your latest post. Great work!

Dan K

Dan K (view profile)

Yair,
I love your work, but the most recent version of this is crashing out on me:

uiinspect(0)
uiinspect: Dot name reference on non-scalar structure.
Error in uiinspect>getCbsPane (line 1080)
hModel = handle(callbacksTable.getModel, 'CallbackProperties');
Error in uiinspect>displayObj (line 323)
[callbacksPanel, cbTable] = getCbsPane(objCallbacks, false);
Error in uiinspect (line 128)
fig = displayObj(obj, objMethods, objProps, objCallbacks, objChildren, inputname(1), fig);

Many thanks for your submissions, regardless.

Dan

Yair Altman

Yair Altman (view profile)

@Johannes & @Henrik - the latest versions of uiinspect and findjobj that I uploaded a few days ago should have these issues fixed. They also have a few functional fixes/improvements, so it's worth downloading an update.

Johannes Korsawe

Yair,
thanks for all your work.
I tried the latest versions of uiinspect(9.12.2011) and findjobj (25.7.2012) together and ended up with the following error:
>> hFig = uiinspect(0);
Warning: Possible deprecated use of set on a Java callback.
> In uiinspect>getHandleTree at 1093
In uiinspect>getMethodsPane at 1030
In uiinspect>displayObj at 308
In uiinspect at 114
Warning: Possible deprecated use of set on a Java callback.
> In uiinspect>getHandleTree at 1094
In uiinspect>getMethodsPane at 1030
In uiinspect>displayObj at 308
In uiinspect at 114
Warning: Possible deprecated use of set on a Java callback.
> In uiinspect>getHandleTree at 1101
In uiinspect>getMethodsPane at 1030
In uiinspect>displayObj at 308
In uiinspect at 114
Warning: Possible deprecated use of set on a Java callback.
> In uiinspect>getHandleTree at 1102
In uiinspect>getMethodsPane at 1030
In uiinspect>displayObj at 308
In uiinspect at 114
Warning: Possible deprecated use of set on a Java callback.
> In uiinspect>getCbsPane at 902
In uiinspect>displayObj at 309
In uiinspect at 114
??? uiinspect: Java exception occurred:
java.lang.ArrayIndexOutOfBoundsException: No such child: 0
at java.awt.Container.getComponent(Unknown Source)
Error in ==> uiinspect>getPropsPane at 449
inspectorTable = inspectorTable.getComponent(0);
Error in ==> uiinspect>displayObj at 310
[propsPane, inspectorTable] = getPropsPane(objProps);
Error in ==> uiinspect at 114
fig = displayObj(obj, objMethods, objProps, objCallbacks, objChildren,
inputname(1), fig);

My version:
-------------------------------------------------------------------------------------
MATLAB Version 7.11.0.584 (R2010b)
MATLAB License Number: XXXXXX
Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)
Java VM Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
-------------------------------------------------------------------------------------

Any help is appreciated.
Regards,
Johannes

Absoluytely incredible !! superbe work.

Henrik Toft

I get following error when I try to use "uiinspect" in MATLAB R2011a. I have JUST downloaded the latest version on this page.

>> hFig = uiinspect(gcf);
Warning: Possible deprecated use of set on a Java object with an HG Property 'MousePressedCallback'.
> In uiinspect>getHandleTree at 1094
In uiinspect>getMethodsPane at 1023
In uiinspect>displayObj at 306
In uiinspect at 112
Warning: Possible deprecated use of set on a Java object with an HG Property 'MouseMovedCallback'.
> In uiinspect>getHandleTree at 1095
In uiinspect>getMethodsPane at 1023
In uiinspect>displayObj at 306
In uiinspect at 112
Warning: Possible deprecated use of set on a Java object with an HG Property 'UserData'.
> In uiinspect>getCbsPane at 895
In uiinspect>displayObj at 307
In uiinspect at 112
??? uiinspect: Java exception occurred:
java.lang.ArrayIndexOutOfBoundsException: No such child: 0

at java.awt.Container.getComponent(Unknown Source)

Error in ==> uiinspect>getPropsPane at 446
inspectorTable = inspectorTable.getComponent(0);

Error in ==> uiinspect>displayObj at 308
[propsPane, inspectorTable] = getPropsPane(objProps);

Error in ==> uiinspect at 112
fig = displayObj(obj, objMethods, objProps, objCallbacks, objChildren, inputname(1), fig);

>>
>> ver
-------------------------------------------------------------------------------------
MATLAB Version 7.12.0.635 (R2011a)
MATLAB License Number: ******
Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)
Java VM Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
-------------------------------------------------------------------------------------
MATLAB Version 7.12 (R2011a)
Neural Network Toolbox Version 7.0.1 (R2011a)
Statistics Toolbox Version 7.5 (R2011a)
>>

Cheers,
Henrik

Yair Altman

Yair Altman (view profile)

@Deng - I am not seeing the error that you reported. Please ensure that you are using the latest version of uiinspect. If you are using the latest version, please specify your system configuration as reported by the Matlab ver command.

Changshun Deng

error:

hFig = uiinspect(0); % root (desktop)
??? uiinspect: Conversion to double from javahandle_withcallbacks.com.mathworks.hg.peer.UITreePeer is not possible.

Error in ==> uiinspect>getHandleTree at 1227
setappdata(tree_h, 'userdata',userdata);

Error in ==> uiinspect>getMethodsPane at 1162
paneContents = getHandleTree(obj);

Error in ==> uiinspect>displayObj at 318
[methodsPane, hgFlag] = getMethodsPane(objMethods, obj);

Error in ==> uiinspect at 124
fig = displayObj(obj, objMethods, objProps, objCallbacks, objChildren, inputname(1), fig);

Pablo Tacconi

Simply excellent. Thanks Yair

Yair Altman

Yair Altman (view profile)

thanks Andrew - this will be fixed in the next update

Andrew Stamps

To follow up my rating, I wanted to say that I have found this to be a very useful tool. However, I think I found a small bug: On line 773 where it is attempting to get property values to display the code currently reads:

if strcmpi(mp.SetAccess,'public')

For this to make sense, I believe it really should be:

if strcmpi(mp.GetAccess,'public')

Yuri K

Yuri K (view profile)

wma

wma (view profile)

Yair Altman

Yair Altman (view profile)

For anyone interested, UIInspect now supports:
- Handle Graphics (GUI) objects
- Matlab class objects (e.g., memmapfile)
- Custom (user-defined) class objects
- Java objects
- COM (ActiveX or server) objects

Darik

Darik (view profile)

what are the chances this could be extended to work with custom handle objects, i.e. classes that inherit from handle?

Thanks for this very useful and sophisticated tool! Works great even with Java objects

Brandon Baker

"Thank you for this excellent application" is what I meant to say.

Brandon Baker

I love this program! What a nice way to ease myself into COM objects! Thank you for this excellent applications.

Updates

1.28

Fix for R2014a and older Matlab releases

1.27

Additional fixes for R2014b (HG2) - a lot of changes were indeed required for 14b, which broke numerous things!

1.26

Fixed properties panel for .Net objects

1.25

Fixed a reported "invalid object handle" bug

1.24

Fixes for multiple edge cases

1.23

Fixed for R2014a, R2014b

1.22

Fixes for the upcoming HG2

1.18

Prevented intermittent error reported for uiinspect(0); added hidden properties to the properties tooltip; updated help section; updated javadoc hyperlinks; fixed and improved callbacks table

1.21

Added context-menu options to export handle to workspace; prevented intermittent crash reported for uiinspect(0); fixed and improved callbacks table; added hidden properties to the properties tooltip; updated help section

1.17

Fixes for R2012a+

1.16

Fixed R2011b crash when inspecting COM; fixed problems with Value field in "Other properties" table of static fields; fixed display of non-static Java fields; fixed display of some cases of Java class names; minor fixes for Matlab class properties

1.15

Fixed several issues in the Value field of the "Other properties" table

1.14

Removed R2010b warning messages; minor fix for Dot-Net classes; minor fixes for callbacks table; fixed online docpage for Java Swing classes

1.13

Major fix for pre-R2010 compatibility

1.12

Major fix for pre-R2010 compatibility

1.11

Minor fix suggested by Andrew Stamps; added automatic callbacks grouping

1.10

Displayed class modifiers; improved performance; removed empty panels by default; fixed warning msgs when sorting props table; fixes for R2010b; fixed download (m-file => zip-file)

1.9

Displayed class modifiers; improved performance; removed empty panels by default; fixed warning msgs when sorting props table; fixes for R2010b

1.8

Fixes for R2010a

1.7

Added CaretPositionChanged & InputMethodTextChanged to list of standard callbacks; minor fix to requesting focus of Java handles; minor fix to version-check display; fixed a few bugs in properties meta-info of Matlab classes

1.6

Added support for Matlab classes (helped by Darik Gamble); improved display for classname input; fixed methods info gathering for some handles

1.5

Improved information display for HG handles; added HG-handle screenshot to animated gif (added to COM and Java screenshots); enabled reuse of uiinspect window

1.4

Fixed setting callbacks on non-handle('CallbackProperties')ed Java objects; fixed input param edge-case; hyperlinked the className to Sun's javadocs where relevant; auto-checked newer version; removed figure main menu

1.3

Fixed case of no methods (e.g., uimenus); fixed superclass/interfaces of classname input; auto-hide callbacks pane if no CBs are available; fixed occasional endless loop upon callback update error

1.2

Added Extra method details checkbox (default=off); auto-hide inspectable checkbox if irrelevant; auto-sort methods by args list; hyperlinked classes; fixed title for classname inputs

1.1

Fixed single property edge-case; fixed prop name case sensitivity problem; fixed properties tooltip; now accepts class names - not just object handles; added display of class interfaces & static fields

MATLAB Release
MATLAB 7.4 (R2007a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video