Example usage for com.google.gwt.user.client.ui Label wrap

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

Introduction

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

Prototype

public static Label wrap(Element element) 

Source Link

Document

Creates a Label widget that wraps an existing <div> or <span> element.

Usage

From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java

License:Apache License

/** preserves event handlers on element to be wrapped */
public static Widget elementToWidget(Element e, String typ) {
    Widget result = null;/* w  w  w.  ja  va2  s .c o  m*/
    if (e != null) {
        int eventsSunk = DOM.getEventsSunk(e);
        EventListener el = DOM.getEventListener(e);
        if (typ == TEXT)
            result = TextBox.wrap(e);
        else if (typ == TEXT_AREA)
            result = TextArea.wrap(e);
        else if (typ == PASSWORD)
            result = PasswordTextBox.wrap(e);
        else if (typ == LABEL)
            result = Label.wrap(e);
        else if (typ == A)
            result = Anchor.wrap(e);
        else if (typ == IMAGE)
            result = Image.wrap(e);
        else if (typ == SELECT)
            result = ListBox.wrap(e);
        else if (typ == HIDDEN)
            result = Hidden.wrap(e);
        else if (typ == FILE)
            result = FileUpload.wrap(e);
        else if (typ == FORM)
            result = FormPanel.wrap(e, true);
        else if (typ == FRAME)
            result = Frame.wrap(e);
        else if (typ == SUBMIT)
            result = SubmitButton.wrap(e);
        else if (typ == BUTTON)
            result = Button.wrap(e);
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
        DOM.sinkEvents(e, eventsSunk);
        DOM.setEventListener(e, el);
    } else {
        if (typ == TEXT)
            result = new TextBox();
        else if (typ == TEXT_AREA)
            result = new TextArea();
        else if (typ == PASSWORD)
            result = new PasswordTextBox();
        else if (typ == LABEL)
            result = new Label();
        else if (typ == A)
            result = new Anchor();
        else if (typ == SELECT)
            result = new ListBox();
        else if (typ == IMAGE)
            result = new Image();
        else if (typ == HIDDEN)
            result = new Hidden();
        else if (typ == FILE)
            result = new FileUpload();
        else if (typ == FORM)
            result = new FormPanel();
        else if (typ == FRAME)
            result = new Frame();
        else if (typ == SUBMIT)
            result = new SubmitButton();
        else if (typ == BUTTON)
            result = new Button();
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
    }
    return result;
}

From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java

License:Apache License

/** preserves event handlers on element to be wrapped  */
public static Widget elementToWidget(String elementName, String typ) {
    Widget result = null;//from   www . j a va2s.  c  om
    Element e = DOM.getElementById(elementName);
    if (e != null) {
        int eventsSunk = DOM.getEventsSunk(e);
        EventListener el = DOM.getEventListener(e);
        if (typ == TEXT)
            result = TextBox.wrap(e);
        else if (typ == TEXT_AREA)
            result = TextArea.wrap(e);
        else if (typ == PASSWORD)
            result = PasswordTextBox.wrap(e);
        else if (typ == LABEL)
            result = Label.wrap(e);
        else if (typ == A)
            result = Anchor.wrap(e);
        else if (typ == SELECT)
            result = ListBox.wrap(e);
        else if (typ == IMAGE)
            result = Image.wrap(e);
        else if (typ == HIDDEN)
            result = Hidden.wrap(e);
        else if (typ == FILE)
            result = FileUpload.wrap(e);
        else if (typ == FORM)
            result = FormPanel.wrap(e, true);
        else if (typ == FRAME)
            result = Frame.wrap(e);
        else if (typ == SUBMIT)
            result = SubmitButton.wrap(e);
        else if (typ == BUTTON)
            result = Button.wrap(e);
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
        DOM.sinkEvents(e, eventsSunk);
        DOM.setEventListener(e, el);
    } else {
        if (typ == TEXT)
            result = new TextBox();
        else if (typ == TEXT_AREA)
            result = new TextArea();
        else if (typ == PASSWORD)
            result = new PasswordTextBox();
        else if (typ == LABEL)
            result = new Label();
        else if (typ == A)
            result = new Anchor();
        else if (typ == IMAGE)
            result = new Image();
        else if (typ == SELECT)
            result = new ListBox();
        else if (typ == HIDDEN)
            result = new Hidden();
        else if (typ == FILE)
            result = new FileUpload();
        else if (typ == FORM)
            result = new FormPanel();
        else if (typ == FRAME)
            result = new Frame();
        else if (typ == SUBMIT)
            result = new SubmitButton();
        else if (typ == BUTTON)
            result = new Button();
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
    }
    return result;
}

From source file:fr.gael.dhus.gwt.client.module.LoginModule.java

License:Open Source License

private static void loginRefresh() {
    final SecurityServiceAsync securityService = SecurityServiceAsync.Util.getInstance();
    AccessDeniedRedirectionCallback<UserData> callback = new AccessDeniedRedirectionCallback<UserData>() {
        public void onSuccess(UserData result) {
            if (result == null) {
                showLogin();/*from ww w .j  a v a  2s. co  m*/
                usernameInput.setValue("");
                passwordInput.setValue("");
                Label login_forgot = Label.wrap(RootPanel.get("login_forgot").getElement());
                login_forgot.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        Page.FORGOT.load();
                    }
                });
                GWTClient.loggedOut();
            } else {
                showLogout(result.getUsername());
                GWTClient.loggedIn(result);
            }
        }

        public void _onFailure(Throwable ex) {
            Window.alert("Error while requesting user information.\n" + ex.getMessage());
            showLogin();
            GWTClient.loggedOut();
        }
    };

    securityService.getCurrentUser(callback);
}

From source file:fr.gael.dhus.gwt.client.page.OverviewPage.java

License:Open Source License

private static void refresh() {
    Label registerLink = Label.wrap(RootPanel.get("overview_registerLink").getElement());
    registerLink.setVisible(GWTClient.getCurrentUser() == null);
    registerLink.addClickHandler(new ClickHandler() {
        @Override//from   w ww. ja  va 2  s  .  c  o m
        public void onClick(ClickEvent event) {
            Page.REGISTER.load();
        }
    });
}

From source file:fr.gael.dhus.gwt.client.page.SearchViewPage.java

License:Open Source License

private static void generateDownloadLink() {
    Label downloadLink = Label.wrap(RootPanel.get("searchView_download").getElement());
    if (GWTClient.getCurrentUser().getRoles().contains(RoleData.DOWNLOAD)) {
        downloadLink.setText("Download the product");
        downloadLink.getElement().setClassName("searchView_download");
        downloadLink.addClickHandler(new ClickHandler() {
            @Override//from   w w  w .j a  va  2s  .  c  o  m
            public void onClick(ClickEvent event) {
                openUrl(displayedProduct.getOdataDownaloadPath(GWT.getHostPageBaseURL()));
            }
        });
    } else {
        downloadLink.setText("Explore the product");
        downloadLink.getElement().setClassName("");
    }
}

From source file:org.cruxframework.crux.widgets.client.maskedlabel.MaskedLabel.java

License:Apache License

/**
 * // w w  w .  ja  v a2s .co  m
 * @param element
 * @param formatter
 * @return
 */
public static MaskedLabel wrap(Element element, Formatter formatter) {
    return new MaskedLabel(Label.wrap(element), formatter);
}