- /**\r
- * Retrieves all user tags from the server and updates the FlowPanel\r
- *\r
- * @param userId\r
- */\r
- private void updateTags() {\r
- GetCommand<TagsResource> tc = new GetCommand<TagsResource>(TagsResource.class, GSS.get().getCurrentUserResource().getTagsPath()) {\r
-\r
- @Override\r
- public void onComplete() {\r
- allTagsContent.clear();\r
- TagsResource tagr = getResult();\r
- List<String> userTags = tagr.getTags();\r
- Iterator t = userTags.iterator();\r
- while (t.hasNext()) {\r
- final Button tag = new Button((String) t.next(), new ClickListener() {\r
-\r
- public void onClick(Widget sender) {\r
- String existing = tags.getText();\r
- String newTag = ((Button) sender).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() + (existing.length() > 0 ? ", " : "") + newTag);\r
- }\r
- });\r
- allTagsContent.add(tag);\r
- }\r
- }\r
-\r
- @Override\r
- public void onError(Throwable t) {\r
- GWT.log("", t);\r
- GSS.get().displayError("Unable to fetch user tags");\r
- }\r
- };\r
- DeferredCommand.addCommand(tc);\r
-\r
- }\r
-\r
- @Override\r
- @SuppressWarnings("fallthrough")\r
- public boolean onKeyDownPreview(char key, int modifiers) {\r
- // Use the popup's key preview hooks to close the dialog when either\r
- // enter or escape is pressed.\r
- switch (key) {\r
- case KeyboardListener.KEY_ENTER:\r
- accept();\r
- case KeyboardListener.KEY_ESCAPE:\r
- closeDialog();\r
- break;\r
- }\r
-\r
- return true;\r
- }\r