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

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

Introduction

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

Prototype

@Override
public void add(Widget widget) 

Source Link

Document

Adds a child widget to the panel.

Usage

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//w ww  .  ja v a 2 s  .  c o m
        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);
        issuePanel.add(new Label(issue.getTitle()));

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

            @Override//from ww w.ja  v a  2 s . c om
            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.retech.reader.web.client.home.MyDownLoadPanel.java

License:Apache License

private void displayResource(final ResourceProxy resource, final HTMLPanel imagePanel) {
    SafeHtml safe = template.img(UriUtils.fromTrustedString(
            "data:" + resource.getMimeType().getType() + ";base64," + resource.getDataString()));
    String asString = safe.asString();
    imagePanel.add(new HTML(asString));
}

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/*ww w. j  a  v  a2s .c o  m*/
    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 w w w. ja va 2s . co  m*/
}

From source file:com.tasktop.c2c.server.profile.web.ui.client.place.HudsonHeaderPlace.java

License:Open Source License

@Override
protected void handleBatchResults() {
    super.handleBatchResults();
    project = getResult(GetProjectResult.class).get();
    createBreadcrumbs(project);/*  w w  w. j  ava 2s . c  o m*/

    HeaderPresenter headerPresenter = new HeaderPresenter((Header) GWT.create(Header.class));
    headerPresenter.setPlace(this);
    Header header = headerPresenter.getView();

    HTMLPanel container = HTMLPanel.wrap(Document.get().getElementById(elementId));
    container.add(header);
}

From source file:com.tasktop.c2c.server.tasks.client.widgets.wiki.WikiHTMLPanel.java

License:Open Source License

public void setWikiHTML(String wikiHtml) {

    // First, clear out previous contents.
    super.clear();

    // Add all of our HTML to our element so that it gets converted to DOM format.
    HTML html = new HTML(wikiHtml);
    super.add(html);

    // Then, find all of our anchors and see if they are task links
    NodeList<Element> anchors = this.getElement().getElementsByTagName("a");

    for (int i = 0; i < anchors.getLength(); i++) {
        Element curElem = anchors.getItem(i);
        // Grab out our href
        String href = curElem.getAttribute("href");

        if (isTaskAnchor(href)) {
            String internalUrl = href.substring(href.indexOf("#"));

            // We need to do some fancy footwork here in order to inject a TaskAnchor into the body of this page -
            // hold on tight, it's going to get a bit bumpy.

            // First, grab the text inside the anchor - we'll use this and the href to construct our TaskAnchor.
            String label = curElem.getInnerText();

            // Next, replace our existing anchor with a <span>-based HTMLPanel - we do this to ensure we are
            // preserving our location within the DOM tree (i.e. inserting our TaskAnchor at the right point in the
            // Document)
            HTMLPanel panel = new HTMLPanel("span", "") {
                @Override//from w  w  w . j a  v a 2  s.c  o m
                public void add(Widget widget) {
                    // Very ugly hack - need to call onAttach(), but it's a protected method. Sooo, we insert that
                    // call in the add() method, which we'll call one time further inside this method, to ensure
                    // that the widget is attached (otherwise it won't bind, and we won't get the normal Widget
                    // behaviour, which is required for our TaskAnchor hovers to work).
                    // If you are reading this comment and you know of a better way to handle this, you are
                    // honour-bound to implement it and remove this hack.
                    onAttach();
                    super.add(widget);
                }
            };
            curElem.getParentElement().replaceChild(panel.getElement(), curElem);

            // Next, wrap that span in an HTML widget - this is done so that we can then inject our TaskAnchor as a
            // widget.
            panel.add(createTaskAnchor(label, internalUrl));
        }
    }
}

From source file:cz.filmtit.client.widgets.VLCWidget.java

License:Open Source License

/**
 * Construct a VLC widget for Workspace. Should be used instead of constructor which is protected.
 * @param path Path of file./*from  ww  w .ja va  2  s  .  c o m*/
 * @param playerFixedPanel Top fixed panel where the player will be.
 * @param table Table of the player.
 * @param fixedWrapper Wrapper for the fixed class.
 * @param synchronizer Synchronizer, that holds the subtitles.
 * @param workspace Workspace that will get changed and that created the VLC widget.
 * @return The new VLC widget.
 */
public static VLCWidget initVLCWidget(String path, HTMLPanel playerFixedPanel, FlexTable table,
        HTMLPanel fixedWrapper, SubtitleSynchronizer synchronizer, TranslationWorkspace workspace) {
    HTMLPanel panelForVLC = Gui.getPanelForVLC();

    panelForVLC.add(playerFixedPanel);
    playerFixedPanel.setWidth("100%");
    playerFixedPanel.setHeight("250px");
    playerFixedPanel.addStyleName("fixedPlayer");
    table.addStyleName("tableMoved");

    fixedWrapper.setWidth("984 px");

    HTML leftLabel = new HTML("");
    leftLabel.addStyleName("subtitleDisplayedLeft");
    fixedWrapper.addStyleName("fixedPlayerWrapper");
    fixedWrapper.add(leftLabel);

    HTML rightLabel = new HTML("");
    rightLabel.addStyleName("subtitleDisplayedRight");

    InlineLabel fromLabel = new InlineLabel("00:00:00");
    InlineLabel toLabel = new InlineLabel("00:00:30");
    Anchor pauseA = new Anchor("[pause]");
    Anchor replayA = new Anchor("[replay]");
    Anchor closeA = new Anchor("[close player]");

    VLCWidget vlcPlayer = new VLCWidget(path, 400, 225, leftLabel, rightLabel, synchronizer, fromLabel, toLabel,
            pauseA, replayA, closeA, 0, workspace);
    vlcPlayer.addStyleName("vlcPlayerDisplayed");
    fixedWrapper.add(vlcPlayer);

    fixedWrapper.add(rightLabel);

    HTMLPanel playerStatusPanel = new HTMLPanel("");
    playerStatusPanel.add(new InlineLabel("currently playing from "));
    playerStatusPanel.add(fromLabel);
    playerStatusPanel.add(new InlineLabel(" to "));
    playerStatusPanel.add(toLabel);

    playerStatusPanel.add(new InlineLabel(" "));
    playerStatusPanel.add(pauseA);
    playerStatusPanel.add(new InlineLabel(" "));
    playerStatusPanel.add(replayA);
    playerStatusPanel.add(new InlineLabel(" "));
    playerStatusPanel.add(closeA);

    fixedWrapper.add(playerStatusPanel);
    playerStatusPanel.addStyleName("statusPanel");

    playerFixedPanel.add(fixedWrapper);
    return vlcPlayer;
}

From source file:gov.wa.wsdot.mobile.client.activities.home.HomeViewGwtImpl.java

License:Open Source License

@Override
public void render(List<HighwayAlertItem> alerts) {
    int length = alerts.size();

    if (!alerts.isEmpty()) {
        for (final HighwayAlertItem alert : alerts) {
            HTMLPanel alertPanel = new HTMLPanel("");
            String text = alert.getHeadlineDescription();
            String shortenedAlert = ParserUtils.ellipsis(text, 128);
            HTML html = new HTML("<div><p>" + shortenedAlert + "</p></div><div></div>");

            if (length == 1) {
                alertsCarousel.setShowCarouselIndicator(false);
                if (alert.getAlertId() == -1) {
                    html.addStyleName(AppBundle.INSTANCE.css().noHighImpactAlerts());
                } else {
                    html.addStyleName(AppBundle.INSTANCE.css().highImpactAlert());

                    if (alert.getAlertId() != -1) {
                        html.addClickHandler(new ClickHandler() {

                            @Override
                            public void onClick(ClickEvent event) {
                                presenter.onHighImpactAlertSelected(alert.getAlertId());
                            }//ww w  .j  av a  2 s  . c  om
                        });
                    }
                }

                alertPanel.add(html);
                alertsCarousel.add(alertPanel);
            } else {
                alertsCarousel.setShowCarouselIndicator(true);
                html.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent event) {
                        presenter.onHighImpactAlertSelected(alert.getAlertId());
                    }
                });

                html.addStyleName(AppBundle.INSTANCE.css().highImpactAlert());
                alertPanel.add(html);
                alertsCarousel.add(alertPanel);
            }
        }

        alertsCarousel.setHeight("75px");
        alertsCarousel.refresh();
    }
}

From source file:gov.wa.wsdot.search.client.SearchWidget.java

License:Open Source License

private static Widget addAlerts(final HighwayAlertsItem item) {
    double lat = item.getStartRoadwayLocation().getLatitude();
    double lon = item.getStartRoadwayLocation().getLongitude();
    final String map = "http://maps.google.com/maps/api/staticmap?center=" + lat + "," + lon
            + "&zoom=14&size=600x400&markers=|" + lat + "," + lon + "|&sensor=false";

    Anchor link = new Anchor();
    link.setText("View location");
    link.setHref("javascript:;");
    link.addClickHandler(new ClickHandler() {
        @Override/* w  w  w.jav a  2  s  . c  o m*/
        public void onClick(ClickEvent event) {
            if (ANALYTICS_ENABLED) {
                Analytics.trackEvent(EVENT_TRACKING_CATEGORY, "Travel Alerts", item.getEventCategory());
            }
            String description = "<b>" + item.getEventCategory() + "</b> " + item.getHeadlineDescription();
            Popup popup = new Popup(map, description, item.getAlertID());
            popup.setAnimationEnabled(true);
            popup.setGlassEnabled(true);
            popup.setVisible(false);
            popup.show();
        }
    });

    HTML content = new HTML("<b>" + item.getEventCategory() + "</b><br />" + item.getHeadlineDescription());
    HTMLPanel contentPanel = new HTMLPanel(content.toString());
    contentPanel.addStyleName("alert-content");
    contentPanel.add(link);

    return contentPanel;
}