Ejemplo n.º 1
0
 @Override
 public void setVocabulary(VocabularyDto vocabulary, JsArrayString locales) {
   name.setText(vocabulary.getName());
   titles.setLocaleTexts(vocabulary.getTitleArray(), JsArrays.toList(locales));
   descriptions.setLocaleTexts(vocabulary.getDescriptionArray(), JsArrays.toList(locales));
   repeatable.setValue(vocabulary.hasRepeatable() && vocabulary.getRepeatable());
 }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 3
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);
    }
  }
Ejemplo n.º 4
0
  @Override
  public void onDeleteAttribute(List<JsArray<AttributeDto>> selectedItems) {
    VariableDto dto = getVariableDto();

    JsArray<AttributeDto> filteredAttributes = JsArrays.create().cast();
    List<AttributeDto> allAttributes = JsArrays.toList(dto.getAttributesArray());

    for (AttributeDto attribute : allAttributes) {
      boolean keep = true;
      for (JsArray<AttributeDto> toRemove : selectedItems) {
        if (attribute.getName().equals(toRemove.get(0).getName())
            && attribute.getNamespace().equals(toRemove.get(0).getNamespace())) {
          keep = false;
          break;
        }
      }

      if (keep) {
        filteredAttributes.push(attribute);
      }
    }

    dto.setAttributesArray(filteredAttributes);

    UriBuilder uriBuilder =
        table.hasViewLink()
            ? UriBuilders.DATASOURCE_VIEW_VARIABLE.create()
            : UriBuilders.DATASOURCE_TABLE_VARIABLE.create();

    ResourceRequestBuilderFactory.newBuilder() //
        .forResource(
            uriBuilder.build(table.getDatasourceName(), table.getName(), variable.getName())) //
        .withResourceBody(VariableDto.stringify(dto)) //
        .withCallback(
            SC_OK,
            new ResponseCodeCallback() {
              @Override
              public void onResponseCode(Request request, Response response) {
                fireEvent(new VariableRefreshEvent());
              }
            }) //
        .withCallback(SC_BAD_REQUEST, new ErrorResponseCallback(getView().asWidget())) //
        .put()
        .send();
  }
Ejemplo n.º 5
0
 @Override
 public void renderRows(JsArray<TableDto> rows) {
   dataProvider.setList(JsArrays.toList(JsArrays.toSafeArray(rows)));
   pager.firstPage();
 }