예제 #1
0
 @Override
 public void onFilterUpdate(String filter) {
   if (Strings.isNullOrEmpty(filter)) {
     getView().setVocabularies(taxonomy.getVocabulariesArray());
   } else {
     JsArray<VocabularyDto> filtered = JsArrays.create();
     for (VocabularyDto vocabulary : JsArrays.toIterable(taxonomy.getVocabulariesArray())) {
       if (vocabularyMatches(vocabulary, filter)) {
         filtered.push(vocabulary);
       }
     }
     getView().setVocabularies(filtered);
   }
 }
예제 #2
0
  @Override
  public void onMoveDownVocabulary(VocabularyDto vocabularyDto) {
    List<VocabularyDto> vocabularies = JsArrays.toList(taxonomy.getVocabulariesArray());
    int idx = vocabularies.indexOf(vocabularyDto);

    if (idx > -1 && idx < vocabularies.size() - 1) {
      Collections.swap(vocabularies, idx, idx + 1);
      getView().setDirty(true);
      getView().setTaxonomy(taxonomy);
    }
  }
예제 #3
0
 private void redrawVocabularies(TaxonomyDto taxonomy, FlowPanel panelTaxonomy) {
   JsArrayString vocabularies = JsArrays.toSafeArray(taxonomy.getVocabulariesArray());
   if (vocabularies.length() > 0) {
     panelTaxonomy.add(new Heading(5, translations.vocabulariesLabel()));
     FlowPanel vocabulariesPanel = new FlowPanel();
     for (int i = 0; i < vocabularies.length(); i++) {
       vocabulariesPanel.add(getVocabularyLink(getUiHandlers(), taxonomy, vocabularies.get(i)));
     }
     panelTaxonomy.add(vocabulariesPanel);
   }
 }
예제 #4
0
  @Override
  public void onSortVocabularies(final boolean isAscending) {
    if (taxonomy.getVocabulariesCount() > 1) {
      Collections.sort(
          JsArrays.toList(taxonomy.getVocabulariesArray()),
          new Comparator<VocabularyDto>() {
            @Override
            public int compare(VocabularyDto o1, VocabularyDto o2) {
              return (isAscending ? 1 : -1) * o1.getName().compareTo(o2.getName());
            }
          });

      getView().setDirty(true);
      getView().setTaxonomy(taxonomy);
    }
  }