/*
* Copyright (C) 2004 TiongHiang Lee
*
* 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.1 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
*
* Email: thlee@onemindsoft.org
*/
package org.onemind.swingweb.client.gwt.ui;
import java.util.List;
import org.onemind.swingweb.client.core.AbstractClient;
import org.onemind.swingweb.client.dom.DomNode;
import org.onemind.swingweb.client.gwt.widget.IContainer;
import org.onemind.swingweb.client.gwt.widget.SplitPane;
import com.google.gwt.user.client.ui.Widget;
public class SplitPaneUIHandler extends ContainerUIHandler
{
public SplitPaneUIHandler(AbstractClient client)
{
super(client);
}
protected Object createComponentInstance(Object parent, DomNode element)
{
SplitPane sp = new SplitPane();
return sp;
}
protected void handleChildren(AbstractClient rootHandler, IContainer c, DomNode element)
{
SplitPane sp = (SplitPane) c;
List firstChild = getChildrenByTag(element, "firstComponent");
if (firstChild.size() > 0)
{
DomNode childNode = (DomNode) firstChild.get(0);
Widget w = (Widget) rootHandler.handle(c, getFirstChildElement(childNode));
sp.setFirstComponent(w);
}
List secondChild = getChildrenByTag(element, "secondComponent");
if (secondChild.size() > 0)
{
DomNode childNode = (DomNode) secondChild.get(0);
Widget w = (Widget) rootHandler.handle(c, getFirstChildElement(childNode));
sp.setSecondComponent(w);
}
}
protected Object updateUI(Object com, DomNode element)
{
int dividerSize = getInt(element, "dividerSize");
int dividerLoc = getInt(element, "dividerLocation");
String orientation = element.getAttribute("orientation");
SplitPane sp = (SplitPane) com;
sp.setDividerSize(dividerSize);
sp.setDividerLoc(dividerLoc);
if ("horizontal".equals(orientation))
{
sp.setOrientation(SplitPane.HORIZONTAL);
} else
{
sp.setOrientation(SplitPane.VERTICAL);
}
return super.updateUI(com, element);
}
}