是否有一个“AcceptsOneWidget”也“ProvidesResze”(“ScrollPanel”除外)?

发布于 2024-10-19 10:58:56 字数 566 浏览 3 评论 0原文

我有一个扩展了 ResizeComposite 的组合,并以 DockLayoutPanel 作为其根。我可以将其直接粘贴到 RootLayoutPanel 中,并且它可以工作,因为 DockLayoutPanel ProvidesResize

但是,我想使用 GWT 2.2 中的 MVP 功能,并且 RootLayoutPanel 无法传递给 ActivityManager#setDiplay(AcceptsOneWidget) (因为它是一个多窗口小部件)容器)。

乍一看,ScrollPanel 似乎满足了实现 AcceptsOneWidget 以及 ProvidesResizeRequiresResize 的双重要求。

但我发现当我将我的小部件放入 ScrollPanel 中时,它的大小为零,我必须手动调整它的大小才能看到它,而且我很难知道给它多大的尺寸。我更喜欢一个不一定滚动的面板。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橪书 2024-10-26 10:58:56

将会有一个 SimpleLayoutPanel ,描述为:

一个简单的面板,{@link ProvidesResize} 到它的一个子面板。

There will be a SimpleLayoutPanel in GWT 2.3, described as:

A simple panel that {@link ProvidesResize} to its one child.

余生再见 2024-10-26 10:58:56

您可以通过自己实现来将 ProvidesResize 添加到任何小部件,这相对简单 - 您只需将收到的所有调整大小通知传递给 RequiresResize 的每个子子项即可。

或者,如果您只想让面板占据所有可用空间,您可以尝试将 ScrollPanel 上的宽度和高度设置为 “100%”

最后,这是我对 AcceptsOneWidget 的 LayoutPanel 的实现:

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;
        }
    }

}

我已经在我的商业应用程序中使用它几个月了,没有任何问题,并且可以轻松地在其中交换视图。您可以自行使用此代码。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文