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.ephesoft.dcma.gwt.rv.client.view.DocumentTree.java

License:Open Source License

/**
 * @param docBean//from  w ww .j av  a  2  s  .c  om
 * @param docTitleLabel
 * @param docType
 * @param icon
 * @param docItem
 */
private void addDocDisplayItemsAndHandlers(final Document docBean, Label docTitleLabel, Label docType,
        Label icon, final TreeItem docItem) {
    String docDisplayProperty = getDocDisplayProperty(docBean, presenter.batchDTO.getDocDisplayName());
    DocumentTreeItem documentTreeItem = new DocumentTreeItem(docItem, docBean, icon, docDisplayProperty);
    addDocTreeItem(documentTreeItem);

    docItem.setTitle(documentTreeItem.documentTitle);
    docTitleLabel.setText(documentTreeItem.documentTitle);
    docType.setText(documentTreeItem.displayName);
    docTitleLabel.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            if (docItem.getState()) {
                docItem.setState(Boolean.FALSE);
            } else {
                OpenEvent.fire(docTree, docItem);
            }
        }
    });
}

From source file:com.ephesoft.dcma.gwt.rv.client.view.TableExtractionView.java

License:Open Source License

private void setTableUI(final FlexTable flexTable, final DataTable dataTable) {
    ScrollPanel panel = new ScrollPanel();
    if (dataTable.getRows().getRow().size() == 0) {
        setEmptyTableView(flexTable, dataTable.getHeaderRow());
    }/*from  w w w. j  a  v  a2  s  . c o  m*/

    panel.add(flexTable);
    panel.setHeight("150px");
    panel.setWidth("400px");
    panel.setTitle(dataTable.getName());
    HorizontalPanel hPanel = new HorizontalPanel();
    insertRowButton = new Button();
    deleteRowButton = new Button();
    deleteAllRowButton = new Button();
    manualExtractionButton = new Button();
    setButtonsText();

    onInsertButtonClicked(insertRowButton, dataTable);
    onDeleteButtonClicked(deleteRowButton, dataTable);
    onDeleteAllButtonClicked(deleteAllRowButton, dataTable);
    onManualExtractionButtonClicked(manualExtractionButton, dataTable);

    final String tableName = dataTable.getName();
    tableNameVsButtonMap.put(insertRowButton, tableName);
    tableNameVsButtonMap.put(deleteRowButton, tableName);
    tableNameVsButtonMap.put(deleteAllRowButton, tableName);
    tableNameVsButtonMap.put(manualExtractionButton, tableName);
    Label label = new Label();
    label.setWidth(GAP_BETWEEN_BUTTONS);
    hPanel.add(insertRowButton);
    hPanel.add(label);
    label = new Label();
    label.setWidth(GAP_BETWEEN_BUTTONS);
    hPanel.add(deleteRowButton);
    hPanel.add(label);
    label = new Label();
    label.setWidth(GAP_BETWEEN_BUTTONS);
    hPanel.add(deleteAllRowButton);
    hPanel.add(label);
    hPanel.add(manualExtractionButton);
    Label emptyLabel = new Label();
    emptyLabel.setHeight("20px");
    verticalPanel.add(emptyLabel);
    emptyLabel = new Label();
    emptyLabel.setText(dataTable.getName());
    verticalPanel.add(emptyLabel);
    verticalPanel.add(hPanel);
    emptyLabel = new Label();
    emptyLabel.setHeight("10px");
    verticalPanel.add(emptyLabel);
    verticalPanel.add(panel);

}

From source file:com.ephesoft.gxt.admin.client.view.plugin.PluginDetailView.java

License:Open Source License

public void addNoFieldExists() {
    HorizontalPanel cont = new HorizontalPanel();
    cont.addStyleName("pluginPanel");
    Label label = new Label();
    label.setText(LocaleDictionary.getConstantValue(BatchClassConstants.NO_FIELD_EXISTS));
    label.addStyleName("noPluginLabel");
    cont.add(label);//w  w  w  . j  ava  2 s . c o  m
    vlayoutContainer.add(cont);
}

From source file:com.ephesoft.gxt.login.client.LoginEntryPoint.java

License:Open Source License

@Override
public void onLoad() {
    Window.setTitle(LocaleDictionary.getConstantValue(LoginConstants.LOGIN_TITLE));

    Label userName = new Label(LocaleDictionary.getConstantValue(LoginConstants.login_username));
    Label password = new Label(LocaleDictionary.getConstantValue(LoginConstants.login_password));
    RootPanel.get("loginHeader").getElement()
            .setInnerText(LocaleDictionary.getConstantValue(LoginConstants.login_button_text));
    RootPanel.get("j_username").getElement().setAttribute("placeholder", userName.getText());
    RootPanel.get("j_username").getElement().focus();
    RootPanel.get("j_password").getElement().setAttribute("placeholder", password.getText());
    final Label versionNumber = new Label();

    ((LoginRemoteServiceAsync) createRpcService()).getProductVersion(new AsyncCallback<String>() {

        @Override/*from w  w  w .  ja v  a  2s.co m*/
        public void onSuccess(String version) {
            versionNumber.setText(version);
            RootPanel.get("versionLabel").getElement().setInnerText(versionNumber.getText());
        }

        @Override
        public void onFailure(Throwable arg0) {
            DialogUtil.showMessageDialog(LocaleDictionary.getConstantValue(LocaleCommonConstants.ERROR_TITLE),
                    LocaleDictionary.getConstantValue(LoginConstants.UNABLE_TO_RETRIVE_VERSION_INFO),
                    DialogIcon.ERROR);

        }
    });

    final Label expiryMsg = new Label();
    final Label failOverMsg = new Label();
    ((LoginRemoteServiceAsync) createRpcService()).getLicenseExpiryMsg(new AsyncCallback<Void>() {

        @Override
        public void onFailure(Throwable arg0) {
            String alertMsg = arg0.getLocalizedMessage();
            int indexOfDelimiter = alertMsg.indexOf('@');
            String days = alertMsg.substring(0, indexOfDelimiter);
            int remainingDays = Integer.parseInt(days);
            String dateString = alertMsg.substring(indexOfDelimiter + 1);
            if (remainingDays != 0) {
                expiryMsg.setText(
                        LocaleDictionary.getMessageValue(LoginMessages.LICENSE_EXPIRY_MSG, days, dateString));
            } else {
                expiryMsg.setText(LocaleDictionary.getMessageValue(LoginMessages.LICENSE_EXPIRY_MSG_TODAY));
            }
            expiryMsg.addStyleName(FONT_RED_CSS);
            expiryMsg.addStyleName(BOLD_TEXT_CSS);
            RootPanel.get(EXPIRY_MSG_LEBEL).getElement().setInnerText(expiryMsg.getText());
            RootPanel.get(EXPIRY_MSG_LEBEL).addStyleName(expiryMsg.getStyleName());
        }

        @Override
        public void onSuccess(Void arg0) {
        }
    });

    ((LoginRemoteServiceAsync) createRpcService()).getFailOverMessage(new AsyncCallback<Boolean>() {

        @Override
        public void onSuccess(Boolean result) {
            if (true == result) {
                // failOverMsg.setText("");
            } else {
                failOverMsg.setText(LocaleDictionary.getMessageValue(LoginMessages.FAILOVER_MSG));
                failOverMsg.addStyleName(FONT_RED_CSS);
                failOverMsg.addStyleName(BOLD_TEXT_CSS);
                RootPanel.get(FAIL_OVER_LABEL).getElement().setInnerText(failOverMsg.getText());
                RootPanel.get(FAIL_OVER_LABEL).addStyleName(failOverMsg.getStyleName());
            }
        }

        @Override
        public void onFailure(Throwable arg0) {

        }

    });
    final HorizontalPanel horPanel = new HorizontalPanel();
    horPanel.addStyleName("horizontalPanel");
    RootPanel.get().add(horPanel);
    ScreenMaskUtility.maskScreen(LocaleDictionary.getMessageValue(LoginMessages.LOADING));
    rpcService.getFooterProperties(new AsyncCallback<Map<String, String>>() {

        @Override
        public void onSuccess(Map<String, String> footerProperties) {
            footerText = footerProperties.get(CoreCommonConstants.FOOTER_TEXT_KEY);
            footerLink = footerProperties.get(CoreCommonConstants.FOOTER_LINK_KEY);
            final Anchor footerInfo = new Anchor(footerText, footerLink);
            horPanel.addStyleName("loginFooter");
            horPanel.add(footerInfo);
            horPanel.setCellHorizontalAlignment(footerInfo, HasHorizontalAlignment.ALIGN_CENTER);
            ScreenMaskUtility.unmaskScreen();
        }

        @Override
        public void onFailure(Throwable arg0) {
            ScreenMaskUtility.unmaskScreen();
            DialogUtil.showMessageDialog(LocaleDictionary.getConstantValue(LocaleCommonConstants.ERROR_TITLE),
                    LocaleDictionary.getMessageValue(LoginMessages.APPLICATION_NOT_AUTHORIZED),
                    DialogIcon.ERROR);
        }
    });
    RootPanel.get("error").getElement()
            .setInnerText(LocaleDictionary.getConstantValue(LoginConstants.INVALID_CREDENTIALS));
    RootPanel.get("error").addStyleName(FONT_RED_CSS);

    SubmitButton submitButton = new SubmitButton();
    //            (SubmitButton) SubmitButton.wrap(RootPanel.get("button").getElement());
    // submitButton.setFocus(true);

    submitButton.getElement().setTitle(LocaleDictionary.getConstantValue(LoginConstants.login_button_text));
    submitButton.getElement().setInnerHTML("<i class=\"icon-arrow-right icon-large\"></i>");
    submitButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            login();
        }
    });

    submitButton.setStyleName("gwt-Button");
    RootPanel.get("button").getElement().addClassName("submit");
    RootPanel.get("button").add(submitButton);

}

From source file:com.example.jumpnote.web.client.screens.NotesList.java

License:Apache License

public void refreshNotes() {
    notesList.clear();//from  ww  w.  j  ava  2  s. c om
    if (JumpNoteWeb.sNotes.keySet().isEmpty()) {
        Label emptyLabel = new Label();
        emptyLabel.setStyleName("empty");
        emptyLabel.setText("You haven't written any notes, create one by clicking " + "'Create Note' below!");
        notesList.add(emptyLabel);
    } else {
        List<ModelJso.Note> notes = new ArrayList<ModelJso.Note>();
        for (String id : JumpNoteWeb.sNotes.keySet()) {
            ModelJso.Note note = (ModelJso.Note) JumpNoteWeb.sNotes.get(id);
            notes.add(note);
        }

        Collections.sort(notes, new Comparator<ModelJso.Note>() {
            public int compare(Note o1, Note o2) {
                return o1.getTitle().compareTo(o2.getTitle());
            }
        });

        for (ModelJso.Note note : notes) {
            NoteItem itemWidget = new NoteItem(note, mNoteItemActionCallback);
            notesList.add(itemWidget);
        }
    }
}

From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java

License:Open Source License

/**
 * Helper method called by constructor to initialize the author's info
 * @param container   The container that author's info resides
 *//* ww  w  .j a  v a2s .co m*/
private void initAppAuthor(Panel container) {

    // Add author's image - not when creating a new app
    if (editStatus != NEWAPP) {
        final Image authorAvatar = new Image();
        authorAvatar.addStyleName("app-userimage");
        authorAvatar.setUrl(gallery.getUserImageURL(app.getDeveloperId()));
        // If the user has provided a gallery app image, we'll load it. But if not
        // the error will occur and we'll load default image
        authorAvatar.addErrorHandler(new ErrorHandler() {
            public void onError(ErrorEvent event) {
                authorAvatar.setUrl(GalleryApp.DEFAULTUSERIMAGE);
            }
        });
        authorAvatar.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                Ode.getInstance().switchToUserProfileView(app.getDeveloperId(), 1 /* 1 for public view */ );
            }
        });
        appInfo.add(authorAvatar);
    }

    // Add author's name
    final Label authorName = new Label();
    if (editStatus == NEWAPP) {
        // App doesn't have author info yet, grab current user info
        final User currentUser = Ode.getInstance().getUser();
        authorName.setText(currentUser.getUserName());
    } else {
        authorName.setText(app.getDeveloperName());
        authorName.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                Ode.getInstance().switchToUserProfileView(app.getDeveloperId(), 1 /* 1 for public view*/ );
            }
        });
    }
    authorName.addStyleName("app-username");
    authorName.addStyleName("app-subtitle");
    appInfo.add(authorName);
}

From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java

License:Open Source License

/**
 * Helper method called by constructor to initialize the app's meta fields
 * @param container   The container that date fields reside
 *///from   w  ww.  j a v a 2  s. co  m
private void initAppMeta(Panel container) {
    Date createdDate = new Date();
    Date changedDate = new Date();
    if (editStatus == NEWAPP) {
    } else {
        createdDate = new Date(app.getCreationDate());
        changedDate = new Date(app.getUpdateDate());
    }
    DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyy/MM/dd");

    Label appCreatedLabel = new Label(MESSAGES.galleryCreatedDateLabel());
    appCreatedLabel.addStyleName("app-meta-label");
    container.add(appCreatedLabel);
    appCreated.setText(dateFormat.format(createdDate));
    container.add(appCreated);

    Label appChangedLabel = new Label(MESSAGES.galleryChangedDateLabel());
    appChangedLabel.addStyleName("app-meta-label");
    container.add(appChangedLabel);
    appChanged.setText(dateFormat.format(changedDate));
    container.add(appChanged);

    if (newOrUpdateApp()) {
        // GUI for editable title container
        // Set the placeholders of textarea
        moreInfoText.getElement().setPropertyString("placeholder", MESSAGES.galleryMoreInfoHint());
        creditText.getElement().setPropertyString("placeholder", MESSAGES.galleryCreditHint());

        if (editStatus == NEWAPP) {
            // If it's a new app, it will show the placeholder hint
        } else if (editStatus == UPDATEAPP) {
            // If it's not new, just set whatever's in the data field already
            moreInfoText.setText(app.getMoreInfo());
            creditText.setText(app.getCredit());
        }

        moreInfoText.addValueChangeHandler(new ValueChangeHandler<String>() {
            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                app.setMoreInfo(moreInfoText.getText());
            }
        });
        creditText.addValueChangeHandler(new ValueChangeHandler<String>() {
            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                app.setCredit(creditText.getText());
            }
        });

        moreInfoText.addStyleName("app-desc-textarea");
        creditText.addStyleName("app-desc-textarea");
        container.add(moreInfoText);
        container.add(creditText);

    } else { // Public app view
        String linktext = makeValidLink(app.getMoreInfo());
        if (linktext != null) {
            Label moreInfoLabel = new Label(MESSAGES.galleryMoreInfoLabel());
            moreInfoLabel.addStyleName("app-meta-label");
            container.add(moreInfoLabel);

            Anchor userLinkDisplay = new Anchor();
            userLinkDisplay.setText(linktext);
            userLinkDisplay.setHref(linktext);
            userLinkDisplay.setTarget("_blank");
            container.add(userLinkDisplay);
        }
        //"remixed from" field
        container.add(initRemixFromButton());

        //"credits" field
        if (app.getCredit() != null && app.getCredit().length() > 0) {
            Label creditLabel = new Label(MESSAGES.galleryCreditLabel());
            creditLabel.addStyleName("app-meta-label");
            container.add(creditLabel);

            Label creditText = new Label(app.getCredit());
            container.add(creditText);
        }
    }

    container.addStyleName("app-meta");
}

From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java

License:Open Source License

/**
 * Helper method called by constructor to initialize the remix button
 *//*from  w ww.  j  a  va  2  s. com*/
private FlowPanel initRemixFromButton() {
    FlowPanel container = new FlowPanel();
    final Label remixedFrom = new Label(MESSAGES.galleryRemixedFrom());
    remixedFrom.addStyleName("app-meta-label");
    final Label parentApp = new Label();
    //gwt-Label use fixed width which will case border-underline-dot
    //be longer than text link.
    //gwt-Label-auto use auto width
    parentApp.removeStyleName("gwt-Label");
    parentApp.addStyleName("gwt-Label-auto");
    parentApp.addStyleName("primary-link");
    container.add(remixedFrom);
    container.add(parentApp);
    remixedFrom.setVisible(false);
    parentApp.setVisible(false);

    final Result<GalleryApp> attributionGalleryApp = new Result<GalleryApp>();
    final OdeAsyncCallback<Long> remixedFromCallback = new OdeAsyncCallback<Long>(
            // failure message
            MESSAGES.galleryError()) {
        @Override
        public void onSuccess(final Long attributionId) {
            if (attributionId != UserProject.FROMSCRATCH) {
                remixedFrom.setVisible(true);
                parentApp.setVisible(true);
                final OdeAsyncCallback<GalleryApp> callback = new OdeAsyncCallback<GalleryApp>(
                        // failure message
                        MESSAGES.galleryError()) {
                    @Override
                    public void onSuccess(GalleryApp AppRemixedFrom) {
                        parentApp.setText(AppRemixedFrom.getTitle());
                        attributionGalleryApp.t = AppRemixedFrom;
                    }
                };
                Ode.getInstance().getGalleryService().getApp(attributionId, callback);
            } else {
                attributionGalleryApp.t = null;
            }
        }
    };
    Ode.getInstance().getGalleryService().remixedFrom(app.getGalleryAppId(), remixedFromCallback);

    parentApp.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (attributionGalleryApp.t == null) {
            } else {
                Ode.getInstance().switchToGalleryAppView(attributionGalleryApp.t, GalleryPage.VIEWAPP);
            }
        }
    });

    final OdeAsyncCallback<List<GalleryApp>> callback = new OdeAsyncCallback<List<GalleryApp>>(
            // failure message
            MESSAGES.galleryError()) {
        @Override
        public void onSuccess(final List<GalleryApp> apps) {
            if (apps.size() != 0) {
                // Display remixes at the sidebar on the same page
                galleryGF.generateSidebar(apps, sidebarTabs, appsRemixes, "Remixes",
                        MESSAGES.galleryAppsRemixesSidebar() + app.getTitle(), false, false);
            }
        }
    };
    Ode.getInstance().getGalleryService().remixedTo(app.getGalleryAppId(), callback);

    return container;
}

From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java

License:Open Source License

/**
 * Helper method called by constructor to initialize the like section
 * @param container   The container that like label & image reside
 *//* www.j a v a2  s .  c  o  m*/
private void initLikeSection(Panel container) { //TODO: Update the location of this button
    final Image likeButton = new Image();
    likeButton.setUrl(HOLLOW_HEART_ICON_URL);
    container.add(likeButton);
    likeCount = new Label(MESSAGES.galleryEmptyText());
    container.add(likeCount);
    final Label likePrompt = new Label(MESSAGES.galleryEmptyText());
    likePrompt.addStyleName("primary-link");
    container.add(likePrompt);
    likePrompt.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final OdeAsyncCallback<Integer> changeLikeCallback = new OdeAsyncCallback<Integer>(
                    // failure message
                    MESSAGES.galleryError()) {
                @Override
                public void onSuccess(Integer num) {
                    // TODO: deal with/discuss server data sync later; now is updating locally.
                    final OdeAsyncCallback<Boolean> checkCallback = new OdeAsyncCallback<Boolean>(
                            MESSAGES.galleryError()) {
                        @Override
                        public void onSuccess(Boolean b) {
                            //email will be send automatically if condition matches (in ObjectifyGalleryStorageIo)
                        }
                    };
                    Ode.getInstance().getGalleryService().checkIfSendAppStats(app.getDeveloperId(),
                            app.getGalleryAppId(), gallery.getGallerySettings().getAdminEmail(),
                            Window.Location.getHost(), checkCallback);
                }
            };
            final OdeAsyncCallback<Boolean> isLikedByUserCallback = new OdeAsyncCallback<Boolean>(
                    // failure message
                    MESSAGES.galleryError()) {
                @Override
                public void onSuccess(Boolean bool) {
                    if (bool) { // If the app is already liked before, and user clicks again, that means unlike
                        Ode.getInstance().getGalleryService().decreaseLikes(app.getGalleryAppId(),
                                changeLikeCallback);
                        likePrompt.setText(MESSAGES.galleryAppsLike());
                        // Old code
                        likeCount.setText(String.valueOf(Integer.valueOf(likeCount.getText()) - 1));
                        likeButton.setUrl(HOLLOW_HEART_ICON_URL); // Unliked
                    } else {
                        // If the app is not yet liked, and user clicks like, that means add a like
                        Ode.getInstance().getGalleryService().increaseLikes(app.getGalleryAppId(),
                                changeLikeCallback);
                        likePrompt.setText(MESSAGES.galleryAppsAlreadyLike());
                        // Old code
                        likeCount.setText(String.valueOf(Integer.valueOf(likeCount.getText()) + 1));
                        likeButton.setUrl(RED_HEART_ICON_URL); // Liked
                    }
                }
            };
            Ode.getInstance().getGalleryService().isLikedByUser(app.getGalleryAppId(), isLikedByUserCallback); // This happens when user click on like, we need to check if it's already liked
        }
    });

    final OdeAsyncCallback<Integer> likeNumCallback = new OdeAsyncCallback<Integer>(
            // failure message
            MESSAGES.galleryError()) {
        @Override
        public void onSuccess(Integer num) {
            likeCount.setText(String.valueOf(num));
        }
    };
    Ode.getInstance().getGalleryService().getNumLikes(app.getGalleryAppId(), likeNumCallback);

    final OdeAsyncCallback<Boolean> isLikedCallback = new OdeAsyncCallback<Boolean>(
            // failure message
            MESSAGES.galleryError()) {
        @Override
        public void onSuccess(Boolean bool) {
            if (!bool) {
                likePrompt.setText(MESSAGES.galleryAppsLike());
                likeButton.setUrl(HOLLOW_HEART_ICON_URL);//unliked
            } else {
                likePrompt.setText(MESSAGES.galleryAppsAlreadyLike());
                likeButton.setUrl(RED_HEART_ICON_URL);//liked
            }
        }
    };
    Ode.getInstance().getGalleryService().isLikedByUser(app.getGalleryAppId(), isLikedCallback);
}

From source file:com.google.appinventor.client.explorer.youngandroid.GalleryPage.java

License:Open Source License

/**
 * Helper method called by constructor to initialize the salvage section
 * @param container   The container that salvage label reside
 *///from  w w w  .  j  a  v a 2 s.  c o m
private void initSalvageSection(Panel container) { //TODO: Update the location of this button
    if (!canSalvage()) { // Permitted to salvage?
        return;
    }

    final Label salvagePrompt = new Label("salvage");
    salvagePrompt.addStyleName("primary-link");
    container.add(salvagePrompt);

    salvagePrompt.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            final OdeAsyncCallback<Void> callback = new OdeAsyncCallback<Void>(
                    // failure message
                    MESSAGES.galleryError()) {
                @Override
                public void onSuccess(Void bool) {
                    salvagePrompt.setText("done");
                }
            };
            Ode.getInstance().getGalleryService().salvageGalleryApp(app.getGalleryAppId(), callback);
        }
    });
}