@PostConstruct public void init() { initWidget(uiBinder.createAndBindUi(this)); accordion.setId(DOM.createUniqueId()); formAccordionHeader.setDataParent(accordion.getId()); formAccordionHeader.setDataTargetWidget(formAccordionCollapse); resultAccordionHeader.setDataParent(accordion.getId()); resultAccordionHeader.setDataTargetWidget(resultAccordionCollapse); // TODO {porcelli} due a bug on bootstrap we can't use custom date formats createdAfter.setFormat(ApplicationPreferences.getDroolsDateFormat()); createdBefore.setFormat(ApplicationPreferences.getDroolsDateFormat()); lastModifiedAfter.setFormat(ApplicationPreferences.getDroolsDateFormat()); lastModifiedBefore.setFormat(ApplicationPreferences.getDroolsDateFormat()); formGroup.setStyleName(null); formatTypeahead.setDatasets( new StringDataset( new ArrayList<String>() { { for (final ClientResourceType resourceType : clientTypeRegistry.getRegisteredTypes()) { add(resourceType.getShortName()); } } })); }
@UiHandler("search") public void onSearchClick(final ClickEvent e) { errorPanel.clear(); formGroup.setValidationState(ValidationState.NONE); final Map<String, Object> metadata = new HashMap<String, Object>(); if (!sourceTextBox.getText().trim().isEmpty()) { metadata.put("dcore.source[0]", sourceTextBox.getText().trim()); } if (!createdByTextBox.getText().trim().isEmpty()) { metadata.put("createdBy", createdByTextBox.getText().trim()); } if (!descriptionByTextBox.getText().trim().isEmpty()) { metadata.put("dcore.description[0]", descriptionByTextBox.getText().trim()); } if (!formatTypeahead.getText().trim().isEmpty()) { final String pattern = clientTypeRegistry.resolveWildcardPattern(formatTypeahead.getText().trim()); metadata.put("filename", pattern); } if (!subjectTextBox.getText().trim().isEmpty()) { metadata.put("dcore.subject[0]", subjectTextBox.getText().trim()); } if (!typeTextBox.getText().trim().isEmpty()) { metadata.put("dcore.type[0]", typeTextBox.getText().trim()); } if (!lastModifiedByTextBox.getText().trim().isEmpty()) { metadata.put("lastModifiedBy", lastModifiedByTextBox.getText().trim()); } if (!externalLinkTextBox.getText().trim().isEmpty()) { metadata.put("dcore.relation[0]", externalLinkTextBox.getText().trim()); } if (!checkinCommentTextBox.getText().trim().isEmpty()) { metadata.put("checkinComment", checkinCommentTextBox.getText().trim()); } boolean hasSomeDateValue = false; if (createdAfter.getValue() != null) { hasSomeDateValue = true; } if (createdBefore.getValue() != null) { hasSomeDateValue = true; } if (lastModifiedAfter.getValue() != null) { hasSomeDateValue = true; } if (lastModifiedBefore.getValue() != null) { hasSomeDateValue = true; } if (metadata.size() == 0 && !hasSomeDateValue) { formGroup.setValidationState(ValidationState.ERROR); Alert alert = new Alert(Constants.INSTANCE.AtLeastOneFieldMustBeSet(), AlertType.DANGER); alert.setVisible(true); alert.setDismissable(true); errorPanel.add(alert); return; } final SearchResultTable queryTable = new SearchResultTable( new QueryMetadataPageRequest( metadata, createdAfter.getValue(), createdBefore.getValue(), lastModifiedAfter.getValue(), lastModifiedBefore.getValue(), 0, null)); simplePanel.clear(); simplePanel.add(queryTable); formAccordionCollapse.setIn(false); resultAccordionCollapse.setIn(true); }