com.vaadin.v7.ui.Table.getItem()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(381)

本文整理了Java中com.vaadin.v7.ui.Table.getItem()方法的一些代码示例,展示了Table.getItem()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getItem()方法的具体详情如下:
包路径:com.vaadin.v7.ui.Table
类名称:Table
方法名:getItem

Table.getItem介绍

[英]Get the item description generator which generates tooltips for cells and rows in the Table.
[中]获取项目描述生成器,该生成器为表中的单元格和行生成工具提示。

代码示例

代码示例来源:origin: OpenNMS/opennms

  1. @Override
  2. public String getStyle(Table source, Object itemId, Object propertyId) {
  3. if (!Strings.isNullOrEmpty(BusinessServiceTreeTable.this.businessServiceNameFilter) &&
  4. source != null &&
  5. itemId != null &&
  6. BusinessServiceFilter.NAME_PROPERTY.equals(propertyId)) {
  7. Item item = source.getItem(itemId);
  8. if (item != null) {
  9. Property<?> property = item.getItemProperty(BusinessServiceFilter.NAME_PROPERTY);
  10. if (property != null) {
  11. if (property.getValue() != null) {
  12. String value = property.getValue().toString();
  13. if (!value.toLowerCase().contains(BusinessServiceTreeTable.this.businessServiceNameFilter)) {
  14. return "grey";
  15. }
  16. }
  17. }
  18. }
  19. }
  20. return null;
  21. }
  22. });

代码示例来源:origin: OpenNMS/opennms

  1. @Override
  2. public void buttonClick(Button.ClickEvent event) {
  3. for (Map.Entry<String, String> entry : requiredParameters.entrySet()) {
  4. String newValue = table.getItem(entry.getKey()).getItemProperty("Value").getValue().toString();
  5. dashletSpec.getParameters().put(entry.getKey(), newValue);
  6. }
  7. WallboardProvider.getInstance().save();
  8. ((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Properties");
  9. close();
  10. }
  11. });

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

  1. @Override
  2. protected Element writeItem(Element tbody, Object itemId,
  3. DesignContext context) {
  4. Element tr = tbody.appendElement("tr");
  5. tr.attr("item-id", String.valueOf(itemId));
  6. Item item = getItem(itemId);
  7. for (Object id : getVisibleColumns()) {
  8. Element td = tr.appendElement("td");
  9. Object value = item.getItemProperty(id).getValue();
  10. td.html(value != null ? value.toString() : "");
  11. }
  12. return tr;
  13. }

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

  1. @Test
  2. public void testGetJcrItem() {
  3. // GIVEN
  4. when(table.getItem("someItemId")).thenReturn(item);
  5. // WHEN
  6. javax.jcr.Item item = abstractColumnFormatter.getJcrItem(table, "someItemId");
  7. // THEN - don't fail w/ ClassCastException
  8. assertNull(item);
  9. }

代码示例来源:origin: com.vaadin/vaadin-compatibility-server

  1. Item item = getItem(itemId);
  2. if (item != null) {
  3. fireEvent(new ItemClickEvent(this, item, itemId, propertyId,

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

  1. @Test
  2. public void testGetJcrItemPropertyIsEscaped() throws Exception {
  3. // GIVEN
  4. ContentDecorator decorator = new HTMLEscapingContentDecorator(false);
  5. JcrItemAdapter nodeAdapter = mock(JcrItemAdapter.class);
  6. when(nodeAdapter.getJcrItem()).thenReturn(property);
  7. when(nodeAdapter.isNode()).thenReturn(false);
  8. when(table.getItem(itemId)).thenReturn(nodeAdapter);
  9. // WHEN
  10. javax.jcr.Item value = abstractColumnFormatter.getJcrItem(table, itemId);
  11. // THEN
  12. assertThat(decorator.wrapProperty(property).getString(), is(((Property) value).getString()));
  13. }

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

  1. @Before
  2. public void setUp() throws Exception {
  3. when(context.getLocale()).thenReturn(Locale.ENGLISH);
  4. when(context.getUser()).thenReturn(user);
  5. Item item = mock(Item.class);
  6. Date date = new Date();
  7. date.setTime(0);
  8. Property<Date> property = new ObjectProperty<>(date);
  9. when(item.getItemProperty(anyString())).thenReturn(property);
  10. when(source.getItem(anyObject())).thenReturn(item);
  11. UI ui = mock(UI.class);
  12. Page page = mock(Page.class);
  13. WebBrowser browser = mock(WebBrowser.class);
  14. when(ui.getPage()).thenReturn(page);
  15. when(page.getWebBrowser()).thenReturn(browser);
  16. CurrentInstance.set(UI.class, ui);
  17. }

代码示例来源:origin: com.haulmont.cuba/cuba-web

  1. @Override
  2. public Object generateCell(com.vaadin.v7.ui.Table source, Object itemId, Object columnId) {
  3. Property property = source.getItem(itemId).getItemProperty(columnId);
  4. Object value = property.getValue();
  5. if (value == null) {
  6. return null;
  7. }
  8. String stringValue = value.toString();
  9. if (columnId instanceof MetaPropertyPath) {
  10. MetaProperty metaProperty = ((MetaPropertyPath) columnId).getMetaProperty();
  11. if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) {
  12. stringValue = dynamicAttributesTools.getDynamicAttributeValueAsString(metaProperty, value);
  13. }
  14. }
  15. String cellValue = stringValue;
  16. boolean isMultiLineCell = StringUtils.contains(stringValue, "\n");
  17. if (isMultiLineCell) {
  18. cellValue = StringUtils.replaceChars(cellValue, '\n', ' ');
  19. }
  20. int maxTextLength = column.getMaxTextLength();
  21. if (stringValue.length() > maxTextLength + MAX_TEXT_LENGTH_GAP || isMultiLineCell) {
  22. return StringUtils.abbreviate(cellValue, maxTextLength);
  23. } else {
  24. return cellValue;
  25. }
  26. }
  27. }

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

  1. @Test
  2. public void testGetJcrItemIsEscaped() throws Exception {
  3. // GIVEN
  4. ContentDecorator decorator = new HTMLEscapingContentDecorator(false);
  5. JcrNodeAdapter nodeAdapter = mock(JcrNodeAdapter.class);
  6. when(nodeAdapter.getJcrItem()).thenReturn(node);
  7. when(nodeAdapter.isNode()).thenReturn(true);
  8. when(table.getItem(itemId)).thenReturn(nodeAdapter);
  9. // WHEN
  10. javax.jcr.Item value = abstractColumnFormatter.getJcrItem(table, itemId);
  11. // THEN
  12. assertThat(decorator.wrapNode(node).getName(), is(value.getName()));
  13. }

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

  1. @Before
  2. public void setUp() throws Exception {
  3. this.columnFormatter = new NodeTypeColumnFormatter(new NodeTypeColumnDefinition());
  4. this.table = mock(Table.class);
  5. this.session = new MockSession("foo");
  6. fooNode = session.getRootNode().addNode("foo", "fooType");
  7. barNode = session.getRootNode().addNode("bar", "barType");
  8. doReturn(new JcrNodeAdapter(fooNode)).when(table).getItem(JcrItemUtil.getItemId(fooNode));
  9. doReturn(new JcrNodeAdapter(barNode)).when(table).getItem(JcrItemUtil.getItemId(barNode));
  10. final MockContext context = new MockContext();
  11. context.addSession("foo", session);
  12. MgnlContext.setInstance(context);
  13. }

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility

  1. @Test
  2. public void renderPropertyType() throws Exception {
  3. // GIVEN
  4. fooNode.setProperty("doubleBaz", 0d);
  5. fooNode.setProperty("longBaz", 0l);
  6. fooNode.setProperty("dateBaz", Calendar.getInstance());
  7. final Property doubleBaz = fooNode.getProperty("doubleBaz");
  8. final Property longBaz = fooNode.getProperty("longBaz");
  9. final Property dateBaz = fooNode.getProperty("dateBaz");
  10. final JcrItemId doubleBazId = JcrItemUtil.getItemId(doubleBaz);
  11. final JcrItemId longBazId = JcrItemUtil.getItemId(longBaz);
  12. final JcrItemId dateBazId = JcrItemUtil.getItemId(dateBaz);
  13. doReturn(new JcrPropertyAdapter(doubleBaz)).when(table).getItem(doubleBazId);
  14. doReturn(new JcrPropertyAdapter(longBaz)).when(table).getItem(longBazId);
  15. doReturn(new JcrPropertyAdapter(dateBaz)).when(table).getItem(dateBazId);
  16. // WHEN
  17. final String doubleBazColumnContent = (String) columnFormatter.generateCell(table, doubleBazId, null);
  18. final String longBazColumnContent = (String) columnFormatter.generateCell(table, longBazId, null);
  19. final String dateBazColumnContent = (String) columnFormatter.generateCell(table, dateBazId, null);
  20. // THEN
  21. assertThat(doubleBazColumnContent, equalTo("Double"));
  22. assertThat(longBazColumnContent, equalTo("Long"));
  23. assertThat(dateBazColumnContent, equalTo("Date"));
  24. }

相关文章

Table类方法