File Exchange

image thumbnail

propertiesGUI - display properties in an editable context-aware table

version 1.6 (69.3 KB) by

propertiesGUI processes and displays a list of data properties in a context-aware GUI table

8 Downloads

Updated

View License

Syntax:
[hPropsPane,parameters] = propertiesGUI(hParent, parameters, filename, selectedBranch)

Description:
propertiesGUI processes a list of data properties and displays
them in a GUI table, where each parameter value has a unique
associated editor.

propertiesGUI by itself, with no input parameters, displays a demo

By default, propertiesGUI identifies and processes the following
field types: signed, unsigned, float, file, folder, text or string, color,
IP Address, password, date, boolean, cell-array, numeric array,
font, struct and class object.

Inputs:
hParent - optional handle of a parent GUI container (figure/uipanel
/uitab) in which the properties table will appear.
If missing or empty or 0, the table will be shown in a
new modal dialog window; otherwise it will be embedded
in the parent container.

parameters - struct with data fields. The fields are processed
separately to determine their corresponding cell editor.
If parameters is not specified, then the global test_data
will be used. If test_data is also empty, then a demo of
several different data types will be used.

filename, selectedBranch - additional optional inputs that enable
runtime update of a data branch (see help section within
the utility for details)

Outputs:
hPropsPane - handle of the properties panel widget, which can be
customized to display field descriptions, toolbar, etc.

parameters - the resulting (possibly-updated) parameters struct.
Naturally, this is only relevant in case of a modal dialog.

(global test_data) - this global variable is updated internally when
the <OK> button is clicked. It is meant to enable easy data
passing between the properties GUI and other application
component. Using global vars is generally discouraged as
bad programming, but it simplifies component interaction.

Customization:
This utility is meant to be used either as stand-alone, or as a
template for customization. For example, you can attach a unique
description to each property that will be shown in an internal
sub-panel: see the customizePropertyPane() and preparePropsList()
sub-functions.

When passing the properties in an input parameters struct, the
utility automatically inspects each struct field and assigns a
corresponding cell-editor with no description and a field label
that reflects the field name. The properties are automatically
set as modifiable (editable) and assigned a default callback
function (propUpdatedCallback() sub-function).
See the demoParameters() sub-function for some examples.

You can have specific control over each property's description,
label, editability, cell-editor and callback function. See the
preparePropsList() sub-functions for some examples. You can add
additional cell-editors/renderers in the newProperty() sub-function.

You can place specific control over the acceptable property values
by entering custom code into the checkProp() sub-function.

Future development:
1. Improve the editor for time format
2. Enable more control over appearance and functionality via
propertiesGUI's input parameters
3. Add new cell editors/renderers: slider, point, rectangle (=position), ...

Example:
propertiesGUI; % displays the demo

params.name = 'Yair';
params.age = uint8(41);
params.folder = pwd;
params.date = now;
params.size.width = 10;
params.size.height = 20;
[hPropsPane, params] = propertiesGUI(params);

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

Warning:
This code heavily relies on undocumented and unsupported Matlab
functionality. It works on Matlab 7+, but use at your own risk!

A technical description of the implementation can be found at:
http://undocumentedmatlab.com/blog/propertiesGUI
http://undocumentedmatlab.com/blog/jide-property-grids
http://undocumentedmatlab.com/blog/advanced-jide-property-grids

Comments and Ratings (13)

Tapan

Tapan (view profile)

Hi Yair - Excellent tool!! I am running into the following error when I try to click on a drop-down menu. (Running Matlab 2014b, on MacOS, Java 1.7.0_55-b13). Would appreciate any recommendations...

Exception in thread "AWT-EventQueue-0" java.lang.IllegalAccessError: com/apple/laf/AquaUtils
at com.jidesoft.plaf.aqua.AquaExComboBoxPopup.computePopupBounds(Unknown Source)
at com.jidesoft.plaf.aqua.AquaExComboBoxPopup.adjustPopupAndGetBounds(Unknown Source)
at com.jidesoft.plaf.aqua.AquaExComboBoxPopup.getPreferredWidth(Unknown Source)
at com.jidesoft.plaf.basic.ExComboBoxPopup.showPopupPanelAsPopup(Unknown Source)
at com.jidesoft.plaf.basic.ExComboBoxPopup.a(Unknown Source)
at com.jidesoft.plaf.basic.ExComboBoxPopup.showPopupPanel(Unknown Source)
at com.jidesoft.plaf.basic.ExComboBoxPopup.show(Unknown Source)
at com.jidesoft.plaf.basic.ExComboBoxPopup.togglePopup(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup$Handler.mousePressed(BasicComboPopup.java:825)
at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:280)
at java.awt.Component.processMouseEvent(Component.java:6502)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
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:4489)
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:735)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
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:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
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)

Alexander

Yair Altman

Yair Altman (view profile)

@Sebastian - I've just uploaded a new version with fixes for R2014b (or newer) as well as many functional improvements. Enjoy!

Sebastian Hölz

For 2015a (and most likely 2014b) line 189 has to be changed from:

hFig = figure('Number','off', ...

to

hFig = figure('NumberTitle','off', ...

Cheers

Sebastian

Yair Altman

Yair Altman (view profile)

Sebastian - you can modify the propUpdatedCallback() function in propertiesGUI.m and where it is used within the code. It's pretty straight-forward.

Sebastian Hölz

Hi Yair,

is it possible to trigger a callback, if one of the items in the generated list is selected? I have a potentially complicated tree structure generated from a collection of graphical objects. As the user selects an item in the list, I would like to high-light the according graphics object.

Sebastian

Andrew Ness

I just commented out that statement and things have been working.

Andrew Ness

This looks like a nice utility. Unfortunately I am experiencing an error in R2012b, even when running just the demo multiple times. If I execute it twice, selecting cancel each time, there isn't a problem, however on the third try I receive this error:

>> propertiesGUI
>> propertiesGUI
>> propertiesGUI
Dot name reference on non-scalar structure.

Error in propertiesGUI (line 224)
pane.setBorderColor(pane.getBackground);

Yair Altman

Yair Altman (view profile)

@Izhar - you can easily modify the preparePropsList() sub-function, specifically lines #303-314 to handle a non-scalar numeric vector

izhar karbat

Hi Yair,
1) +1.

2) one of my fields contains an array of float values. only the first value is displayed in the table. is there any obvious workaround ?

Yair Altman

Yair Altman (view profile)

@Julien -

1. MATLAB uses JIDE internaly in numerous places, including uitable. You can use them freely, as part of the MATLAB license. For this reason I do not think there is any issue. But if you insist then you could ask MathWorks about it.

2. You can process objects using the standard struct() method, as follows:

params = struct(myClassObject);
[hPropsPane,params] = propertiesGUI(hParent, params);

Julien

Julien (view profile)

Very nice utility, thanks !
Do you know the terms of JIDE's license about using such components in deployed applications? Or maybe should I ask Mathworks directly?
Moreover, I have a suggestion : it would be nice to support matlab's classes in addition to structures. Do you plan to expand this?

Cristiano

Updates

1.6

Fixes for R2014b; added support for matrix data, data save/load, feedback links

1.5

Fixes for R2013b and R2014a; added support for Font property

1.3

Fixed case of empty ([]) data, handled class objects & numeric/cell arrays, fixed error reported by Andrew Ness

1.2

fixes for file/folder/date/color properties

1.1

Accept any object having properties/fields as input parameter; support multi-level properties

MATLAB Release
MATLAB 7.11 (R2010b)

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

» Watch video