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.blackducksoftware.tools.commonframework.core.gwt.ui.StandardLoginScreen.java

License:Open Source License

/**
 * Builds the title label.//  ww  w  .  j ava 2 s .  c o  m
 *
 * @param title
 *            the title
 * @return the label
 */
private Label buildTitleLabel(String title) {
    Label titleLabel = new Label();
    titleLabel.setStyleName("appTitle");
    titleLabel.setVisible(true);
    titleLabel.setSize("459px", "64px");
    titleLabel.setText(title);
    return titleLabel;
}

From source file:com.blackducksoftware.tools.commonframework.core.gwt.ui.StandardLoginScreen.java

License:Open Source License

/**
 * Builds the version label.//from  w w w. ja v a 2s.  c  o m
 *
 * @param appVersionString
 *            the app version string
 * @return the label
 */
private Label buildVersionLabel(String appVersionString) {
    Label versionLabel = new Label("");
    versionLabel.setStyleName("gwt-Version-Label");
    versionLabel.setSize("93px", "36px"); // was "93px", "18px"
    String versionToDisplay = debugMode ? LOGIN_SCREEN_VERSION_STRING : appVersionString;
    versionLabel.setText(versionToDisplay);
    return versionLabel;
}

From source file:com.brainz.wokhei.client.about.AboutModulePart.java

private Label addMenuItem(Panel menu, final String title, final Panel panel, final String token) {
    Label menuItem = new Label();
    menuItem.setStyleName("labelButton");
    menuItem.addStyleName("menuItem");

    menuItem.setText(title);
    menuItem.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            _title.setText(title);// w w w .  j  a  v a2 s . c om
            hideAllPanels();
            panel.setVisible(true);
            _text.setVisible(false);
            History.newItem(token, false);
            applyCufon();
        }
    });

    menu.add(menuItem);

    return menuItem;

}

From source file:com.brainz.wokhei.client.about.AboutModulePart.java

/**
 * @return/*from  w w w . ja v  a2  s. co m*/
 */
private Label addMenuItem(Panel menu, final String title, final String text, final String token) {
    Label menuItem = new Label();
    menuItem.setStyleName("labelButton");
    menuItem.addStyleName("menuItem");

    menuItem.setText(title);
    menuItem.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            _title.setText(title);
            _text.setHTML(text);
            hideAllPanels();
            _text.setVisible(true);
            History.newItem(token, false);
            applyCufon();
        }
    });

    menu.add(menuItem);

    return menuItem;
}

From source file:com.cgxlib.xq.client.plugins.widgets.LabelWidgetFactory.java

License:Apache License

public Label create(Element e) {
    Label label = new Label();
    label.setText(e.getInnerText());
    WidgetsUtils.replaceOrAppend(e, label);
    return label;
}

From source file:com.codenvy.example.gwt.client.GWTEntryPoint.java

License:Open Source License

/**
 * This is the entry point method.//from ww w.ja  v  a2s . co m
 */
public void onModuleLoad() {
    final Button sendButton = new Button(messages.sendButton());
    final TextBox nameField = new TextBox();
    nameField.setText(messages.nameField());
    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);
        }
    });

    // 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("");
            greetingService.greetServer(textToServer, new AsyncCallback<String>() {
                public void onFailure(Throwable caught) {
                    // Show the RPC error message to the user
                    dialogBox.setText("Remote Procedure Call - Failure");
                    serverResponseLabel.addStyleName("serverResponseLabelError");
                    serverResponseLabel.setHTML(SERVER_ERROR);
                    dialogBox.center();
                    closeButton.setFocus(true);
                }

                public void onSuccess(String result) {
                    dialogBox.setText("Remote Procedure Call");
                    serverResponseLabel.removeStyleName("serverResponseLabelError");
                    serverResponseLabel.setHTML(result);
                    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);
}

From source file:com.connoisseur.menuapp.client.Authenticate.java

/** This is essentially the main method for the menu app. */
public static void go() {
    storage.clear(); // uncomment to completely reset app

    final DialogBox startupBox = new DialogBox(); // movable box that contains widgets
    startupBox.setAnimationEnabled(true);
    final VerticalPanel startupPanel = new VerticalPanel(); // can contain other widgets
    startupPanel.addStyleName("marginPanel"); // interacts with Menuapp.css
    startupPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    // check to see if storage is supported
    if (storage != null) {

        // load viewer if license key and restID have been submitted before
        if (storage.getLength() > 0) {
            Viewer.loadViewer();/*  ww  w.  j a va 2  s  .c  o m*/
        }

        // otherwise load authentication UI in order to receive input
        else {
            final Button submitButton = new Button("Submit"); // "Submit" appears on button
            submitButton.addStyleName("myButton"); // interacts with Menuapp.css
            final HorizontalPanel buttonPanel = new HorizontalPanel(); // used to center button
            buttonPanel.addStyleName("marginlessPanel");

            // license widgets
            final Label licenseErrorLabel = new Label(); // dynamic text
            licenseErrorLabel.addStyleName("errorLabel"); // interacts with Menuapp.css
            final TextBox submitLicense = new TextBox(); // user can input text using this
            submitLicense.setText("license key..."); // default text to be seen on load

            // restaurant ID widgets
            final Label restErrorLabel = new Label();
            restErrorLabel.addStyleName("errorLabel");
            final TextBox submitRestID = new TextBox();
            submitRestID.setText("restaurant ID...");

            // organize UI
            startupPanel.add(new HTML("Please enter your license key:"));
            startupPanel.add(submitLicense);
            startupPanel.add(licenseErrorLabel);
            startupPanel.add(new HTML("<br>Please enter your restaurant ID:"));
            startupPanel.add(submitRestID);
            startupPanel.add(restErrorLabel);
            startupPanel.add(new HTML("<br>"));
            buttonPanel.add(submitButton);
            startupPanel.add(buttonPanel);

            // setup startupBox, which is what will be seen by the user
            startupBox.setWidget(startupPanel); // connects the two widgets
            startupBox.center(); // also shows the box

            // focus the cursor on submitLicense when startupBox appears
            submitLicense.setFocus(true);
            submitLicense.selectAll();

            // create a handler for submitButton, submitLicense and submitRestID
            class MyHandler implements ClickHandler, KeyUpHandler {
                /** Fired when the user clicks submit. */
                public void onClick(ClickEvent event) {
                    submit();
                }

                /** Fired when the user presses Enter in a submit field. */
                public void onKeyUp(KeyUpEvent event) {
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                        submit();
                }

                /** Checks the submitted license key and restaurant ID for validity. Loads Viewer if valid. */
                private void submit() {
                    String license = submitLicense.getText(); // unused for now
                    String restID = submitRestID.getText(); // not sure how to validate yet
                    int returnFlag = 0; // so that both tests can be done
                    licenseErrorLabel.setText("");
                    restErrorLabel.setText("");

                    // validate license
                    String result = FieldVerifier.isValidLicenseKey(license); // from FieldVerifier.java
                    if (!result.equals("")) { // error
                        licenseErrorLabel.setText("You submitted an invalid license key.");
                        submitLicense.selectAll();
                        returnFlag = 1;
                    }

                    // validate restID
                    result = FieldVerifier.isValidRestaurantID(restID);
                    if (!result.equals("")) { // error
                        restErrorLabel.setText("You submitted an invalid restaurant ID.");
                        submitRestID.selectAll();
                        returnFlag = 1;
                    }

                    // don't do anything until the errors are resolved
                    if (returnFlag == 1)
                        return;

                    // clean up
                    submitButton.setEnabled(false);
                    submitLicense.setEnabled(false);
                    submitRestID.setEnabled(false);
                    startupBox.hide();

                    // set up storage
                    storage.setItem("license", license); // secret key for security
                    storage.setItem("restID", restID); // used for almost every call to the backend

                    // show menu
                    Viewer.loadViewer();
                }
            } // MyHandler

            // attach the handler
            final MyHandler handler = new MyHandler();
            submitButton.addClickHandler(handler);
            submitLicense.addKeyUpHandler(handler);
            submitRestID.addKeyUpHandler(handler);
        } // else load authentication UI

    } // if storage supported

    // storage is not supported, so report error
    else {
        startupPanel.add(new HTML("<font color=red>The app will not function because local<br>"
                + "storage is not supported on this platform.</font>"));
        startupBox.setWidget(startupPanel);
        startupBox.center();
    }
}

From source file:com.dawg6.web.dhcalc.client.MainPanel.java

License:Open Source License

protected void showBuildData(int which) {
    CompareData data = compareData[which];

    int col = which * 2 + 1;

    if (data == null) {

        for (int row = 0; row < NUM_COMPARE_ROWS; row++) {
            Label label = (Label) compareTable.getWidget(row + 2, col);

            if (label != null)
                label.setText("No Data");
        }//from  w  ww.j  ava2  s.co  m

    } else {
        CompareData baseline = compareData[0];

        int row = 2;

        Label aps = (Label) compareTable.getWidget(row, col);
        Label wd = (Label) compareTable.getWidget(row + 1, col);
        Label elapsed = (Label) compareTable.getWidget(row + 3, col);
        Label dps = (Label) compareTable.getWidget(row + 5, col);

        aps.setText(Util.format(data.exportData.data.getAps()));
        wd.setText(Util.format(Math.round(data.exportData.data.getWeaponDamage() * 10.0) / 10.0));
        dps.setText(Util.format(Math.round(data.exportData.sentryDps)));
        elapsed.setText(Util.format(Math.round(data.exportData.output.duration * 100.0) / 100.0));

        if ((which > 0) && (baseline != null)) {

            Label wdPctL = (Label) compareTable.getWidget(row + 2, col);
            Label dpsPctL = (Label) compareTable.getWidget(row + 6, col);
            Label elapsedPctL = (Label) compareTable.getWidget(row + 4, col);

            double wdPct = (baseline.exportData.data.getWeaponDamage() > 0)
                    ? ((data.exportData.data.getWeaponDamage() - baseline.exportData.data.getWeaponDamage())
                            / baseline.exportData.data.getWeaponDamage())
                    : 0.0;
            double dpsPct = (baseline.exportData.sentryDps > 0)
                    ? ((data.exportData.sentryDps - baseline.exportData.sentryDps)
                            / baseline.exportData.sentryDps)
                    : 0.0;
            double elapsedPct = (baseline.exportData.output.duration > 0)
                    ? ((data.exportData.output.duration - baseline.exportData.output.duration)
                            / baseline.exportData.output.duration)
                    : 0.0;

            wdPctL.setText(
                    "(" + ((wdPct >= 0) ? "+" : "") + Util.format(Math.round(wdPct * 1000.0) / 10.0) + "%)");
            dpsPctL.setText(
                    "(" + ((dpsPct >= 0) ? "+" : "") + Util.format(Math.round(dpsPct * 1000.0) / 10.0) + "%)");
            elapsedPctL.setText("(" + ((elapsedPct >= 0) ? "+" : "")
                    + Util.format(Math.round(elapsedPct * 1000.0) / 10.0) + "%)");

        }

    }

    if (which == 0) {
        for (int i = 1; i < compareData.length; i++) {
            showBuildData(i);
        }
    }
}

From source file:com.dimdim.conference.ui.envcheck.client.main.EnvChecksSummaryPanel.java

License:Open Source License

private void prepareCheckResultPanel(HorizontalPanel row, PNGImage okImage, PNGImage errorImage,
        Label commentLabel, String comment) {
    row.add(okImage);//from  w  w w.j a v  a  2s.c o m
    row.setCellHorizontalAlignment(okImage, HorizontalPanel.ALIGN_LEFT);
    row.setCellVerticalAlignment(okImage, VerticalPanel.ALIGN_MIDDLE);

    row.add(errorImage);
    row.setCellHorizontalAlignment(errorImage, HorizontalPanel.ALIGN_LEFT);
    row.setCellVerticalAlignment(errorImage, VerticalPanel.ALIGN_MIDDLE);

    commentLabel.setText(comment);
    commentLabel.setStyleName("common-text");
    commentLabel.addStyleName("env-check-result-comment");
    row.add(commentLabel);
    row.setCellWidth(commentLabel, "100%");
    row.setCellHorizontalAlignment(commentLabel, HorizontalPanel.ALIGN_LEFT);
    row.setCellVerticalAlignment(commentLabel, VerticalPanel.ALIGN_MIDDLE);
    Window.alert("commentLabel = " + commentLabel);
    this.basePanel.add(row);
    row.setStyleName("env-check-result-row");
    row.setVisible(false);
}

From source file:com.dimdim.conference.ui.sharing.client.ResourceSharingPanel.java

License:Open Source License

private void writeResName(boolean dtpShare, String appName, String pptName) {
    RootPanel rp = RootPanel.get(resNameDivId);
    //Window.alert("resNameDivId = "+ resNameDivId);
    if (null != rp) {
        Label headerLabel = new Label();
        ;//  ww  w.  java 2s  . c  om
        if (headerLabel != null) {
            if (dtpShare) {
                //   Presenter is sharing desktop.
                headerLabel.setText(UIGlobals.getDesktopSubTabLabel());
            } else if (appName != null && UIResourceObject.RESOURCE_TYPE_WHITEBOARD.equals(appName)) {
                //   Presenter is sharing a specific application
                headerLabel.setText(UIGlobals.getWhiteboardTabLabel());

            } else if (appName != null) {
                //   Presenter is sharing a whiteboard
                headerLabel.setText(appName);
            } else if (pptName != null) {
                //   Presenter is sharing a powerpoint presentation
                headerLabel.setText(pptName);
            } else {
                //   No sharing is in progress at present.
                headerLabel.setText(UIGlobals.getWorkspaceHeaderText());
            }
        }
        rp.clear();
        //Window.alert("adding label text = "+headerLabel.getText());
        rp.add(headerLabel);
    } else {
        //Window.alert("div tag is null...");
    }
}