是否有'AcceptsOneWidget`也是`ProvideResze`(除了`ScrollPanel`)? [英] Is there a `AcceptsOneWidget` which also `ProvidesResze` (other than `ScrollPanel`)?

查看:105
本文介绍了是否有'AcceptsOneWidget`也是`ProvideResze`(除了`ScrollPanel`)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组合扩展了 ResizeComposite 并且有一个 DockLayoutPanel 作为它的根。我可以将它直接粘贴到 RootLayoutPanel 中,它可以工作,因为 DockLayoutPanel ProvideResize RootLayoutPanel 可以' t被传递给 ActivityManager#setDiplay(AcceptsOneWidget)(因为它是一个多窗口小部件容器)。

起初一目了然, ScrollPanel 似乎满足实现 AcceptsOneWidget ProvideResize RequiresResize



但是我发现,当我将我的小部件放入 ScrollPanel 时,它具有'零大小' ,我必须手动调整大小才能看到它,而且我很难知道提供的尺寸。

解决方案

您可以添加 ProvideResize

code>通过自己实现它来实现它,这相对简单 - 您只需将所有调整大小通知传递给每个 RequiresResize 子子项。

或者,如果您只希望面板占用所有可用空间,则可以尝试在 ScrollPanel 100%



这里是我的一个LayoutPanel的实现, code> 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;



$ 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆