• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DataBoundTransferable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IWidgetTokenOwner类代码示例发布时间:2022-05-22
下一篇:
Java MassAirFlowCommand类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap