List of usage examples for com.vaadin.ui Label setId
@Override public void setId(String id)
From source file:org.lucidj.browser.ComponentPalette.java
License:Apache License
private boolean add_component_to_palette(ComponentDescriptor component) { String canonical_name = component.getComponentClass(); String icon_title = component.getIconTitle(); log.info("*** => ADDING component {} ({})", canonical_name, component); int base_width = 6; int margin_h_size_px = base_width / 2; int margin_v_size_px = base_width; int icon_size_px = base_width * 6; int font_size_px = 2 * base_width + 2; int icon_box_width_px = base_width * 12; String icon_html = "<div style='text-align: center; height:auto; display:inline-block; " + "margin:" + margin_v_size_px + "px " + margin_h_size_px + "px;" + "width:" + icon_box_width_px + "px; line-height:1.1em;'>" + "<img src='" + component.getIconUrl() + "' " + "width='" + icon_size_px + "px' height='" + icon_size_px + "px' />" + "<div style='white-space:normal; word-wrap:break-word; font-weight: 400;" + "font-size:" + font_size_px + "px;'>" + icon_title + "</div>" + "</div>"; Label icon_label = new Label(icon_html, ContentMode.HTML); icon_label.setWidthUndefined();// w ww . j a v a2 s .c o m // Put the component in a D&D wrapper and allow dragging it final DragAndDropWrapper icon_dd_wrap = new DragAndDropWrapper(icon_label); icon_dd_wrap.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT); // Set the wrapper to wrap tightly around the component icon_dd_wrap.setSizeUndefined(); icon_dd_wrap.setData(component); // Set canonical_name for drag-drop AND on the Label for double-click icon_dd_wrap.setId(canonical_name); icon_label.setId(canonical_name); // Remember this association component_to_vaadin.put(component, icon_dd_wrap); // Add the wrapper, not the component, to the layout self.addComponent(icon_dd_wrap); return (true); }