2019独角兽企业重金招聘Python工程师标准>>>

public abstract class MessageDialog extends AbstractDialog<String>
{
    private static final long serialVersionUID = 1L;

private Label label;
    private DialogButtons buttons;

/**
     * Constructor.
     * @param id the markupId, an html div suffice to host a dialog.
     * @param title the title of the dialog
     * @param message the message to be displayed
     * @param buttons button set to display
     */
    public MessageDialog(String id, String title, String message, DialogButtons buttons)
    {
        this(id, title, message, buttons, DialogIcon.NONE);
    }

/**
     * Constructor.
     * @param id the markupId, an html div suffice to host a dialog.
     * @param title the title of the dialog
     * @param message the message to be displayed
     * @param buttons button set to display
     */
    public MessageDialog(String id, IModel<String> title, IModel<String> message, DialogButtons buttons)
    {
        this(id, title, message, buttons, DialogIcon.NONE);
    }

/**
     * Constructor.
     * @param id the markupId, an html div suffice to host a dialog.
     * @param title the title of the dialog
     * @param message the message to be displayed
     * @param buttons button set to display
     * @param icon the predefined icon to display
     */
    public MessageDialog(String id, String title, String message, DialogButtons buttons, DialogIcon icon)
    {
        this(id, Model.of(title), Model.of(message), buttons, icon);
    }

/**
     * Constructor.
     * @param id the markupId, an html div suffice to host a dialog.
     * @param title the title of the dialog
     * @param message the message to be displayed
     * @param buttons button set to display
     * @param icon the predefined icon to display
     */
    public MessageDialog(String id, IModel<String> title, IModel<String> message, DialogButtons buttons, DialogIcon icon)
    {
        super(id, title, message, true);
        this.buttons = buttons;

WebMarkupContainer container = new WebMarkupContainer("container");
        this.add(container);

container.add(AttributeModifier.append("class", icon.getStyle()));
        container.add(new EmptyPanel("icon").add(AttributeModifier.replace("class", icon)));

this.label = new Label("message", this.getModel());
        container.add(this.label.setOutputMarkupId(true));
    }

@Override
    protected final List<DialogButton> getButtons()
    {
        if (this.buttons != null)
        {
            return this.buttons.toList();
        }

return super.getButtons(); //cannot happen
    }

@Override
    protected void onOpen(AjaxRequestTarget target)
    {
        target.add(this.label);
    }
}

<html xmlns:wicket="http://wicket.apache.org">
    <head>
    </head>
    <body>
        <wicket:panel>
            <div wicket:id="container" style="padding: 4px;">
                <span wicket:id="icon" style="display: inline-block; margin-right: 0.1em; vertical-align: middle;"></span>
                <span wicket:id="message" style="vertical-align: middle;"></span>
            </div>
        </wicket:panel>
    </body>
</html>
public class MessageDialogPage extends AbstractDialogPage
{
    private static final long serialVersionUID = 1L;

public MessageDialogPage()
    {
        this.init();
    }

private void init()
    {
        final Form<Void> form = new Form<Void>("form");
        this.add(form);

// FeedbackPanel //
        final FeedbackPanel feedback = new JQueryFeedbackPanel("feedback");
        form.add(feedback.setOutputMarkupId(true));

// Dialog //
        final MessageDialog informDialog = new MessageDialog("infoDialog", "Information", "This is a information message", DialogButtons.OK_CANCEL, DialogIcon.INFO) {

private static final long serialVersionUID = 1L;

@Override
            public void onClose(AjaxRequestTarget target, DialogButton button)
            {
            }
        };

this.add(informDialog);

final MessageDialog warningDialog = new MessageDialog("warningDialog", "Warning", "Are you sure you want to do something?", DialogButtons.YES_NO, DialogIcon.WARN) {

private static final long serialVersionUID = 1L;

@Override
            public void onClose(AjaxRequestTarget target, DialogButton button)
            {
            }
        };

this.add(warningDialog);

final MessageDialog errorDialog = new MessageDialog("errorDialog", new StringResourceModel("dialog.error.title", this, null), new StringResourceModel("dialog.error.message", this, null), DialogButtons.OK, DialogIcon.ERROR) {

private static final long serialVersionUID = 1L;

@Override
            public void onClose(AjaxRequestTarget target, DialogButton button)
            {
            }
        };

this.add(errorDialog);

// Buttons //
        form.add(new AjaxButton("info") {

private static final long serialVersionUID = 1L;

@Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form)
            {
                informDialog.open(target);
            }
        });

form.add(new AjaxButton("warning") {

private static final long serialVersionUID = 1L;

@Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form)
            {
                warningDialog.open(target);
            }
        });

form.add(new AjaxButton("error") {

private static final long serialVersionUID = 1L;

@Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form)
            {
                errorDialog.open(target);
            }
        });
    }
}

AbstractDialogPage

abstract class AbstractDialogPage extends SamplePage
{
    private static final long serialVersionUID = 1L;
    
    public AbstractDialogPage()
    {
        
    }
    
    @Override
    protected List<DemoLink> getDemoLinks()
    {
        return Arrays.asList(
                new DemoLink(MessageDialogPage.class, "Message Dialogs"),
                new DemoLink(CustomDialogPage.class, "Custom Dialog"),
                new DemoLink(FragmentDialogPage.class, "Fragment Dialog"),

new DemoLink(InputDialogPage.class, "Input Dialog"),
                new DemoLink(FormDialogPage.class, "Form Dialog (Slider sample)"),
                new DemoLink(UserDialogPage.class, "<b>Demo:</b> User Accounts")
            );
    }
}

SamplePage

public abstract class SamplePage extends TemplatePage
{
    private static final long serialVersionUID = 1L;
    private enum Source { HTML, JAVA, TEXT }

private static String getSource(Source source, Class<? extends SamplePage> scope)
    {
        PackageTextTemplate stream = new PackageTextTemplate(scope, String.format("%s.%s", scope.getSimpleName(), source.toString().toLowerCase()));
        String string = ResourceUtil.readString(stream);

try
        {
            stream.close();
        }
        catch (IOException e) { /* not handled */ }

return string;
    }

public SamplePage()
    {
        super();

this.add(new Label("title", this.getResourceString("title")));
        this.add(new Label("source-desc", this.getSource(Source.TEXT)).setEscapeModelStrings(false));
        this.add(new Label("source-java", this.getSource(Source.JAVA)));
        this.add(new Label("source-html", this.getSource(Source.HTML)));
        this.add(new JQueryBehavior("#wrapper-panel-source", "tabs"));

this.add(new ListView<DemoLink>("demo-list", this.getDemoLinks()) {

private static final long serialVersionUID = 1L;

@Override
            protected void populateItem(ListItem<DemoLink> item)
            {
                DemoLink object = item.getModelObject();
                Link<SamplePage> link = new BookmarkablePageLink<SamplePage>("link", object.getPage());
                link.add(new Label("label", object.getLabel()).setEscapeModelStrings(false)); //new StringResourceModel("title", ), getString("title", type)

item.add(link);
            }

@Override
            public boolean isVisible()
            {
                return this.getModelObject().size() > 0; //model object cannot be null
            }

});
    }

private String getResourceString(String string)
    {
        return this.getString(String.format("%s.%s", this.getClass().getSimpleName(), string));
    }

private String getSource(Source source)
    {
        return SamplePage.getSource(source, this.getClass());
    }

protected List<DemoLink> getDemoLinks()
    {
        return Collections.emptyList();
    }

protected class DemoLink implements IClusterable
    {
        private static final long serialVersionUID = 1L;

private final Class<? extends SamplePage> page;
        private final String label;

public DemoLink(Class<? extends SamplePage> page, String label)
        {
            this.page = page;
            this.label = label;
        }

public Class<? extends SamplePage> getPage()
        {
            return this.page;
        }

public String getLabel()
        {
            return this.label;
        }
    }
}

public abstract class TemplatePage extends WebPage
{
    private static final long serialVersionUID = 1L;

public TemplatePage()
    {
        super();

this.add(new Label("version", getApplication().getFrameworkSettings().getVersion()));
    }

@Override
    protected void onInitialize()
    {
        super.onInitialize();

this.add(new GoogleAnalyticsBehavior(this));
    }
}

class GoogleAnalyticsBehavior extends Behavior
{
    private static final long serialVersionUID = 1L;

private final String url;

public GoogleAnalyticsBehavior(final WebPage page)
    {
        this.url = GoogleAnalyticsBehavior.getUrl(page);
    }

private IModel<Map<String, Object>> newResourceModel()
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("url", this.url);

return Model.ofMap(map);
    }

private ResourceReference newResourceReference()
    {
        return new TextTemplateResourceReference(GoogleAnalyticsBehavior.class, "gaq.js", this.newResourceModel());
    }

@Override
    public void renderHead(Component component, IHeaderResponse response)
    {
        super.renderHead(component, response);

response.render(JavaScriptHeaderItem.forReference(this.newResourceReference(), "gaq"));
    }

private static String getUrl(WebPage page)
    {
        Url pageUrl = Url.parse(page.urlFor(page.getClass(), null).toString());
        Url baseUrl = new Url(page.getRequestCycle().getUrlRenderer().getBaseUrl());

baseUrl.resolveRelative(pageUrl);

return String.format("%s/%s", page.getRequest().getContextPath(), baseUrl);
    }
}

<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<wicket:head>
    <title>Wicket - jQuery UI: message dialog box</title>
</wicket:head>
</head>
<body>
<wicket:extend>
    <div id="wrapper-panel-frame" class="ui-corner-all">
        <form wicket:id="form">
            <button wicket:id="info">Open info</button>
            <button wicket:id="warning">Open warning</button>
            <button wicket:id="error">Open error</button>
            <br/><br/>
            <div wicket:id="feedback" style="width: 360px;"></div>
        </form>
    </div>
    <div wicket:id="infoDialog">[info]</div>
    <div wicket:id="warningDialog">[warning]</div>
    <div wicket:id="errorDialog">[error]</div>
</wicket:extend>
</body>
</html>

转载于:https://my.oschina.net/u/1047983/blog/146597

MessageDialog MessageDialogPage相关推荐

  1. xamarin UWP中MessageDialog与ContentDialog的区别

    MessageDialog与ContentDialog的异同点解析: 相同点一:都是uwp应用上的一个弹窗控件.都能做为弹出应用. 相异点一:所在命名空间不同,MessageDialog在Window ...

  2. wxPython第四篇、Choice、MessageDialog控件实例讲解

    wxPython第四篇.Choice.MessageDialog控件实例讲解 前言: ​ wxPython有很多控件例如Button.CheckBox.StaticText.ListBox 等等(an ...

  3. Java Swing弹出对话框之消息提示对话框MessageDialog

    消息提示对话框主要通过JOptionPane类的showMessageDialog来实现,主要用于信息提示.报警提示.错误提示等. 一.重载方法: JOptionPane.showMessageDia ...

  4. [UWP]实现一个轻量级的应用内消息通知控件

    [UWP]实现一个轻量级的应用内消息通知控件 原文:[UWP]实现一个轻量级的应用内消息通知控件 在UWP应用开发中,我们常常有向用户发送一些提示性消息的需求.这种时候我们一般会选择MessageDi ...

  5. pythongui登录界面密码显示_python的GUI之一个简单的登录界面

    self代表这个类,所以要注意self的用法 先总结一下遇到的错误: python positional argument follows keyword argument 位置参数在关键字参数之后 ...

  6. JOptionPane

    JOptionPane类 1.属于javax.swing 包. 2.功能:定制四种不同种类的标准对话框. ConfirmDialog 确认对话框.提出问题,然后由用户自己来确认(按"Yes& ...

  7. wxPython:Python首选的GUI库 | CSDN博文精选

    作者 | 天元浪子 来源 | CSDN博客 文章目录 概述 窗口程序的基本框架 事件和事件驱动 菜单栏/工具栏/状态栏 动态布局 AUI布局 DC绘图 定时器和线程 后记 概述 跨平台的GUI工具库, ...

  8. Windows 8 动手实验系列教程 实验8:Windows应用商店API

    动手实验 实验 8: Windows应用商店API 2012年9月 简介 编写Windows应用商店应用最令人瞩目的理由之一是您可以方便地将它们发布到Windows应用商店.考虑到世界范围内目前有超过 ...

  9. 为自己搭建一个鹊桥 -- Native Page与Web View之间的JSBridge实现方式

    原文:为自己搭建一个鹊桥 -- Native Page与Web View之间的JSBridge实现方式 说起JSBridge,大家最熟悉的应该就是微信的WeixinJSBridge,通过它各个公众页面 ...

  10. WP8.1 Study4:WP8.1中控件集合应用

    1.AutoSuggestBox的应用 在xaml里代码可如下: <AutoSuggestBox Name="autobox" Header="suggestion ...

最新文章

  1. ubuntu 修改时区、时间、同步网络时间、将时间写入硬件
  2. sql server 2000 版本查询
  3. python手机版打了代码运行不了-android手机安装python并写代码运行
  4. input标签内容改变的触发事件
  5. JS中怎样获取当前年以及前后几年并构造成对象数组
  6. VS2005 快捷键
  7. java maximumpoolsize,如果maximumPoolSize小于corePoolSize怎么办? Java 6中可能存在的错误?...
  8. c语言中三种常用的循环控制结构是,三C语言的基本控制结构.ppt
  9. Java 泛型中的? super T和? extends T
  10. jsp+servlet+mysql简单实现用户登陆注册
  11. 为了研究,可以在 Linux 内核中植入漏洞吗?
  12. android消息通知布局,Android Design
  13. 卡西欧计算机能开根号吗,考研计算器怎么开根号
  14. 倒立摆c语言程序设计,清华大学倒立摆控制系统实验指导书.pdf
  15. 不带HDMI的PD HUB方案深度解析(LDR6023A)性价比极高的充电数据方案
  16. mysql:Row size too large (> 8126)
  17. 细读HTTPS -- SSL/TLS历史,密码学
  18. 【HTML5+CSS】怎样去美化你的页面
  19. border边框部分不显示
  20. 电脑上怎么登录几个微信(微信多开)?不需要安装软件的方法,超简单

热门文章

  1. 谈一谈SQL Server中的执行计划缓存(下)
  2. 时尚服装行业挑战及软件机遇分享 -- 许鹏
  3. 544B. Sea and Islands
  4. Jmeter学习(一)
  5. PHP中的的一个挺好用的函数 array_chunk
  6. [WPF系列]Adorner应用-自定义控件ImageHotSpot
  7. 几点忠告送给在科研道路艰难跋涉的自己
  8. 精选 | 2018年4月R新包推荐
  9. C++函数指针和仿函数【转】
  10. 关于Mysql datetime类型存储范围测试