propertiesGUI - display data in editable context-aware table

propertiesGUI processes and displays a list of data property values in a context-aware GUI table
2.2K Downloads
Updated 26 May 2024

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 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.
Possible 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), time, ...
Usage examples:
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)
Note:
This code heavily relies on Java component. Therefore, it does NOT work in uifigures, Live Editor, Matlab Online, or the Matlab JavaScript Desktop.
This is a known limitation, not a bug. There is no point in reporting it or complaining about it, because there is nothing that I can do about it.
If you want this functionality in uifigures etc., ask MathWorks to support a web-based properties-grid component.
Warning:
This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7+ or newer, but use at your own risk!
A technical description of the implementation can be found at:

Cite As

Yair Altman (2024). propertiesGUI - display data in editable context-aware table (https://www.mathworks.com/matlabcentral/fileexchange/38864-propertiesgui-display-data-in-editable-context-aware-table), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Environment and Settings in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.21.0.0

Fixes for class objects; prevent endless recursion (>5 levels); restored drop-down selections; fixed prop names column visibility; fixed default drop-down selection (was always set to 1st value); minor code cleanup

1.19.0.0

Fixes for R2022a; many small improvements/fixes

1.6.0.0

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

1.5.0.0

Fixes for R2013b and R2014a; added support for Font property

1.3.0.0

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

1.2.0.0

fixes for file/folder/date/color properties

1.1.0.0

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

1.0.0.0