Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.ui;
  5. import java.util.Collection;
  6. import com.vaadin.data.Container;
  7. import com.vaadin.terminal.PaintException;
  8. import com.vaadin.terminal.PaintTarget;
  9. import com.vaadin.terminal.gwt.client.ui.VListSelect;
  10. /**
  11. * This is a simple list select without, for instance, support for new items,
  12. * lazyloading, and other advanced features.
  13. */
  14. @SuppressWarnings("serial")
  15. @ClientWidget(VListSelect.class)
  16. public class ListSelect extends AbstractSelect {
  17. private int columns = 0;
  18. private int rows = 0;
  19. public ListSelect() {
  20. super();
  21. }
  22. public ListSelect(String caption, Collection options) {
  23. super(caption, options);
  24. }
  25. public ListSelect(String caption, Container dataSource) {
  26. super(caption, dataSource);
  27. }
  28. public ListSelect(String caption) {
  29. super(caption);
  30. }
  31. /**
  32. * Sets the number of columns in the editor. If the number of columns is set
  33. * 0, the actual number of displayed columns is determined implicitly by the
  34. * adapter.
  35. *
  36. * @param columns
  37. * the number of columns to set.
  38. */
  39. public void setColumns(int columns) {
  40. if (columns < 0) {
  41. columns = 0;
  42. }
  43. if (this.columns != columns) {
  44. this.columns = columns;
  45. requestRepaint();
  46. }
  47. }
  48. public int getColumns() {
  49. return columns;
  50. }
  51. public int getRows() {
  52. return rows;
  53. }
  54. /**
  55. * Sets the number of rows in the editor. If the number of rows is set 0,
  56. * the actual number of displayed rows is determined implicitly by the
  57. * adapter.
  58. *
  59. * @param rows
  60. * the number of rows to set.
  61. */
  62. public void setRows(int rows) {
  63. if (rows < 0) {
  64. rows = 0;
  65. }
  66. if (this.rows != rows) {
  67. this.rows = rows;
  68. requestRepaint();
  69. }
  70. }
  71. @Override
  72. public void paintContent(PaintTarget target) throws PaintException {
  73. target.addAttribute("type", "list");
  74. // Adds the number of columns
  75. if (columns != 0) {
  76. target.addAttribute("cols", columns);
  77. }
  78. // Adds the number of rows
  79. if (rows != 0) {
  80. target.addAttribute("rows", rows);
  81. }
  82. super.paintContent(target);
  83. }
  84. }