我正在尝试遍历整个工作区并在树视图中列出每个元素,但是当我尝试获取找到的文件夹中的工作表时,Folder 类中的 getSheets() 方法总是返回 null。难道我做错了什么?
TreeItem<String> workspace = new TreeItem<>("Earls Workspace", workspaceIcon);
workspace.setExpanded(true);
try {
Workspace earlsWorkspace = SmartsheetConnector.getInstance().getSmartsheet().workspaces().getWorkspace(*****);
List<Sheet> sheets = earlsWorkspace.getSheets();
List<Folder> folders = earlsWorkspace.getFolders();
for (Folder folder : folders) {
TreeItem<String> item = new TreeItem<>(folder.getName(), new ImageView(folderIcon));
System.out.println("Folder: " + folder.getName());
List<Sheet> folderSheets = folder.getSheets(); <- problem is here
System.out.println(folderSheets.toArray());
for (Sheet sheet : folderSheets) {
TreeItem<String> subItem = new TreeItem<>(sheet.getName(), new ImageView(sheetIcon));
item.getChildren().add(subItem);
}
workspace.getChildren().add(item);
}
for (Sheet sheet : sheets) {
TreeItem<String> item = new TreeItem<>(sheet.getName(), new ImageView(sheetIcon));
workspace.getChildren().add(item);
}
sheetExplorer.setRoot(workspace);
} catch (SmartsheetException ex) {
ex.printStackTrace();
}
我故意屏蔽了工作区 ID。