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

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

Introduction

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

Prototype

public InlineHTML() 

Source Link

Document

Creates an empty HTML widget.

Usage

From source file:com.achow101.bctalkaccountpricer.client.Bitcointalk_Account_Pricer.java

License:Open Source License

/**
 * This is the entry point method./*from   w  w w . j  a  va2s . co m*/
 */
public void onModuleLoad() {

    // Add Gui stuff      
    final Button sendButton = new Button("Estimate Price");
    final TextBox nameField = new TextBox();
    nameField.setText("User ID/Token");
    final Label errorLabel = new Label();
    final Label uidLabel = new Label();
    final Label usernameLabel = new Label();
    final Label postsLabel = new Label();
    final Label activityLabel = new Label();
    final Label potActivityLabel = new Label();
    final Label postQualityLabel = new Label();
    final Label trustLabel = new Label();
    final Label priceLabel = new Label();
    final Label loadingLabel = new Label();
    final Label tokenLabel = new Label();
    final InlineHTML estimateShareLabel = new InlineHTML();
    final InlineHTML reportTimeStamp = new InlineHTML();
    final RadioButton radioNormal = new RadioButton("merch", "Normal");
    final RadioButton radioMerchant = new RadioButton("merch", "Merchant");

    // We can add style names to widgets
    sendButton.addStyleName("sendButton");
    radioNormal.setValue(true);
    radioMerchant.setValue(false);

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(nameField);
    RootPanel.get("sendButtonContainer").add(sendButton);
    RootPanel.get("errorLabelContainer").add(errorLabel);
    RootPanel.get("uidLabelContainer").add(uidLabel);
    RootPanel.get("usernameLabelContainer").add(usernameLabel);
    RootPanel.get("postsLabelContainer").add(postsLabel);
    RootPanel.get("activityLabelContainer").add(activityLabel);
    RootPanel.get("potActivityLabelContainer").add(potActivityLabel);
    RootPanel.get("postQualityLabelContainer").add(postQualityLabel);
    RootPanel.get("trustLabelContainer").add(trustLabel);
    RootPanel.get("priceLabelContainer").add(priceLabel);
    RootPanel.get("loadingLabelContainer").add(loadingLabel);
    RootPanel.get("tokenLabelContainer").add(tokenLabel);
    RootPanel.get("tokenShareLabelContainer").add(estimateShareLabel);
    RootPanel.get("radioNormalContainer").add(radioNormal);
    RootPanel.get("radioMerchantContainer").add(radioMerchant);
    RootPanel.get("reportTimeStamp").add(reportTimeStamp);

    // Create activity breakdown panel
    final VerticalPanel actPanel = new VerticalPanel();
    final FlexTable actTable = new FlexTable();
    actPanel.add(actTable);
    RootPanel.get("activityBreakdown").add(actPanel);

    // Create posts breakdown panel
    final VerticalPanel postsPanel = new VerticalPanel();
    final FlexTable postsTable = new FlexTable();
    postsPanel.add(postsTable);
    RootPanel.get("postsBreakdown").add(postsPanel);

    // Create addresses breakdown panel
    final VerticalPanel addrPanel = new VerticalPanel();
    final FlexTable addrTable = new FlexTable();
    postsPanel.add(addrTable);
    RootPanel.get("addrBreakdown").add(addrTable);

    // Focus the cursor on the name field when the app loads
    nameField.setFocus(true);
    nameField.selectAll();

    // Create a handler for the sendButton and nameField
    class MyHandler implements ClickHandler, KeyUpHandler {
        /**
         * Fired when the user clicks on the sendButton.
         */
        public void onClick(ClickEvent event) {

            // Add request to queue
            addToQueue();
        }

        /**
         * Fired when the user types in the nameField.
         */
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                addToQueue();
            }
        }

        // Adds the request to server queue
        private void addToQueue() {

            // Clear previous output
            uidLabel.setText("");
            usernameLabel.setText("");
            postsLabel.setText("");
            activityLabel.setText("");
            potActivityLabel.setText("");
            postQualityLabel.setText("");
            trustLabel.setText("");
            priceLabel.setText("");
            sendButton.setEnabled(false);
            errorLabel.setText("");
            loadingLabel.setText("");
            tokenLabel.setText("");
            estimateShareLabel.setText("");
            reportTimeStamp.setText("");
            actTable.removeAllRows();
            postsTable.removeAllRows();
            addrTable.removeAllRows();

            // Create and add request
            request = new QueueRequest();
            request.setMerchant(radioMerchant.getValue());
            if (nameField.getText().matches("^[0-9]+$"))
                request.setUid(Integer.parseInt(escapeHtml(nameField.getText())));
            else {
                request.setToken(escapeHtml(nameField.getText()));
                request.setOldReq();
            }

            final String urlPath = com.google.gwt.user.client.Window.Location.getPath();
            final String host = com.google.gwt.user.client.Window.Location.getHost();
            final String protocol = com.google.gwt.user.client.Window.Location.getProtocol();
            final String url = protocol + "//" + host + urlPath + "?token=";

            // Request check loop
            Timer requestTimer = new Timer() {
                public void run() {
                    // send request to server
                    pricingService.queueServer(request, new AsyncCallback<QueueRequest>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            errorLabel.setText("Request Queuing failed. Please try again.");
                            sendButton.setEnabled(true);
                            pricingService.removeRequest(request, null);
                            cancel();
                        }

                        @Override
                        public void onSuccess(QueueRequest result) {

                            if (result.getQueuePos() == -3) {
                                loadingLabel.setText(
                                        "Please wait for your previous request to finish and try again");
                                sendButton.setEnabled(true);
                                cancel();
                            }

                            else if (result.getQueuePos() == -2) {
                                loadingLabel.setText("Please wait 2 minutes before requesting again.");
                                sendButton.setEnabled(true);
                                cancel();
                            }

                            else if (result.getQueuePos() == -4) {
                                loadingLabel.setText("Invalid token");
                                sendButton.setEnabled(true);
                                cancel();
                            }

                            else {
                                tokenLabel.setText("Your token is " + result.getToken());
                                estimateShareLabel.setHTML("Share this estimate: <a href=\"" + url
                                        + result.getToken() + "\">" + url + result.getToken() + "</a>");
                                if (!result.isProcessing() && !result.isDone()) {
                                    loadingLabel.setText("Please wait. You are number " + result.getQueuePos()
                                            + " in the queue.");
                                }
                                if (result.isProcessing()) {
                                    loadingLabel.setText("Request is processing. Please wait.");
                                }
                                if (result.isDone()) {
                                    // Clear other messages
                                    errorLabel.setText("");
                                    loadingLabel.setText("");

                                    // Output results
                                    uidLabel.setText(result.getResult()[0]);
                                    usernameLabel.setText(result.getResult()[1]);
                                    postsLabel.setText(result.getResult()[2]);
                                    activityLabel.setText(result.getResult()[3]);
                                    potActivityLabel.setText(result.getResult()[4]);
                                    postQualityLabel.setText(result.getResult()[5]);
                                    trustLabel.setText(result.getResult()[6]);
                                    priceLabel.setText(result.getResult()[7]);
                                    int indexOfLastAct = 0;
                                    int startAddrIndex = 0;
                                    for (int i = 8; i < result.getResult().length; i++) {
                                        if (result.getResult()[i].equals("<b>Post Sections Breakdown</b>")) {
                                            indexOfLastAct = i;
                                            break;
                                        }
                                        actTable.setHTML(i - 8, 0, result.getResult()[i]);
                                    }
                                    for (int i = indexOfLastAct; i < result.getResult().length; i++) {
                                        if (result.getResult()[i]
                                                .contains("<b>Addresses posted in non-quoted text</b>")) {
                                            startAddrIndex = i;
                                            break;
                                        }
                                        postsTable.setHTML(i - indexOfLastAct, 0, result.getResult()[i]);
                                    }
                                    if (!result.isMerchant()) {
                                        for (int i = startAddrIndex; i < result.getResult().length; i++) {
                                            addrTable.setHTML(i - startAddrIndex, 0, result.getResult()[i]);
                                        }
                                    }

                                    // Set the right radio
                                    radioMerchant.setValue(result.isMerchant());
                                    radioNormal.setValue(!result.isMerchant());

                                    // Report the time stamp
                                    DateTimeFormat fmt = DateTimeFormat.getFormat("MMMM dd, yyyy, hh:mm:ss a");
                                    Date completedDate = new Date(1000L * result.getCompletedTime());
                                    Date expireDate = new Date(
                                            1000L * (result.getCompletedTime() + result.getExpirationTime()));
                                    reportTimeStamp
                                            .setHTML("<i>Report generated at " + fmt.format(completedDate)
                                                    + " and expires at " + fmt.format(expireDate) + "</i>");

                                    // Kill the timer after everything is done
                                    cancel();
                                }
                                request = result;
                                request.setPoll(true);
                                sendButton.setEnabled(true);
                            }
                        }
                    });
                }
            };
            requestTimer.scheduleRepeating(2000);

        }
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);

    // Check the URL for URL parameters
    String urlTokenParam = com.google.gwt.user.client.Window.Location.getParameter("token");
    if (!urlTokenParam.isEmpty()) {
        nameField.setText(urlTokenParam);
        handler.addToQueue();
    }
}

From source file:com.badlogic.gdx.backends.gwt.GwtApplication.java

License:Apache License

public PreloaderCallback getPreloaderCallback() {
    final Panel preloaderPanel = new VerticalPanel();
    preloaderPanel.setStyleName("gdx-preloader");
    final Image logo = new Image(GWT.getModuleBaseURL() + "logo.png");
    logo.setStyleName("logo");
    preloaderPanel.add(logo);/*from w w  w .  ja  v a 2s.co  m*/
    final Panel meterPanel = new SimplePanel();
    meterPanel.setStyleName("gdx-meter");
    meterPanel.addStyleName("red");
    final InlineHTML meter = new InlineHTML();
    final Style meterStyle = meter.getElement().getStyle();
    meterStyle.setWidth(0, Unit.PCT);
    meterPanel.add(meter);
    preloaderPanel.add(meterPanel);
    getRootPanel().add(preloaderPanel);
    return new PreloaderCallback() {

        @Override
        public void error(String file) {
            System.out.println("error: " + file);
        }

        @Override
        public void update(PreloaderState state) {
            meterStyle.setWidth(100f * state.getProgress(), Unit.PCT);
        }

    };
}

From source file:com.google.appinventor.client.editor.simple.components.MockLabel.java

License:Open Source License

/**
 * Creates a new MockLabel component./*from  w  ww  .java2s. c  o m*/
 *
 * @param editor  editor of source file the component belongs to
 */
public MockLabel(SimpleEditor editor) {
    super(editor, TYPE, images.label());

    // Initialize mock label UI
    labelWidget = new InlineHTML();
    labelWidget.setStylePrimaryName("ode-SimpleMockComponent");
    initComponent(labelWidget);
}

From source file:com.mashery.examples.api.client.EtsyExample.java

License:Open Source License

public EtsyExample(final PopupMapWidget mapWidget) {
    AbsolutePanel rootPanel = new AbsolutePanel();
    rootPanel.setSize("100%", "100%");

    SplitLayoutPanel panel = new SplitLayoutPanel();
    rootPanel.add(panel);//from   w ww  .  j  a  v a  2  s. c o m
    panel.setHeight("100%");

    FlowPanel topPanel = new FlowPanel();
    panel.addNorth(topPanel, 250d);

    topPanel.add(new HTML("<h1>Featured Listings</h1>"));

    dragController = new PickupDragController(rootPanel, false);
    dragController.setBehaviorDragProxy(true);
    dragController.setBehaviorMultipleSelection(false);
    dragController.setBehaviorDragStartSensitivity(2);

    featuredListingsTable = new FeaturedListingsTable(20);
    topPanel.add(new ScrollPanel(featuredListingsTable));

    DockLayoutPanel bottomPanelContainer = new DockLayoutPanel(Unit.PX);
    panel.add(bottomPanelContainer);

    bottomPanelContainer.addNorth(new HTML("<h1>Favorite Listings</h1>"), 50d);

    bottomPanel = new DeckPanel();
    bottomPanelContainer.add(bottomPanel);

    bottomPanel.add(new HTML("Obtaining your Etsy account information..."));

    favoriteListingsTable = new FavoriteListingsTable(20);

    dropController = new SimpleDropController(favoriteListingsTable) {
        public void onDrop(DragContext context) {
            Image img = (Image) context.draggable;
            String id = img.getElement().getId();
            if (id != null && id.startsWith("listing_")) {
                try {
                    int listingId = Integer.parseInt(id.substring("listing_".length()));
                    favoriteListingsTable.createUserFavoriteListing(listingId);
                } catch (NumberFormatException e) {
                    GWT.log("Unable to parse listing id.", e);
                }
            }
        }
    };

    dragController.registerDropController(dropController);

    FlowPanel userPanel = new FlowPanel();

    userPanel.add(userLabel = new InlineHTML());
    userPanel.add(new InlineHTML("&nbsp;&nbsp;&nbsp;"));
    Anchor disconnectLink = new Anchor("Disconnect", "#");
    userPanel.add(disconnectLink);
    disconnectLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            disconnectEtsyAccount();
        }
    });

    userPanel.add(new InlineHTML("&nbsp;|&nbsp;"));
    Anchor mapProfileLink = new Anchor("Map Profile", "#");
    userPanel.add(mapProfileLink);
    mapProfileLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            if (user != null) {
                UserProfile profile = user.getProfile();
                if (profile != null) {
                    MarkerOptions opt = new MarkerOptions();
                    opt.setTitle(profile.getLoginName());
                    opt.setPosition(new LatLng(profile.getLat(), profile.getLon()));
                    opt.setClickable(true);
                    opt.setVisible(true);
                    mapWidget.show(new Marker(opt));
                }
            }
        }
    });

    mapWidget.addAutoHidePartner(mapProfileLink.getElement());

    userPanel.add(new HTML());
    userPanel.add(favoriteListingsTable);

    bottomPanel.add(new ScrollPanel(userPanel));
    bottomPanel.add(new HTML("You must be logged in in order to manage your favorite listings."));
    bottomPanel.add(createOAuthPanel());

    etsySvc = GWT.create(EtsyService.class);

    infoPanel = new PopupPanel(true);
    infoPanel.setAutoHideOnHistoryEventsEnabled(true);
    infoGrid = new Grid(2, 1);
    infoPanel.setWidget(infoGrid);
    infoGrid.setWidth("240px");

    mapListingLink = new Anchor("Map", "#");
    mapListingLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            if (selectedListing == null)
                return;

            Shop shop = selectedListing.getShop();
            if (shop == null) {
                Window.alert("No shop information available.");
                return;
            }

            if (!shop.hasLatLon()) {
                Window.alert("No location information available.");
                return;
            }

            MarkerOptions opt = new MarkerOptions();
            opt.setTitle(shop.getShopName());
            opt.setPosition(new LatLng(shop.getLat(), shop.getLon()));
            opt.setClickable(true);
            opt.setVisible(true);
            mapWidget.show(new Marker(opt));
        }
    });

    mapWidget.addAutoHidePartner(mapListingLink.getElement());

    deleteFavListingLink = new Anchor("Delete", "#");
    deleteFavListingLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            favoriteListingsTable.deleteUserFavoriteListing(selectedListing.getListingId());
            infoPanel.hide();
        }
    });

    initWidget(rootPanel);

    bottomPanel.showWidget(0);
}

From source file:com.tasktop.c2c.server.profile.web.ui.client.view.components.HeaderView.java

License:Open Source License

public void setBreadcrumbs(List<Breadcrumb> breadcrumbs) {
    breadcrumbNavigation.clear();/*  ww  w .  j  av  a 2s. c o m*/
    boolean first = true;
    for (Breadcrumb breadcrumb : breadcrumbs) {
        if (first == false) {
            InlineHTML span = new InlineHTML();
            span.setStyleName("arrow");
            span.setText("/");
            breadcrumbNavigation.add(span);
        }
        Anchor link = new Anchor(breadcrumb.getLabel(), breadcrumb.getUri());
        link.setStyleName("crumb");
        breadcrumbNavigation.add(link);

        first = false;
    }

}

From source file:com.wcs.wcslib.vaadin.widget.filtertablestate.client.FilterTableStateConnector.java

License:Apache License

private void initAddProfileBtn(VLabel vLabel, HTML layout) {
    InlineHTML addBtn = new InlineHTML();
    addBtn.setStyleName(ADD_BUTTON_STYLE);
    addBtn.setTitle(getMsg(NEW_PROFILE));
    $(addBtn).click(new Function() {
        @Override//  w w  w  .  ja va2  s .  co m
        public void f() {
            $(newProfileDiv).slideDown(150).delay(150, new Function() {
                @Override
                public void f() {
                    overlay.positionOrSizeUpdated();
                }
            });
        }
    });
    $(layout).append($(addBtn));
    vLabel.getElement().appendChild(addBtn.getElement());
}

From source file:com.wcs.wcslib.vaadin.widget.filtertablestate.client.FilterTableStateConnector.java

License:Apache License

private void initResetProfileBtn(VLabel vLabel, HTML layout) {
    InlineHTML resetBtn = new InlineHTML();
    resetBtn.setStyleName(RESET_BUTTON_STYLE);
    resetBtn.setTitle(getMsg(DEFAULT_PROFILE));
    $(resetBtn).click(new Function() {
        @Override//from w w w .jav a 2 s .com
        public void f() {
            closeOverlay();
            rpc.resetProfile();
        }
    });
    $(layout).append($(resetBtn));
    vLabel.getElement().appendChild(resetBtn.getElement());
}

From source file:com.wcs.wcslib.vaadin.widget.filtertablestate.client.FilterTableStateConnector.java

License:Apache License

private InlineHTML initProfileSaveButton(final String profile, HTML layout) {
    InlineHTML saveBtn = new InlineHTML();
    saveBtn.setStyleName(RESAVE_BUTTON_STYLE);
    saveBtn.setTitle(getMsg(SAVE_PROFILE));
    $(saveBtn).click(new Function() {
        @Override/*from   w  w w.j  a v  a 2  s  . c  om*/
        public void f() {
            closeOverlay();
            rpc.saveProfile(profile, false);
        }
    });
    $(layout).append($(saveBtn));
    return saveBtn;
}

From source file:com.wcs.wcslib.vaadin.widget.filtertablestate.client.FilterTableStateConnector.java

License:Apache License

private InlineHTML initProfileDeleteButton(final String profile, HTML layout) {
    InlineHTML delBtn = new InlineHTML();
    delBtn.setStyleName(DELETE_BUTTON_STYLE);
    delBtn.setTitle(getMsg(DELETE_PROFILE));
    $(delBtn).click(new Function() {
        @Override/*from w  w  w  .j  av  a  2s  . c o m*/
        public void f() {
            closeOverlay();
            rpc.deleteProfile(profile);
        }
    });
    $(layout).append($(delBtn));
    return delBtn;
}

From source file:com.wcs.wcslib.vaadin.widget.filtertablestate.client.FilterTableStateConnector.java

License:Apache License

private InlineHTML initDefaultProfileButton(final String profile, HTML layout) {
    InlineHTML defaultProfileBtn = new InlineHTML();
    if (!profile.equals(getState().defaultProfile)) {
        defaultProfileBtn.addStyleName(DEFAULT_PROFILE_BUTTON_OPEN_STYLE);
        defaultProfileBtn.setTitle(getMsg(DEFAULT_PROFILE_ON));
    } else {/*from ww  w . j a  v  a2 s.c  o  m*/
        defaultProfileBtn.addStyleName(DEFAULT_PROFILE_BUTTON_STYLE);
        defaultProfileBtn.setTitle(getMsg(DEFAULT_PROFILE_OFF));
    }

    $(defaultProfileBtn).click(new Function() {
        @Override
        public void f() {
            closeOverlay();
            if (profile.equals(getState().defaultProfile)) {
                rpc.setDefaultProfile(null);
            } else {
                rpc.setDefaultProfile(profile);
            }
        }
    });

    $(layout).append($(defaultProfileBtn));
    return defaultProfileBtn;
}