private ArrayList<LocatableHLayout> createTagLayouts() { ArrayList<LocatableHLayout> tagLayouts = new ArrayList<LocatableHLayout>(tags.size()); for (final Tag tag : tags) { LocatableHLayout tagLayout = new LocatableHLayout(extendLocatorId(tag.getName())); tagLayout.setHeight(18); tagLayout.setHeight(16); HTMLFlow tagString = new HTMLFlow( "<nobr><a href=\"" + LinkManager.getTagLink(tag.toString()) + "\">" + tag.toString() + "</a></nobr>"); tagString.setAutoWidth(); tagLayout.addMember(tagString); if (!readOnly) { final LayoutSpacer spacer = new LayoutSpacer(); spacer.setHeight(16); spacer.setWidth(16); final Img remove = new LocatableImg( tagLayout.extendLocatorId("Remove"), "[skin]/images/actions/remove.png", 16, 16); remove.setTooltip(MSG.view_tags_tooltip_1()); remove.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { tags.remove(tag); save(); } }); tagLayout.addMember(remove); tagLayout.addMember(spacer); remove.hide(); tagLayout.addMouseOverHandler( new MouseOverHandler() { public void onMouseOver(MouseOverEvent mouseOverEvent) { remove.show(); spacer.hide(); } }); tagLayout.addMouseOutHandler( new MouseOutHandler() { public void onMouseOut(MouseOutEvent mouseOutEvent) { spacer.show(); remove.hide(); } }); } tagLayouts.add(tagLayout); } return tagLayouts; }
public TagEditorView( String locatorId, Set<Tag> tags, boolean readOnly, TagsChangedCallback callback, boolean vertical) { super(locatorId); setVertical(vertical); setAutoWidth(); if (!vertical) { setMembersMargin(8); } if (tags != null) { this.tags.addAll(tags); } this.readOnly = readOnly; this.callback = callback; // create the following widgets once and re-use as needed tagTitleLabel = new HTMLFlow("<nobr><b>" + MSG.view_tags_tags() + ":</b></nobr>"); tagTitleLabel.setAutoWidth(); if (!this.readOnly) { tagInputDialog = new TagInputDialog(extendLocatorId("tagInputDialog")); addImg = new LocatableImg(extendLocatorId("addImg"), "[skin]/images/actions/add.png", 16, 16); addImg.setTooltip(MSG.view_tags_tooltip_2()); addImg.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { showTagInput(); } }); } }
public TagInputDialog(String locatorId) { super(locatorId); setIsModal(true); setShowHeader(false); setShowEdges(false); setEdgeSize(10); setWidth(200); setHeight(30); setShowToolbar(false); setDismissOnEscape(true); setDismissOnOutsideClick(true); Map<String, Integer> bodyDefaults = new HashMap<String, Integer>(2); bodyDefaults.put("layoutLeftMargin", 5); bodyDefaults.put("membersMargin", 10); setBodyDefaults(bodyDefaults); final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("tagInputForm")); addItem(form); tagInputItem = new ComboBoxItem("tag"); tagInputItem.setShowTitle(false); tagInputItem.setHideEmptyPickList(true); tagInputItem.setValueField("tag"); tagInputItem.setDisplayField("tag"); tagInputItem.setType("comboBox"); tagInputItem.setTextMatchStyle(TextMatchStyle.SUBSTRING); tagInputItem.setTooltip(MSG.view_tags_tooltip_3()); tagInputItem.addKeyPressHandler( new KeyPressHandler() { public void onKeyPress(KeyPressEvent event) { if ((event.getCharacterValue() != null) && (event.getCharacterValue() == KeyCodes.KEY_ENTER)) { // String tag = form.getValueAsString("tag"); String tag = tagInputItem.getEnteredValue(); if (tag != null) { Tag newTag = new Tag(tag); tags.add(newTag); TagEditorView.this.save(); TagInputDialog.this.hide(); } } } }); form.setFields(tagInputItem); }