com.vaadin.event.dd.DragAndDropEvent Java Examples
The following examples show how to use
com.vaadin.event.dd.DragAndDropEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultAbsoluteLayoutDropHandler.java From cuba with Apache License 2.0 | 6 votes |
/** * Called when a component changed location within the layout * * @param event * The drag and drop event */ @Override protected void handleComponentReordering(DragAndDropEvent event) { AbsoluteLayoutTargetDetails details = (AbsoluteLayoutTargetDetails) event .getTargetDetails(); DDAbsoluteLayout layout = (DDAbsoluteLayout) details.getTarget(); LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); Component component = transferable.getComponent(); // Get top-left pixel position int leftPixelPosition = details.getRelativeLeft(); int topPixelPosition = details.getRelativeTop(); ComponentPosition position = layout.getPosition(component); position.setLeft((float) leftPixelPosition, Sizeable.UNITS_PIXELS); position.setTop((float) topPixelPosition, Sizeable.UNITS_PIXELS); }
Example #2
Source File: AbstractTable.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
private DropHandler getTableDropHandler() { return new DropHandler() { private static final long serialVersionUID = 1L; @Override public AcceptCriterion getAcceptCriterion() { return getDropAcceptCriterion(); } @Override public void drop(final DragAndDropEvent event) { if (!isDropValid(event)) { return; } if (event.getTransferable().getSourceComponent() instanceof Table) { onDropEventFromTable(event); } else if (event.getTransferable().getSourceComponent() instanceof DragAndDropWrapper) { onDropEventFromWrapper(event); } } }; }
Example #3
Source File: AbstractTable.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
protected boolean isDropValid(final DragAndDropEvent dragEvent) { final Transferable transferable = dragEvent.getTransferable(); final Component compsource = transferable.getSourceComponent(); final List<String> missingPermissions = hasMissingPermissionsForDrop(); if (!missingPermissions.isEmpty()) { notification.displayValidationError(i18n.getMessage("message.permission.insufficient", missingPermissions)); return false; } if (compsource instanceof Table) { return validateTable((Table) compsource) && validateDropList(getDraggedTargetList((TableTransferable) transferable, (Table) compsource)); } if (compsource instanceof DragAndDropWrapper) { return validateDragAndDropWrapper((DragAndDropWrapper) compsource) && validateDropList(getDraggedTargetList(dragEvent)); } notification.displayValidationError(i18n.getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED)); return false; }
Example #4
Source File: DefaultPanelDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); PanelTargetDetails details = (PanelTargetDetails) event .getTargetDetails(); Component component = transferable.getComponent(); DDPanel panel = (DDPanel) details.getTarget(); // Detach from old source Component source = transferable.getSourceComponent(); if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(component); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } // Attach to new source panel.setContent(component); }
Example #5
Source File: DistributionTable.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
private void assignTargetTag(final DragAndDropEvent event) { final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails(); final Object distItemId = dropData.getItemIdOver(); final String targetTagName = HawkbitCommonUtil.removePrefix( event.getTransferable().getSourceComponent().getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); // get all the targets assigned to the tag // assign dist to those targets targetTagManagement.getByName(targetTagName).ifPresent(tag -> { Pageable query = PageRequest.of(0, 500); Page<Target> assignedTargets; boolean assigned = false; do { assignedTargets = targetManagement.findByTag(query, tag.getId()); if (assignedTargets.hasContent()) { assignTargetToDs(getItem(distItemId), assignedTargets.getContent()); assigned = true; } } while (assignedTargets.hasNext() && (query = assignedTargets.nextPageable()) != null); if (assigned) { getNotification() .displaySuccess(getI18n().getMessage("message.no.targets.assiged.fortag", targetTagName)); } }); }
Example #6
Source File: DefaultGridLayoutDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void handleComponentReordering(DragAndDropEvent event) { GridLayoutTargetDetails details = (GridLayoutTargetDetails) event .getTargetDetails(); DDGridLayout layout = (DDGridLayout) details.getTarget(); LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); Component comp = transferable.getComponent(); int row = details.getOverRow(); int column = details.getOverColumn(); if (layout.getComponent(column, row) == null) { layout.removeComponent(comp); addComponent(event, comp, column, row); } }
Example #7
Source File: DistributionTable.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
private void assignDsTag(final DragAndDropEvent event) { final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails(); final Table distTable = (Table) taregtDet.getTarget(); final Set<Long> distsSelected = getTableValue(distTable); final Set<Long> distList = new HashSet<>(); final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails(); final Object distItemId = dropData.getItemIdOver(); if (!distsSelected.contains(distItemId)) { distList.add((Long) distItemId); } else { distList.addAll(distsSelected); } final String distTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(), SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS); final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distList, distTagName); getNotification().displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, getI18n())); if (result.getAssigned() >= 1 && managementUIState.getDistributionTableFilters().isNoTagSelected()) { refreshFilter(); } }
Example #8
Source File: DefaultGridLayoutDropHandler.java From cuba with Apache License 2.0 | 6 votes |
protected void addComponent(DragAndDropEvent event, Component component, int column, int row) { GridLayoutTargetDetails details = (GridLayoutTargetDetails) event .getTargetDetails(); DDGridLayout layout = (DDGridLayout) details.getTarget(); // If no components exist in the grid, then just add the // component if (!layout.getComponentIterator().hasNext()) { layout.addComponent(component, column, row); return; } // If component was dropped on top of another component, abort if (layout.getComponent(column, row) != null) { return; } // Add the component layout.addComponent(component, column, row); // Add component alignment if given if (dropAlignment != null) { layout.setComponentAlignment(component, dropAlignment); } }
Example #9
Source File: DistSMTypeFilterButtons.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Override protected DropHandler getFilterButtonDropHandler() { return new DropHandler() { private static final long serialVersionUID = 1L; @Override public AcceptCriterion getAcceptCriterion() { return distributionsViewClientCriterion; } @Override public void drop(final DragAndDropEvent event) { /* Not required */ } }; }
Example #10
Source File: TargetTagFilterButtons.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Override protected DropHandler getFilterButtonDropHandler() { return new DropHandler() { private static final long serialVersionUID = 1L; @Override public AcceptCriterion getAcceptCriterion() { return managementViewClientCriterion; } @Override public void drop(final DragAndDropEvent event) { if (validate(event) && isNoTagAssigned(event)) { final TableTransferable tbl = (TableTransferable) event.getTransferable(); final Table source = tbl.getSourceComponent(); if (source.getId().equals(UIComponentIdProvider.TARGET_TABLE_ID)) { UI.getCurrent().access(() -> processTargetDrop(event)); } } } }; }
Example #11
Source File: DefaultCssLayoutDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void handleComponentReordering(DragAndDropEvent event) { // Component re-ordering LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); CssLayoutTargetDetails details = (CssLayoutTargetDetails) event .getTargetDetails(); DDCssLayout layout = (DDCssLayout) details.getTarget(); Component comp = transferable.getComponent(); int idx = details.getOverIndex(); // Detach from old source Component source = transferable.getSourceComponent(); if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(comp); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } // Add component if (idx >= 0 && idx < layout.getComponentCount()) { layout.addComponent(comp, idx); } else { layout.addComponent(comp); } }
Example #12
Source File: TargetTable.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
private void tagAssignment(final DragAndDropEvent event) { final List<Long> targetList = new ArrayList<>(getDraggedTargetList(event)); final String targTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); if (targetList.isEmpty()) { final String actionDidNotWork = getI18n().getMessage("message.action.did.not.work"); getNotification().displayValidationError(actionDidNotWork); return; } final TargetTagAssignmentResult result = toggleTagAssignment(targetList, targTagName); final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags(); if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) { refreshFilter(); } }
Example #13
Source File: DefaultAccordionDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void handleHTML5Drop(DragAndDropEvent event) { AccordionTargetDetails details = (AccordionTargetDetails) event .getTargetDetails(); VerticalDropLocation location = details.getDropLocation(); DDAccordion acc = (DDAccordion) details.getTarget(); int idx = details.getOverIndex(); Component c = resolveComponentFromHTML5Drop(event); c.setCaption(resolveCaptionFromHTML5Drop(event)); if (location == VerticalDropLocation.TOP) { acc.addTab(c, idx); } else if (location == VerticalDropLocation.BOTTOM) { acc.addTab(c, idx + 1); } else { acc.addTab(c); } }
Example #14
Source File: DSTypeFilterButtons.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Override protected DropHandler getFilterButtonDropHandler() { return new DropHandler() { private static final long serialVersionUID = 1L; @Override public AcceptCriterion getAcceptCriterion() { return distributionsViewClientCriterion; } @Override public void drop(final DragAndDropEvent event) { /* Not required */ } }; }
Example #15
Source File: AbstractDefaultLayoutDropHandler.java From cuba with Apache License 2.0 | 6 votes |
public void drop(DragAndDropEvent event) { // Get information about the drop TargetDetails details = event.getTargetDetails(); DropTarget layout = details.getTarget(); Component source = event.getTransferable().getSourceComponent(); if (event.getTransferable().getData("html5Data") != null) { handleHTML5Drop(event); } else if (layout == source) { handleComponentReordering(event); } else if (event.getTransferable() instanceof LayoutBoundTransferable) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); Component comp = transferable.getComponent(); if (comp == layout) { if (comp.getParent() instanceof DDAbsoluteLayout) { handleDropFromAbsoluteParentLayout(event); } } else { handleDropFromLayout(event); } } }
Example #16
Source File: TargetTableHeader.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
/** * Validation for drag event. * * @param dragEvent * @return */ private Boolean doValidations(final DragAndDropEvent dragEvent) { final Component compsource = dragEvent.getTransferable().getSourceComponent(); Boolean isValid = Boolean.TRUE; if (compsource instanceof Table && !isComplexFilterViewDisplayed) { final TableTransferable transferable = (TableTransferable) dragEvent.getTransferable(); final Table source = transferable.getSourceComponent(); if (!source.getId().equals(UIComponentIdProvider.DIST_TABLE_ID)) { notification.displayValidationError(i18n.getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED)); isValid = Boolean.FALSE; } else { if (getDropppedDistributionDetails(transferable).size() > 1) { notification.displayValidationError(i18n.getMessage("message.onlyone.distribution.dropallowed")); isValid = Boolean.FALSE; } } } else { notification.displayValidationError(i18n.getMessage(UIMessageIdProvider.MESSAGE_ACTION_NOT_ALLOWED)); isValid = Boolean.FALSE; } return isValid; }
Example #17
Source File: DefaultHorizontalSplitPanelDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void handleHTML5Drop(DragAndDropEvent event) { HorizontalSplitPanelTargetDetails details = (HorizontalSplitPanelTargetDetails) event .getTargetDetails(); DDHorizontalSplitPanel panel = (DDHorizontalSplitPanel) details .getTarget(); if (details.getDropLocation() == HorizontalDropLocation.LEFT) { // Dropped in the left area panel.setFirstComponent(resolveComponentFromHTML5Drop(event)); } else if (details.getDropLocation() == HorizontalDropLocation.RIGHT) { // Dropped in the right area panel.setSecondComponent(resolveComponentFromHTML5Drop(event)); } }
Example #18
Source File: DefaultTabSheetDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); TabSheetTargetDetails details = (TabSheetTargetDetails) event .getTargetDetails(); DDTabSheet tabSheet = (DDTabSheet) details.getTarget(); Component c = transferable.getComponent(); HorizontalDropLocation location = details.getDropLocation(); int idx = details.getOverIndex(); ComponentContainer source = (ComponentContainer) transferable .getSourceComponent(); // Detach from old source if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(c); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } if (location == HorizontalDropLocation.LEFT) { tabSheet.addTab(c, idx); } else if (location == HorizontalDropLocation.RIGHT) { tabSheet.addTab(c, idx + 1); } }
Example #19
Source File: TargetTableHeader.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
private void filterByDroppedDist(final DragAndDropEvent event) { if (doValidations(event)) { final TableTransferable tableTransferable = (TableTransferable) event.getTransferable(); final Table source = tableTransferable.getSourceComponent(); if (!UIComponentIdProvider.DIST_TABLE_ID.equals(source.getId())) { return; } final Set<Long> distributionIdSet = getDropppedDistributionDetails(tableTransferable); if (CollectionUtils.isEmpty(distributionIdSet)) { return; } final Long distributionSetId = distributionIdSet.iterator().next(); final Optional<DistributionSet> distributionSet = distributionSetManagement.get(distributionSetId); if (!distributionSet.isPresent()) { notification.displayWarning(i18n.getMessage("distributionset.not.exists")); return; } final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distributionSet.get()); getManagementUIState().getTargetTableFilters().setDistributionSet(distributionSetIdName); addFilterTextField(distributionSetIdName); } }
Example #20
Source File: DefaultTabSheetDropHandler.java From cuba with Apache License 2.0 | 6 votes |
@Override protected void handleHTML5Drop(DragAndDropEvent event) { TabSheetTargetDetails details = (TabSheetTargetDetails) event .getTargetDetails(); HorizontalDropLocation location = details.getDropLocation(); DDTabSheet tabSheet = (DDTabSheet) details.getTarget(); int idx = details.getOverIndex(); Component c = resolveComponentFromHTML5Drop(event); c.setCaption(resolveCaptionFromHTML5Drop(event)); if (location == HorizontalDropLocation.LEFT) { tabSheet.addTab(c, idx); } else if (location == HorizontalDropLocation.RIGHT) { tabSheet.addTab(c, idx + 1); } }
Example #21
Source File: TargetTableHeader.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
@Override protected DropHandler getDropFilterHandler() { return new DropHandler() { /** * */ private static final long serialVersionUID = 1L; @Override public void drop(final DragAndDropEvent event) { filterByDroppedDist(event); } @Override public AcceptCriterion getAcceptCriterion() { return managementViewClientCriterion; } }; }
Example #22
Source File: TargetTagFilterButtons.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
/** * Validate the drop. * * @param event * DragAndDropEvent reference * @return Boolean */ private Boolean validate(final DragAndDropEvent event) { final Transferable transferable = event.getTransferable(); final Component compsource = transferable.getSourceComponent(); if (!(compsource instanceof AbstractTable)) { uiNotification.displayValidationError(getI18n().getMessage(getActionNotAllowedMessage())); return false; } final TableTransferable tabletransferable = (TableTransferable) transferable; final AbstractTable<?> source = (AbstractTable<?>) tabletransferable.getSourceComponent(); if (!validateIfSourceIsTargetTable(source) && !hasTargetUpdatePermission()) { return false; } final Set<Long> deletedEntityByTransferable = source.getSelectedEntitiesByTransferable(tabletransferable); if (deletedEntityByTransferable.isEmpty()) { final String actionDidNotWork = getI18n().getMessage("message.action.did.not.work"); uiNotification.displayValidationError(actionDidNotWork); return false; } return true; }
Example #23
Source File: TargetTagFilterButtons.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
private Boolean isNoTagAssigned(final DragAndDropEvent event) { final String tagName = ((DragAndDropWrapper) (event.getTargetDetails().getTarget())).getData().toString(); if (tagName.equals(getTargetTagCaption())) { uiNotification.displayValidationError(getI18n().getMessage("message.tag.cannot.be.assigned", getI18n().getMessage("label.no.tag.assigned"))); return false; } return true; }
Example #24
Source File: DistributionTable.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
private void assignTargetToDs(final DragAndDropEvent event) { final TableTransferable transferable = (TableTransferable) event.getTransferable(); final TargetTable targetTable = (TargetTable) transferable.getSourceComponent(); final Set<Long> targetIdSet = targetTable.getSelectedEntitiesByTransferable(transferable); selectDraggedEntities(targetTable, targetIdSet); final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails(); final Object distItemId = dropData.getItemIdOver(); assignTargetToDs(getItem(distItemId), targetManagement.get(targetIdSet)); }
Example #25
Source File: DefaultAbsoluteLayoutDropHandler.java From cuba with Apache License 2.0 | 5 votes |
/** * Handle a drop from another layout * * @param event * The drag and drop event */ @Override protected void handleDropFromLayout(DragAndDropEvent event) { AbsoluteLayoutTargetDetails details = (AbsoluteLayoutTargetDetails) event .getTargetDetails(); LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); Component component = transferable.getComponent(); Component source = event.getTransferable().getSourceComponent(); DDAbsoluteLayout layout = (DDAbsoluteLayout) details.getTarget(); int leftPixelPosition = details.getRelativeLeft(); int topPixelPosition = details.getRelativeTop(); // Check that we are not dragging an outer layout into an // inner // layout Component parent = source.getParent(); while (parent != null) { parent = parent.getParent(); } // remove component from source if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(component); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } // Add component to absolute layout layout.addComponent(component, "left:" + leftPixelPosition + "px;top:" + topPixelPosition + "px"); }
Example #26
Source File: UploadDropAreaLayout.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
@Override public void drop(final DragAndDropEvent event) { if (validate(event)) { final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); // selected software module at the time of file drop is // considered for upload artifactUploadState.getSelectedBaseSwModuleId() .ifPresent(selectedSwId -> uploadFilesForSoftwareModule(files, selectedSwId)); } }
Example #27
Source File: UploadDropAreaLayout.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
private boolean validate(final DragAndDropEvent event) { // check if drop is valid.If valid ,check if software module is // selected. if (!isFilesDropped(event)) { uiNotification.displayValidationError(i18n.getMessage("message.drop.onlyFiles")); return false; } return validateSoftwareModuleSelection(); }
Example #28
Source File: UploadDropAreaLayout.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
private boolean isFilesDropped(final DragAndDropEvent event) { if (event.getTransferable() instanceof WrapperTransferable) { final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles(); return files != null; } return false; }
Example #29
Source File: DefaultVerticalSplitPanelDropHandler.java From cuba with Apache License 2.0 | 5 votes |
@Override protected void handleDropFromLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event .getTransferable(); VerticalSplitPanelTargetDetails details = (VerticalSplitPanelTargetDetails) event .getTargetDetails(); Component component = transferable.getComponent(); DDVerticalSplitPanel panel = (DDVerticalSplitPanel) details.getTarget(); ComponentContainer source = (ComponentContainer) transferable .getSourceComponent(); // Detach from old source if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(component); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } if (details.getDropLocation() == VerticalDropLocation.TOP) { // Dropped in the left area panel.setFirstComponent(component); } else if (details.getDropLocation() == VerticalDropLocation.BOTTOM) { // Dropped in the right area panel.setSecondComponent(component); } }
Example #30
Source File: DistributionTable.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
@Override protected void onDropEventFromWrapper(final DragAndDropEvent event) { if (event.getTransferable().getSourceComponent().getId() .startsWith(SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS)) { assignDsTag(event); } else { assignTargetTag(event); } }