I'm writing some code to expand the current folder viewer and I've found that expanding the folders, equivalent to clicking on the plus buttons, is a non-blocking call. The children of the folder are not valid until the folder has expanded. I'd like to put in some call that waits until the expansion is done but I'm not exactly sure how to proceed. Below is some code that will create a testing folder structure. The second part of code makes the expansion requests and indicates the failure point.
root = cd;
mkdir(cd,'test_root')
cd test_root
for i = 1:50
root2 = cd;
name = sprintf('test%d',i);
mkdir(cd,name);
cd(name)
for j = 1:20
root3 = cd;
name = sprintf('test%d',j);
mkdir(cd,name);
cd(name)
for k = 1:5
root4 = cd;
name = sprintf('test%d',k);
mkdir(cd,name);
end
cd(root3)
end
cd(root2)
end
cd(root)
cd test_root
h = com.mathworks.mde.explorer.Explorer.getInstance;
table = h.getTable;
table.collapseAll;
pause(1)
r = table.getRowAt(0);
n1 = r.getChildrenCount;
r.setExpanded(true);
x = r.isExpanded;
pause(0.001);
r2 = r.getChildAt(1);
n2 = r.getChildrenCount;
I can probably put together a hack based on getting the directory listing (e.g. dir) and waiting until the # of children equals the returned value, but I was hoping someone with more Java experience might have some insight into how to look for events that would notify the user that rendering has completed (or even better, if someone has actually has knowledge of this interface and could comment accordingly).
0 Comments
Sign in to comment.