|
6 | 6 |
|
7 | 7 | % File or folder selection control with browse button |
8 | 8 |
|
9 | | - % Copyright 2020-2022 The MathWorks Inc. |
| 9 | + % Copyright 2020-2023 The MathWorks Inc. |
10 | 10 |
|
11 | 11 |
|
12 | 12 | %% Public properties |
|
36 | 36 |
|
37 | 37 | properties (AbortSet) |
38 | 38 |
|
39 | | - % Selection type: file or folder |
| 39 | + % Selection type: (get)file, folder, putfile |
40 | 40 | SelectionType (1,1) wt.enum.FileFolderState = wt.enum.FileFolderState.file |
41 | 41 |
|
42 | 42 | % Optional root directory. If unspecified, Value uses an absolute |
|
75 | 75 |
|
76 | 76 |
|
77 | 77 | %% Internal Properties |
78 | | - properties ( Transient, NonCopyable, ... |
79 | | - Access = {?matlab.uitest.TestCase, ?matlab.ui.componentcontainer.ComponentContainer} ) |
| 78 | + properties (Transient, NonCopyable, Hidden, SetAccess = protected) |
80 | 79 |
|
81 | 80 | % Button |
82 | 81 | ButtonControl (1,1) matlab.ui.control.Button |
@@ -197,6 +196,8 @@ function updateButtonIcon(obj) |
197 | 196 | % Update the button icon |
198 | 197 | if obj.SelectionType == "file" |
199 | 198 | obj.ButtonControl.Icon = "folder_file_24.png"; |
| 199 | + elseif obj.SelectionType == "putfile" |
| 200 | + obj.ButtonControl.Icon = "folder_file_24.png"; |
200 | 201 | else |
201 | 202 | obj.ButtonControl.Icon = "folder_24.png"; |
202 | 203 | end |
@@ -260,6 +261,8 @@ function onButtonPushed(obj,~) |
260 | 261 | % Prompt user for the path |
261 | 262 | if obj.SelectionType == "file" |
262 | 263 | [fileName,pathName] = uigetfile(filter,"Select a file",initialPath); |
| 264 | + elseif obj.SelectionType == "putfile" |
| 265 | + [fileName,pathName] = uiputfile(filter,"Specify an output file",initialPath); |
263 | 266 | else |
264 | 267 | pathName = uigetdir(initialPath, "Select a folder"); |
265 | 268 | fileName = ""; |
@@ -307,6 +310,8 @@ function addToHistory(obj,value) |
307 | 310 | % Filter to valid paths |
308 | 311 | if obj.SelectionType == "file" |
309 | 312 | fcn = @(x)gt(exist(fullfile(obj.RootDirectory, x),"file"), 0); |
| 313 | + elseif obj.SelectionType == "putfile" |
| 314 | + fcn = @(x)gt(exist(fullfile(obj.RootDirectory, x),"file"), 0); |
310 | 315 | else |
311 | 316 | fcn = @(x)eq(exist(fullfile(obj.RootDirectory, x),"dir"), 7); |
312 | 317 | end |
@@ -427,6 +432,7 @@ function setValueFromFullPath(obj,fullPath) |
427 | 432 | function value = get.ValueIsValidPath(obj) |
428 | 433 | filePath = fullfile(obj.RootDirectory, obj.Value); |
429 | 434 | value = ( obj.SelectionType == "file" && isfile(filePath) ) || ... |
| 435 | + ( obj.SelectionType == "putfile" && isfolder(fileparts(filePath)) ) || ... |
430 | 436 | ( obj.SelectionType == "folder" && isfolder(filePath) ); |
431 | 437 | end |
432 | 438 |
|
|
0 commit comments