![JAR search and dependency download from the Maven repository](/logo.png)
com.sencha.gxt.data.shared.loader.TreeLoader Maven / Gradle / Ivy
/**
* Sencha GXT 3.1.0 - Sencha for GWT
* Copyright(c) 2007-2014, Sencha, Inc.
* [email protected]
*
* http://www.sencha.com/products/gxt/license/
*/
package com.sencha.gxt.data.shared.loader;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Default implementation of the TreeLoader
interface.
*
*
* - Events:
* - {@link BeforeLoadEvent}
* - {@link LoadEvent}
* - {@link LoadExceptionEvent}
*
*
*
* @param the model data type
*/
public class TreeLoader extends Loader> {
private Set children = new HashSet();
/**
* Creates a new tree loader instance.
*
* @param proxy the data reader
*/
public TreeLoader(DataProxy> proxy) {
super(proxy);
}
/**
* Creates a new tree loader instance.
*
* @param proxy the data proxy
* @param reader the data reader
*/
public TreeLoader(DataProxy proxy, DataReader, T> reader) {
super(proxy, reader);
}
/**
* Returns true if the model has children. This method allows tree based
* components to determine if the expand icon should be displayed next to a
* node.
*
* @param parent the parent model
* @return true if the model has children, otherwise false
*/
public boolean hasChildren(M parent) {
return false;
}
/**
* Initiates a load request for the parent's children.
*
* @param parent the parent
* @return true if the load was requested
*/
public boolean loadChildren(M parent) {
if (children.contains(parent)) {
return false;
}
children.add(parent);
return load(parent);
}
@Override
protected void onLoadFailure(M loadConfig, Throwable t) {
children.remove(loadConfig);
fireEvent(new LoadExceptionEvent(loadConfig, t));
}
@Override
protected void onLoadSuccess(M loadConfig, List result) {
children.remove(loadConfig);
fireEvent(new LoadEvent>(loadConfig, result));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy