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(); } }); } }