是否有'AcceptsOneWidget`也是`ProvideResze`(除了`ScrollPanel`)? [英] Is there a `AcceptsOneWidget` which also `ProvidesResze` (other than `ScrollPanel`)?
问题描述
我有一个组合扩展了 起初一目了然, 但是我发现,当我将我的小部件放入 您可以添加 或者,如果您只希望面板占用所有可用空间,则可以尝试在 这里是我的一个LayoutPanel的实现, code> AcceptsOneWidget ResizeComposite
并且有一个 DockLayoutPanel
作为它的根。我可以将它直接粘贴到 RootLayoutPanel
中,它可以工作,因为 DockLayoutPanel
ProvideResize $ c $不过,我想要在GWT 2.2中使用MVP工具,而
: RootLayoutPanel
可以' t被传递给 ActivityManager#setDiplay(AcceptsOneWidget)
(因为它是一个多窗口小部件容器)。
ScrollPanel
似乎满足实现 AcceptsOneWidget
和 ProvideResize $的双重要求c $ c>和
RequiresResize
。
ScrollPanel
时,它具有'零大小' ,我必须手动调整大小才能看到它,而且我很难知道提供的尺寸。 ProvideResize
RequiresResize
子子项。
ScrollPanel
到100%
。
public class PanelForView extends LayoutPanel implements AcceptsOneWidget
{
IsWidget myWidget = null;
@Override
public void setWidget(IsWidget w)
{
if(myWidget!= w)
{
if(myWidget! = null)
{
remove(myWidget);
}
if(w!= null)
{
add(w);
}
myWidget = w;
$ b $ / code $ / pre
$ b $ I'我一直在我的商业应用程序中使用这个几个月没有任何问题,并且很容易将视图换入和换出。请随意使用此代码。
I have a composite which extends ResizeComposite
and has a DockLayoutPanel
as its root. I can stick it directly into RootLayoutPanel
and it works because DockLayoutPanel
ProvidesResize
.
However, I'm wanting to use the MVP facilities in GWT 2.2, and RootLayoutPanel
can't be passed to ActivityManager#setDiplay(AcceptsOneWidget)
(since it's a multi-widget container).
At first glance, ScrollPanel
appears to meet the dual requirement of implementing AcceptsOneWidget
and both ProvidesResize
and RequiresResize
.
But I am finding that when I put my widget into a ScrollPanel
, that it has a 'zero size', and I have to size it manually in order to see it, and I'm having trouble knowing what size to give it. I'd rather a Panel that didn't necessarily scroll.
解决方案 You can add ProvidesResize
to any widget by implementing it yourself, which is relatively simple - you just pass along all of the resize notifications you get to every sub-child that RequiresResize
.
Alternatively, if you just want your panel to take up all of the available space, you might try setting the width and height on the ScrollPanel
to "100%"
.
Finally, here's my implementation of a LayoutPanel that AcceptsOneWidget
:
public class PanelForView extends LayoutPanel implements AcceptsOneWidget
{
IsWidget myWidget = null;
@Override
public void setWidget(IsWidget w)
{
if (myWidget != w)
{
if (myWidget != null)
{
remove(myWidget);
}
if (w != null)
{
add(w);
}
myWidget = w;
}
}
}
I've been using this in my commercial app for months without any problems, and it's easy to swap views in and out of it. Feel free to use this code yourself.
这篇关于是否有'AcceptsOneWidget`也是`ProvideResze`(除了`ScrollPanel`)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!