public void populateQuestionInformation(GeneralQuestionAnswerVoCollection questions) { clearQuestions(); if(questions == null) return; if(questionOrInformation.equals("Information")) this.columnName = this.gridQuestions.getColumns().newColumn(questionOrInformation); else this.columnName = this.gridQuestions.getColumns().newColumn("Question / Information"); this.columnName.setWidth(DEFAULT_QUESTION_COLUMN_WIDTH); int noDynamicColumns = getDynamicColumnsNumber(questions); DynamicGridColumn[] columnsAnswer = new DynamicGridColumn[noDynamicColumns]; for(int x = 0; x < noDynamicColumns; x++) { if(x == 0) columnsAnswer[x] = this.gridQuestions.getColumns().newColumn("Answer(s)"); else columnsAnswer[x] = this.gridQuestions.getColumns().newColumn(" "); columnsAnswer[x].setDynamicWidthSupported(true); } GeneralQuestionAnswerVoCollection collInvQuestions = getQuestionsByType(questions, OrderQuestionType.INVESTIGATION); if(collInvQuestions != null) { for(int i=0; i<collInvQuestions.size(); i++) { DynamicGridRow row = createOrFindInvestigationRow(collInvQuestions.get(i)); GeneralQuestionAnswerVoCollection question = new GeneralQuestionAnswerVoCollection(); question.add(collInvQuestions.get(i)); addQuestions(row, columnsAnswer, question); } } }
private GeneralQuestionAnswerVoCollection getQuestionsByType(GeneralQuestionAnswerVoCollection questions, OrderQuestionType type) { if(questions == null || type == null) return null; GeneralQuestionAnswerVoCollection voCollQuestionAnswers = new GeneralQuestionAnswerVoCollection(); for(int i=0;i<questions.size();i++) { if(questions.get(i).getIQuestionTypeOrderQuestionType().equals(type)) voCollQuestionAnswers.add(questions.get(i)); } return voCollQuestionAnswers.size() > 0 ? voCollQuestionAnswers : null; }