本文整理汇总了Java中com.vaadin.event.DataBoundTransferable类的典型用法代码示例。如果您正苦于以下问题:Java DataBoundTransferable类的具体用法?Java DataBoundTransferable怎么用?Java DataBoundTransferable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataBoundTransferable类属于com.vaadin.event包,在下文中一共展示了DataBoundTransferable类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: drop
import com.vaadin.event.DataBoundTransferable; //导入依赖的package包/类
@Override
public void drop(DragAndDropEvent event) {
final Transferable t = event.getTransferable();
AbstractSelect.AbstractSelectTargetDetails dropData = ((AbstractSelect.AbstractSelectTargetDetails) event.getTargetDetails());
Object sourceItemId = ((DataBoundTransferable) t).getItemId();
Object targetItemId = dropData.getItemIdOver();
VerticalDropLocation location = dropData.getDropLocation();
Item sourceItem = tree.getItem(sourceItemId);
NavNode sourceNode = (NavNode) sourceItem.getItemProperty("object").getValue();
Item targetItem = tree.getItem(targetItemId);
NavNode targetNode = (NavNode) targetItem.getItemProperty("object").getValue();
NavigationView.this.move(sourceNode, targetNode, location);
// Sorting goes as
// - If dropped ON (MIDDLE) a node, we preppend it as a child
// - If dropped on the TOP part of a node, we move/add it before the node
// - If dropped on the BOTTOM part of a node, we move/add it after the node if it has no children, or prepend it as a child if it has children
}
开发者ID:mhus,项目名称:cherry-web,代码行数:21,代码来源:NavigationView.java
示例2: initTree
import com.vaadin.event.DataBoundTransferable; //导入依赖的package包/类
private void initTree() {
this.setSizeFull();
this.setImmediate(true);
this.setSelectable(true);
this.addItemClickListener(this);
this.addContainerProperty("", String.class, null);
this.addContainerProperty(ACTIONS, HorizontalLayout.class, null );
this.addItem(new Object[] {TOOL, getActionLayout(false, false, TOOL)}, TOOL);
this.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
private static final long serialVersionUID = -1913286695570843896L;
@Override
public String generateDescription(Component source, Object itemId,
Object propertyId) {
String description = "Show all ";
if(itemId.equals(TOOL))
description += "elements";
else if (itemId.equals(INPUTS))
description += "inputs";
else if (itemId.equals(OUTPUTS))
description += "outputs";
else if (itemId.equals(PARAMETERS))
description += "parameters";
else
return null;
return description;
}
});
this.setCollapsed(TOOL, false);
String[] rootToolElements = new String[] {INPUTS, OUTPUTS, PARAMETERS};
for(String element : rootToolElements) {
this.addItem(new Object[] {element, getActionLayout(true, false, element)}, element);
this.setParent(element, TOOL);
this.setCollapsed(element, false);
}
this.setDragMode(TableDragMode.ROW);
this.setDropHandler(new DropHandler() {
private static final long serialVersionUID = -4415321436294383112L;
@Override
public AcceptCriterion getAcceptCriterion() {
return new Or(Tree.TargetItemAllowsChildren.get(), new Not(VerticalLocationIs.MIDDLE));
}
@Override
public void drop(DragAndDropEvent event) {
final Transferable t = event.getTransferable();
if (t.getSourceComponent() != TreeToolEditor.this
|| !(t instanceof DataBoundTransferable)) {
return;
}
final AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) event.getTargetDetails());
final Object sourceItemId = ((DataBoundTransferable) t).getItemId();
final Object targetItemId = dropData.getItemIdOver();
final VerticalDropLocation location = dropData.getDropLocation();
moveNode(sourceItemId, targetItemId, location);
}
});
}
开发者ID:chipster,项目名称:chipster,代码行数:64,代码来源:TreeToolEditor.java
示例3: initDragAndDrop
import com.vaadin.event.DataBoundTransferable; //导入依赖的package包/类
@Override
public void initDragAndDrop(Table<User> usersTable, Tree<Group> groupsTree, Consumer<UserGroupChangedEvent> userGroupChangedHandler) {
com.vaadin.ui.Table vTable = usersTable.unwrap(com.vaadin.ui.Table.class);
vTable.setDragMode(com.vaadin.ui.Table.TableDragMode.MULTIROW);
CubaTree vTree = groupsTree.unwrap(CubaTree.class);
vTree.setDragMode(com.vaadin.ui.Tree.TreeDragMode.NODE);
vTree.setDropHandler(new DropHandler() {
@Override
public void drop(DragAndDropEvent dropEvent) {
DataBoundTransferable transferable = (DataBoundTransferable) dropEvent.getTransferable();
AbstractSelect.AbstractSelectTargetDetails dropData =
((AbstractSelect.AbstractSelectTargetDetails) dropEvent.getTargetDetails());
Component sourceComponent = transferable.getSourceComponent();
List<User> users = null;
if (sourceComponent instanceof com.vaadin.ui.Table) {
users = new ArrayList<>(usersTable.getSelected());
}
if (users == null) {
return;
}
if (users.isEmpty()) {
User user = convertToEntity(vTable.getItem(transferable.getItemId()), User.class);
users.add(user);
}
final Object targetItemId = dropData.getItemIdOver();
if (targetItemId == null) {
return;
}
Group group = convertToEntity(vTree.getItem(targetItemId), Group.class);
if (group == null) {
return;
}
userGroupChangedHandler.accept(new UserGroupChangedEvent(groupsTree, users, group));
}
@Override
public AcceptCriterion getAcceptCriterion() {
return new And(AbstractSelect.AcceptItem.ALL);
}
});
}
开发者ID:cuba-platform,项目名称:cuba,代码行数:50,代码来源:AccessGroupCompanion.java
注:本文中的com.vaadin.event.DataBoundTransferable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论