Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

IntArrayRendererConnector.java 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2000-2014 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.widgetset.client.grid;
  17. import com.vaadin.client.ui.grid.FlyweightCell;
  18. import com.vaadin.client.ui.grid.Renderer;
  19. import com.vaadin.client.ui.grid.renderers.AbstractRendererConnector;
  20. import com.vaadin.shared.ui.Connect;
  21. @Connect(com.vaadin.tests.components.grid.IntArrayRenderer.class)
  22. public class IntArrayRendererConnector extends AbstractRendererConnector<int[]> {
  23. public static class IntArrayRenderer implements Renderer<int[]> {
  24. private static final String JOINER = " :: ";
  25. @Override
  26. public void render(FlyweightCell cell, int[] data) {
  27. String text = "";
  28. for (int i : data) {
  29. text += i + JOINER;
  30. }
  31. if (!text.isEmpty()) {
  32. text = text.substring(0, text.length() - JOINER.length());
  33. }
  34. cell.getElement().setInnerText(text);
  35. }
  36. }
  37. @Override
  38. public IntArrayRenderer getRenderer() {
  39. return (IntArrayRenderer) super.getRenderer();
  40. }
  41. @Override
  42. public Class<int[]> getType() {
  43. return int[].class;
  44. }
  45. }