Package org.xhtmlrenderer.simple.xhtml.controls

Examples of org.xhtmlrenderer.simple.xhtml.controls.ButtonControl


    protected Control createSWTControl(FormControl control,
            BasicRenderer parent, LayoutContext c, CalculatedStyle style,
            UserAgentCallback uac) {

        final ButtonControl bc = (ButtonControl) control;
        final Button button = new Button(parent, SWT.PUSH);
        button.setText(bc.getLabel());
        if (bc.isExtended()) {
            // when defined with <button>, allow the first image to be used
            NodeList images = bc.getElement().getElementsByTagName("img");
            if (images.getLength() > 0) {
                Element img = (Element) images.item(0);
                String uri = c.getNamespaceHandler().getImageSourceURI(img);
                ImageResource res = uac.getImageResource(uri);
                SWTFSImage fsi = (SWTFSImage) res.getImage();
                // copy the image to prevent disposal, and apply a disabled
                // effect if needed
                _image = new Image(button.getDisplay(), fsi.getImage(), (bc
                    .isEnabled() ? SWT.IMAGE_COPY : SWT.IMAGE_DISABLE));
                button.setImage(_image);
            }
        }

        if (bc.getType().equals("submit")) {
            button.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    if (bc.press()) {
                        bc.getForm().submit();
                    }
                }
            });
            // TODO better per form handling?
            parent.getShell().setDefaultButton(button);
        } else if (bc.getType().equals("reset")) {
            button.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    if (bc.press()) {
                        bc.getForm().reset();
                    }
                }
            });
        } else {
            button.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    bc.press();
                }
            });
        }

        return button;
View Full Code Here


                control = new TextControl(form, e);
            } else if (type.equals("hidden")) {
                control = new HiddenControl(form, e);
            } else if (type.equals("button") || type.equals("submit")
                    || type.equals("reset")) {
                control = new ButtonControl(form, e);
            } else if (type.equals("checkbox") || type.equals("radio")) {
                control = new CheckControl(form, e);
            } else {
                return null;
            }
        } else if (name.equals("textarea")) {
            control = new TextControl(form, e);
        } else if (name.equals("button")) {
            control = new ButtonControl(form, e);
        } else if (name.equals("select")) {
            control = new SelectControl(form, e);
        } else {
            return null;
        }
View Full Code Here

TOP

Related Classes of org.xhtmlrenderer.simple.xhtml.controls.ButtonControl

Copyright © 2018 www.massapicom. 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.