Example usage for com.google.gwt.user.client.ui HTMLPanel getWidgetCount

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

Introduction

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

Prototype

public int getWidgetCount() 

Source Link

Usage

From source file:com.agnie.gwt.common.client.mvp.AppController.java

License:Open Source License

protected boolean checkIfWeCanProceed() {
    HTMLPanel contentPanel = getMainContentRootPanel();
    if (contentPanel != null) {
        for (int index = 0; index < contentPanel.getWidgetCount(); index++) {
            Widget widget = contentPanel.getWidget(index);
            if (widget instanceof MainView) {
                MainView priviousDisplay = (MainView) widget;
                boolean resp = priviousDisplay.shouldWeProceed();
                if (!resp)
                    return false;
            }/*from www.  j a  va  2 s . c  om*/
        }
    }
    return true;
}

From source file:com.retech.reader.web.client.home.MyDownLoadPanel.java

License:Apache License

private void displayIssue(final List<IssueProxy> proxys, final boolean isDownloadFinish) {
    for (final IssueProxy issue : proxys) {
        final HTMLPanel issuePanel = new HTMLPanel("");
        final HTMLPanel imagePanel = new HTMLPanel("");
        issuePanel.add(imagePanel);/*www  .jav  a 2s .  c om*/
        issuePanel.add(new Label(issue.getTitle()));

        final String myDownLoadPanelStyleName = res.mydownloadStyle().myDownLoadPanel();
        final Timer timer = new Timer() {

            @Override
            public void run() {
                isStart = false;
                if (myDownLoadPanel.getStyleName().contains(myDownLoadPanelStyleName)) {
                    myDownLoadPanel.removeStyleName(myDownLoadPanelStyleName);
                } else {
                    myDownLoadPanel.addStyleName(myDownLoadPanelStyleName);
                }
            }

        };

        issuePanel.addDomHandler(new TouchStartHandler() {

            @Override
            public void onTouchStart(final TouchStartEvent event) {
                timer.schedule(700);

            }
        }, TouchStartEvent.getType());

        issuePanel.addDomHandler(new TouchEndHandler() {

            @Override
            public void onTouchEnd(final TouchEndEvent event) {
                timer.cancel();
            }

        }, TouchEndEvent.getType());

        issuePanel.addDomHandler(new MouseDownHandler() {

            @Override
            public void onMouseDown(final MouseDownEvent event) {
                timer.schedule(700);
            }

        }, MouseDownEvent.getType());

        issuePanel.addDomHandler(new MouseUpHandler() {

            @Override
            public void onMouseUp(final MouseUpEvent event) {
                timer.cancel();
            }
        }, MouseUpEvent.getType());

        issuePanel.addDomHandler(new ClickHandler() {
            @Override
            public void onClick(final ClickEvent event) {
                if (myDownLoadPanel.getStyleName().contains(myDownLoadPanelStyleName)) {
                    if (event.getX() < 12 && event.getY() < 12) {
                        List<IssueProxy> issueDownloadFinish = storage
                                .get(keyUtil.listKey(IssueProxy.ISSUE_DOWN_FINISH));
                        if (issueDownloadFinish == null) {
                            return;
                        }
                        if (issueDownloadFinish.contains(issue)) {
                            issueDownloadFinish.remove(issue);
                            myDownLoadPanel.remove(issuePanel);
                        }
                        if (issueDownloadFinish.size() == 0) {
                            Storage.getLocalStorageIfSupported()
                                    .removeItem(keyUtil.listKey(IssueProxy.ISSUE_DOWN_FINISH));
                            return;
                        }
                        storage.put(keyUtil.listKey(IssueProxy.ISSUE_DOWN_FINISH), issueDownloadFinish);
                    }
                    return;
                }
                if (isStart) {
                    EntityProxyId<IssueProxy> stableId = issue.stableId();
                    placeController
                            .goTo(places.get().setPath(IssueNews.class.getName()).setParameter(stableId));
                }
                isStart = true;
            }
        }, ClickEvent.getType());

        if (isDownloadFinish) {
            ProgressWidget progressWidget = progresses.get();
            IssueDownloadMessage issueDownloadMessage = new IssueDownloadMessage();
            issueDownloadMessage.setProgress(progressWidget);
            issueDownloadMessage.setIssueProxy(issue);
            issuePanel.add(progressWidget);
            downLoadIssue(issueDownloadMessage, issue.stableId());
        } else if (issuePanel.getWidgetCount() == 3) {
            issuePanel.remove(2);
        }

        myDownLoadPanel.add(issuePanel);

        new BaseReceiver<ResourceProxy>() {
            @Override
            public void onSuccessAndCached(final ResourceProxy response) {
                displayResource(response, imagePanel);
            }

            @Override
            public Request<ResourceProxy> provideRequest() {
                return f.resource().getImage(issue);
            }
        }.setKeyForProxy(issue.stableId(), ResourceProxy.class.getName()).fire();
    }
}

From source file:org.ednovo.gooru.client.mvp.shelf.collection.tab.resource.add.AddQuestionResourceView.java

License:Open Source License

public void removeSelectedOption(HTMLPanel questionAnswerChoiceContainer,
        AddQuestionAnswerChoice selectedAnswerChoice) {
    for (int i = 0; i < questionAnswerChoiceContainer.getWidgetCount(); i++) {
        AddQuestionAnswerChoice addQuestionAnswerChoice = (AddQuestionAnswerChoice) questionAnswerChoiceContainer
                .getWidget(i);//from w ww .  j  ava 2s.  co m
        removeStyleToBody(addQuestionAnswerChoice);
        if (selectedAnswerChoice != null
                && addQuestionAnswerChoice.optionSelectedButton.getStyleName()
                        .equals(addWebResourceStyle.answerSelected())
                && selectedAnswerChoice.optionSelectedButton.getStyleName()
                        .equals(addWebResourceStyle.answerSelected())) {

        } else {
            addQuestionAnswerChoice.optionSelectedButton.setStyleName(addWebResourceStyle.answerDeselected());
        }

    }
}

From source file:org.ednovo.gooru.client.mvp.shelf.collection.tab.resource.add.AddQuestionResourceView.java

License:Open Source License

private boolean isAnswerChoiceSelected(HTMLPanel questionAnswerChoiceContainer) {

    boolean isAnswerChoiceSelected = false;
    for (int i = 0; i < questionAnswerChoiceContainer.getWidgetCount(); i++) {
        AddQuestionAnswerChoice addQuestionAnswerChoice = (AddQuestionAnswerChoice) questionAnswerChoiceContainer
                .getWidget(i);/*from  w w  w  .ja  v a2 s.co m*/
        if (addQuestionAnswerChoice.optionSelectedButton.getStyleName()
                .equals(addWebResourceStyle.answerSelected())) {
            isAnswerChoiceSelected = true;
        }

    }

    return isAnswerChoiceSelected;

}

From source file:org.ednovo.gooru.client.mvp.shelf.collection.tab.resource.add.AddQuestionResourceView.java

License:Open Source License

public boolean isAnswerChoiceEmpty(HTMLPanel questionAnswerChoiceContainer) {
    profanityList = new ArrayList<ProfanityCheckDo>();
    for (int i = 0; i < questionAnswerChoiceContainer.getWidgetCount(); i++) {
        final AddQuestionAnswerChoice addQuestionAnswerChoice = (AddQuestionAnswerChoice) questionAnswerChoiceContainer
                .getWidget(i);/*w  ww.j  av  a 2  s  .  c om*/
        String answerChoiceValue = null;
        addQuestionAnswerChoice.errorMessageforAnswerChoice.setText("");
        if (getQuestionType().equalsIgnoreCase("T/F")) {
            answerChoiceValue = addQuestionAnswerChoice.fieldValue;
        } else if (getQuestionType().equalsIgnoreCase("MC") || getQuestionType().equalsIgnoreCase("MA")) {
            answerChoiceValue = addQuestionAnswerChoice.answerTextBox.getContent().replaceAll("\\<.*?>", "");
        }
        ProfanityCheckDo profanitymodel = new ProfanityCheckDo();
        if (answerChoiceValue == null || answerChoiceValue.trim().equalsIgnoreCase("")) {
            isAnswerChoiceSelected = true;
            addQuestionAnswerChoice.errorMessageforAnswerChoice.setText(ERROR_MSG_ANSWER);
            profanitymodel.setQuestionID(Integer.toString(i));
            profanityList.add(profanitymodel);
            addQuestionAnswerChoice.errorMessageforAnswerChoice.getElement().setAttribute("style",
                    "display:block");
        } else {
            if (answerChoiceValue.trim().length() > ANSWER_CHOICE_HINTS_TEXT_LENGTH) {
                isAnswerChoiceSelected = true;
                Document.get().getElementById(addQuestionAnswerChoice.answerTextBox.getID() + "_message")
                        .setInnerText("");
                addQuestionAnswerChoice.errorMessageforAnswerChoice.setText(ERROR_MSG_ANSWER_LENGTH);
            } else {
                isAnswerChoiceSelected = false;
                profanitymodel.setQuestionID(Integer.toString(i));
                profanitymodel.setQuestionText(answerChoiceValue);
                profanityList.add(profanitymodel);
            }
        }
    }
    return isAnswerChoiceSelected;
}

From source file:org.ednovo.gooru.client.mvp.shelf.collection.tab.resource.add.AddQuestionResourceView.java

License:Open Source License

public boolean isHintsAdded(HTMLPanel hintsContainer) {
    boolean hintsAdded = false;
    hintsListForProfanity = new ArrayList<ProfanityCheckDo>();
    if (hintsContainer.getWidgetCount() >= 1) {
        for (int i = 0; i < hintsContainer.getWidgetCount(); i++) {
            final AddHintsView addHints = (AddHintsView) hintsContainer.getWidget(i);
            ProfanityCheckDo profanitymodel = new ProfanityCheckDo();
            profanitymodel.setQuestionID(Integer.toString(i));
            if (addHints.hintTextBox.getContent() != null
                    || !addHints.hintTextBox.getContent().trim().equals("")) {
                String hintsText = addHints.hintTextBox.getContent().replaceAll("\\<.*?>", "");
                if (hintsText.trim().length() > ANSWER_CHOICE_HINTS_TEXT_LENGTH) {
                    Document.get().getElementById(addHints.hintTextBox.getID() + "_message").setInnerText("");
                    addHints.errorMessageforHints.setText(ERROR_MSG_HINTS_LENGTH);
                    hintsAdded = true;//from w ww . j  a  va  2s  . c o m
                    isAddBtnClicked = true;
                }
                profanitymodel.setQuestionText(addHints.hintTextBox.getContent());
            }
            hintsListForProfanity.add(profanitymodel);
        }
    }

    return hintsAdded;
}