com.vaadin.event.dd.DropHandler Java Examples

The following examples show how to use com.vaadin.event.dd.DropHandler. 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: AbstractTable.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
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 #2
Source File: DSTypeFilterButtons.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@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 #3
Source File: DistSMTypeFilterButtons.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@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 #4
Source File: TargetTableHeader.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@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 #5
Source File: SMTypeFilterButtons.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@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 */
        }
    };
}
 
Example #6
Source File: TargetTagFilterButtons.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@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 #7
Source File: DDPanel.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the drop handler which handles component drops on the layout
 * 
 * @param dropHandler
 *            The drop handler to set
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (this.dropHandler != dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}
 
Example #8
Source File: DDGridLayout.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (dropHandler != this.dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}
 
Example #9
Source File: DDUtil.java    From cuba with Apache License 2.0 5 votes vote down vote up
public static void verifyHandlerType(HasComponents layout,
        DropHandler handler) {
    if (handler instanceof AbstractDefaultLayoutDropHandler) {
        AbstractDefaultLayoutDropHandler dropHandler = (AbstractDefaultLayoutDropHandler) handler;
        if (!dropHandler.getTargetLayoutType()
                .isAssignableFrom(layout.getClass())) {
            throw new IllegalArgumentException("Cannot add a handler for "
                    + dropHandler.getTargetLayoutType() + " to a "
                    + layout.getClass());
        }
    }
}
 
Example #10
Source File: DDAbsoluteLayout.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the drop handler which handles component drops on the layout
 * 
 * @param dropHandler
 *            The drop handler to set
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (this.dropHandler != dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}
 
Example #11
Source File: DDCssLayout.java    From cuba with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the drop handler which handles component drops on the layout
 * 
 * @param dropHandler
 *            The drop handler to set
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (this.dropHandler != dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}
 
Example #12
Source File: DistributionTagButtons.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected DropHandler getFilterButtonDropHandler() {
    return spDistTagDropEvent;
}
 
Example #13
Source File: AbstractDistributionSetTableHeader.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected DropHandler getDropFilterHandler() {
    return null;
}
 
Example #14
Source File: DDTabSheet.java    From cuba with Apache License 2.0 4 votes vote down vote up
public DropHandler getDropHandler() {
    return dropHandler;
}
 
Example #15
Source File: DDAccordion.java    From cuba with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public DropHandler getDropHandler() {
    return dropHandler;
}
 
Example #16
Source File: AbstractSoftwareModuleTableHeader.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected DropHandler getDropFilterHandler() {
    return null;
}
 
Example #17
Source File: TreeToolEditor.java    From chipster with MIT License 4 votes vote down vote up
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);
		}
	});

}
 
Example #18
Source File: Calendar.java    From calendar-component with Apache License 2.0 4 votes vote down vote up
/**
 * Get the currently active drop handler
 */
@Override
public DropHandler getDropHandler() {
    return dropHandler;
}
 
Example #19
Source File: DDPanel.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public DropHandler getDropHandler() {
    return dropHandler;
}
 
Example #20
Source File: DDGridLayout.java    From cuba with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
public DropHandler getDropHandler() {
    return dropHandler;
}
 
Example #21
Source File: CubaManagedTabSheet.java    From cuba with Apache License 2.0 4 votes vote down vote up
public void setDropHandler(DropHandler dropHandler) {
    tabbedHeader.setDropHandler(dropHandler);
}
 
Example #22
Source File: DDAbsoluteLayout.java    From cuba with Apache License 2.0 4 votes vote down vote up
/**
 * Get the drophandler which handles component drops on the layout
 */
public DropHandler getDropHandler() {
    return dropHandler;
}
 
Example #23
Source File: DDCssLayout.java    From cuba with Apache License 2.0 4 votes vote down vote up
/**
 * gets the drop handler which handles component drops on the layout
 */
public DropHandler getDropHandler() {
    return dropHandler;
}
 
Example #24
Source File: DDHorizontalLayout.java    From cuba with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the current handler which handles dropped components on the layout.
 * By setting a drop handler dropping components on the layout is enabled.
 * By setting the dropHandler to null dropping is disabled.
 * 
 * @param dropHandler
 *            The drop handler to handle drop events or null to disable
 *            dropping
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (this.dropHandler != dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}
 
Example #25
Source File: DDHorizontalSplitPanel.java    From cuba with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the current handler which handles dropped components on the layout.
 * By setting a drop handler dropping components on the layout is enabled.
 * By setting the dropHandler to null dropping is disabled.
 * 
 * @param dropHandler
 *            The drop handler to handle drop events or null to disable
 *            dropping
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (this.dropHandler != dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}
 
Example #26
Source File: DDVerticalLayout.java    From cuba with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the current handler which handles dropped components on the layout.
 * By setting a drop handler dropping components on the layout is enabled.
 * By setting the dropHandler to null dropping is disabled.
 * 
 * @param dropHandler
 *            The drop handler to handle drop events or null to disable
 *            dropping
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (this.dropHandler != dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}
 
Example #27
Source File: DDAccordion.java    From cuba with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the current handler which handles dropped components on the layout.
 * By setting a drop handler dropping components on the layout is enabled.
 * By setting the dropHandler to null dropping is disabled.
 * 
 * @param dropHandler
 *            The drop handler to handle drop events or null to disable
 *            dropping
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (this.dropHandler != dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}
 
Example #28
Source File: DDVerticalSplitPanel.java    From cuba with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the current handler which handles dropped components on the layout.
 * By setting a drop handler dropping components on the layout is enabled.
 * By setting the dropHandler to null dropping is disabled.
 * 
 * @param dropHandler
 *            The drop handler to handle drop events or null to disable
 *            dropping
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (this.dropHandler != dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}
 
Example #29
Source File: DDTabSheet.java    From cuba with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the current handler which handles dropped components on the layout.
 * By setting a drop handler dropping components on the layout is enabled.
 * By setting the dropHandler to null dropping is disabled.
 * 
 * @param dropHandler
 *            The drop handler to handle drop events or null to disable
 *            dropping
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (this.dropHandler != dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}
 
Example #30
Source File: DDFormLayout.java    From cuba with Apache License 2.0 3 votes vote down vote up
/**
 * Sets the current handler which handles dropped components on the layout.
 * By setting a drop handler dropping components on the layout is enabled.
 * By setting the dropHandler to null dropping is disabled.
 * 
 * @param dropHandler
 *            The drop handler to handle drop events or null to disable
 *            dropping
 */
public void setDropHandler(DropHandler dropHandler) {
    DDUtil.verifyHandlerType(this, dropHandler);
    if (this.dropHandler != dropHandler) {
        this.dropHandler = dropHandler;
        markAsDirty();
    }
}