List of usage examples for com.vaadin.ui DragAndDropWrapper setDragStartMode
public void setDragStartMode(DragStartMode dragStartMode)
From source file:org.jumpmind.metl.ui.views.design.EditFlowPalette.java
License:Open Source License
protected void addItemToFlowPanelSection(String labelName, String componentType, VerticalLayout componentLayout, ClassResource icon, String componentId) { FlowPaletteItem paletteItem = new FlowPaletteItem(labelName); if (componentId != null) { paletteItem.setShared(true);//from w ww. j a va 2s.c om paletteItem.setComponentId(componentId); } else { paletteItem.setComponentType(componentType); paletteItem.setShared(false); } paletteItem.setIcon(icon); paletteItem.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP); paletteItem.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); paletteItem.addStyleName("leftAligned"); paletteItem.setWidth(100, Unit.PERCENTAGE); DragAndDropWrapper wrapper = new DragAndDropWrapper(paletteItem); wrapper.setSizeUndefined(); wrapper.setDragStartMode(DragStartMode.WRAPPER); componentLayout.addComponent(wrapper); componentLayout.setComponentAlignment(wrapper, Alignment.TOP_CENTER); }
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(); }//from ww w . j a v a 2 s. c om } 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();//from w w w. j ava 2 s . co 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); }
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"; }/*from ww w.jav a 2s . c o m*/ 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); }
From source file:org.peergreen.vaadin.diagram.Toolbar.java
License:Open Source License
private Component createDragEntry(final ToolbarItem item) { Entry entry = new Entry(item); DragAndDropWrapper drag = new DragAndDropWrapper(entry) { @Override//w w w . j a v a 2 s.c om public Transferable getTransferable(final Map<String, Object> variables) { variables.put("component-type", item.getName()); return super.getTransferable(variables); } }; drag.setSizeUndefined(); drag.setDragStartMode(DragStartMode.COMPONENT); return drag; }
From source file:org.vaadin.alump.masonry.DnDMasonryLayout.java
License:Apache License
/** * Create DnD wrapper for component if not yet defined * @param component Component wrapped//from www. ja va 2 s. c o m * @return Wrapper made or found */ protected DragAndDropWrapper createComponentDnDWrapper(Component component, String wrapperStyleName) { DragAndDropWrapper wrapper = getComponentDnDWrapper(component); if (wrapper == null) { wrapper = new DragAndDropWrapper(component); wrapper.addStyleName("masonry-dnd-wrapper"); if (wrapperStyleName != null) { wrapper.addStyleName(wrapperStyleName); } wrapper.setDragStartMode(allowReorder ? getComponentDragStartMode() : DragStartMode.NONE); wrapper.setDropHandler(createDropHandlerForComponents(wrapper)); } return wrapper; }
From source file:org.vaadin.alump.masonry.DnDMasonryLayout.java
License:Apache License
/** * Set if user is allowed to reorder components by dragging them. This does not affect to server APIs. * @param reorderable true to allow, false to disallow *//* www. j av a2 s .c o m*/ public void setReorderable(boolean reorderable) { allowReorder = reorderable; // Update drag start modes for (int i = 0; i < getMasonryLayout().getComponentCount(); ++i) { Component child = getMasonryLayout().getComponent(i); if (child instanceof DragAndDropWrapper) { DragAndDropWrapper wrapper = (DragAndDropWrapper) child; wrapper.setDragStartMode(allowReorder ? getComponentDragStartMode() : DragStartMode.NONE); } } }