- /**\r
- * Retrieves all user tags from the server and updates the FlowPanel\r
- */\r
- protected void updateTags() {\r
- GetCommand<TagsResource> tc = new GetCommand<TagsResource>(app, TagsResource.class, app.getCurrentUserResource().getTagsPath(),null) {\r
-\r
- @Override\r
- public void onComplete() {\r
- allTagsContent.clear();\r
- TagsResource tagr = getResult();\r
- List<String> userTags = tagr.getTags();\r
- Anchor tag = null;\r
- for(String usrTag : userTags){\r
- tag = new Anchor(usrTag.toString(), false);\r
- tag.addStyleName("pithos-tag");\r
- allTagsContent.add(tag);\r
- Label separator = new Label(", ");\r
- separator.addStyleName("pithos-tag");\r
- allTagsContent.add(separator);\r
- tag.addClickHandler( new ClickHandler() {\r
-\r
- @Override\r
- public void onClick(ClickEvent event) {\r
- String existing = tags.getText();\r
- if (MULTIPLE_VALUES_TEXT.equals(existing)) existing = "";\r
- String newTag = ((Anchor) event.getSource()).getText().trim();\r
- // insert the new tag only if it is not in the list\r
- // already\r
- if (existing.indexOf(newTag) == -1 && !existing.trim().endsWith(newTag))\r
- tags.setText(existing.trim()\r
- + (existing.length() > 0 ? ", " : "")\r
- + newTag);\r
- }\r
- });\r
- }\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- app.displayError("Unable to fetch user tags");\r
- }\r
- };\r
- DeferredCommand.addCommand(tc);\r
-\r
- }\r