所以我在设计API时遇到了一个小问题,该API可以从DropBox的选定列表检查视图中还原数据-
checkList获取已删除数据的列表,并将其存储在另一个名为DeletedItems的列表中,因此,当在checkList上选择删除的数据时,它会存储在deltedItems中。
checkList = new ListView();
Label labelresponse= new Label();
checkList.setPadding(new Insets(10, 10, 10, 10));
checkList.setMaxHeight(400);
checkList.setMaxWidth(280);
checkList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
checkList.setCellFactory(CheckBoxListCell.forListView(new Callback<String, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(String item) {
BooleanProperty observable = new SimpleBooleanProperty();
observable.addListener((ObservableValue<? extends Boolean> obs, Boolean wasSelected, Boolean isNowSelected) -> {
//System.out.println("Check box for " + checkList+ " changed from " + wasSelected + " to " + isNowSelected);
if(isNowSelected) {
deletedItems.add(item);
}else{
deletedItems.remove(item);
}
System.out.println(deletedItems + "\n");
System.out.println(deletedItems.size() + "\n");
});
observable.set(deletedItems.contains(item));
deletedItems.addListener((SetChangeListener.Change<? extends String> c) ->
observable.set(deletedItems.contains(item)));
return observable ;
}
}));
现在,我想要将还原选定的DeletedItems的方法。但是我似乎无法正确实现它。我确实找到了有关如何在DropBox中还原数据的Java代码
public void dataRestoreFromList() throws DbxException {
FileMetadata revision = revisions.get(0);
revision.getRev();
String rPath = revision.getPathLower();
getDbxCleint().files().restore(rPath, revision.getRev());
}
反正我可以使用此方法从DeletedItems Set中还原数据吗?