本文整理汇总了Java中com.vaadin.event.dd.DragAndDropEvent类的典型用法代码示例。如果您正苦于以下问题:Java DragAndDropEvent类的具体用法?Java DragAndDropEvent怎么用?Java DragAndDropEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DragAndDropEvent类属于com.vaadin.event.dd包,在下文中一共展示了DragAndDropEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFilterButtonDropHandler
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
@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));
}
}
}
};
}
示例2: drop
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
@Override
public void drop(DragAndDropEvent event) {
WrapperTransferable transfrable = (WrapperTransferable) event.getTransferable();
WrapperTargetDetails details = (WrapperTargetDetails) event.getTargetDetails();
System.out.println("transfrable " + transfrable.getClass().getCanonicalName());
System.out.println("transfrable.getDraggedComponent() " + transfrable.getDraggedComponent().getClass().getCanonicalName());
if (transfrable.getDraggedComponent() instanceof Button) {
// Calculate the drag coordinate difference
int xChange = details.getMouseEvent().getClientX() - transfrable.getMouseDownEvent().getClientX();
int yChange = details.getMouseEvent().getClientY() - transfrable.getMouseDownEvent().getClientY();
// Move the component in the absolute layout
AbsoluteLayout.ComponentPosition componentPosition = processModelLayout.getPosition(transfrable.getSourceComponent());
componentPosition.setLeftValue(componentPosition.getLeftValue() + xChange);
componentPosition.setTopValue(componentPosition.getTopValue() + yChange);
ElementModelLayout elementModelLayout = (ElementModelLayout) ((Button) transfrable.getDraggedComponent()).getParent();
TaskModel elementModel = elementModelLayout.getTaskModel();
elementModel.setX(componentPosition.getLeftValue());
elementModel.setY(componentPosition.getTopValue());
processModel.getTaskModels().put(elementModel.getId(), elementModel);
transitionManager.setValue(processModel.getTaskModels(), processModel.getTransitionModels());
setTaskActive(elementModel);
}
}
示例3: accept
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
@Override
public boolean accept(DragAndDropEvent dragEvent) {
String dragSourceId = dragEvent.getTransferable().getSourceComponent().getId();
// double-check if this is the right handler:
if (!dragSourceId.startsWith(getDragSourcePrefix())) {
return false;
}
final String dropTargetId = dragEvent.getTargetDetails().getTarget().getId();
for (String cId : validDropTargetIdPrefixes) {
if (dropTargetId.startsWith(cId)) {
return true;
}
}
return false;
}
示例4: drop
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
@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 -> {
// reset the flag
hasDirectory = false;
final SoftwareModule softwareModule = softwareModuleManagement.get(selectedSwId)
.orElse(null);
for (final Html5File file : files) {
processFile(file, softwareModule);
}
if (artifactUploadState.getNumberOfFileUploadsExpected().get() > 0) {
processBtn.setEnabled(false);
} else {
// If the upload is not started, it signifies all
// dropped files as either duplicate or directory.So
// display message accordingly
displayCompositeMessage();
}
});
}
}
示例5: getFilterButtonDropHandler
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
@Override
protected DropHandler getFilterButtonDropHandler() {
return new DropHandler() {
private static final long serialVersionUID = 1L;
@Override
public AcceptCriterion getAcceptCriterion() {
return uploadViewClientCriterion;
}
@Override
public void drop(final DragAndDropEvent event) {
/* Not required */
}
};
}
示例6: processDroppedComponent
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
@Override
protected void processDroppedComponent(final DragAndDropEvent event) {
final Component sourceComponent = event.getTransferable().getSourceComponent();
if (sourceComponent instanceof Table) {
final Table sourceTable = (Table) event.getTransferable().getSourceComponent();
addToDeleteList(sourceTable, (TableTransferable) event.getTransferable());
updateSWActionCount();
}
if (sourceComponent.getId().startsWith(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) {
final String swModuleTypeName = sourceComponent.getId()
.replace(UIComponentIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, "");
if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType()
.map(type -> type.getName().equalsIgnoreCase(swModuleTypeName)).orElse(false)) {
notification.displayValidationError(
i18n.getMessage("message.swmodule.type.check.delete", new Object[] { swModuleTypeName }));
} else {
deleteSWModuleType(swModuleTypeName);
updateSWActionCount();
}
}
}
示例7: assignDsTag
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
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);
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
if (result.getAssigned() >= 1 && managementUIState.getDistributionTableFilters().isNoTagSelected()) {
refreshFilter();
}
}
示例8: validate
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
/**
* 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)) {
notification.displayValidationError(i18n.getMessage(SPUILabelDefinitions.ACTION_NOT_ALLOWED));
return false;
}
final TableTransferable tabletransferable = (TableTransferable) transferable;
final AbstractTable<?> source = (AbstractTable<?>) tabletransferable.getSourceComponent();
if (!validateIfSourceisTargetTable(source) && !checkForTargetUpdatePermission()) {
return false;
}
final Set<Long> deletedEntityByTransferable = source.getDeletedEntityByTransferable(tabletransferable);
if (deletedEntityByTransferable.isEmpty()) {
final String actionDidNotWork = i18n.getMessage("message.action.did.not.work", new Object[] {});
notification.displayValidationError(actionDidNotWork);
return false;
}
return true;
}
示例9: getDropFilterHandler
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
@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;
}
};
}
示例10: filterByDroppedDist
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
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);
}
}
示例11: doValidations
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
/**
* 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("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("message.action.not.allowed"));
isValid = Boolean.FALSE;
}
return isValid;
}
示例12: tagAssignment
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
private void tagAssignment(final DragAndDropEvent event) {
final List<Long> targetList = getDraggedTargetList(event).stream().collect(Collectors.toList());
final String targTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent().getId(),
SPUIDefinitions.TARGET_TAG_ID_PREFIXS);
if (targetList.isEmpty()) {
final String actionDidNotWork = i18n.getMessage("message.action.did.not.work");
notification.displayValidationError(actionDidNotWork);
return;
}
final TargetTagAssignmentResult result = toggleTagAssignment(targetList, targTagName);
final List<String> tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags();
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) {
refreshFilter();
}
}
示例13: processDistributionDrop
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
private void processDistributionDrop(final DragAndDropEvent event) {
final com.vaadin.event.dd.TargetDetails targetDetails = event.getTargetDetails();
final TableTransferable transferable = (TableTransferable) event.getTransferable();
final AbstractTable<?> source = (AbstractTable<?>) transferable.getSourceComponent();
final Set<Long> distSelected = source.getDeletedEntityByTransferable(transferable);
final String distTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(),
SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS);
final List<String> tagsClickedList = distFilterParameters.getDistSetTags();
final DistributionSetTagAssignmentResult result = distributionSetManagement.toggleTagAssignment(distSelected,
distTagName);
notification.displaySuccess(HawkbitCommonUtil.createAssignmentMessage(distTagName, result, i18n));
if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) {
eventBus.publish(this, TargetFilterEvent.FILTER_BY_TAG);
}
}
示例14: getFilterButtonDropHandler
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
@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 */
}
};
}
示例15: processDroppedComponent
import com.vaadin.event.dd.DragAndDropEvent; //导入依赖的package包/类
@Override
protected void processDroppedComponent(final DragAndDropEvent event) {
final Component sourceComponent = event.getTransferable().getSourceComponent();
if (sourceComponent instanceof Table) {
final Table sourceTable = (Table) event.getTransferable().getSourceComponent();
if (isDistributionTable(sourceTable)) {
addInDeleteDistributionList(sourceTable, (TableTransferable) event.getTransferable());
updateDSActionCount();
} else if (isSoftwareModuleTable(sourceTable)) {
addToSWDeleteList(sourceTable, (TableTransferable) event.getTransferable());
updateDSActionCount();
}
} else if (sourceComponent.getId().startsWith(SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS)) {
processDeleteDitSetType(sourceComponent.getId());
} else if (sourceComponent.getId().startsWith(SPUIDefinitions.SOFTWARE_MODULE_TAG_ID_PREFIXS)) {
processDeleteSWType(sourceComponent.getId());
}
}