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:client.reservation.panel.NspFixedReservationCreatePanel.java

License:Open Source License

/**
 * // w  ww. ja  va2s  .  com
 */
public NspFixedReservationCreatePanel(final String epr) {
    super(epr);

    final Label labelStart = new Label();
    labelStart.setText("Start: ");
    this.start.setText(this.dateTimeFormat.format(new Date()));
    this.table.setWidget(2, 0, labelStart);
    this.table.setWidget(2, 1, this.start);

    final Label labelDuration = new Label();
    labelDuration.setText("Duration: ");
    this.duration.setText(800 + "");
    this.table.setWidget(2, 2, labelDuration);
    this.table.setWidget(2, 3, this.duration);
}

From source file:client.reservation.panel.NspMalleableReservationCreatePanel.java

License:Open Source License

public NspMalleableReservationCreatePanel(final String epr) {
    super(epr);/*from  w  w w  .ja  v a  2 s. co m*/

    final Label labelStart = new Label();
    labelStart.setText("Start: ");
    this.start.setText(this.dateTimeFormat.format(new Date()));
    this.table.setWidget(2, 0, labelStart);
    this.table.setWidget(2, 1, this.start);

    final Label labelDuration = new Label();
    labelDuration.setText("Deadline: ");
    this.table.setWidget(2, 2, labelDuration);
    this.table.setWidget(2, 3, this.deadline);

    final Label labelAmount = new Label();
    labelAmount.setText("Amount: ");
    this.table.setWidget(2, 4, labelAmount);
    this.table.setWidget(2, 5, this.amount);
}

From source file:client.reservation.panel.NspReservationCreatePanel.java

License:Open Source License

/**
 * //from   ww w. ja  v  a  2  s  .  com
 */
public NspReservationCreatePanel(final String epr) {
    this.add(this.table);

    this.epr = epr;

    this.activity.setVisible(false);

    final Label labelSrc = new Label();
    labelSrc.setText("Src: ");
    this.table.setWidget(0, 0, labelSrc);
    this.table.setWidget(0, 1, this.src);

    final Label labelDst = new Label();
    labelDst.setText("Dst: ");
    this.table.setWidget(0, 2, labelDst);
    this.table.setWidget(0, 3, this.dst);

    final HorizontalPanel buttonPanel = new HorizontalPanel();
    this.button.addClickListener(this.getClickListener());
    this.button.setText("Create");
    buttonPanel.add(this.button);
    buttonPanel.add(this.activity);

    final Label labelBw = new Label();
    labelBw.setText("minBW: ");
    this.minBW.setText(800 + "");
    this.table.setWidget(1, 0, labelBw);
    this.table.setWidget(1, 1, this.minBW);

    final Label labelMaxBw = new Label();
    labelMaxBw.setText("maxBW (leave 0 for unset): ");
    this.maxBW.setText(800 + "");
    this.table.setWidget(1, 2, labelMaxBw);
    this.table.setWidget(1, 3, this.maxBW);

    final Label labelDelay = new Label();
    labelDelay.setText("Delay: ");
    this.delay.setText(8000 + "");
    this.table.setWidget(1, 4, labelDelay);
    this.table.setWidget(1, 5, this.delay);

    this.add(buttonPanel);
}

From source file:client.reservation.panel.RefreshReservationPanel.java

License:Open Source License

/**
 * Constructor. Create the whole panel at once.
 * //from  w ww  . j a  v  a 2  s  . c  om
 * @param callback
 *            Callback Object which gets the Refresh parameters.
 * @param list
 *            ListPanel which should be attached to the refresh Panel.
 */
public RefreshReservationPanel(final AsyncCallback callback, final ListPanel list) {
    final Label labelOne = new Label();
    labelOne.setText("Period: ");

    // TODO: user those values??
    this.dropdown = new ListBox();
    this.dropdown.addItem("Now", "0");
    this.dropdown.addItem("1 Hour", "1");
    this.dropdown.addItem("3 Hours", "3");
    this.dropdown.addItem("1 Day", "24");
    this.dropdown.addItem("3 Days", "72");
    this.dropdown.addItem("1 Week", "168");

    // activity indicator
    this.button = new Button();
    this.button.setText("refresh");
    this.activity = new Image("ajaxloader.gif");
    this.activity.setVisible(false);

    // tell refresh-Button which elements to update
    final RefreshButtonListener listener = new RefreshButtonListener();
    listener.setButton(this.button);
    listener.setActivity(this.activity);
    listener.setCallback(callback);
    listener.setList(list);
    listener.setListBox(this.dropdown);
    this.button.addClickListener(listener);

    this.add(labelOne);
    this.add(this.dropdown);
    this.add(this.button);
    this.add(this.activity);
    this.setStyleName("res-Top");
    this.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
}

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

License:Open Source License

/**
 * This is the entry point method.//  ww  w .j  ava  2  s  .c o 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.arcbees.chosen.integrationtest.client.testcases.SimpleMultiValueListBoxOnChange.java

License:Apache License

@Override
public void run() {
    super.run();//from w ww  . j ava  2  s  . c  o m

    final Label label = new Label();
    label.getElement().setId(LABEL_ID);

    getListBox().addValueChangeHandler(new ValueChangeHandler<List<CarBrand>>() {
        @Override
        public void onValueChange(ValueChangeEvent<List<CarBrand>> event) {
            label.setText(joinValues(event.getValue()));
        }
    });

    RootPanel.get().add(label);
}

From source file:com.arcbees.chosen.integrationtest.client.testcases.SimpleValueListBoxOnChange.java

License:Apache License

@Override
public void run() {
    super.run();// w w  w.jav a 2s.co m

    final Label label = new Label();
    label.getElement().setId(LABEL_ID);

    getListBox().addValueChangeHandler(new ValueChangeHandler<CarBrand>() {
        @Override
        public void onValueChange(ValueChangeEvent<CarBrand> event) {
            CarBrand value = event.getValue();
            label.setText(value == null ? "" : value.name());
        }
    });

    RootPanel.get().add(label);
}

From source file:com.areahomeschoolers.baconbits.client.content.calendar.dayview.DayViewHeader.java

License:Open Source License

public void setDays(Date date, int days) {

    dayPanel.clear();/*  w w  w .j a v  a2s.  c om*/
    weekPanel.clear();

    float dayWidth = 100f / days;
    float dayLeft;
    int week = DateUtils.calendarWeekIso(date);
    int previousDayWeek = week;
    Date previousDate = date;
    float weekWidth = 0f;
    float weekLeft = 0f;

    for (int i = 0; i < days; i++) {

        // set the left position of the day splitter to
        // the width * incremented value
        dayLeft = dayWidth * i;

        // increment the date by 1
        if (i > 0) {
            DateUtils.moveOneDayForward(date);
        } else {
            // initialize the week values
            weekLeft = dayLeft;
            weekWidth = dayWidth;
        }

        String headerTitle = CalendarFormat.INSTANCE.getDateFormat().format(date);

        Label dayLabel = new Label();
        dayLabel.setStylePrimaryName("day-cell");
        dayLabel.setWidth(dayWidth + "%");
        dayLabel.setText(headerTitle);
        DOM.setStyleAttribute(dayLabel.getElement(), "left", dayLeft + "%");

        addDayClickHandler(dayLabel, (Date) date.clone());

        boolean found = false;
        for (Date day : settings.getSettings().getHolidays()) {
            if (DateUtils.areOnTheSameDay(day, date)) {
                dayLabel.setStyleName("day-cell-holiday");
                found = true;
                break;
            }
        }

        // set the style of the header to show that it is today
        if (DateUtils.areOnTheSameDay(new Date(), date)) {
            dayLabel.setStyleName("day-cell-today");
        } else if (!found && DateUtils.isWeekend(date)) {
            dayLabel.setStyleName("day-cell-weekend");
        }

        if (showWeekNumbers) {
            week = DateUtils.calendarWeekIso(date);
            boolean lastDay = i + 1 == days;
            if ((previousDayWeek != week) || lastDay) {
                if (lastDay) {
                    previousDayWeek = week;
                    previousDate = date;
                }
                String weekTitle = "W " + previousDayWeek;

                Label weekLabel = new Label();
                weekLabel.setStylePrimaryName("week-cell");
                weekLabel.setWidth(weekWidth + "%");
                weekLabel.setText(weekTitle);
                DOM.setStyleAttribute(weekLabel.getElement(), "left", weekLeft + "%");

                addWeekClickHandler(weekLabel, previousDate);

                weekPanel.add(weekLabel);

                weekWidth = dayWidth;
                weekLeft = dayLeft + dayWidth;
            } else {
                weekWidth += dayWidth;
            }
            previousDayWeek = week;
            previousDate = date;
        }

        dayPanel.add(dayLabel);
    }
}

From source file:com.audata.client.newRecord.Metadata.java

License:Open Source License

private void paintFields() {
    this.main.clear();
    //Display Record Type
    Label type = new Label(this.rTypeName);
    type.setWidth("150px");
    type.addStyleName("audoc-sectionSubTitle");
    this.main.add(type);

    //Add Fields//from w w  w  .j av a  2s .  co m
    for (int i = 0; i < this.fields.size(); i++) {
        Field f = (Field) this.fields.get(i);
        HorizontalPanel hp = new HorizontalPanel();
        hp.setSpacing(5);

        Label l = new Label(f.name);
        l.setWidth("150px");
        l.addStyleName("audoc-label");
        l.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
        Widget w = null;
        w = f.getField();
        Label n = new Label("");
        n.addStyleName("audoc-note");
        switch (f.type) {
        case FieldTypes.TYPE_INT:
            n.setText(LANG.int_Text());
            break;
        case FieldTypes.TYPE_DEC:
            n.setText(LANG.dec_Text());
            break;
        case FieldTypes.TYPE_DATE:
            n.setText(LANG.date_format_Text());
            break;
        case FieldTypes.TYPE_STRING:
            break;
        case FieldTypes.TYPE_KEYWORD:
            break;
        case FieldTypes.TYPE_CLASS:
            n.setText(LANG.req_field_marker_Text());
            n.removeStyleName("audoc-note");
            n.addStyleName("audoc-required");
            break;
        case FieldTypes.TYPE_NOTES:
            break;
        case FieldTypes.TYPE_RECNUM:
            n.setText(LANG.req_field_marker_Text());
            n.removeStyleName("audoc-note");
            n.addStyleName("audoc-required");
        }
        hp.add(l);
        hp.add(w);
        hp.add(n);
        this.main.add(hp);
    }
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(5);

    Label l = new Label(LANG.document_Text());
    l.setWidth("150px");
    l.addStyleName("audoc-label");
    l.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
    hp.add(l);
    hp.add(this.upload);
    this.main.add(hp);

    Label req = new Label();
    req.setText(LANG.req_field_Text());
    req.addStyleName("audoc-required");
    this.main.add(req);
}

From source file:com.audata.client.record.RecordProperties.java

License:Open Source License

/**
 * Called when all the udfs have been added
 *
 *//* w  ww  .  j  a v  a  2  s  . c o m*/
public void paint() {
    this.main.clear();
    ArrayList fields = this.parent.getFields();
    for (int i = 0; i < fields.size(); i++) {
        Field f = (Field) fields.get(i);
        HorizontalPanel hp = new HorizontalPanel();
        hp.setSpacing(5);

        Label l = new Label(f.name);
        l.setWidth("150px");
        l.addStyleName("audoc-label");
        l.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
        Widget w = null;
        w = f.getField();
        Label n = new Label("");
        n.addStyleName("audoc-note");
        switch (f.type) {
        case FieldTypes.TYPE_INT:
            n.setText(LANG.int_Text());
            break;
        case FieldTypes.TYPE_DEC:
            n.setText(LANG.dec_Text());
            break;
        case FieldTypes.TYPE_DATE:
            n.setText(LANG.date_format_Text());
            break;
        case FieldTypes.TYPE_STRING:
            break;
        case FieldTypes.TYPE_KEYWORD:
            break;
        case FieldTypes.TYPE_CLASS:
            n.setText(LANG.req_field_marker_Text());
            n.removeStyleName("audoc-note");
            n.addStyleName("audoc-required");
            break;
        case FieldTypes.TYPE_NOTES:
            break;
        case FieldTypes.TYPE_RECNUM:
            f.setReadOnly();
        }
        hp.add(l);
        hp.add(w);
        hp.add(n);
        this.main.add(hp);
    }
    if ((this.cot.equals(AuDoc.state.getItem("username"))) || (this.cot.equals(""))) {
        Label newRev = new Label(LANG.check_in_new_doc_Text());
        newRev.addStyleName("audoc-subTitle");
        this.main.add(newRev);
        HorizontalPanel hp = new HorizontalPanel();
        hp.setSpacing(5);

        Label l = new Label(LANG.document_Text());
        l.setWidth("150px");
        l.addStyleName("audoc-label");
        l.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
        hp.add(l);
        hp.add(this.upload);
        this.main.add(hp);
    }
}