Thanks, Andrea.
I think (hope?) I'm getting closer. I can trigger my RPC call and get back a List of my objects, but I'm not seeing the magic that converts that list to a visible tree in my browser.
I've modified my data provider's instantiation to
public MyDataProvider(DirectoryObject directory) {
GWT.log("new data provider");
AsyncCallback<ArrayList<DirectoryObject>> callback =
new AsyncCallback<ArrayList<DirectoryObject>>() {
@Override
public void onFailure(Throwable caught) {
Window.alert((new MyGwtException(caught)).getMessage());
}
@Override
public void onSuccess(ArrayList<DirectoryObject> result) {{
GWT.log("got "+result.size()+" rows");
updateRowCount(result.size(), true);
updateRowData(0, result);
}
};
MyApp.getRpcService().getDirectoryListing(folderName, callback);
}
Is this right? It looks like CellTable stuff. There's no HasData<T> for CellTree. What fills in the CellTree?
The tree is declared in UiBinder with a null root. But since a null is also the condition for the server to start at the root of my directory tree, I test for login in my model:
@Override
public <T> NodeInfo<?> getNodeInfo(T value) {
GWT.log("getNodeInfo()");
if (value == null) {
GWT.log("value is null");
if (MyApp.isLoggedIn()) {
GWT.log("user is logged in");
// Create a cell to display a folder.
Cell<DirectoryObject> cell = new AbstractCell<DirectoryObject>() {
@Override
public void render(Context context, DirectoryObject value,
SafeHtmlBuilder sb) {
if (value != null) {
}
}
};
// Return a node info that pairs the data provider and the cell.
MyDataProvider provider = new MyDataProvider(null);
return new DefaultNodeInfo<DirectoryObject>(provider, cell);
}
else
return null;
}
else if (value instanceof DirectoryObject) {
DirectoryObject rec = (DirectoryObject) value;
if (rec.type.equals("folder")) {
Cell<DirectoryObject> cell = new AbstractCell<DirectoryObject>() {
@Override
public void render(Context context, DirectoryObject value,
SafeHtmlBuilder sb) {
if (value != null) {
}
}
};
// Return a node info that pairs the data provider and the cell.
MyDataProvider provider = new MyDataProvider(rec);
return new DefaultNodeInfo<DirectoryObject>(provider, cell);
}
else { // it's a file
Cell<DirectoryObject> cell = new AbstractCell<DirectoryObject>() {
@Override
public void render(Context context, DirectoryObject value,
SafeHtmlBuilder sb) {
if (value != null) {
}
}
};
// Return a node info that pairs the data provider and the cell.
MyDataProvider provider = new MyDataProvider(rec);
return new DefaultNodeInfo<DirectoryObject>(provider, cell, selectionModel, null);
}
}
return null;
}
I'm assuming this code creates a cell with the name from my DirectoryObject (later I want to expand this to add a folder icon).
My button's action is now
@UiHandler("list")
void onList(ClickEvent event) {
treeModel.getNodeInfo(null);
}
When I click the button I can see the log results I expect:
00:00:42.800 [INFO] getNodeInfo()
00:00:42.800 [INFO] value is null
00:00:42.800 [INFO] user is logged in
00:00:42.801 [INFO] new data provider
00:00:49.376 [INFO] got 31 rows
However I see nothing in the browser. Firebug shows an empty <div> where the CellTree belongs:
<div style="overflow: auto; position: relative; height: 200px; width: 100px;">
<div style="position: relative;">
<div class="GPBYFDEAG GPBYFDEKK" __gwtcellbasedwidgetimpldispatchingfocus="true" __gwtcellbasedwidgetimpldispatchingblur="true"></div>
</div>
</div>
What magic am I missing that turns my ArrayList<DirectoryObject> into the cells of a CellTree?