Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

GridDraggerTwoGrids.java 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.components.grid;
  17. import com.vaadin.annotations.Theme;
  18. import com.vaadin.annotations.Widgetset;
  19. import com.vaadin.server.VaadinRequest;
  20. import com.vaadin.tests.util.Person;
  21. import com.vaadin.ui.CheckBox;
  22. import com.vaadin.ui.Grid;
  23. import com.vaadin.ui.components.grid.DropIndexCalculator;
  24. import com.vaadin.ui.components.grid.GridDragger;
  25. import com.vaadin.ui.components.grid.SourceDataProviderUpdater;
  26. @Theme("valo")
  27. @Widgetset("com.vaadin.DefaultWidgetSet")
  28. public class GridDraggerTwoGrids extends AbstractGridDnD {
  29. @Override
  30. protected void setup(VaadinRequest request) {
  31. getUI().setMobileHtml5DndEnabled(true);
  32. // Drag source Grid
  33. Grid<Person> left = createGridAndFillWithData(50);
  34. // Drop target Grid
  35. Grid<Person> right = createGridAndFillWithData(0);
  36. GridDragger<Person> gridDragger = new GridDragger<>(left, right);
  37. CheckBox addItemsToEnd = new CheckBox("Add Items To End", false);
  38. addItemsToEnd.addValueChangeListener(
  39. event -> gridDragger.setDropIndexCalculator(event.getValue()
  40. ? DropIndexCalculator.ALWAYS_DROP_TO_END : null));
  41. CheckBox removeItemsFromSource = new CheckBox(
  42. "Remove items from source grid", true);
  43. removeItemsFromSource.addValueChangeListener(event -> gridDragger
  44. .setSourceDataProviderUpdater(event.getValue() ? null
  45. : SourceDataProviderUpdater.NOOP));
  46. controls.addComponents(addItemsToEnd, removeItemsFromSource);
  47. initializeTestFor(gridDragger);
  48. }
  49. }