Beispiel #1
0
  protected Widget newTaxonomyLink(
      final TaxonomiesUiHandlers handlers, final TaxonomyDto taxonomy) {
    FlowPanel titlePanel = new FlowPanel();
    Label taxonomyTitle = new Label(taxonomy.getName());
    taxonomyTitle.addStyleName("inline-block");
    taxonomyTitle.setTitle(taxonomy.getName());
    taxonomyTitle.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent clickEvent) {
            handlers.onTaxonomySelection(taxonomy);
          }
        });

    titlePanel.add(taxonomyTitle);
    IconAnchor edit = new IconAnchor();
    edit.setIcon(IconType.EDIT);
    edit.addStyleName("small-dual-indent");
    edit.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent clickEvent) {
            handlers.onTaxonomyEdit(taxonomy);
          }
        });

    titlePanel.add(edit);

    Heading head = new Heading(4);
    head.addStyleName("inline-block small-right-indent");
    head.add(titlePanel);
    return head;
  }
Beispiel #2
0
 private void saveTaxonomy() {
   UriBuilders.SYSTEM_CONF_TAXONOMY.create().build(taxonomy.getName());
   fireEvent(new TaxonomyUpdatedEvent(taxonomy.getName()));
   ResourceRequestBuilderFactory.<TaxonomyDto>newBuilder()
       .forResource(UriBuilders.SYSTEM_CONF_TAXONOMY.create().build(taxonomy.getName())) //
       .withResourceBody(TaxonomyDto.stringify(taxonomy)) //
       .withCallback(
           new ResponseCodeCallback() {
             @Override
             public void onResponseCode(Request request, Response response) {
               getEventBus().fireEvent(new TaxonomyUpdatedEvent(taxonomy.getName()));
               getView().setDirty(false);
             }
           },
           Response.SC_OK,
           Response.SC_CREATED) //
       .withCallback(
           new ResponseCodeCallback() {
             @Override
             public void onResponseCode(Request request, Response response) {
               if (response.getText() != null && !response.getText().isEmpty()) {
                 fireEvent(NotificationEvent.newBuilder().error(response.getText()).build());
               }
             }
           },
           Response.SC_BAD_REQUEST,
           Response.SC_INTERNAL_SERVER_ERROR) //
       .put()
       .send();
 }
Beispiel #3
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);
   }
 }
Beispiel #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);
    }
  }
Beispiel #5
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);
    }
  }
Beispiel #6
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);
   }
 }
Beispiel #7
0
  private void redraw() {
    panel.clear();
    for (TaxonomyDto taxonomy : JsArrays.toIterable(taxonomies)) {
      FlowPanel panelTaxonomy = new FlowPanel();
      panelTaxonomy.addStyleName("item");

      Widget taxonomyLink = newTaxonomyLink(getUiHandlers(), taxonomy);
      panelTaxonomy.add(taxonomyLink);

      for (int i = 0; i < taxonomy.getDescriptionsCount(); i++) {
        if (!taxonomy.getDescriptions(i).getText().isEmpty()) {
          panelTaxonomy.add(
              new LocalizedLabel(
                  taxonomy.getDescriptions(i).getLocale(), taxonomy.getDescriptions(i).getText()));
        }
      }

      redrawVocabularies(taxonomy, panelTaxonomy);

      panel.add(panelTaxonomy);
    }
  }
Beispiel #8
0
  private void retrieveCommitInfos() {
    String requestUri =
        UriBuilders.SYSTEM_CONF_TAXONOMY_COMMITS_INFO.create().build(taxonomy.getName());

    ResourceRequestBuilderFactory.<VcsCommitInfosDto>newBuilder() //
        .forResource(requestUri)
        .withCallback(
            new ResourceCallback<VcsCommitInfosDto>() {
              @Override
              public void onResource(Response response, VcsCommitInfosDto commitInfos) {
                getView().setData(commitInfos.getCommitInfosArray());
              }
            })
        .get()
        .send();
  }
Beispiel #9
0
 @Override
 public void onResetChanges() {
   refreshTaxonomy(taxonomy.getName());
 }
Beispiel #10
0
 @Override
 public void onDownload() {
   String downloadUrl =
       UriBuilders.SYSTEM_CONF_TAXONOMY.create().build(taxonomy.getName()) + "/_download";
   fireEvent(new FileDownloadRequestEvent(downloadUrl));
 }