本文整理汇总了Java中com.vaadin.client.ui.dd.VDragEvent类的典型用法代码示例。如果您正苦于以下问题:Java VDragEvent类的具体用法?Java VDragEvent怎么用?Java VDragEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VDragEvent类属于com.vaadin.client.ui.dd包,在下文中一共展示了VDragEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Override
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
protected boolean accept(VDragEvent drag, UIDL configuration) {
try {
String component = drag.getTransferable().getDragSource().getWidget().getElement().getId();
int c = configuration.getIntAttribute(COMPONENT_COUNT);
String mode = configuration.getStringAttribute(MODE);
for (int dragSourceIndex = 0; dragSourceIndex < c; dragSourceIndex++) {
String requiredPid = configuration.getStringAttribute(COMPONENT + dragSourceIndex);
if ((STRICT_MODE.equals(mode) && component.equals(requiredPid))
|| (PREFIX_MODE.equals(mode) && component.startsWith(requiredPid))) {
return true;
}
}
} catch (Exception e) {
// log and continue
LOGGER.log(Level.SEVERE, "Error verifying drop target: " + e.getLocalizedMessage());
}
return false;
}
示例2: setMultiRowDragDecoration
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
/**
* Styles a multi-row selection with the number of elements.
*
* @param drag
* the current drag event holding the context.
*/
void setMultiRowDragDecoration(VDragEvent drag) {
Widget widget = drag.getTransferable().getDragSource().getWidget();
if (widget instanceof VScrollTable) {
VScrollTable table = (VScrollTable) widget;
int rowCount = table.selectedRowKeys.size();
Element dragCountElement = Document.get().getElementById(SP_DRAG_COUNT);
if (rowCount > 1 && table.selectedRowKeys.contains(table.focusedRow.getKey())) {
if (dragCountElement == null) {
dragCountElement = Document.get().createStyleElement();
dragCountElement.setId(SP_DRAG_COUNT);
HeadElement head = HeadElement.as(Document.get().getElementsByTagName(HeadElement.TAG).getItem(0));
head.appendChild(dragCountElement);
}
SafeHtml formattedCssStyle = getDraggableTemplate().multiSelectionStyle(determineActiveTheme(drag),
String.valueOf(rowCount));
StyleElement dragCountStyleElement = StyleElement.as(dragCountElement);
dragCountStyleElement.setInnerSafeHtml(formattedCssStyle);
} else if (dragCountElement != null) {
dragCountElement.removeFromParent();
}
}
}
示例3: isValidDragSource
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
/**
* Checks if this accept criterion is responsible for the current drag
* source. Therefore the current drag source id has to start with the drag
* source id-prefix configured for the criterion.
*
* @param drag
* the current drag event holding the context.
* @param configuration
* for the accept criterion to retrieve the configured drag
* source id-prefix.
* @return <code>true</code> if the criterion is responsible for the current
* drag source, otherwise <code>false</code>.
*/
// Exception squid:S1166 - Hide origin exception
// Exception squid:S2221 - This code is trans-coded to JavaScript, hence
// Exception semantics changes
@SuppressWarnings({ "squid:S1166", "squid:S2221" })
boolean isValidDragSource(final VDragEvent drag, final UIDL configuration) {
try {
final String dragSource = drag.getTransferable().getDragSource().getWidget().getElement().getId();
final String dragSourcePrefix = configuration.getStringAttribute(DRAG_SOURCE);
if (dragSource.startsWith(dragSourcePrefix)) {
return true;
}
} catch (final Exception e) {
// log and continue
LOGGER.log(Level.SEVERE, "Error verifying drag source: " + e.getLocalizedMessage());
}
return false;
}
示例4: checkDragSourceWithValidId
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Test
@Description("Verifies that drag source is valid for the configured prefix")
public void checkDragSourceWithValidId() {
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare drag-event:
final String prefix = "this";
final String id = "thisId";
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
// prepare configuration:
final UIDL uidl = GWT.create(UIDL.class);
when(uidl.getStringAttribute("ds")).thenReturn(prefix);
// act
final boolean result = cut.isValidDragSource(dragEvent, uidl);
// assure that drag source is valid: [thisId startsWith this]
assertThat(result).as("Expected: [" + id + " startsWith " + prefix + "].").isTrue();
}
示例5: checkDragSourceWithInvalidId
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Test
@Description("Verifies that drag source is not valid for the configured prefix")
public void checkDragSourceWithInvalidId() {
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare drag-event:
final String prefix = "this";
final String id = "notThis";
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
// prepare configuration:
final UIDL uidl = GWT.create(UIDL.class);
when(uidl.getStringAttribute("ds")).thenReturn(prefix);
// act
final boolean result = cut.isValidDragSource(dragEvent, uidl);
// assure that drag source is valid: [thisId !startsWith this]
assertThat(result).as("Expected: [" + id + " !startsWith " + prefix + "].").isFalse();
}
示例6: exceptionWhenCheckingDragSource
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Test
@Description("An exception occures while the drag source is validated against the configured prefix")
public void exceptionWhenCheckingDragSource() {
final ViewComponentClientCriterion cut = new ViewComponentClientCriterion();
// prepare drag-event:
final String prefix = "this";
final String id = "notThis";
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(id);
doThrow(new RuntimeException()).when(dragEvent).getTransferable();
// prepare configuration:
final UIDL uidl = GWT.create(UIDL.class);
when(uidl.getStringAttribute("ds")).thenReturn(prefix);
// act
Boolean result = null;
try {
result = cut.isValidDragSource(dragEvent, uidl);
} catch (final Exception ex) {
fail("Exception is not re-thrown");
}
// assure that in case of exception the drag source is declared invalid
assertThat(result).as("Expected: Invalid drag if exception occures.").isFalse();
}
示例7: processMultiRowDragDecorationNonTable
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Test
@Description("Check multi row drag decoration with non-table widget")
public void processMultiRowDragDecorationNonTable() {
final ViewClientCriterion cut = new ViewClientCriterion();
// prepare drag-event with non table widget:
final VDragAndDropWrapper nonTable = Mockito.mock(VDragAndDropWrapper.class);
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent("thisId", nonTable);
final Document document = Document.get();
// act
cut.setMultiRowDragDecoration(dragEvent);
// assure that multi-row decoration processing was skipped
verify(document, Mockito.never()).getElementById(ViewClientCriterion.SP_DRAG_COUNT);
}
示例8: id
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Test
@Description("Verifies that drag source is not valid for the configured id (strict mode)")
public void noMatchInStrictMode() {
final ItemIdClientCriterion cut = new ItemIdClientCriterion();
// prepare drag-event:
final String testId = "thisId";
final VDragEvent dragEvent = CriterionTestHelper.createMockedVDragEvent(testId);
// prepare configuration:
final UIDL uidl = GWT.create(UIDL.class);
final String configuredId = "component0";
final String id = "this";
when(uidl.getStringAttribute(configuredId)).thenReturn(id);
final String configuredMode = "m";
final String strictMode = "s";
when(uidl.getStringAttribute(configuredMode)).thenReturn(strictMode);
final String count = "c";
when(uidl.getIntAttribute(count)).thenReturn(1);
// act
final boolean result = cut.accept(dragEvent, uidl);
// verify that in strict mode: [thisId !equals this]
assertThat(result).as("Expected: [" + id + " !equals " + testId + "].").isFalse();
}
示例9: dragAccepted
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Override
protected void dragAccepted(VDragEvent drag) {
deEmphasis();
currentTargetElement = drag.getElementOver();
currentTargetDay = WidgetUtil.findWidget(currentTargetElement,
DateCell.class);
emphasis();
}
示例10: dragOver
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Override
public void dragOver(final VDragEvent drag) {
if (isLocationValid(drag.getElementOver())) {
validate(new VAcceptCallback() {
@Override
public void accepted(VDragEvent event) {
dragAccepted(drag);
}
}, drag);
}
}
示例11: drop
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Override
public boolean drop(VDragEvent drag) {
if (isLocationValid(drag.getElementOver())) {
updateDropDetails(drag);
deEmphasis();
return super.drop(drag);
} else {
deEmphasis();
return false;
}
}
示例12: updateDropDetails
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
/**
* Update the drop details sent to the server
*
* @param drag
* The drag event
*/
private void updateDropDetails(VDragEvent drag) {
int slotIndex = currentTargetDay.getSlotIndex(currentTargetElement);
int dayIndex = calendarConnector.getWidget().getWeekGrid()
.getDateCellIndex(currentTargetDay);
drag.getDropDetails().put("dropDayIndex", dayIndex);
drag.getDropDetails().put("dropSlotIndex", slotIndex);
}
示例13: dragAccepted
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Override
protected void dragAccepted(VDragEvent drag) {
deEmphasis();
currentTargetElement = drag.getElementOver();
currentTargetDay = WidgetUtil.findWidget(currentTargetElement,
SimpleDayCell.class);
emphasis();
}
示例14: updateDropDetails
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
/**
* Updates the drop details sent to the server
*
* @param drag
* The drag event
*/
private void updateDropDetails(VDragEvent drag) {
int dayIndex = calendarConnector.getWidget().getMonthGrid()
.getDayCellIndex(currentTargetDay);
drag.getDropDetails().put("dropDayIndex", dayIndex);
}
示例15: accept
import com.vaadin.client.ui.dd.VDragEvent; //导入依赖的package包/类
@Override
// Exception squid:S1604 - GWT 2.7 does not support Java 8
@SuppressWarnings("squid:S1604")
public void accept(final VDragEvent drag, final UIDL configuration, final VAcceptCallback callback) {
if (isDragStarting(drag)) {
final NativePreviewHandler nativeEventHandler = new NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
if (isEscKey(event) || isMouseUp(event)) {
try {
hideDropTargetHints(configuration);
} finally {
nativeEventHandlerRegistration.removeHandler();
}
}
}
};
nativeEventHandlerRegistration = Event.addNativePreviewHandler(nativeEventHandler);
setMultiRowDragDecoration(drag);
}
int childCount = configuration.getChildCount();
accepted = false;
for (int childIndex = 0; childIndex < childCount; childIndex++) {
VAcceptCriterion crit = getCriteria(configuration, childIndex);
crit.accept(drag, configuration.getChildUIDL(childIndex), this);
if (Boolean.TRUE.equals(accepted)) {
callback.accepted(drag);
return;
}
}
// if no VAcceptCriterion accepts and the mouse is release, an error
// message is shown
if (Event.ONMOUSEUP == Event.getTypeInt(drag.getCurrentGwtEvent().getType())) {
showErrorNotification(drag);
}
}