Example usage for com.google.gwt.user.client.ui HTML HTML

List of usage examples for com.google.gwt.user.client.ui HTML HTML

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HTML HTML.

Prototype

protected HTML(Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

From source file:asquare.gwt.tk.demo.client.MiscPanel.java

License:Apache License

private Widget createBasicPanelPanel() {
    BasicPanel panel = new BasicPanel("div");
    panel.setStyleName("division");

    String content = "<H2>BasicPanel</H2>"
            + "A barebones ComplexPanel which allows customization of the root element and <code>display</code> style of added children. ";
    HTML header = new HTML(content);
    header.addStyleName("header");
    panel.add(header);//from  w  w  w.j  a  v  a 2s .  c o  m

    BasicPanel example = new BasicPanel();
    example.addStyleName("example");

    BasicPanel panel1 = new BasicPanel("div", BasicPanel.DISPLAY_INLINE);
    for (int i = 0; i < 5; i++) {
        panel1.add(new Button("Button"));
    }
    for (int i = 0; i < 5; i++) {
        panel1.add(new Button("Button"));
    }
    example.add(panel1);

    BasicPanel panel2 = new BasicPanel("span", BasicPanel.DISPLAY_BLOCK);
    for (int i = 0; i < 10; i++) {
        panel2.add(new Button("Button"));
    }
    example.add(panel2);

    panel.add(example);
    return panel;
}

From source file:asquare.gwt.tk.uitest.popuppanel.client.Demo.java

License:Apache License

private Widget createDefaultTransparencyTest() {
    RowPanel outer = new RowPanel();
    outer.add(new HTML("<h3>Default transparency test</h3>"));
    final Button button = new Button("Show popup");
    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            PopupPanel popup = new PopupPanel(true);
            popup.setPopupPosition(button.getAbsoluteLeft(),
                    button.getAbsoluteTop() + button.getOffsetHeight());
            popup.setWidth("10em");
            DomUtil.setStyleAttribute(popup, "border", "solid black 1px");
            popup.setWidget(new HTML("<p>This popup should be transparent in all browsers.</p>"));
            popup.show();/* w  ww  . j av a 2s  .  c o m*/
        }
    });
    outer.add(button);
    return outer;
}

From source file:asquare.gwt.tk.uitest.popuppanel.client.Demo.java

License:Apache License

private Widget createTransparencyTest() {
    RowPanel outer = new RowPanel();
    BasicToolTip toolTip = new BasicToolTip();
    Controller ttController = new BasicToolTipController(toolTip);

    outer.add(new HTML("<h3>Popup transparency</h3><p>Hover over a widget</p>"));

    ListBox list = new ListBox(true);
    list.setVisibleItemCount(4);//from w ww  .j  av a  2  s .c om
    list.addItem("ListBox");
    list.addItem("1");
    list.addItem("2");
    list.addItem("3");
    list.addItem("4");
    list.addItem("5");
    outer.add(new ToolTipWrapper(list, "Popup transparency over a ListBox").addController(ttController));

    outer.add(new ToolTipWrapper(new Frame("FrameContents.html"), "Popup transparency over a Frame")
            .addController(ttController));

    outer.add(new ToolTipWrapper(new RadioButton("radioGroup", "RadioButton a"), "Choice a")
            .addController(ttController));
    outer.add(new ToolTipWrapper(new RadioButton("radioGroup", "RadioButton b"), "Choice b")
            .addController(ttController));
    outer.add(new ToolTipWrapper(new RadioButton("radioGroup", "RadioButton c"), "Choice c")
            .addController(ttController));
    return outer;
}

From source file:asquare.gwt.tkdemo.client.Demo.java

License:Apache License

public void onModuleLoad() {
    Debug.enableSilently();//from w ww.ja  v  a2s  .  c om

    final AppPanelCollection panels = new DemoPanelCollection();

    String initialTabToken = History.getToken();
    int initialIndex = panels.getIndexForToken(initialTabToken);
    if (initialIndex == -1) {
        initialIndex = 0;
    }

    // use a table for border to work around bugs with 100% child width
    RowPanel outer = new RowPanel();
    DomUtil.setAttribute(outer, "id", "main");
    outer.setWidth("100%");

    ExposedCellPanel tabPanel = new ColumnPanel();
    tabPanel.setSize("100%", "100%");

    CTabBar tabbar = new CTabBar(new ListWidgetVTable(), new SideTabRenderer3());
    tabbar.removeController(tabbar.getController(CompositeCellViewHoverController.class));
    tabbar.setStyleName("DemoTabBar");
    History.addValueChangeHandler(new TabModelUpdateController(panels, tabbar.getListModel()));
    tabPanel.add(tabbar);
    tabPanel.setCellStyleName("DemoTabPanel-tabBar");

    tabPanel.add(new HTML("<h2 style='text-align: center; width: 100%; height: 100%;'>Loading...</h2>"));
    tabPanel.setCellStyleName("DemoTabPanel-tabBody");
    tabPanel.setCellWidth("100%");
    new TabBodyUpdateController(tabbar.getListModel(), tabPanel, panels);

    outer.add(tabPanel);
    RootPanel.get().add(outer);

    BrowserInfo browserInfo = (BrowserInfo) GWT.create(BrowserInfo.class);
    String compatMode = describeCompatMode();
    Label env = new Label(compatMode + " (" + browserInfo.getUserAgent() + ")");
    env.setStyleName("compatMode");
    outer.add(env);

    new DebugElementDumpInspector().install();

    /**
    * Incrementally add tabs to TabBar, allowing the UI to redraw to show
    * progress.
    */
    DeferredCommand.addCommand(new LoadUICommand(panels, tabbar, initialIndex));
}

From source file:asquare.gwt.tkdemo.client.demos.DialogPanel.java

License:Apache License

private Widget createModalDialogDemo() {
    BasicPanel panel = new BasicPanel("div", "block");
    panel.setStyleName("example division");
    DomUtil.setStyleAttribute(panel, "whiteSpace", "nowrap");

    panel.add(new HTML("<h4>ModalDialog examples</h4>"));

    class CloseListener implements ClickHandler {
        private final ModalDialog m_dialog;

        public CloseListener(ModalDialog dialog) {
            m_dialog = dialog;//from   w w  w . j a va 2  s  .  co  m
        }

        public void onClick(ClickEvent event) {
            m_dialog.hide();
        }
    }

    class CloseButton extends Button {
        public CloseButton(ModalDialog dialog) {
            super("Close");
            addClickHandler(new CloseListener(dialog));
        }

        public CloseButton(ModalDialog dialog, String text) {
            super(text);
            addClickHandler(new CloseListener(dialog));
        }
    }

    final Button plainDialog = new Button("Plain");
    plainDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.setCaption("Caption area", false);
            dialog.add(new Label("Content area"));
            dialog.add(new CloseButton(dialog));
            dialog.show(plainDialog);
        }
    });
    panel.add(plainDialog);

    final Button verboseDialog = new Button("Verbose");
    verboseDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.setCaption("Verbose dialog", false);
            dialog.add(new Label("Twas brillig, and the slithy toves " + "  Did gyre and gimble in the wabe: "
                    + "All mimsy were the borogoves, " + "  And the mome raths outgrabe "
                    + "Beware the Jabberwock, my son! " + "The jaws that bite, the claws that catch! "
                    + "Beware the Jubjub bird, and shun " + "The frumious Bandersnatch!"));
            dialog.add(new CloseButton(dialog));
            dialog.show(verboseDialog);
        }
    });
    panel.add(verboseDialog);

    final Button captionLessDialog = new Button("No caption");
    captionLessDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.add(new Label("Captionless dialog"));
            dialog.add(new CloseButton(dialog));
            dialog.show(captionLessDialog);
        }
    });
    panel.add(captionLessDialog);

    final Button loadingDialog = new Button("Loading...");
    loadingDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            final Label label = new Label("0% loaded");
            dialog.add(label);
            dialog.show(loadingDialog);
            new Timer() {
                private int m_count = 0;

                public void run() {
                    label.setText(++m_count + "% loaded");
                    if (m_count == 100) {
                        dialog.hide();
                        cancel();
                    }
                }
            }.scheduleRepeating(1);
        }
    });
    panel.add(loadingDialog);

    final Button undraggableDialog = new Button("Drag disabled");
    undraggableDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog() {
                protected List<Controller> createCaptionControllers() {
                    List<Controller> result = new ArrayList<Controller>();
                    result.add(ControlSurfaceController.getInstance());
                    return result;
                }
            };
            dialog.setCaption("Drag disabled", false);
            dialog.add(new Label(
                    "This dialog uses a custom controller in the header which does not provide drag support."));
            dialog.add(new CloseButton(dialog));
            dialog.show(undraggableDialog);
        }
    });
    panel.add(undraggableDialog);

    final Button styledDragDialog = new Button("Drag style");
    styledDragDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            String oldPrimaryName = dialog.getStylePrimaryName();
            dialog.setStylePrimaryName("dialog-dragstyle");
            dialog.addStyleName(oldPrimaryName);
            dialog.setCaption("Drag me", false);
            dialog.add(new Label(
                    "This dialog employs the \"tk-ModalDialog-dragging\" style which is applied while dragging. "));
            dialog.add(new CloseButton(dialog));
            dialog.show(styledDragDialog);
        }
    });
    panel.add(styledDragDialog);

    final Button focusManagementDialog = new Button("Focus management");
    focusManagementDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.setCaption("Register", false);
            FocusModel fModel = dialog.getFocusModel();

            final int FIELD_COUNT = 3;
            Grid table = new Grid(FIELD_COUNT, 2);
            dialog.add(table);
            Widget[] labels = new Widget[FIELD_COUNT];
            labels[0] = new Label("User name: ");
            labels[1] = new Label("Password: ");
            labels[2] = new Label("Retype password: ");

            FocusWidget[] fields = new FocusWidget[FIELD_COUNT];
            fields[0] = new TextBox();
            fields[1] = new PasswordTextBox();
            fields[2] = new PasswordTextBox();

            CellFormatter formatter = table.getCellFormatter();
            for (int i = 0; i < labels.length; i++) {
                table.setWidget(i, 0, labels[i]);
                formatter.setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_LEFT);
                table.setWidget(i, 1, fields[i]);

                /*
                 * Manually add fields to focus cycle. (The dialog does not
                 * scan the children of panels for focusable widgets.)
                 */
                fModel.add(fields[i]);
            }

            // this widget will be focused when the dialog is shown
            fModel.setFocusWidget(fields[0]);

            ColumnPanel buttonPanel = new ColumnPanel();
            buttonPanel.setWidth("100%");
            dialog.add(buttonPanel);

            Button closeButton = new CloseButton(dialog, "Register!");
            fModel.add(closeButton);
            buttonPanel.add(closeButton);

            Button cancelButton = new CloseButton(dialog, "Cancel");
            fModel.add(cancelButton);
            buttonPanel.addWidget(cancelButton, false);
            buttonPanel.setCellHorizontalAlignment(ColumnPanel.ALIGN_RIGHT);

            dialog.show(focusManagementDialog);
        }
    });
    panel.add(focusManagementDialog);

    final Button explicitlyPositionedDialog = new Button("Explicitly positioned");
    explicitlyPositionedDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.removeController(dialog.getController(ModalDialog.PositionDialogController.class));
            int contentWidth = 300;
            int contentHeight = 100;
            dialog.setContentWidth(contentWidth + "px");
            dialog.setContentHeight(contentHeight + "px");
            dialog.setPopupPosition(100, 100);
            dialog.setCaption("Explicitly positioned dialog", false);
            dialog.add(new Label(
                    "Automatic positioning is disabled. Dimensions and position are set explicitly. "));
            dialog.add(new CloseButton(dialog));
            dialog.show(explicitlyPositionedDialog);
        }
    });
    panel.add(explicitlyPositionedDialog);

    final Button multipleDialogs = new Button("Multiple dialogs");
    multipleDialogs.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            ModalDialog dialog = new ModalDialog();
            dialog.setCaption("First dialog", false);
            FocusModel fModel = dialog.getFocusModel();
            RowPanel outer = new RowPanel();

            dialog.add(new HTML(""));

            final UrlLocation urlBox = new UrlLocation();
            urlBox.setText("http://www.asquare.net");
            urlBox.setWidth("350px");
            fModel.add(urlBox);
            outer.add(urlBox);

            Button goButton = new Button("Go");
            fModel.add(goButton);
            fModel.setFocusWidget(goButton);
            outer.addWidget(goButton, false);

            ListBox addressList = new ListBox();
            addressList.addItem("Select an address");
            addressList.addItem("http://www.asquare.net");
            addressList.addItem("http://www.google.com");
            addressList.addItem("http://www.sourceforge.net");
            addressList.addItem("http://www.apache.org");
            fModel.add(addressList);
            outer.add(addressList);

            final Frame frame = new Frame();
            frame.setSize("400px", "200px");
            outer.add(frame);
            urlBox.addChangeHandler(new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    frame.setUrl(urlBox.getURL());
                }
            });
            goButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    frame.setUrl(urlBox.getURL());
                }
            });
            addressList.addChangeHandler(new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    ListBox list = (ListBox) event.getSource();
                    if (list.getSelectedIndex() > 0) {
                        urlBox.setText(list.getItemText(list.getSelectedIndex()));
                        frame.setUrl(list.getItemText(list.getSelectedIndex()));
                    }
                }
            });
            final Button secondDialog = new Button("Show second dialog");
            secondDialog.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    final ModalDialog dialog = new ModalDialog();
                    dialog.setCaption("Second dialog", false);
                    dialog.add(new Label("Note that you cannot manipulate the widgets in the first dialog. "));
                    dialog.add(new CloseButton(dialog));
                    dialog.show(secondDialog);
                }
            });
            fModel.add(secondDialog);
            outer.add(secondDialog);
            Button closeButton = new CloseButton(dialog);
            fModel.add(closeButton);
            outer.add(closeButton);
            dialog.add(outer);
            dialog.show(multipleDialogs);
        }
    });
    panel.add(multipleDialogs);

    final Button styledDialog = new Button("Styled");
    styledDialog.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final ModalDialog dialog = new ModalDialog();
            dialog.addStyleName("dialog-styled");
            HorizontalPanel caption = new HorizontalPanel();
            caption.setWidth("100%");
            Label captionText = new Label("Oopsie!");
            caption.add(captionText);
            caption.setCellWidth(captionText, "100%");
            Image close = new Image("close.gif");
            close.addClickHandler(new CloseListener(dialog));
            caption.add(close);
            dialog.setCaption(caption);
            dialog.add(new Label("I've been a bad, bad browser."));
            dialog.add(new Button("Deny ice cream", new CloseListener(dialog)));
            dialog.show(styledDialog);
        }
    });
    panel.add(styledDialog);

    return panel;
}

From source file:asquare.gwt.tkdemo.client.demos.DialogPanel.java

License:Apache License

private Widget createAlertDialogDemo() {
    BasicPanel panel = new BasicPanel("div", "block");
    panel.setStyleName("example division");
    DomUtil.setStyleAttribute(panel, "whiteSpace", "nowrap");

    panel.add(new HTML("<h4>AlertDialog examples</h4>"));

    final Button showInfo = new Button("Info");
    showInfo.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AlertDialog.createInfo(null, "Caption text", "Message text").show(showInfo);
        }//ww  w . ja v  a2s  .co m
    });
    panel.add(showInfo);

    final Button showWarning = new Button("Warning");
    showWarning.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AlertDialog.createWarning(null, "Caption text", "Message text").show(showWarning);
        }
    });
    panel.add(showWarning);

    final Button showError = new Button("Error");
    showError.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AlertDialog.createError(null, "Caption text", "Message text").show(showError);
        }
    });
    panel.add(showError);

    final Button showModified = new Button("Modified");
    showModified.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AlertDialog dialog = AlertDialog.createWarning(null, "Modified alert",
                    "This dialog was created by a factory method. It was modified to remove the Cancel button");
            dialog.removeButton(dialog.getButton(1));
            dialog.getKeyMap().remove('C'); // hotkeys are mapped in upper case
            dialog.show(showModified);
        }
    });
    panel.add(showModified);

    final Button showImagesAsButtons = new Button("Images as buttons");
    showImagesAsButtons.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AlertDialog dialog = new AlertDialog();
            dialog.addStyleName("alert-imageButtons");
            dialog.setCaptionText("Caption text", false);
            dialog.setMessage(
                    "Plain images are used instead of buttons. Since images cannot be focused, they are omitted from the focus cycle. ");
            dialog.setIcon(TkImageFactory.getInstance().createAlertDialogImages().AlertIcon16().createImage());
            Icon check = new Icon("CheckIcon32.png", 32, 32);
            check.setTitle("OK");
            dialog.addButton(check, (char) KeyCodes.KEY_ENTER, null, AlertDialog.BUTTON_DEFAULT);
            Icon x = new Icon("XIcon32.png", 32, 32);
            x.setTitle("Cancel");
            dialog.addButton(x, 'x', null, AlertDialog.BUTTON_CANCEL);
            dialog.show(showImagesAsButtons);
        }
    });
    panel.add(showImagesAsButtons);

    final Button showImagesInButtons = new Button("Images in buttons");
    showImagesInButtons.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AlertDialog dialog = new AlertDialog();
            dialog.setCaptionText("Caption text", false);
            dialog.setMessage("Buttons can contain images and text. ");
            dialog.setIcon(TkImageFactory.getInstance().createAlertDialogImages().AlertIcon16().createImage());
            Button ok = new Button(
                    "<img src='CheckIcon16.png' title='OK' style='width: 16; height: 16; vertical-align: middle;'/>&nbsp;OK");
            dialog.addButton(ok, 'o', null, AlertDialog.BUTTON_DEFAULT);
            Button cancel = new Button(
                    "<img src='XIcon16.png' title='Cancel' style='width: 16; height: 16; vertical-align: middle;'/>&nbsp;Cancel");
            dialog.addButton(cancel, 'c', null, AlertDialog.BUTTON_CANCEL);
            dialog.show(showImagesInButtons);
        }
    });
    panel.add(showImagesInButtons);

    final Button showStyled = new Button("Styled");
    showStyled.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            AlertDialog dialog = new AlertDialog();
            dialog.addStyleName("alert-styled");
            dialog.getGlassPanel().addStyleName("alert-styled-glassPanel");
            dialog.setCaptionText("Caption text", false);
            ColumnPanel message = new ColumnPanel();
            message.setWidth("100%");
            message.add(TkImageFactory.getInstance().createAlertDialogImages().AlertIcon32().createImage());
            message.add(new HTML("&nbsp"));
            message.add(new HTML("<b>Message summary</b><br/>Message detail"));
            message.addCell();
            message.setCellWidth("32px");
            dialog.setMessage(message);
            dialog.addButton(AlertDialog.TEXT_OK, 'o', null, AlertDialog.BUTTON_DEFAULT);
            dialog.addButton(AlertDialog.TEXT_CANCEL, 'c', null, AlertDialog.BUTTON_CANCEL);
            dialog.show(showStyled);
        }
    });
    panel.add(showStyled);
    return panel;
}

From source file:asquare.gwt.tkdemo.client.demos.DropDownPanelPanel.java

License:Apache License

public DropDownPanelPanel() {
    HorizontalPanel outer = new HorizontalPanel();
    outer.setSize("100%", "100%");

    initWidget(outer);/*from   ww  w . j a v  a 2  s  .  co  m*/

    BasicPanel left = new BasicPanel();
    left.addStyleName("division");
    DomUtil.setAttribute(left, "id", "dropDown-left");

    DropDownPanel dropDown1 = new DropDownPanel();
    DomUtil.setAttribute(dropDown1, "id", "dropDown-1");
    dropDown1.setHeaderText("Drop Down 1", false);
    HTML dd1Content = new HTML("This DropDownPanel uses CSS to change the header image.");
    dropDown1.add(dd1Content);
    dropDown1.setOpen(true);
    left.add(dropDown1);

    final DropDownPanel dropDown2 = new DropDownPanel();
    DomUtil.setAttribute(dropDown2, "id", "dropDown-2");
    final String closedHeader = "<img src='triangle.gif'/>&nbsp;Drop Down 2";
    final String openHeader = "<img src='opentriangle.gif'/>&nbsp;Drop Down 2";
    dropDown2.setHeaderText(closedHeader, true);
    dropDown2.addDropDownListener(new DropDownListener() {
        public void dropDownClosed(DropDownPanel sender) {
            dropDown2.setHeaderText(closedHeader, true);
        }

        public void dropDownOpened(DropDownPanel sender) {
            dropDown2.setHeaderText(openHeader, true);
        }
    });
    HTML dd2Content = new HTML("This DropDownPanel uses a listener to change the header image.");
    dropDown2.add(dd2Content);
    dropDown2.setOpen(true);
    left.add(dropDown2);

    outer.add(left);
    outer.setCellWidth(left, "1px");

    String content = "<H2>DropDownPanel</H2>"
            + "<p>This widget consists of a hideable content DIV and an optional header DIV.</p>"
            + "<p>The content can be <span id='open'></span>&nbsp;&amp; <span id='close'></span>&nbsp;programatically.</p>"
            + "<p>The headers prevent selection of the text within them. In IE this is done in a special implementation using an <code>onselectstart</code> listener which returns <code>false</code>. In other browsers, <code>DOM.eventPreventDefault(Event)</code> for <code>Event.ONMOUSEDOWN</code> suffices. </p>"
            + "<p>You can add a listener to the DropDownPanel and make layout changes when the it opens/closes (e.g. maximize its parent element when it opens). </p>"
            + "<p><em>Note: we cannot put a border around the Drop Down 1 header because in IE the background image would be obscured by the border.</em></p>";
    DropDownPanel dropDown3 = new DropDownPanel();
    dropDown3.addStyleName("division");
    DomUtil.setAttribute(dropDown3, "id", "dropDown-3");
    dropDown3.setHeaderText("Drop&nbsp;Down&nbsp;3", true);
    HTMLPanel center = new HTMLPanel(content);
    center.addStyleName("description");
    SimpleHyperLink close = new SimpleHyperLink("hidden");
    SimpleHyperLink open = new SimpleHyperLink("shown");
    center.add(close, "close");
    center.add(open, "open");
    dropDown3.add(center);
    dropDown3.setOpen(true);
    outer.add(dropDown3);

    final DropDownPanel dropDown4 = new DropDownPanel();
    dropDown4.addStyleName("division");
    DomUtil.setAttribute(dropDown4, "id", "dropDown-4");
    Image image = new Image("icecube.jpg");
    image.setSize("200px", "250px");
    dropDown4.add(image);
    outer.add(dropDown4);
    outer.setCellWidth(dropDown4, "1px");

    open.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dropDown4.setOpen(true);
        }
    });
    close.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dropDown4.setOpen(false);
        }
    });
}

From source file:asquare.gwt.tkdemo.client.demos.EventsPanel.java

License:Apache License

private static Collection<Widget> createSomeWidgets() {
    ArrayList<Widget> result = new ArrayList<Widget>();
    result.add(new HTML("<b>Double-click a widget to select it</b>"));
    result.add(new Button("Button"));
    result.add(new CheckBox("CheckBox"));
    result.add(new RadioButton("group", "RadioButton"));
    result.add(new SimpleHyperLink("SimpleHyperLink"));
    TextBox tb = new TextBox();
    tb.setText("TextBox");
    result.add(tb);// w w  w. ja  v  a 2 s  . com
    PasswordTextBox ptb = new PasswordTextBox();
    ptb.setText("PasswordTextBox");
    result.add(ptb);
    return result;
}

From source file:asquare.gwt.tkdemo.client.demos.EventsPanel.java

License:Apache License

/**
 * This example shows how to use EventWrapper to process events propagated
 * to the wrapped widget. It employs an ad hoc design with an intermingling
 * of concerns.//  w  w w  .ja va2  s  .c  o m
 */
private static Widget createEx1() {
    BasicPanel outer = new BasicPanel();

    HTML description = new HTML("<h2>Example 1</h2>"
            + "<p>Shows how to use an EventWrapper to process unsupported events on widgets without subclassing. "
            + "In this example we add a style name to the widget when it is double-clicked. "
            + "Logic to prevent text selection is implemented in an ad hoc manner. "
            + "Logic for preventing selection, handling platform differences and handling the double-click event are intermingled. </p>");
    description.setStyleName("description division");
    outer.add(description);

    BasicPanel example = new BasicPanel("div", BasicPanel.DISPLAY_BLOCK);
    example.setStyleName("example division");
    outer.add(example);

    for (Iterator<Widget> iter = createSomeWidgets().iterator(); iter.hasNext();) {
        example.add(new Ex1_EventWrapper(iter.next()));
    }

    return outer;
}

From source file:asquare.gwt.tkdemo.client.demos.EventsPanel.java

License:Apache License

private static Widget createEx2() {
    BasicPanel outer = new BasicPanel();

    HTML description = new HTML("<h2>Example 2</h2>"
            + "<p>This is a rewrite of the previous example using separate controllers to handle events. "
            + "  We can use <code>PreventSelectionController</code> to prevent text selection. "
            + "  This keeps the double-click controller pristine and ensures that selection logic is consistent across the entire system. "
            + "</p>"
            + "<p><code>PreventSelectionController</code> encapsulates differences in browsers using implementation classes and the deferred binding mechanism.</p>"
            + "<p>Deferred binding results in: </p>" + "<ul>" + "  <li>smaller script size</li>"
            + "  <li>easy replacement of existing logic via rules in your Module.gwt.xml file</li>"
            + "  <li>simple and clean support for additional browsers</li>" + "</ul>" + "");
    description.setStyleName("description division");
    outer.add(description);//from w  w w  .  j ava  2  s  . c o  m

    BasicPanel example = new BasicPanel("div", BasicPanel.DISPLAY_BLOCK);
    example.setStyleName("example division");
    outer.add(example);

    /*
     * Create a list of controllers to process events on each widget. 
     * These controllers are stateless, so they may be shared between all widgets. 
     */
    ArrayList<Controller> controllers = new ArrayList<Controller>();
    controllers.add(ControlSurfaceController.getInstance());
    controllers.add(new Ex2_Controller());
    for (Iterator<Widget> iter = createSomeWidgets().iterator(); iter.hasNext();) {
        example.add(new CWrapper(iter.next(), controllers));
    }

    return outer;
}