Code covered by the BSD License  

Highlights from
UIINSPECT - display methods, properties & callbacks of an object

5.0
5.0 | 16 ratings Rate this file 94 Downloads (last 30 days) File Size: 130 KB File ID: #17935 Version: 1.28
image thumbnail

UIINSPECT - display methods, properties & callbacks of an object

by

Yair Altman (view profile)

 

08 Dec 2007 (Updated )

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

| Watch this File

File Information
Description

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)

Acknowledgements

Find J Obj Find Java Handles Of Matlab Graphic Objects inspired this file.

This file inspired Check Version Check For A Newer File Version On The File Exchange, Properties Gui Display Properties In An Editable Context Aware Table, Convert Objects To String, Getundoc Get Undocumented Object Properties, Figure From Text File (Supports Html Tags), Programmatically Scroll Variables Editor, Find J Obj Find Java Handles Of Matlab Graphic Objects, and Check Class Inspect A Java/Matlab Class Object/Name.

MATLAB release MATLAB 7.4 (R2007a)
MATLAB Search Path
/
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (35)
02 Mar 2015 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).

Comment only
02 Mar 2015 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).

Comment only
01 Mar 2015 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)
>>

Comment only
01 Nov 2014 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.

Comment only
01 Nov 2014 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

24 Oct 2014 Yair Altman

Yair Altman (view profile)

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

Comment only
23 Oct 2014 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

Comment only
13 Oct 2014 Egon Geerardyn

Great tool. I couldn't live without it.

23 Jun 2014 Lorenzo  
15 Apr 2014 Jon Griffiths  
28 Aug 2013 Emmanuel Farhi

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

13 Jul 2013 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.

Comment only
12 Jul 2013 Jonathan Lister

Jonathan Lister (view profile)

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

Comment only
23 May 2013 Martin Lechner  
24 Apr 2013 Paul Andrews  
13 Feb 2013 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.

Comment only
28 Jan 2013 Andrew

Andrew (view profile)

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

21 Jan 2013 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

Comment only
17 Jan 2013 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.

Comment only
08 Jan 2013 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

Comment only
22 Aug 2012 Emmanuel Farhi

Absoluytely incredible !! superbe work.

26 Sep 2011 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

Comment only
17 Aug 2011 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.

Comment only
03 Aug 2011 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);

Comment only
23 Mar 2011 Martin Lechner  
21 Mar 2011 Paul Andrews

Simply excellent. Thanks Yair

19 Oct 2010 Yair Altman

Yair Altman (view profile)

thanks Andrew - this will be fixed in the next update

Comment only
19 Oct 2010 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')

29 Mar 2010 Yuri K

Yuri K (view profile)

 
09 Feb 2010 wma

wma (view profile)

 
18 Jan 2010 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

Comment only
01 May 2009 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?

Comment only
27 Mar 2009 Matthias Höller

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

12 Jun 2008 Brandon Baker

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

Comment only
12 Jun 2008 Brandon Baker

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

Updates
05 Mar 2009 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

30 Mar 2009 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

16 Apr 2009 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

03 May 2009 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

19 May 2009 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

26 May 2009 1.6

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

16 Jan 2010 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

16 Mar 2010 1.8

Fixes for R2010a

11 Jun 2010 1.9

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

12 Jun 2010 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)

20 Oct 2010 1.11

Minor fix suggested by Andrew Stamps; added automatic callbacks grouping

01 Nov 2010 1.12

Major fix for pre-R2010 compatibility

02 Nov 2010 1.13

Major fix for pre-R2010 compatibility

28 Feb 2011 1.14

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

03 Mar 2011 1.15

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

08 Dec 2011 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

14 Jan 2013 1.17

Fixes for R2012a+

25 Jan 2013 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

25 Jan 2013 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

08 Jul 2013 1.22

Fixes for the upcoming HG2

13 Oct 2014 1.23

Fixed for R2014a, R2014b

20 Oct 2014 1.24

Fixes for multiple edge cases

24 Oct 2014 1.25

Fixed a reported "invalid object handle" bug

24 Oct 2014 1.26

Fixed properties panel for .Net objects

21 Nov 2014 1.27

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

02 Mar 2015 1.28

Fix for R2014a and older Matlab releases

Contact us