private List<String> validate() { List<String> errors = new ArrayList<String>(); if (selectionListbox.getItemCount() == 0 && !ViewUtil.isTextPopulated(dbInstructionArea)) { errors.add(TEXT_CONSTANTS.noDBSurveyMandatory()); } if (!ViewUtil.isTextPopulated(notificationEmailBox)) { errors.add(TEXT_CONSTANTS.emailMandatory()); } return errors; }
public BootstrapGeneratorWidget() { contentPanel = new VerticalPanel(); contentPanel.setWidth("800px"); surveyService = GWT.create(SurveyService.class); addSurveyButton = new Button(TEXT_CONSTANTS.addSelected()); addSurveyButton.addClickHandler(this); generateFileButton = new Button(TEXT_CONSTANTS.generate()); generateFileButton.addClickHandler(this); removeButton = new Button(TEXT_CONSTANTS.removeSelected()); removeButton.addClickHandler(this); CaptionPanel selectorPanel = new CaptionPanel(TEXT_CONSTANTS.selectSurveyForInclusion()); HorizontalPanel temp = new HorizontalPanel(); selectionWidget = new SurveySelectionWidget(Orientation.HORIZONTAL, TerminalType.SURVEY); temp.add(selectionWidget); temp.add(addSurveyButton); selectorPanel.add(temp); contentPanel.add(selectorPanel); CaptionPanel zipPanel = new CaptionPanel(TEXT_CONSTANTS.fileContents()); selectionListbox = new ListBox(true); selectionListbox.setVisibleItemCount(DEFAULT_ITEM_COUNT); VerticalPanel zipPanelContent = new VerticalPanel(); HorizontalPanel selectedSurveyPanel = new HorizontalPanel(); ViewUtil.installFieldRow( selectedSurveyPanel, TEXT_CONSTANTS.selectedSurveys(), selectionListbox, LABEL_STYLE); selectedSurveyPanel.add(removeButton); zipPanelContent.add(selectedSurveyPanel); temp = new HorizontalPanel(); includeDbScriptBox = new CheckBox(); includeDbScriptBox.addClickHandler(this); ViewUtil.installFieldRow(temp, TEXT_CONSTANTS.includeDB(), includeDbScriptBox, LABEL_STYLE); zipPanelContent.add(temp); dbInstructionArea = new TextArea(); dbInstructionArea.setVisible(false); zipPanelContent.add(dbInstructionArea); temp = new HorizontalPanel(); notificationEmailBox = new TextBox(); ViewUtil.installFieldRow( temp, TEXT_CONSTANTS.notificationEmail(), notificationEmailBox, LABEL_STYLE); zipPanelContent.add(temp); zipPanelContent.add(generateFileButton); zipPanel.add(zipPanelContent); contentPanel.add(zipPanel); initWidget(contentPanel); }