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

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

Introduction

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

Prototype

public void setText(String text) 

Source Link

Document

Sets the label's content to the given text.

Usage

From source file:com.google.livingstories.client.contentmanager.ContentItemManager.java

License:Apache License

/**
 * Make an RPC call to the server to delete an existing content entity. After it's done, remove
 * it from the content item Listbox and clear the edit area.
 *//*from w w  w . j a va  2  s. co m*/
private void deleteContentItem(final BaseContentItem contentItem, final Label statusLabel) {
    final Long id = contentItem.getId();
    AsyncCallback<Void> callback = new AsyncCallback<Void>() {
        public void onFailure(Throwable caught) {
            statusLabel.setText("Delete not successful. Try again.");
            statusLabel.setStyleName("serverResponseLabelError");
        }

        public void onSuccess(Void result) {
            statusLabel.setText("Saved!");
            statusLabel.setStyleName("serverResponseLabelSuccess");
            contentPanel.showWidget(0);
            contentItemListBox.removeContentItem(id);
            if (contentItem.getLivingStoryId() == null
                    && contentItem.getContentItemType() == ContentItemType.PLAYER) {
                removeUnassignedPlayer(id, ((PlayerContentItem) contentItem).getName());
            }
        }
    };

    contentRpcService.deleteContentItem(contentItem.getId(), callback);
}

From source file:com.google.mobile.trippy.web.client.view.CreateNewTripView.java

License:Apache License

@Override
public void addSuggestedTripList(final List<String> suggestedTripList) {
    tripNameList.clear();//from   w w w .  jav  a2 s.co  m
    if (suggestedTripListClicks == null) {
        suggestedTripListClicks = new ArrayList<HasClickHandlers>();
    } else {
        suggestedTripListClicks.clear();
    }
    for (final String suggestedTrip : suggestedTripList) {
        final Label tripLabel = new Label();
        tripLabel.setText(suggestedTrip);
        tripLabel.addStyleName(style.tripName());
        tripLabel.addStyleName(TrippyBundle.INSTANCE.commonStyle().baseFont());
        tripLabel.addStyleName(TrippyBundle.INSTANCE.commonStyle().colorFont());
        tripNameList.add(tripLabel);
        suggestedTripListClicks.add(tripLabel);
    }
}

From source file:com.google.mobile.trippy.web.client.view.DayPopUpView.java

License:Apache License

/**
 * Sets the content of Pop up Panel.//from ww  w.  j a  va2 s .c om
 * 
 */
@Override
public void createPopUp(final int daysCount) {
    if (dayHandlers == null) {
        dayHandlers = new ArrayList<HasClickHandlers>();
    } else {
        dayHandlers.clear();
    }
    content.clear();
    final FlowPanel daysMenu = new FlowPanel();
    selectDaysLabel.addStyleName(dayStyle.style.titleBaseOriginal());
    for (int i = 0; i <= daysCount; i++) {
        Label dayLabel = new Label("Day " + i);
        dayLabel.setStyleName(dayStyle.style.dayLabel());
        if (i == 0) {
            final Message messages = GWT.create(Message.class);
            dayLabel.setText(messages.unscheduled());
        }
        daysMenu.add(dayLabel);
        dayHandlers.add(dayLabel);
    }
    content.add(daysMenu);
    dayPopUp.hide();
}

From source file:com.google.sampling.experiential.client.ExperimentDefinitionPanel.java

License:Open Source License

public static PanelPair createDisplayLine(String key, String value) {
    HorizontalPanel line = new HorizontalPanel();
    line.setStyleName("left");
    Label keyLabel = new Label(key + ": ");
    keyLabel.setStyleName("keyLabel");

    Label valueBox = new Label();
    if (value != null) {
        valueBox.setText(value);
    }/*from   w  w  w .  j  a v a2 s.co m*/
    line.add(keyLabel);
    line.add(valueBox);
    return new PanelPair(line, valueBox);
}

From source file:com.google.sampling.experiential.client.ExperimentDescriptionPanel.java

License:Open Source License

private Widget createFormLine(String key, String value) {
    HorizontalPanel line = new HorizontalPanel();
    line.setStyleName("left");
    Label keyLabel = new Label(key + ":  ");
    keyLabel.setStyleName("keyLabel");
    Label valueBox = new Label();
    if (value != null) {
        valueBox.setText(value);
    }/* www.j  a v  a2 s. c om*/
    line.add(keyLabel);
    line.add(valueBox);
    return line;
}

From source file:com.google.testing.testify.risk.frontend.client.view.impl.CapabilityDetailsViewImpl.java

License:Apache License

private void updateTestSection() {
    testGrid.setTitle("Recent Test Activity");
    testGrid.resize(capabilityTests.size() + 1, 1);
    testGrid.setWidget(0, 0, buildTestHeaderWidget("Recent Test Activity", "add test"));

    int passed = 0, failed = 0, notRun = 0;
    for (int i = 0; i < capabilityTests.size(); i++) {
        TestCase test = capabilityTests.get(i);
        HorizontalPanel panel = new HorizontalPanel();
        panel.add(getTestStateImage(test.getState()));
        Anchor anchor = new Anchor(test.getLinkText(), test.getLinkUrl());
        anchor.setTarget("_blank");
        panel.add(anchor);/*www. j  a v a 2s  . c om*/
        Label statusLabel = new Label();

        int state = getTestState(test.getState());
        if (state < 0) {
            statusLabel.setText(" - failed " + getDateText(test.getStateDate()));
            failed++;
        } else if (state > 0) {
            statusLabel.setText(" - passed " + getDateText(test.getStateDate()));
            passed++;
        } else {
            statusLabel.setText(" - no result");
            notRun++;
        }
        panel.add(statusLabel);
        testGrid.setWidget(i + 1, 0, panel);
    }
    testNotRunCount.setHTML("not run <b>" + notRun + "</b>");
    testPassedCount.setHTML("passed <b>" + passed + "</b>");
    testFailedCount.setHTML("failed <b>" + failed + "</b>");
    String imageUrl = getTestChartUrl(passed, failed, notRun);
    if (imageUrl == null || "".equals(imageUrl)) {
        testChart.setVisible(false);
    } else {
        testChart.setUrl(imageUrl);
        testChart.setVisible(true);
    }
}

From source file:com.google.testing.testify.risk.frontend.client.view.impl.CapabilityDetailsViewImpl.java

License:Apache License

private void updateBugSection() {
    bugGrid.resize(capabilityBugs.size() + 1, 1);
    bugGrid.setTitle("Bugs (" + capabilityBugs.size() + " total)");
    bugGrid.setWidget(0, 0, buildBugHeaderWidget("Bugs (" + capabilityBugs.size() + " total)", "add bug"));

    for (int i = 0; i < capabilityBugs.size(); i++) {
        Bug bug = capabilityBugs.get(i);
        HorizontalPanel panel = new HorizontalPanel();
        panel.add(getBugStateImage(bug.getState()));
        Anchor anchor = new Anchor(bug.getLinkText(), bug.getLinkUrl());
        anchor.setTarget("_blank");
        panel.add(anchor);/*from   w ww. j  a  v  a  2  s  .c o m*/
        Label statusLabel = new Label();
        statusLabel.setText(" - filed " + getDateText(bug.getStateDate()));
        panel.add(statusLabel);
        bugGrid.setWidget(i + 1, 0, panel);
    }
}

From source file:com.google.testing.testify.risk.frontend.client.view.impl.CapabilityDetailsViewImpl.java

License:Apache License

private void updateCheckinsSection() {
    changeGrid.setTitle("Recent Code Changes (" + capabilityCheckins.size() + " total)");
    changeGrid.resize(capabilityCheckins.size() + 1, 1);
    changeGrid.setWidget(0, 0, buildCheckinHeaderWidget(
            "Recent Code Changes (" + capabilityCheckins.size() + " total)", "add code change"));

    for (int i = 0; i < capabilityCheckins.size(); i++) {
        Checkin checkin = capabilityCheckins.get(i);
        HorizontalPanel panel = new HorizontalPanel();
        panel.add(new Image("/images/teststate-passed.png"));
        Anchor anchor = new Anchor(checkin.getLinkText(), checkin.getLinkUrl());
        anchor.setTarget("_blank");
        panel.add(anchor);//from  w ww  .  j  a v a  2s . c  om
        Label statusLabel = new Label();
        statusLabel.setText(" - submitted " + getDateText(checkin.getStateDate()));
        panel.add(statusLabel);
        changeGrid.setWidget(i + 1, 0, panel);
    }
}

From source file:com.google.webcourse.picasaapp.client.ui.CommentsPanel.java

License:Apache License

/**
 * Shows the given comments.//from   w w w .jav  a 2  s .  com
 */
public void setComments(String[] comments) {
    mainPanel.clear();

    for (String comment : comments) {
        Label commentLabel = new Label();
        commentLabel.setText(comment);
        commentLabel.setStyleName("comment");
        mainPanel.add(commentLabel);
    }
}

From source file:com.googlecode.konamigwt.hadoken.client.Hadoken.java

License:BEER-WARE LICENSE

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

    final Button sendButton = new Button("Send");
    final TextBox nameField = new TextBox();
    nameField.setText("GWT User");
    final Label errorLabel = new Label();

    // We can add style names to widgets
    sendButton.addStyleName("sendButton");

    // 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);

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

    // Create the popup dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);
    final Button closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    final Label textToServerLabel = new Label();
    final HTML serverResponseLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
    dialogVPanel.add(textToServerLabel);
    dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
    dialogVPanel.add(serverResponseLabel);
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);

    // Add a handler to close the DialogBox
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {

            dialogBox.hide();
            sendButton.setEnabled(true);
            sendButton.setFocus(true);
        }
    });

    // Quick and Dirty implementation
    new Konami(new KonamiHandler() {
        @Override
        public void onKonamiCodePerformed() {
            final Image image = new Image("media/ryu.gif");
            DOM.appendChild(RootPanel.get().getElement(), image.getElement());

            final Audio audio = Audio.createIfSupported();
            if (audio != null) {
                audio.setSrc("media/hadoken.ogg");
                DOM.appendChild(RootPanel.get().getElement(), audio.getElement());
                audio.play();
            }
            Timer timer = new Timer() {

                @Override
                public void run() {
                    DOM.removeChild(RootPanel.get().getElement(), image.getElement());
                    if (audio != null) {
                        DOM.removeChild(RootPanel.get().getElement(), audio.getElement());
                    }
                }

            };
            timer.schedule(1100);

        }
    }).start();

    // 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) {
            sendNameToServer();
        }

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

        /**
         * Send the name from the nameField to the server and wait for a response.
         */
        private void sendNameToServer() {
            // First, we validate the input.
            errorLabel.setText("");
            String textToServer = nameField.getText();
            if (!FieldVerifier.isValidName(textToServer)) {
                errorLabel.setText("Please enter at least four characters");
                return;
            }

            // Then, we send the input to the server.
            sendButton.setEnabled(false);
            textToServerLabel.setText(textToServer);
            serverResponseLabel.setText("");
            serverResponseLabel.removeStyleName("serverResponseLabelError");
            serverResponseLabel.setHTML("Hello " + textToServer);
            dialogBox.center();
            closeButton.setFocus(true);
        }
    }

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