Create functions to create and then upgrade a toolbox factory
tree and then test that the upgrade completes successfully.
Create the function createMyToolboxFactoryTree
that
creates the factory settings tree for the toolbox
mytoolbox
.
Create the function
createMyToolboxSettingsFileUpgraders
with an empty
settings file upgrader object.
Create the settingsInfo.json
file for the toolbox.
Specify mytoolbox
as the root settings group name,
createMyToolboxFactoryTree
as the settings tree
creation function, and
createMyToolboxSettingsFileUpgraders
as the settings
tree upgrade function. Place settingsInfo.json
in the
toolbox resources
folder.
Add the folder that contains the settings tree creation function and the
toolbox resources folder to the MATLAB® path. Then, load the factory settings tree for
mytoolbox
.
Use the settings
function to access the root of the
settings tree and set the personal value for the
MyFontSize
setting.
Change the settings names in createMyToolboxFactoryTree
to be FontSize
and FontColor
.
Record the rename of the two settings in the
createMyToolboxSettingsFileUpgraders
function as
changes to the settings tree for version 2
of
mytoolbox
. When recording the rename of the two
settings, introduce an error in one of the paths. For example, remove
mytoolbox
from the destination path of the first
recorded change.
Reload the factory settings tree for
mytoolbox
.
Use the settings
function to access the root of the
settings tree and verify the personal value for the
FontSize
setting. Notice that the personal value was
not moved.
ans =
Setting 'mytoolbox.font.FontSize' with properties:
ActiveValue: 11
TemporaryValue: <no value>
PersonalValue: <no value>
FactoryValue: 11
Get the upgrade results for version 2
of
mytoolbox
and check the exception log for the first
operation.
ans =
ReleaseCompatibilityException with properties:
ExceptionString: ''font.FontSize' is an invalid path for adding a new group.
The path needs to be relative to the master settings file
and cannot contain ".." between folder names.'
ExceptionID: "MATLAB:settings:config:PathNotRelativeToMasterFile"