I too have been wrestling with this. It's not quite there yet but I
sat down after reading your post and I have got a bit further.
It is possible to create a composite for "HorizontalSplitPanel" and
set a listener to watch what the mouse is doing. I defined this below
and a listener interface which the owner view can implement.
>>>CODE
package com.google.gwt.user.client.ui;
import com.google.gwt.event.dom.client.MouseMoveEvent;
import com.google.gwt.event.dom.client.MouseMoveHandler;
import com.google.gwt.user.client.Element;
public class HorizontalSplitPanelEx extends Composite
{
private SplitterEventHandler handler = null;
private HorizontalSplitPanel horizontalSplitPanel = null;
private Element splitElement = null;
public Element getSplitElement()
{
return splitElement;
}
public HorizontalSplitPanelEx(SplitterEventHandler handler)
{
this.handler = handler;
horizontalSplitPanel = new HorizontalSplitPanel();
initWidget(horizontalSplitPanel);
splitElement = horizontalSplitPanel.getSplitElement();
}
/**
* Attach mouse listener
*/
@Override
protected void onLoad()
{
super.onLoad();
getSplitPanel().addHandler(new MouseMoveHandler()
{
@Override
public void onMouseMove(MouseMoveEvent event)
{
handler.onMouseMove(event);
}
}, MouseMoveEvent.getType());
}
public HorizontalSplitPanel getSplitPanel()
{
return horizontalSplitPanel;
}
}
>>>> CODE
The owning view looks like
>>>> CODE
public class MainComposite extends Composite implements ResizeHandler,
SplitterEventHandler
{
private HorizontalSplitPanelEx mainHorizontalSplitPanel = null;
private MainListBox mainListBox = null;
private MainTextArea mainTextArea = null;
/**
*
*/
public MainComposite()
{
super();
mainHorizontalSplitPanel = new HorizontalSplitPanelEx(this);
initWidget(mainHorizontalSplitPanel);
mainHorizontalSplitPanel.getSplitPanel().setSplitPosition
("30%");
mainListBox = new MainListBox();
mainTextArea = new MainTextArea();
mainHorizontalSplitPanel.setWidth("100%");
mainHorizontalSplitPanel.setHeight("100%");
mainHorizontalSplitPanel.getSplitPanel().setLeftWidget
(mainListBox);
mainHorizontalSplitPanel.getSplitPanel().setRightWidget
(mainTextArea);
// Test items.
mainListBox.addItem("One");
mainListBox.addItem("Two");
mainListBox.addItem("Three");
mainListBox.addItem("Four");
mainListBox.addItem("Five");
mainListBox.setSelectedIndex(-1);
mainListBox.setVisibleItemCount(3);
}
@Override
protected void onLoad()
{
super.onLoad();
}
/**
* @return
*/
public ListBox getListBox()
{
return mainListBox;
}
/**
* @return
*/
public TextArea getTextArea()
{
return mainTextArea;
}
/**
* Adjust elements.
*
* @param event
*/
@Override
public void onResize(ResizeEvent event)
{
int listWidth = (int) (event.getWidth()*
MainListBox.PERCENTAGE);
mainHorizontalSplitPanel.getSplitPanel().setSplitPosition
(listWidth+ "px");
mainListBox.onResize(event);
mainTextArea.onResize(event);
}
/**
* Handle On Splitter move
*/
@Override
public void onMouseMove(MouseMoveEvent event)
{
String left = DOM.getStyleAttribute
(mainHorizontalSplitPanel.getSplitElement(), "left");
System.out.println(left);
if (MouseMoveEvent.getType().equals(Event.ONMOUSEMOVE))
{
// TODO RESIZE YOUR VIEWS
}
}
}
>>>> CODE
The secret-sauce is the getting the position of the splitter element
using the DOM.getStyleAttribute call. We can then use this to
calculate the new size of the right pane.
Al.
On Oct 28, 1:08 am, renju <[email protected]> wrote:
> Hello friends,
>
> I have a horizontal split panel which has a tree on the left side and
> a custom widget on the right side. When the horizontal split panel is
> re-sized, my tree is resizing. But my custom widget is not resizing
> itself.
>
> Also I cannot override the onSplitterResize() inside HorizontalPanel
> since it is final. Neither can I extend theHorizontalSplitPanelsince
> the class itself is final.
>
> If you guys know, please let me know a way out.
>
> Thanks,
> George
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---