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 { bsmBtnWrapper.setData(getButtonWrapperData().concat("" + id)); } } bsmBtnWrapper.setId(getButttonWrapperIdPrefix().concat(name)); bsmBtnWrapper.setDragStartMode(DragStartMode.WRAPPER); bsmBtnWrapper.setDropHandler(getFilterButtonDropHandler()); return bsmBtnWrapper; }
protected void addItemToFlowPanelSection(String labelName, String componentType, VerticalLayout componentLayout, StreamResource icon, String componentId) { FlowPaletteItem paletteItem = new FlowPaletteItem(labelName); if (componentId != null) { paletteItem.setShared(true); 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); }
private Component buildPaletteItem(final PaletteItemType type) { Label caption = new Label(type.getIcon().getHtml() + type.getTitle(), ContentMode.HTML); caption.setSizeUndefined(); DragAndDropWrapper ddWrap = new DragAndDropWrapper(caption); ddWrap.setSizeUndefined(); ddWrap.setDragStartMode(DragStartMode.WRAPPER); ddWrap.setData(type); return ddWrap; }
public WrappedComponent(final Component content) { super(content); setDragStartMode(DragStartMode.WRAPPER); }
private Component buildMenuItems() { CssLayout menuItemsLayout = new CssLayout(); menuItemsLayout.addStyleName("valo-menuitems"); for (final DashboardViewType view : DashboardViewType.values()) { Component menuItemComponent = new ValoMenuItemButton(view); if (view == DashboardViewType.REPORTS) { // Add drop target to reports button DragAndDropWrapper reports = new DragAndDropWrapper( menuItemComponent); reports.setSizeUndefined(); reports.setDragStartMode(DragStartMode.NONE); reports.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent event) { UI.getCurrent() .getNavigator() .navigateTo( DashboardViewType.REPORTS.getViewName()); Table table = (Table) event.getTransferable() .getSourceComponent(); DashboardEventBus.post(new TransactionReportEvent( (Collection<Transaction>) table.getValue())); } @Override public AcceptCriterion getAcceptCriterion() { return AcceptItem.ALL; } }); menuItemComponent = reports; } if (view == DashboardViewType.DASHBOARD) { notificationsBadge = new Label(); notificationsBadge.setId(NOTIFICATIONS_BADGE_ID); menuItemComponent = buildBadgeWrapper(menuItemComponent, notificationsBadge); } if (view == DashboardViewType.REPORTS) { reportsBadge = new Label(); reportsBadge.setId(REPORTS_BADGE_ID); menuItemComponent = buildBadgeWrapper(menuItemComponent, reportsBadge); } menuItemsLayout.addComponent(menuItemComponent); } return menuItemsLayout; }