Examples of McWindow


Examples of com.googlecode.mcvaadin.McWindow

    // --------------------------------------------------------------------------
    // -------------------------

    /** Create new McWindow and add it to current component container. */
    public McWindow mcwindow() {
        McWindow c = new McWindow();
        c.setImmediate(true);
        add(c);
        return c;
    }
View Full Code Here

Examples of com.googlecode.mcvaadin.McWindow

    /**
     * Create new McWindow with given caption and add it to current component
     * container.
     */
    public McWindow mcwindow(String caption) {
        McWindow c = mcwindow();
        c.setCaption(caption);
        return c;
    }
View Full Code Here

Examples of com.googlecode.mcvaadin.McWindow

        if (okTitle == null) {
            okTitle = CONFIRM_OK_TITLE;
        }

        // Create a confirm dialog
        final McWindow confirm = new McWindow(title);
        win.addWindow(confirm);
        confirm.setStyleName(Window.STYLE_LIGHT);

        // Close listener implementation
        confirm.addListener(new Window.CloseListener() {

            private static final long serialVersionUID = 1971800928047045825L;

            public void windowClose(CloseEvent ce) {
                Object data = ce.getWindow().getData();
                if (data != null) {
                    try {
                        listener.exec(new McEvent(ce));
                    } catch (Exception exception) {
                        error("Unhandled Exception", exception);
                    }
                }
            }
        });

        // Approximate the size of the dialog
        int chrW = 5;
        int chrH = 15;
        int txtWidth = Math.max(250, Math.min(350, message.length() * chrW));
        int btnHeight = 25;
        int vmargin = 100;
        int hmargin = 40;

        int txtHeight = 2 * chrH * (message.length() * chrW) / txtWidth;

        confirm.setWidth((txtWidth + hmargin) + "px");
        confirm.setHeight((vmargin + txtHeight + btnHeight) + "px");
        confirm.getContent().setSizeFull();

        // Modal position in the center
        confirm.center();
        confirm.setModal(true);

        // Create content
        final UIBuilder h = new UIBuilder(confirm.getContent());
        Label text = h.label(message);
        text.setWidth("100%");
        text.setHeight("100%");
        h.expand(text, 1f);


        HorizontalLayout buttons = h.horizontal();
        buttons.setHeight(btnHeight + "px");
        buttons.setWidth("100%");
        Label spacer = h.label("");
        spacer.setWidth("100%");
        h.expand(spacer, 1f);

        // Create a listener for buttons
        McListener btnListener = new McListener() {

            private static final long serialVersionUID = 517796258497875393L;

            @Override
            public void exec(McEvent e) throws Exception {
                // Copy the button date to window for passing through either
                // "OK" or "CANCEL"
                confirm.setData(e.getClickEvent().getButton().getData());
                confirm.closeWindow();
            }

        };
        Button cancel = h.button(cancelTitle, btnListener);
        cancel.setData(McEvent.USER_CONFIRM_CANCEL);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.