List of usage examples for com.vaadin.ui DragAndDropWrapper setData
public void setData(Object data)
From source file:org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons.java
License:Open Source License
private DragAndDropWrapper createDragAndDropWrapper(final Button tagButton, final String name, final Long id) { final DragAndDropWrapper bsmBtnWrapper = new DragAndDropWrapper(tagButton); bsmBtnWrapper.addStyleName(ValoTheme.DRAG_AND_DROP_WRAPPER_NO_VERTICAL_DRAG_HINTS); bsmBtnWrapper.addStyleName(ValoTheme.DRAG_AND_DROP_WRAPPER_NO_HORIZONTAL_DRAG_HINTS); bsmBtnWrapper.addStyleName(SPUIStyleDefinitions.FILTER_BUTTON_WRAPPER); if (getButtonWrapperData() != null) { if (id == null) { bsmBtnWrapper.setData(getButtonWrapperData()); } else {/*from w w w.j a va 2 s . co m*/ bsmBtnWrapper.setData(getButtonWrapperData().concat("" + id)); } } bsmBtnWrapper.setId(getButttonWrapperIdPrefix().concat(name)); bsmBtnWrapper.setDragStartMode(DragStartMode.WRAPPER); bsmBtnWrapper.setDropHandler(getFilterButtonDropHandler()); return bsmBtnWrapper; }
From source file:org.lucidj.browser.AbstractCell.java
License:Apache License
private Component build_left_panel() { left_panel = new CssLayout(); left_panel.setWidth(32, Sizeable.Unit.PIXELS); left_panel.addStyleName("cell-panel-left"); left_panel.setHeight(100, Sizeable.Unit.PERCENTAGE); String icon_url = "/VAADIN/~/formulas/impossible.png"; String icon_title = "The Unknown"; ComponentInterface component_interface = Aggregate.adapt(ComponentInterface.class, source_object); if (component_interface != null) { // If it is a valid component, displays its icon on the top left corner of the cell ComponentDescriptor descriptor = (ComponentDescriptor) component_interface .getProperty(ComponentDescriptor.DESCRIPTOR); if (descriptor != null) { icon_url = descriptor.getIconUrl(); icon_title = descriptor.getIconTitle(); }// w ww . ja v a2 s. c o m } String component_icon_html = "<img class='component-icon' src='" + icon_url + "' title='" + SafeHtmlUtils.htmlEscape(icon_title) + "'/>"; component_icon = new Label(component_icon_html, ContentMode.HTML); left_panel.addComponent(component_icon); // Put the component in a D&D wrapper and allow dragging it final DragAndDropWrapper panel_dd_wrap = new DragAndDropWrapper(left_panel); panel_dd_wrap.setDragStartMode(DragAndDropWrapper.DragStartMode.COMPONENT_OTHER); panel_dd_wrap.setDragImageComponent(component_icon); panel_dd_wrap.addStyleName("no-horizontal-drag-hints"); panel_dd_wrap.addStyleName("no-box-drag-hints"); // Set the wrapper to wrap tightly around the component panel_dd_wrap.setHeight(100, Sizeable.Unit.PERCENTAGE); panel_dd_wrap.setWidthUndefined(); panel_dd_wrap.setId("test"); // Setup DD handlers for component insertion panel_dd_wrap.setData(this); panel_dd_wrap.setDropHandler(this); // While left_panel is kept in order to be customized, here we return D&D wrapper return (panel_dd_wrap); }
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 w w. java2 s . c om*/ // 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); }
From source file:org.lucidj.iconlist.renderer.IconListRenderer.java
License:Apache License
private AbstractComponent create_icon(Map<String, Object> component) { String icon_title = (String) component.get("iconTitle"); if (icon_title == null) { icon_title = "No title"; }/* ww w . j a v a 2s . c om*/ Resource icon_resource = iconHelper.getIcon((String) component.get("iconUrl"), 32); Button button_icon = new Button(icon_title); button_icon.setIcon(icon_resource); button_icon.addStyleName(ValoTheme.BUTTON_BORDERLESS); button_icon.addStyleName(ValoTheme.BUTTON_SMALL); button_icon.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); button_icon.addStyleName("x-icon-button"); button_icon.addStyleName("icon-size-32"); button_icon.addClickListener(this); button_icon.setWidthUndefined(); button_caption_wrap(button_icon); // Put the component in a D&D wrapper and allow dragging it final DragAndDropWrapper icon_dd_wrap = new DragAndDropWrapper(button_icon); 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 ID for drag-drop AND on the Label for double-click if (component.containsKey("entryId")) { String entryId = (String) component.get("entryId"); icon_dd_wrap.setId(entryId); button_icon.setId(entryId); } // Component data is the map itself button_icon.setData(component); // Remember this association component_to_vaadin.put(component, icon_dd_wrap); return (icon_dd_wrap); }