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; }
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(); }
@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); } }
@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); } }
@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); } }
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); } }
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); } }
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(); }
@Override public void onResetChanges() { refreshTaxonomy(taxonomy.getName()); }
@Override public void onDownload() { String downloadUrl = UriBuilders.SYSTEM_CONF_TAXONOMY.create().build(taxonomy.getName()) + "/_download"; fireEvent(new FileDownloadRequestEvent(downloadUrl)); }