Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. private class HighlightCallbackIterator implements SerializableEventListener, IteratorRowFieldCallback {
  2. private IIteratorView iteratorView;
  3. private Filter filter;
  4. private Collection<String> highlightFields;
  5. private String highlightMethodId;
  6. private boolean highlightApplied = false;
  7.  
  8. HighlightCallbackIterator(IIteratorView iteratorView, Filter filter, Collection<String> highlightFields, String highlightMethodId) {
  9. this.iteratorView = iteratorView;
  10. this.filter = filter;
  11. this.highlightFields = highlightFields;
  12. this.highlightMethodId = highlightMethodId;
  13. }
  14.  
  15. @Override
  16. public void onEvent(Event event) throws Exception {
  17. /*вся подсветка осуществляется в методе onField. Однако, если высвать iteratorView.doWithColumnByFieldName для поля, у которого нет
  18. view, то коллбэк не будет вызван, а вариант, когда в дескрипторе подсветки есть поле, которого нет в итераторе вполне возможен.
  19. Поэтому перебираем все поля, до тех пор, пока не встретим поле, которое представлено визуальным компонентом в итераторе*/
  20. highlightApplied = false;
  21. for (String highlightField : highlightFields) {
  22. iteratorView.doWithColumnByFieldName(highlightField, this);
  23. if (highlightApplied) {
  24. return;
  25. }
  26. }
  27. }
  28.  
  29. @Override
  30. public void onField(FieldView fieldView, ContainerViewContext containerViewContext) {
  31. highlightApplied = true;
  32. if (filter != null) {
  33. if (containerViewContext instanceof ContentAccessor) {
  34. if (!filter.check((ContentAccessor) containerViewContext)) {
  35. return;
  36. }
  37. } else {
  38. FieldSet fs = containerViewContext.getFieldValues(new FieldSet());
  39. if (!filter.check(fs)) {
  40. return;
  41. }
  42. }
  43. }
  44.  
  45. DocEditViewContext docFormContext = new DocEditViewContext(containerViewContext);
  46. for (String fieldName : highlightFields) {
  47. highlightService.highlightField(docFormContext, FieldPath.from(fieldName), highlightMethodId);
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement