com.gwtext.client.widgets.tree
Class XMLTreeLoader

java.lang.Object
  extended by com.gwtext.client.core.JsObject
      extended by com.gwtext.client.widgets.tree.TreeLoader
          extended by com.gwtext.client.widgets.tree.XMLTreeLoader

public class XMLTreeLoader
extends TreeLoader

Provides the abilty to a TreePanel using remote XML data.This TreeLoader can be configured to load tree data from XML returned from a remote URL.

Sample code for loading a TreePanel using AsyncTreeNode and XmltreeLoader :

 

     final TreePanel treePanel = new TreePanel() {
            {
                setAnimate(true);
                setEnableDD(true);
                setContainerScroll(true);
                setRootVisible(true);
            }
        };

     final XMLTreeLoader loader = new XMLTreeLoader() {
            {
                setDataUrl("countries-cb.xml");
                setMethod("get");
                setRootTag("countries");
                setFolderIdMapping("@id");
                setLeafIdMapping("@id");
                setFolderTitleMapping("@title");
                setFolderTag("team");
                setLeafTitleMapping("@title");
                setLeafTag("country");
                setQtipMapping("@qtip");
                setDisabledMapping("@disabled");
                setCheckedMapping("@checked");
                setIconMapping("@icon");
                setAttributeMappings(new String[]{"@rank"});
            }
        };
        AsyncTreeNode root = new AsyncTreeNode("Countries", loader);

        treePanel.setRootNode(root);
        treePanel.render();

        root.expand();
        treePanel.expandAll();
 
 
The above code loads a Tree using the following XML data - countries-cb.xml
 
<countries>
    <team id="team-a" title="Team A" icon="images/silk/flag_yellow.gif" checked="true">
        <country title="Brazil" qtip="Rank 2" rank="2"  checked="false"/>
        <country title="Canada" qtip="Rank 3" rank="3" checked="false"/>
        <country title="China" qtip="Rank 4" rank="4" checked="false"/>
    </team>
    <team title="Team B" icon="images/silk/flag_blue.gif">
        <country title="Germany" qtip="Captain" checked="true" rank="1"/>
        <country title="France" qtip="Rank 2" rank="2" checked="false"/>
        <country title="Canada" qtip="Rank 3" rank="3" checked="false"/>
        <country title="India" qtip="Rank 4" rank="4" checked="false"/>
        <country title="Seychelles" qtip="Rank 5" rank="5" checked="false"/>
    </team>

    <team title="Team C" icon="images/silk/flag_green.gif">
        <country title="United States" qtip="Captain - Rank 1" checked="true" rank="1"/>
        <country title="Japan" qtip="Rank 2" rank="2" checked="false"/>
        <country title="Italy" qtip="Rank 3" rank="3" checked="false"/>
        <country title="Finland" qtip="Rank 4" rank="4" checked="false"/>
    </team>
  </countries>
 
 

See Also:
TreePanel, TreeLoader, AsyncTreeNode

Field Summary
 
Fields inherited from class com.gwtext.client.widgets.tree.TreeLoader
configJS
 
Fields inherited from class com.gwtext.client.core.JsObject
jsObj
 
Constructor Summary
XMLTreeLoader()
          Construct a new XMLTreeLoader.
XMLTreeLoader(java.lang.String url, java.lang.String rootTag, java.lang.String folderTag)
          Construct a new XMLTreeLoader.
 
Method Summary
protected  com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject configJS)
           
 java.lang.String getAllowDragMapping()
          Return the node's "allow drag" mapping.
 java.lang.String getAllowDropMapping()
          Return the node's "allow drop" mapping.
 java.lang.String[] getAttributeMappings()
          Return the node's attribute name(s) mapping.
 java.lang.String getCheckedMapping()
          Return the checkbox state value mapping.
 java.lang.String getDisabledMapping()
          Return the mapping for the disabled state value.
 java.lang.String getExpandedMapping()
          Return the mapping for the node's expanded state value.
 java.lang.String getFolderIdMapping()
          Return the folder ID value mapping.
 java.lang.String getFolderTag()
          Return the folder tag name.
 java.lang.String getFolderTitleMapping()
          Return the folder title mapping.
 java.lang.String getHrefMapping()
          Return the node's href value mapping
 java.lang.String getHrefTargetMapping()
          Return the node's href target value mapping.
 java.lang.String getIconClsMapping()
          Return the icon class mapping.
 java.lang.String getIconMapping()
          Return the icon mapping.
 java.lang.String getLeafIdMapping()
          Return the leaf ID value mapping.
 java.lang.String getLeafTag()
          Return the leaf tag name.
 java.lang.String getLeafTitleMapping()
          Return the leaf title mapping.
 java.lang.String getQtipMapping()
          Return the quick tip value mapping.
 java.lang.String getRootTag()
          Return the root tag name.
 void setAllowDragMapping(java.lang.String allowDragMapping)
          Set the node's "allow drag" mapping.
 void setAllowDropMapping(java.lang.String allowDropMapping)
          Set the node's "allow drop" mapping.
 void setAttributeMappings(java.lang.String[] attributeMappings)
          Set the node's attribute name(s) mapping.
 void setCheckedMapping(java.lang.String checkedMapping)
          Set the checkbox state value mapping.
 void setDisabledMapping(java.lang.String disabledMapping)
          Set the mapping for the disabled state value.
 void setExpandedMapping(java.lang.String expandedMapping)
          Set the mapping for the node's expanded state value.
 void setFolderIdMapping(java.lang.String folderIdMapping)
          Set the folder ID mapping relative to the folder tag.
 void setFolderTag(java.lang.String folderTag)
          The folder tag name in the XML data.
 void setFolderTitleMapping(java.lang.String folderTitleMapping)
          Mapping corresponding to the title of the folder relative to the folder tag.
 void setHrefMapping(java.lang.String hrefMapping)
          Set the node's href value mapping.
 void setHrefTargetMapping(java.lang.String hrefTargetMapping)
          Return the node's href target value mapping.
 void setIconClsMapping(java.lang.String iconClsMapping)
          Set the icon class mapping.
 void setIconMapping(java.lang.String iconMapping)
          Set the icon mapping.
 void setLeafIdMapping(java.lang.String leafIdMapping)
          Set the leaf ID mapping relative to the leaf tag.
 void setLeafTag(java.lang.String leafTag)
          The leaf tag name in the XML data.
 void setLeafTitleMapping(java.lang.String leafTitleMapping)
          Mapping corresponding to the title of the leaf relative to the leaf tag.
 void setQtipMapping(java.lang.String qtipMapping)
          Set the quick tip value mapping.
 void setRootTag(java.lang.String rootTag)
          The root tag name in the XML data.
 
Methods inherited from class com.gwtext.client.widgets.tree.TreeLoader
addListener, getJsObj, instance, load, load, setBaseAttrs, setBaseParams, setClearOnLoad, setDataUrl, setMethod, setMethod, setPreloadChildren
 
Methods inherited from class com.gwtext.client.core.JsObject
getProperties, isCreated, setJsObj
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLTreeLoader

public XMLTreeLoader()
Construct a new XMLTreeLoader.


XMLTreeLoader

public XMLTreeLoader(java.lang.String url,
                     java.lang.String rootTag,
                     java.lang.String folderTag)
Construct a new XMLTreeLoader.

Parameters:
url - the data url
rootTag - the root tag
folderTag - the folder tag
Method Detail

create

protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject configJS)
Overrides:
create in class TreeLoader

setRootTag

public void setRootTag(java.lang.String rootTag)
The root tag name in the XML data.

Parameters:
rootTag - the root tag name

setFolderTag

public void setFolderTag(java.lang.String folderTag)
The folder tag name in the XML data.

Parameters:
folderTag - the folder tag name

setLeafTag

public void setLeafTag(java.lang.String leafTag)
The leaf tag name in the XML data.

Parameters:
leafTag - the leaf tag name

setFolderTitleMapping

public void setFolderTitleMapping(java.lang.String folderTitleMapping)
Mapping corresponding to the title of the folder relative to the folder tag.

Parameters:
folderTitleMapping - the folder title mapping

setLeafTitleMapping

public void setLeafTitleMapping(java.lang.String leafTitleMapping)
Mapping corresponding to the title of the leaf relative to the leaf tag.

Parameters:
leafTitleMapping - the leaf title mapping

getRootTag

public java.lang.String getRootTag()
Return the root tag name.

Returns:
the root tag

getFolderTag

public java.lang.String getFolderTag()
Return the folder tag name.

Returns:
the folder tag

getLeafTag

public java.lang.String getLeafTag()
Return the leaf tag name.

Returns:
the leaf tag

getFolderTitleMapping

public java.lang.String getFolderTitleMapping()
Return the folder title mapping.

Returns:
folder title mapping

getLeafTitleMapping

public java.lang.String getLeafTitleMapping()
Return the leaf title mapping.

Returns:
the leaftitle mapping

getFolderIdMapping

public java.lang.String getFolderIdMapping()
Return the folder ID value mapping.

Returns:
the folder ID value mapping

getLeafIdMapping

public java.lang.String getLeafIdMapping()
Return the leaf ID value mapping.

Returns:
the leaf ID value mapping

setFolderIdMapping

public void setFolderIdMapping(java.lang.String folderIdMapping)
Set the folder ID mapping relative to the folder tag.

Parameters:
folderIdMapping - the folder ID mapping

setLeafIdMapping

public void setLeafIdMapping(java.lang.String leafIdMapping)
Set the leaf ID mapping relative to the leaf tag.

Parameters:
leafIdMapping - the leaf ID mapping

getIconMapping

public java.lang.String getIconMapping()
Return the icon mapping.

Returns:
the icon mapping

setIconMapping

public void setIconMapping(java.lang.String iconMapping)
Set the icon mapping.

Parameters:
iconMapping - the icon mapping

getIconClsMapping

public java.lang.String getIconClsMapping()
Return the icon class mapping.

Returns:
the icon class mapping

setIconClsMapping

public void setIconClsMapping(java.lang.String iconClsMapping)
Set the icon class mapping.

Parameters:
iconClsMapping - the icon class mapping

getQtipMapping

public java.lang.String getQtipMapping()
Return the quick tip value mapping.

Returns:
the quick tip mapping

setQtipMapping

public void setQtipMapping(java.lang.String qtipMapping)
Set the quick tip value mapping.

Parameters:
qtipMapping - the quick tip mapping

getCheckedMapping

public java.lang.String getCheckedMapping()
Return the checkbox state value mapping.

Returns:
the checked mapping

setCheckedMapping

public void setCheckedMapping(java.lang.String checkedMapping)
Set the checkbox state value mapping.

Parameters:
checkedMapping - the checked mapping

getDisabledMapping

public java.lang.String getDisabledMapping()
Return the mapping for the disabled state value.

Returns:
the disabled mapping

setDisabledMapping

public void setDisabledMapping(java.lang.String disabledMapping)
Set the mapping for the disabled state value.

Parameters:
disabledMapping - the disabled mapping

getExpandedMapping

public java.lang.String getExpandedMapping()
Return the mapping for the node's expanded state value.

Returns:
the expanded mapping

setExpandedMapping

public void setExpandedMapping(java.lang.String expandedMapping)
Set the mapping for the node's expanded state value.

Parameters:
expandedMapping - the expanded mapping

getHrefMapping

public java.lang.String getHrefMapping()
Return the node's href value mapping

Returns:
the href mapping

setHrefMapping

public void setHrefMapping(java.lang.String hrefMapping)
Set the node's href value mapping.

Parameters:
hrefMapping - the href mapping

getHrefTargetMapping

public java.lang.String getHrefTargetMapping()
Return the node's href target value mapping.

Returns:
the href target mapping

setHrefTargetMapping

public void setHrefTargetMapping(java.lang.String hrefTargetMapping)
Return the node's href target value mapping.

Parameters:
hrefTargetMapping - the href target mapping

getAllowDragMapping

public java.lang.String getAllowDragMapping()
Return the node's "allow drag" mapping.

Returns:
the allow drag mapping

setAllowDragMapping

public void setAllowDragMapping(java.lang.String allowDragMapping)
Set the node's "allow drag" mapping.

Parameters:
allowDragMapping - the allow drag mapping

getAllowDropMapping

public java.lang.String getAllowDropMapping()
Return the node's "allow drop" mapping.

Returns:
the allow drop mapping

setAllowDropMapping

public void setAllowDropMapping(java.lang.String allowDropMapping)
Set the node's "allow drop" mapping.

Parameters:
allowDropMapping - the allow drop mapping

getAttributeMappings

public java.lang.String[] getAttributeMappings()
Return the node's attribute name(s) mapping.

Returns:
the attribute name mapping

setAttributeMappings

public void setAttributeMappings(java.lang.String[] attributeMappings)
Set the node's attribute name(s) mapping.

Parameters:
attributeMappings - attribute name mapping