本文整理了Java中com.vaadin.v7.ui.Table.getItem()
方法的一些代码示例,展示了Table.getItem()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getItem()
方法的具体详情如下:
包路径:com.vaadin.v7.ui.Table
类名称:Table
方法名:getItem
[英]Get the item description generator which generates tooltips for cells and rows in the Table.
[中]获取项目描述生成器,该生成器为表中的单元格和行生成工具提示。
代码示例来源:origin: OpenNMS/opennms
@Override
public String getStyle(Table source, Object itemId, Object propertyId) {
if (!Strings.isNullOrEmpty(BusinessServiceTreeTable.this.businessServiceNameFilter) &&
source != null &&
itemId != null &&
BusinessServiceFilter.NAME_PROPERTY.equals(propertyId)) {
Item item = source.getItem(itemId);
if (item != null) {
Property<?> property = item.getItemProperty(BusinessServiceFilter.NAME_PROPERTY);
if (property != null) {
if (property.getValue() != null) {
String value = property.getValue().toString();
if (!value.toLowerCase().contains(BusinessServiceTreeTable.this.businessServiceNameFilter)) {
return "grey";
}
}
}
}
}
return null;
}
});
代码示例来源:origin: OpenNMS/opennms
@Override
public void buttonClick(Button.ClickEvent event) {
for (Map.Entry<String, String> entry : requiredParameters.entrySet()) {
String newValue = table.getItem(entry.getKey()).getItemProperty("Value").getValue().toString();
dashletSpec.getParameters().put(entry.getKey(), newValue);
}
WallboardProvider.getInstance().save();
((WallboardConfigUI) getUI()).notifyMessage("Data saved", "Properties");
close();
}
});
代码示例来源:origin: com.vaadin/vaadin-compatibility-server
@Override
protected Element writeItem(Element tbody, Object itemId,
DesignContext context) {
Element tr = tbody.appendElement("tr");
tr.attr("item-id", String.valueOf(itemId));
Item item = getItem(itemId);
for (Object id : getVisibleColumns()) {
Element td = tr.appendElement("td");
Object value = item.getItemProperty(id).getValue();
td.html(value != null ? value.toString() : "");
}
return tr;
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility
@Test
public void testGetJcrItem() {
// GIVEN
when(table.getItem("someItemId")).thenReturn(item);
// WHEN
javax.jcr.Item item = abstractColumnFormatter.getJcrItem(table, "someItemId");
// THEN - don't fail w/ ClassCastException
assertNull(item);
}
代码示例来源:origin: com.vaadin/vaadin-compatibility-server
Item item = getItem(itemId);
if (item != null) {
fireEvent(new ItemClickEvent(this, item, itemId, propertyId,
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility
@Test
public void testGetJcrItemPropertyIsEscaped() throws Exception {
// GIVEN
ContentDecorator decorator = new HTMLEscapingContentDecorator(false);
JcrItemAdapter nodeAdapter = mock(JcrItemAdapter.class);
when(nodeAdapter.getJcrItem()).thenReturn(property);
when(nodeAdapter.isNode()).thenReturn(false);
when(table.getItem(itemId)).thenReturn(nodeAdapter);
// WHEN
javax.jcr.Item value = abstractColumnFormatter.getJcrItem(table, itemId);
// THEN
assertThat(decorator.wrapProperty(property).getString(), is(((Property) value).getString()));
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility
@Before
public void setUp() throws Exception {
when(context.getLocale()).thenReturn(Locale.ENGLISH);
when(context.getUser()).thenReturn(user);
Item item = mock(Item.class);
Date date = new Date();
date.setTime(0);
Property<Date> property = new ObjectProperty<>(date);
when(item.getItemProperty(anyString())).thenReturn(property);
when(source.getItem(anyObject())).thenReturn(item);
UI ui = mock(UI.class);
Page page = mock(Page.class);
WebBrowser browser = mock(WebBrowser.class);
when(ui.getPage()).thenReturn(page);
when(page.getWebBrowser()).thenReturn(browser);
CurrentInstance.set(UI.class, ui);
}
代码示例来源:origin: com.haulmont.cuba/cuba-web
@Override
public Object generateCell(com.vaadin.v7.ui.Table source, Object itemId, Object columnId) {
Property property = source.getItem(itemId).getItemProperty(columnId);
Object value = property.getValue();
if (value == null) {
return null;
}
String stringValue = value.toString();
if (columnId instanceof MetaPropertyPath) {
MetaProperty metaProperty = ((MetaPropertyPath) columnId).getMetaProperty();
if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) {
stringValue = dynamicAttributesTools.getDynamicAttributeValueAsString(metaProperty, value);
}
}
String cellValue = stringValue;
boolean isMultiLineCell = StringUtils.contains(stringValue, "\n");
if (isMultiLineCell) {
cellValue = StringUtils.replaceChars(cellValue, '\n', ' ');
}
int maxTextLength = column.getMaxTextLength();
if (stringValue.length() > maxTextLength + MAX_TEXT_LENGTH_GAP || isMultiLineCell) {
return StringUtils.abbreviate(cellValue, maxTextLength);
} else {
return cellValue;
}
}
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility
@Test
public void testGetJcrItemIsEscaped() throws Exception {
// GIVEN
ContentDecorator decorator = new HTMLEscapingContentDecorator(false);
JcrNodeAdapter nodeAdapter = mock(JcrNodeAdapter.class);
when(nodeAdapter.getJcrItem()).thenReturn(node);
when(nodeAdapter.isNode()).thenReturn(true);
when(table.getItem(itemId)).thenReturn(nodeAdapter);
// WHEN
javax.jcr.Item value = abstractColumnFormatter.getJcrItem(table, itemId);
// THEN
assertThat(decorator.wrapNode(node).getName(), is(value.getName()));
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility
@Before
public void setUp() throws Exception {
this.columnFormatter = new NodeTypeColumnFormatter(new NodeTypeColumnDefinition());
this.table = mock(Table.class);
this.session = new MockSession("foo");
fooNode = session.getRootNode().addNode("foo", "fooType");
barNode = session.getRootNode().addNode("bar", "barType");
doReturn(new JcrNodeAdapter(fooNode)).when(table).getItem(JcrItemUtil.getItemId(fooNode));
doReturn(new JcrNodeAdapter(barNode)).when(table).getItem(JcrItemUtil.getItemId(barNode));
final MockContext context = new MockContext();
context.addSession("foo", session);
MgnlContext.setInstance(context);
}
代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework-compatibility
@Test
public void renderPropertyType() throws Exception {
// GIVEN
fooNode.setProperty("doubleBaz", 0d);
fooNode.setProperty("longBaz", 0l);
fooNode.setProperty("dateBaz", Calendar.getInstance());
final Property doubleBaz = fooNode.getProperty("doubleBaz");
final Property longBaz = fooNode.getProperty("longBaz");
final Property dateBaz = fooNode.getProperty("dateBaz");
final JcrItemId doubleBazId = JcrItemUtil.getItemId(doubleBaz);
final JcrItemId longBazId = JcrItemUtil.getItemId(longBaz);
final JcrItemId dateBazId = JcrItemUtil.getItemId(dateBaz);
doReturn(new JcrPropertyAdapter(doubleBaz)).when(table).getItem(doubleBazId);
doReturn(new JcrPropertyAdapter(longBaz)).when(table).getItem(longBazId);
doReturn(new JcrPropertyAdapter(dateBaz)).when(table).getItem(dateBazId);
// WHEN
final String doubleBazColumnContent = (String) columnFormatter.generateCell(table, doubleBazId, null);
final String longBazColumnContent = (String) columnFormatter.generateCell(table, longBazId, null);
final String dateBazColumnContent = (String) columnFormatter.generateCell(table, dateBazId, null);
// THEN
assertThat(doubleBazColumnContent, equalTo("Double"));
assertThat(longBazColumnContent, equalTo("Long"));
assertThat(dateBazColumnContent, equalTo("Date"));
}
内容来源于网络,如有侵权,请联系作者删除!