Programming with JViews Maps > Introducing the Main Classes > Map Specific Manager Properties > Data Source Tree

This section describes:

The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir>/jviews-maps81/samples/mapbuilder/index.html

IlvMapDataSourceProperty

The IlvMapDataSourceProperty class is a named property used to attach a IlvMapDataSourceModel to an IlvManager.

This data source model controls all data sources that you import into the manager. It is also persistent data that is saved when you save the map.

Accessing the Data Source Model

You can access the map data source model by calling:

IlvMapDataSourceModel dsm = IlvMapDataSourceProperty.GetMapDataSourceModel(manager);
Adding a Listener

As the IlvMapDataSourceProperty is a named property of the manager, you can add a listener that is called whenever the property as a whole is changed, for example:

manager.addNamedPropertyListener(new NamedPropertyListener() {
  public void propertyChanged(NamedPropertyEvent event) {
    if (event.getPropertyName().equals(IlvMapDataSourceProperty.NAME)) {
      IlvMapDataSourceProperty p = (IlvMapDataSourceProperty) event.getNewValue();
      if (event.getType() == NamedPropertyEvent.PROPERTY_SET) {
		...do something
      }
    }
  }
});
Controlling Data Sources

You can allow users to edit and control individual data sources by adding an IlvDataSourcePanel Bean to your application. See Using the GUI Beans.

For more information about the data source tree, see Creating Data Source Objects, Using Data Sources, and Writing a Data Source.

Note
Although the Data Source Tree contains a Tree structure, JViews Maps 8.1 uses only a single level tree, resulting in a simpler data source list. Future versions, or user applications, may use the full tree structure for advanced features.

Reloading All Data Sources

This section describes the two ways to reload your data sources.

Reloading Using an IlvSDMEngine

If you have created an instance of IlvSDMEngine (even empty) in your manager. To reload the data, you can simply write:

engine.loadData();
Reloading Without Using an IlvSDMEngine

In case you do not want, or do not need, a symbol management utility, you can use the following code to reload your data:

  1. Retrieve the data source model root:
DefaultMutableTreeNode root = (DefaultMutableTreeNode) dsm.getRoot();
  1. Retrieve the map layers attached to each of the data sources:
int count = root.getChildCount();
for (int i = 0; i < count; i++) {
 DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i);
 IlvMapDataSource source = (IlvMapDataSource) node.getUserObject();
 IlvMapLayer mlayer = source.getInsertionLayer();
  1. Restart each data source ensuring that the tile manager updates the visible part of the view for data sources containing tiled layers:
 source.reset();
 source.start();
 IlvManagerLayer layer = mlayer.getManagerLayer();
 if (layer instanceof IlvTiledLayer) {
   ((IlvTiledLayer) layer).getTileController().updateView(getView());
 }