/* SwingML
* Copyright (C) 2002 SwingML Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors:
* Ezequiel Cuellar <ecuellar@crosslogic.com>
*
*/
package org.swingml.xml.mapper;
import java.awt.*;
import org.swingml.*;
import org.swingml.model.*;
import org.swingml.xml.*;
import org.w3c.dom.*;
public class JTreeMapper extends MapperUtil implements Mapper {
public Object getModelToMap (Node aNode, Object aParent, Container aContainer) {
JTreeModel theModel = new JTreeModel();
SwingMLModel theContainer = (SwingMLModel) aParent;
theContainer.addChild(theModel);
theModel.setParent(theContainer);
return theModel;
}
public void mapModel (Node aNode, Object aParent, Container aContainer) {
JTreeModel theModel = (JTreeModel) this.getModelToMap(aNode, aParent, aContainer);
this.mapModelAttributes(aNode, theModel, aParent);
this.iterate(aNode, theModel, aContainer);
}
public void mapModelAttributes (Node aNode, Object aModel, Object aParent) {
JTreeModel theModel = (JTreeModel) aModel;
super.mapCommonAttributes(theModel, aNode);
Node theResultNode = super.getAttribute(aNode, Constants.DNDENABLED);
if (theResultNode != null) {
if (theResultNode.getNodeValue().equalsIgnoreCase(Constants.TRUE)) {
theModel.setDndEnabled(true);
}
}
theResultNode = super.getAttribute(aNode, Constants.VALUE);
if (theResultNode != null) {
theModel.setValue(theResultNode.getNodeValue());
}
theResultNode = super.getAttribute(aNode, Constants.OPEN_ICON);
if (theResultNode != null) {
theModel.setOpenFolderIcon(theResultNode.getNodeValue());
}
theResultNode = super.getAttribute(aNode, Constants.CLOSED_ICON);
if (theResultNode != null) {
theModel.setClosedFolderIcon(theResultNode.getNodeValue());
}
theResultNode = super.getAttribute(aNode, Constants.LEAF_ICON);
if (theResultNode != null) {
theModel.setLeafIcon(theResultNode.getNodeValue());
}
}
}
|