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

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

Introduction

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

Prototype

private HTMLPanel(Element elem) 

Source Link

Document

Construct a new HTMLPanel with the specified element.

Usage

From source file:com.pronoiahealth.olhie.client.features.dialogs.NewBookDialog.java

License:Open Source License

/**
 * Watches for a list of covers to be returned and then loads the cover list
 * //from  ww w .  j a v  a 2s.com
 * @param bookCoverListResponseEvent
 */
protected void observesBookCoverListResponseEvent(
        @Observes BookCoverListResponseEvent bookCoverListResponseEvent) {
    if (mode.equals(ModeEnum.NEW)) {
        bookCoverDropDown.setText("Select a book cover");
    }
    bookCoverDropDown.getMenuWiget().clear();
    List<BookCover> bookCovers = bookCoverListResponseEvent.getBookCover();
    if (bookCovers != null) {
        for (BookCover cover : bookCovers) {
            String coverName = cover.getCoverName();
            NavWidget link = new NavWidget();
            link.setName(coverName);
            HorizontalPanel panel = new HorizontalPanel();
            Image img = new Image();
            img.setUrl(cover.getCustomIcon());
            HTMLPanel htmlPanel = new HTMLPanel(coverName);
            htmlPanel.getElement().setAttribute("style", "padding-left: 10px;");
            panel.add(img);
            panel.add(htmlPanel);
            panel.setCellVerticalAlignment(htmlPanel, HasVerticalAlignment.ALIGN_MIDDLE);
            link.add(panel);
            link.addClickHandler(coverClickedHandler);
            panel.getElement().setAttribute("img-url", cover.getImgUrl());
            bookCoverDropDown.getMenuWiget().add(link);

            if (mode.equals(ModeEnum.EDIT) && cover.getCoverName().equals(book.getCoverName())) {
                largeBookWidget.setBackground(cover.getImgUrl());
            }
        }
    }
}

From source file:com.pronoiahealth.olhie.client.widgets.chat.ChatDialog.java

License:Open Source License

@Inject
public ChatDialog() {
    super();/*from   w w  w.  j  av a  2 s .  co m*/

    // Dialog properties
    setAutoHideEnabled(false);
    setModal(false);
    setAnimationEnabled(true);

    // Style
    getElement().setAttribute("style", "z-index: 30000; opacity: .70;");

    // Set up the dialog box contents
    VerticalPanel vp = new VerticalPanel();
    vp.setHeight("450px");
    vp.setWidth("250px");
    vp.setSpacing(10);

    // Build Chat widget
    chatTxtPanel = new HTMLPanel((String) null);
    vp.add(chatTxtPanel);
    chatTxtPanel.setStyleName("ph-ChatDialog-Txt", true);

    // Build entry and exit button
    HorizontalPanel hp = new HorizontalPanel();
    vp.add(hp);
    txtBox = new TextBox();
    hp.add(txtBox);
    txtBox.addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                String msg = txtBox.getText();
                addMePanel(msg);
                txtBox.setText("");
                txtBox.setFocus(true);
                sendMessageEvent.fire(new SendMessageEvent(dialogChannelId, msg, caption));

            }
        }
    });
    txtBox.setStyleName("ph-ChatDialog-TxtBox", true);
    txtBox.setWidth("175px");
    txtBox.setEnabled(false);

    // Button
    Button endBtn = new Button("End");
    endBtn.setIcon(IconType.SIGNOUT);
    endBtn.setSize(ButtonSize.SMALL);
    endBtn.setType(ButtonType.PRIMARY);
    endBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialogCloseHandler.closeDialog(dialogChannelId, caption);
        }
    });
    hp.add(endBtn);

    // Set widget
    setWidget(vp);
}

From source file:com.pronoiahealth.olhie.client.widgets.chat.ChatDialog.java

License:Open Source License

private HTMLPanel createPanel(String txt, BoxShade shade) {
    HTMLPanel panel = new HTMLPanel(txt);
    if (shade == BoxShade.ME) {
        panel.setStyleName("ph-ChatDialog-BoxShade-Me", true);
    } else if (shade == BoxShade.PEER) {
        panel.setStyleName("ph-ChatDialog-BoxShade-Peer", true);
    } else {/*from   w w  w. jav a2  s  .co  m*/
        panel.setStyleName("ph-ChatDialog-BoxShade-Server", true);
    }
    return panel;
}

From source file:com.retech.reader.web.client.home.MyDownLoadPanel.java

License:Apache License

@Override
public void start(final AcceptsOneWidget panel, final EventBus eventBus) {

    new BaseReceiver<List<IssueProxy>>() {

        @Override/*from w ww.  ja v  a  2  s.  c om*/
        public void onSuccessAndCached(final List<IssueProxy> helpIssue) {
            List<IssueProxy> issueDownloadFinish = storage.get(keyUtil.listKey(IssueProxy.ISSUE_DOWN_FINISH));
            myDownLoadPanel.clear();

            if (issueDownloadFinish == null) {
                storage.put(keyUtil.listKey(IssueProxy.ISSUE_DOWN), helpIssue);
            } else {
                displayIssue(issueDownloadFinish, false);
            }

            List<IssueProxy> issueDownload = storage.get(keyUtil.listKey(IssueProxy.ISSUE_DOWN));

            if (issueDownload != null) {
                displayIssue(issueDownload, true);
                // return;
            }

            HTMLPanel downLoad = new HTMLPanel("");
            HTMLPanel imagePanel = new HTMLPanel(AbstractImagePrototype.create(res.addIssue()).getHTML());
            imagePanel.getElement().getStyle().setOpacity(0);
            downLoad.add(imagePanel);
            downLoad.add(new Label(IssueProxy.ISSUE_STATE_DOWN));
            downLoad.getElement().getStyle().setOpacity(0);
            // myDownLoadPanel.getElement().getStyle().setCursor(Cursor.POINTER);
            myDownLoadPanel.add(downLoad);
        }

        @Override
        public Request<List<IssueProxy>> provideRequest() {
            return f.issue().findHelpIssue(7);
        }
    }.setKey(keyUtil.listKey(IssueProxy.HELP_ISSUE)).fire();

}

From source file:com.retech.reader.web.client.home.MyDownLoadPanel.java

License:Apache License

private void displayIssue(final List<IssueProxy> proxys, final boolean isDownloadFinish) {
    for (final IssueProxy issue : proxys) {
        final HTMLPanel issuePanel = new HTMLPanel("");
        final HTMLPanel imagePanel = new HTMLPanel("");
        issuePanel.add(imagePanel);// w ww  .  j  a v  a  2 s  .com
        issuePanel.add(new Label(issue.getTitle()));

        final String myDownLoadPanelStyleName = res.mydownloadStyle().myDownLoadPanel();
        final Timer timer = new Timer() {

            @Override
            public void run() {
                isStart = false;
                if (myDownLoadPanel.getStyleName().contains(myDownLoadPanelStyleName)) {
                    myDownLoadPanel.removeStyleName(myDownLoadPanelStyleName);
                } else {
                    myDownLoadPanel.addStyleName(myDownLoadPanelStyleName);
                }
            }

        };

        issuePanel.addDomHandler(new TouchStartHandler() {

            @Override
            public void onTouchStart(final TouchStartEvent event) {
                timer.schedule(700);

            }
        }, TouchStartEvent.getType());

        issuePanel.addDomHandler(new TouchEndHandler() {

            @Override
            public void onTouchEnd(final TouchEndEvent event) {
                timer.cancel();
            }

        }, TouchEndEvent.getType());

        issuePanel.addDomHandler(new MouseDownHandler() {

            @Override
            public void onMouseDown(final MouseDownEvent event) {
                timer.schedule(700);
            }

        }, MouseDownEvent.getType());

        issuePanel.addDomHandler(new MouseUpHandler() {

            @Override
            public void onMouseUp(final MouseUpEvent event) {
                timer.cancel();
            }
        }, MouseUpEvent.getType());

        issuePanel.addDomHandler(new ClickHandler() {
            @Override
            public void onClick(final ClickEvent event) {
                if (myDownLoadPanel.getStyleName().contains(myDownLoadPanelStyleName)) {
                    if (event.getX() < 12 && event.getY() < 12) {
                        List<IssueProxy> issueDownloadFinish = storage
                                .get(keyUtil.listKey(IssueProxy.ISSUE_DOWN_FINISH));
                        if (issueDownloadFinish == null) {
                            return;
                        }
                        if (issueDownloadFinish.contains(issue)) {
                            issueDownloadFinish.remove(issue);
                            myDownLoadPanel.remove(issuePanel);
                        }
                        if (issueDownloadFinish.size() == 0) {
                            Storage.getLocalStorageIfSupported()
                                    .removeItem(keyUtil.listKey(IssueProxy.ISSUE_DOWN_FINISH));
                            return;
                        }
                        storage.put(keyUtil.listKey(IssueProxy.ISSUE_DOWN_FINISH), issueDownloadFinish);
                    }
                    return;
                }
                if (isStart) {
                    EntityProxyId<IssueProxy> stableId = issue.stableId();
                    placeController
                            .goTo(places.get().setPath(IssueNews.class.getName()).setParameter(stableId));
                }
                isStart = true;
            }
        }, ClickEvent.getType());

        if (isDownloadFinish) {
            ProgressWidget progressWidget = progresses.get();
            IssueDownloadMessage issueDownloadMessage = new IssueDownloadMessage();
            issueDownloadMessage.setProgress(progressWidget);
            issueDownloadMessage.setIssueProxy(issue);
            issuePanel.add(progressWidget);
            downLoadIssue(issueDownloadMessage, issue.stableId());
        } else if (issuePanel.getWidgetCount() == 3) {
            issuePanel.remove(2);
        }

        myDownLoadPanel.add(issuePanel);

        new BaseReceiver<ResourceProxy>() {
            @Override
            public void onSuccessAndCached(final ResourceProxy response) {
                displayResource(response, imagePanel);
            }

            @Override
            public Request<ResourceProxy> provideRequest() {
                return f.resource().getImage(issue);
            }
        }.setKeyForProxy(issue.stableId(), ResourceProxy.class.getName()).fire();
    }
}

From source file:com.sneakyxpress.webapp.client.pages.truckclaim.TruckClaimContent.java

@Override
public void getAndChangeContent(final String input) {

    HTMLPanel content = new HTMLPanel(""); // The base panel to hold all
    // content/*from   w  ww. jav a2s . c  om*/
    content.addStyleName("row-fluid");

    // The left side will hold the form
    HTMLPanel leftSide = new HTMLPanel("");
    leftSide.addStyleName("span6");

    // Because we're going to add a FileUpload widget, we'll need to set the
    // form to use the POST method, and multipart MIME encoding.
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);
    System.out.println(GWT.getModuleBaseURL());
    form.setAction(GWT.getModuleBaseURL() + "claimFormReq");

    // Create TextBoxes, giving it a name so that it will be submitted.
    // Vendor Id textbox - used to add to form
    vendorIdBox = createTextBox("Vendor Key");
    vendorIdBox.setName("vendorId");
    vendorIdBox.setVisible(false);
    vendorIdBox.setText(input);

    // Facebook Id textbox - used to add to form
    fbIdBox = createTextBox("Vendor Key");
    fbIdBox.setName("fbId");
    fbIdBox.setVisible(false);

    // Name textbox
    nameBox = createTextBox("Name On Business License");
    nameBox.setName("nameBoxInput");
    nameBox.setStyleName("input-block-level");

    // Email textbox
    emailBox = createTextBox("Contact Email");
    emailBox.setName("emailBoxInput");
    emailBox.setStyleName("input-block-level");

    // Phone textbox
    phoneBox = createTextBox("Contact Number");
    phoneBox.setName("phoneBoxInput");
    phoneBox.setStyleName("input-block-level");

    // Terms and agreement checkbox
    checkTerms = new CheckBox("I have read and agree to the Terms of Service.");
    checkTerms.setName("checkTerms");
    checkTerms.setValue(false);
    checkTerms.setWidth("400px");

    // Widget to set as form since can only add one widget to a form.
    VerticalPanel componentPanel = new VerticalPanel();

    // Add text boxes and checkbox
    componentPanel.add(fbIdBox);
    componentPanel.add(vendorIdBox);
    componentPanel.add(nameBox);
    componentPanel.add(emailBox);
    componentPanel.add(phoneBox);
    componentPanel.add(checkTerms);

    // Add a 'submit' button.
    submitButton = new Button("Submit Request");
    submitButton.addStyleName("btn btn-primary");
    submitButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            form.submit();
        }
    });

    // Add an event handler to the form. Form validation checks
    form.addSubmitHandler(new FormPanel.SubmitHandler() {
        public void onSubmit(SubmitEvent event) {
            String name = nameBox.getText().trim();
            String email = emailBox.getText().trim();
            String number = phoneBox.getText().trim();
            String facebookId = "";

            // Check to make sure logged in user is making request
            if (!FacebookTools.isLoggedIn()) {
                String errorMsg = "Sorry you're not logged in. Login or register a new account. ";
                module.addMessage(true, errorMsg);

                // Re-enable button to allow user to resubmit form with
                // changes
                submitButton.setEnabled(true);
                event.cancel();
            }

            // Check for empty strings
            else if (name.length() == 0 || email.length() == 0 || number.length() == 0) {
                String errorMsg = "Sorry some of your inputs are empty. Please enter something.";
                module.addMessage(true, errorMsg);

                // if/else to detect and find a bug (can't submit multiple
                // forms)
                if (name.length() == 0) {
                    logger.log(Level.INFO, "Name Empty. Contents of TextBox: " + nameBox.getText());
                    nameBox.setFocus(true);
                } else if (email.length() == 0) {
                    logger.log(Level.INFO, "Email Empty. Contents of TextBox: " + emailBox.getText());
                    emailBox.setFocus(true);
                } else if (number.length() == 0) {
                    logger.log(Level.INFO, "Number Empty. Contents of TextBox: " + phoneBox.getText());
                    phoneBox.setFocus(true);
                } else {
                    logger.log(Level.SEVERE, "Unfound bug");
                }

                // Re-enable button to allow user to resubmit form with
                // changes
                submitButton.setEnabled(true);
                event.cancel();
            }

            // Check name length does not exceed 70
            else if (name.length() > STANDARD_MAX_FULL_NAME_LENGTH) {
                String errorMsg = "Sorry, " + name + " is too long. "
                        + "Please ensure your full name input is within " + STANDARD_MAX_FULL_NAME_LENGTH
                        + " characters";
                module.addMessage(true, errorMsg);

                // Re-enable button to allow user to resubmit form with
                // changes
                submitButton.setEnabled(true);
                event.cancel();
            } else if (!name.matches(NAME_PATTERN)) {
                String errorMsg = "Sorry, \"" + name + "\" contains invalid characters. "
                        + "Only letters and spaces are allowed. Please check your name input and try again.";
                module.addMessage(true, errorMsg);

                // Re-enable button to allow user to resubmit form with
                // changes
                submitButton.setEnabled(true);
                event.cancel();
            }

            // Check email length does not exceed 255
            else if (email.length() > STANDARD_MAX_EMAIL_LENGTH) {
                String errorMsg = "Sorry, " + email + " is too long. "
                        + "Please ensure your email input is within " + STANDARD_MAX_EMAIL_LENGTH
                        + " characters";
                module.addMessage(true, errorMsg);

                // Re-enable button to allow user to resubmit form with
                // changes
                submitButton.setEnabled(true);
                event.cancel();
            } else if (!email.matches(EMAIL_PATTERN)) {
                String errorMsg = "Sorry, \"" + email + "\" contains invalid characters. "
                        + "Please check your email input and try again.";
                module.addMessage(true, errorMsg);

                // Re-enable button to allow user to resubmit form with
                // changes
                submitButton.setEnabled(true);
                event.cancel();
            }

            // Check phone number input only contains numbers
            else if (!number.matches(PHONE_PATTERN)) {
                String errorMsg = "Sorry, \"" + number + "\" contains invalid characters. "
                        + "Only numbers are allowed. Please check your phone number input and try again.";
                module.addMessage(true, errorMsg);

                // Re-enable button to allow user to resubmit form with
                // changes
                submitButton.setEnabled(true);
                event.cancel();
            }

            // Phone number must have 10 digits
            else if (number.length() > STANDARD_PHONE_NUMBER_LENGTH
                    || number.length() < STANDARD_PHONE_NUMBER_LENGTH) {
                String errorMsg = "Please ensure your phone number input " + number + " contains "
                        + STANDARD_PHONE_NUMBER_LENGTH + " numbers.";
                module.addMessage(true, errorMsg);

                // Re-enable button to allow user to resubmit form with
                // changes
                submitButton.setEnabled(true);
                event.cancel();
            } else if (!checkTerms.getValue()) {
                String errorMsg = "Sorry, please check off terms and agreement box and retry submitting your request again";
                module.addMessage(true, errorMsg);

                // Re-enable button to allow user to resubmit form with
                // changes
                submitButton.setEnabled(true);
                event.cancel();
            } else {
                // All checks passed, grab user's ID
                facebookId = FacebookTools.getUserId();
                fbIdBox.setText(facebookId);

                // Disable button to disallow users to resubmit same form
                // twice
                submitButton.setEnabled(false);
            }
        }
    });

    form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
        public void onSubmitComplete(SubmitCompleteEvent event) {
            // When the form submission is successfully completed, this
            // event is
            // fired. Assuming the service returned a response of type
            // text/html,
            // we can get the result text here (see the FormPanel
            // documentation for
            // further explanation).

            if (event.getResults().equals("true")) {
                // Display message to user
                module.addMessage(false, "Your request has been submitted to our administrators.");
            } else {
                module.addMessage(true,
                        "Error in submitting your request in submitting your requestion. you may have sent a claim form for this truck already.");
            }

            // Clear form
            form.reset();

            // Re-direct to home page since it's faster than re-directing to
            // user profile page
            History.newItem(new GreetingContent(module).getPageStub());
        }
    });

    componentPanel.add(getButtonWidget(submitButton));

    form.setWidget(componentPanel);
    leftSide.add(form);

    // The right side will hold the ToS
    HTMLPanel rightSide = new HTMLPanel(
            "<p class=\"well\"><strong>Terms of Service:</strong> " + TERMS_OF_SERVICE + "</p>");
    rightSide.addStyleName("span6");

    // Put it all together
    content.add(leftSide);
    content.add(rightSide);

    // Change the content
    module.changeContent(content);
}

From source file:com.sneakyxpress.webapp.client.pages.truckclaim.TruckClaimContent.java

private HTMLPanel getButtonWidget(Button button) {
    HTMLPanel div = new HTMLPanel("<br>");
    div.add(button);
    return div;
}

From source file:com.sun.labs.aura.music.wsitm.client.ui.PerformanceTimer.java

License:Open Source License

StatsPopup(String html) {
    super(true);/*from w w w  .j a  v  a 2s . c om*/
    FlowPanel container = new FlowPanel();
    container.setStyleName("performancePopup");
    Panel p = new HTMLPanel(html);
    p.setStyleName("performancePopup");
    container.add(p);
    Button reset = new Button("reset stats");
    reset.addClickListener(new ClickListener() {

        public void onClick(Widget arg0) {
            PerformanceTimer.reset();
            StatsPopup.this.hide();
        }
    });
    container.add(reset);
    setWidget(container);
}

From source file:com.tasktop.c2c.server.profile.web.ui.client.presenter.components.CreateInvitationPresenter.java

License:Open Source License

private void doCreateInvitations() {
    view.invitations.clear();/*from  w  w  w  .  j ava 2  s .c  om*/
    getProfileService().createSignUpTokensFromCsv(view.invitationRecipients.getText(),
            view.sendEmail.getValue(), new AsyncCallbackSupport<SignUpTokens>() {

                @Override
                protected void success(SignUpTokens result) {
                    String output = profileMessages.invitationTokens() + "\n";
                    for (SignUpToken token : result.getTokens()) {
                        output += token.getFirstname() + ", " + token.getLastname() + ", " + token.getEmail()
                                + ", " + token.getToken() + ", " + token.getUrl() + "\n";
                    }
                    view.invitations.clear();
                    view.invitations.add(new HTMLPanel("<pre>\n" + output + "\n</pre>"));
                    view.invitationRecipients.setText("");
                    ProfileGinjector.get.instance().getNotifier().displayMessage(
                            Message.createSuccessMessage(profileMessages.invitationsCreatedSeeBelow()));
                }
            });
}

From source file:com.xpn.xwiki.gwt.api.client.dialog.ChoiceDialog.java

License:Open Source License

/**
 * Choice dialog//from  w w  w  .  ja v  a  2 s.c  om
 * @param app  XWiki GWT App object to access translations and css prefix names
 * @param name dialog name
 * @param buttonModes button modes Dialog.BUTTON_CANCEL|Dialog.BUTTON_NEXT for Cancel / Next
 * @param nextCallback Callback when dialog is finished
 */
public ChoiceDialog(XWikiGWTApp app, String name, int buttonModes, boolean autoSelect,
        AsyncCallback nextCallback) {
    super(app, name, buttonModes, nextCallback);
    this.autoSelect = autoSelect;

    FlowPanel main = new FlowPanel();
    main.addStyleName(getCSSName("main"));

    HTMLPanel invitationPanel = new HTMLPanel(app.getTranslation(getDialogTranslationName() + ".invitation"));
    invitationPanel.addStyleName(getCssPrefix() + "-invitation");
    main.add(invitationPanel);

    buttonPanel.addStyleName(getCSSName("buttons"));
    main.add(buttonPanel);

    helpHeader.addStyleName(getCSSName("help", "head"));
    helpContent.addStyleName(getCSSName("help", "content"));
    helpPanel.addStyleName(getCSSName("help"));
    main.add(helpPanel);

    main.add(getActionsPanel());
    add(main);
}