本文整理匯總了Java中com.haulmont.cuba.gui.data.Datasource.getItem方法的典型用法代碼示例。如果您正苦於以下問題:Java Datasource.getItem方法的具體用法?Java Datasource.getItem怎麽用?Java Datasource.getItem使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.haulmont.cuba.gui.data.Datasource的用法示例。
在下文中一共展示了Datasource.getItem方法的20個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: loadData
點讚 3
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Override
protected void loadData(Map params) {
data.clear();
Datasource mbeanDs = getDsContext().get("mbeanDs");
ManagedBeanInfo mbean = (ManagedBeanInfo) mbeanDs.getItem();
if (mbean != null) {
try {
jmxControlAPI.loadAttributes(mbean);
} catch (JmxControlException e) {
log.error("Error loading attributes", e);
}
if (mbean.getAttributes() != null) {
for (ManagedBeanAttribute attr : mbean.getAttributes()) {
data.put(attr.getId(), attr);
}
}
}
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:22,
示例2: testUnsubscribeDsListener
點讚 3
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testUnsubscribeDsListener() {
DateField dateField = (DateField) factory.createComponent(DateField.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
Date updateTs = new Date();
user.setUpdateTs(updateTs);
dateField.setDatasource(userDs, "updateTs");
// unbind
dateField.setDatasource(null, null);
Datasource.ItemPropertyChangeListener propertyChangeListener = e -> {
throw new RuntimeException("Value was changed externally");
};
userDs.addItemPropertyChangeListener(propertyChangeListener);
dateField.setValue(new Date());
assertEquals(updateTs, user.getUpdateTs());
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:22,
示例3: testUnsubscribeDsListener
點讚 3
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testUnsubscribeDsListener() {
CheckBox checkBox = (CheckBox) factory.createComponent(CheckBox.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setActive(true);
checkBox.setDatasource(userDs, "active");
// unbind
checkBox.setDatasource(null, null);
Datasource.ItemPropertyChangeListener propertyChangeListener = e -> {
throw new RuntimeException("Value was changed externally");
};
userDs.addItemPropertyChangeListener(propertyChangeListener);
checkBox.setValue(false);
assertEquals(true, user.getActive());
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:21,
示例4: testUnsubscribeComponentListener
點讚 3
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testUnsubscribeComponentListener() {
Label label = (Label) factory.createComponent(Label.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setName("testName");
label.setDatasource(userDs, "name");
// unbind
label.setDatasource(null, null);
assertNotNull(label.getValue());
Component.ValueChangeListener listener = e -> {
throw new RuntimeException("Value was changed externally");
};
label.addValueChangeListener(listener);
user.setName("anotherName");
assertEquals("testName", label.getValue());
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:22,
示例5: testUnsubscribeDsListener
點讚 3
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testUnsubscribeDsListener() {
Label label = (Label) factory.createComponent(Label.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setName("testName");
label.setDatasource(userDs, "name");
// unbind
label.setDatasource(null, null);
assertNotNull(label.getValue());
Datasource.ItemPropertyChangeListener propertyChangeListener = e -> {
throw new RuntimeException("Value was changed externally");
};
userDs.addItemPropertyChangeListener(propertyChangeListener);
label.setValue("anotherName");
assertEquals("testName", user.getName());
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:22,
示例6: testUnsubscribeComponentListener
點讚 3
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testUnsubscribeComponentListener() {
DatePicker datePicker = (DatePicker) factory.createComponent(DatePicker.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
Date updateTs = new Date();
user.setUpdateTs(updateTs);
datePicker.setDatasource(userDs, "updateTs");
// unbind
datePicker.setDatasource(null, null);
Component.ValueChangeListener valueChangeListener = e -> {
throw new RuntimeException("Value was changed externally");
};
datePicker.addValueChangeListener(valueChangeListener);
user.setUpdateTs(new Date());
assertEquals(updateTs, datePicker.getValue());
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:23,
示例7: testUnsubscribeDsListener
點讚 3
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testUnsubscribeDsListener() {
DatePicker datePicker = (DatePicker) factory.createComponent(DatePicker.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
Date updateTs = new Date();
user.setUpdateTs(updateTs);
datePicker.setDatasource(userDs, "updateTs");
// unbind
datePicker.setDatasource(null, null);
Datasource.ItemPropertyChangeListener propertyChangeListener = e -> {
throw new RuntimeException("Value was changed externally");
};
userDs.addItemPropertyChangeListener(propertyChangeListener);
datePicker.setValue(new Date());
assertEquals(updateTs, user.getUpdateTs());
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:22,
示例8: testUnsubscribeComponentListener
點讚 3
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testUnsubscribeComponentListener() {
TextField textField = (TextField) factory.createComponent(TextField.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setName("testName");
textField.setDatasource(userDs, "name");
// unbind
textField.setDatasource(null, null);
Component.ValueChangeListener listener = e -> {
throw new RuntimeException("Value was changed externally");
};
textField.addValueChangeListener(listener);
user.setName("anotherName");
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:19,
示例9: testUnsubscribeSubscribeComponentListener
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testUnsubscribeSubscribeComponentListener() {
CheckBox checkBox = (CheckBox) factory.createComponent(CheckBox.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setActive(true);
checkBox.setDatasource(userDs, "active");
// unbind
checkBox.setDatasource(null, null);
// datasource before listener
checkBox.setDatasource(userDs, "active");
assertEquals(true, checkBox.getValue());
boolean[] valueWasChanged = {false};
Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
checkBox.addValueChangeListener(listener);
user.setActive(false);
assertEquals(true, valueWasChanged[0]);
assertEquals(false, checkBox.getValue());
// reset state
checkBox.removeValueChangeListener(listener);
checkBox.setDatasource(null, null);
valueWasChanged[0] = false;
checkBox.setValue(true);
// listener before datasource
checkBox.addValueChangeListener(listener);
checkBox.setDatasource(userDs, "active");
assertEquals(true, valueWasChanged[0]);
assertEquals(false, checkBox.getValue());
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:38,
示例10: testSetValueWithoutOptions
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testSetValueWithoutOptions() {
LookupPickerField component = (LookupPickerField) factory.createComponent(LookupPickerField.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
Group group = metadata.create(Group.class);
group.setName("group #0");
user.setGroup(group);
component.setDatasource(userDs, "group");
assertNotNull(component.getValue());
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:16,
示例11: getMasterEntity
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Nullable
protected Entity getMasterEntity(CollectionDatasource datasource) {
if (datasource instanceof NestedDatasource) {
Datasource masterDs = ((NestedDatasource) datasource).getMaster();
com.google.common.base.Preconditions.checkState(masterDs != null);
return masterDs.getItem();
}
return null;
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:10,
示例12: handleFilteredAttributes
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
/**
* Set field's "required" flag to false if the value has been filtered by Row Level Security
* This is necessary to allow user to submit form with filtered attribute even if attribute is required
*/
public static void handleFilteredAttributes(Field component, Datasource datasource, MetaPropertyPath mpp) {
if (component.isRequired()
&& datasource.getState() == Datasource.State.VALID
&& datasource.getItem() != null
&& mpp.getMetaProperty().getRange().isClass()) {
Entity targetItem = datasource.getItem();
MetaProperty[] propertiesChain = mpp.getMetaProperties();
if (propertiesChain.length > 1) {
String basePropertyItem = Arrays.stream(propertiesChain)
.limit(propertiesChain.length - 1)
.map(MetadataObject::getName)
.collect(Collectors.joining("."));
targetItem = datasource.getItem().getValueEx(basePropertyItem);
}
if (targetItem instanceof BaseGenericIdEntity) {
String metaPropertyName = mpp.getMetaProperty().getName();
Object value = targetItem.getValue(metaPropertyName);
BaseGenericIdEntity baseGenericIdEntity = (BaseGenericIdEntity) targetItem;
String[] filteredAttributes = getFilteredAttributes(baseGenericIdEntity);
if (value == null && filteredAttributes != null
&& ArrayUtils.contains(filteredAttributes, metaPropertyName)) {
component.setRequired(false);
}
}
}
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:37,
示例13: visitComponent
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
protected void visitComponent(DatasourceComponent component, boolean reset) {
Datasource datasource = component.getDatasource();
MetaPropertyPath propertyPath = component.getMetaPropertyPath();
if (datasource == null || datasource.getState() != Datasource.State.VALID || propertyPath == null || datasource.getItem() == null) {
return;
}
if (reset) {
component.setVisible(security.isEntityAttrReadPermitted(datasource.getMetaClass(), propertyPath.toString()));
component.setEditable(security.isEntityAttrUpdatePermitted(datasource.getMetaClass(), propertyPath.toString()));
if (component instanceof Field) {
((Field) component).setRequired(propertyPath.getMetaProperty().isMandatory());
}
}
ComponentState componentState = calculateComponentState(datasource.getItem(), propertyPath);
if (componentState.hidden) {
component.setVisible(false);
}
if (componentState.readOnly) {
component.setEditable(false);
}
if (component instanceof Field) {
if (componentState.required && component.isEditable() && component.isVisible()) {
((Field) component).setRequired(true);
}
}
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:29,
示例14: releaseLock
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
/**
* Release pessimistic lock if it was applied.
*/
protected void releaseLock() {
if (justLocked) {
Datasource ds = getFieldGroup().getDatasource();
Entity entity = ds.getItem();
if (entity != null) {
MetaClass metaClass = getMetaClassForLocking(entity);
AppBeans.get(LockService.class).unlock(metaClass.getName(), entity.getId().toString());
}
}
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:14,
示例15: testSetValueWithoutOptions
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testSetValueWithoutOptions() {
LookupField lookupField = (LookupField) factory.createComponent(LookupField.NAME);
// noinspection unchecked
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setName("Test name");
lookupField.setDatasource(userDs, "name");
assertEquals("Test name", lookupField.getValue());
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:14,
示例16: testValueChangeListener
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testValueChangeListener() {
CheckBox checkBox = (CheckBox) factory.createComponent(CheckBox.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
user.setActive(true);
// listener before datasource
Boolean[] valueWasChanged = {false};
Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
checkBox.addValueChangeListener(listener);
checkBox.setDatasource(userDs, "active");
assertEquals(true, valueWasChanged[0]);
// reset state
checkBox.setDatasource(null, null);
checkBox.removeValueChangeListener(listener);
valueWasChanged[0] = false;
// datasource before listener
checkBox.setDatasource(userDs, "active");
checkBox.addValueChangeListener(listener);
user.setActive(false);
assertEquals(true, valueWasChanged[0]);
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:29,
示例17: setDatasource
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Override
public void setDatasource(Datasource datasource, String property) {
checkDatasourceProperty(datasource, property);
this.datasource = datasource;
// null datasource is not supported for this class
/*if (datasource == null) {
setValue(null);
return;
}*/
resolveMetaPropertyPath(datasource.getMetaClass(), property);
itemChangeListener = e -> {
if (updatingInstance) {
return;
}
Object value = InstanceUtils.getValueEx(e.getItem(), metaPropertyPath.getPath());
updateComponent(value);
fireChangeListeners(value);
};
//noinspection unchecked
datasource.addItemChangeListener(new WeakItemChangeListener(datasource, itemChangeListener));
itemPropertyChangeListener = e -> {
if (updatingInstance) {
return;
}
if (e.getProperty().equals(metaProperty.getName())) {
updateComponent(e.getValue());
fireChangeListeners(e.getValue());
}
};
//noinspection unchecked
datasource.addItemPropertyChangeListener(new WeakItemPropertyChangeListener(datasource, itemPropertyChangeListener));
if ((datasource.getState() == Datasource.State.VALID) && (datasource.getItem() != null)) {
Object newValue = InstanceUtils.getValueEx(datasource.getItem(), metaPropertyPath.getPath());
updateComponent(newValue);
fireChangeListeners(newValue);
}
initRequired(metaPropertyPath);
if (metaProperty.isReadOnly()) {
setEditable(false);
}
handleFilteredAttributes(this, this.datasource, metaPropertyPath);
securityItemChangeListener = e -> handleFilteredAttributes(this, this.datasource, metaPropertyPath);
// noinspection unchecked
this.datasource.addItemChangeListener(new WeakItemChangeListener(this.datasource, securityItemChangeListener));
initBeanValidator();
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:58,
示例18: setDatasource
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Override
public void setDatasource(Datasource datasource, String property) {
this.datasource = datasource;
if (datasource == null) {
setValue(null);
return;
}
resolveMetaPropertyPath(datasource.getMetaClass(), property);
valueFormatter.setMetaProperty(metaProperty);
itemChangeListener = e -> {
if (updatingInstance) {
return;
}
Object value = InstanceUtils.getValueEx(e.getItem(), metaPropertyPath.getPath());
updateComponent(value);
fireChangeListeners(value);
};
//noinspection unchecked
datasource.addItemChangeListener(new WeakItemChangeListener(datasource, itemChangeListener));
itemPropertyChangeListener = e -> {
if (updatingInstance) {
return;
}
if (e.getProperty().equals(metaPropertyPath.toString())) {
updateComponent(e.getValue());
fireChangeListeners(e.getValue());
}
};
//noinspection unchecked
datasource.addItemPropertyChangeListener(new WeakItemPropertyChangeListener(datasource, itemPropertyChangeListener));
if ((datasource.getState() == Datasource.State.VALID) && (datasource.getItem() != null)) {
Object newValue = InstanceUtils.getValueEx(datasource.getItem(), metaPropertyPath.getPath());
updateComponent(newValue);
fireChangeListeners(newValue);
}
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:45,
示例19: setDatasource
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Override
public void setDatasource(Datasource datasource, String property) {
this.datasource = datasource;
if (datasource == null) {
setValue(null);
return;
}
MetaClass metaClass = datasource.getMetaClass();
resolveMetaPropertyPath(metaClass, property);
itemChangeListener = e -> {
if (updatingInstance)
return;
Object value = InstanceUtils.getValueEx(e.getItem(), metaPropertyPath.getPath());
updateComponent(value);
fireChangeListeners(value);
};
// noinspection unchecked
datasource.addItemChangeListener(new WeakItemChangeListener(datasource, itemChangeListener));
itemPropertyChangeListener = e -> {
if (updatingInstance)
return;
if (e.getProperty().equals(metaPropertyPath.toString())) {
updateComponent(e.getValue());
fireChangeListeners(e.getValue());
}
};
// noinspection unchecked
datasource.addItemPropertyChangeListener(new WeakItemPropertyChangeListener(datasource, itemPropertyChangeListener));
initRequired(metaPropertyPath);
if (metaProperty.getRange().isEnum()) {
Enumeration enumeration = metaProperty.getRange().asEnumeration();
@SuppressWarnings("unchecked")
Class javaClass = enumeration.getJavaClass();
setOptionsList(Arrays.asList(javaClass.getEnumConstants()));
setCaptionMode(CaptionMode.ITEM);
}
if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) {
CategoryAttribute categoryAttribute = DynamicAttributesUtils.getCategoryAttribute(metaProperty);
if (categoryAttribute != null && categoryAttribute.getDataType() == PropertyType.ENUMERATION) {
setOptionsMap(categoryAttribute.getLocalizedEnumerationMap());
}
}
if ((datasource.getState() == Datasource.State.VALID) && (datasource.getItem() != null)) {
Object newValue = InstanceUtils.getValueEx(datasource.getItem(), metaPropertyPath.getPath());
updateComponent(newValue);
fireChangeListeners(newValue);
}
if (metaProperty.isReadOnly()) {
setEditable(false);
}
handleFilteredAttributes(this, this.datasource, metaPropertyPath);
securityItemChangeListener = e -> handleFilteredAttributes(this, this.datasource, metaPropertyPath);
// noinspection unchecked
this.datasource.addItemChangeListener(new WeakItemChangeListener(this.datasource, securityItemChangeListener));
initBeanValidator();
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:69,
示例20: testUnsubscribeSubscribeComponentListener
點讚 2
import com.haulmont.cuba.gui.data.Datasource; //導入方法依賴的package包/類
@Test
public void testUnsubscribeSubscribeComponentListener() {
DateField dateField = (DateField) factory.createComponent(DateField.NAME);
Datasource userDs = getTestUserDatasource();
User user = userDs.getItem();
Date updateTs = new Date();
user.setUpdateTs(updateTs);
dateField.setDatasource(userDs, "updateTs");
// unbind
dateField.setDatasource(null, null);
// datasource before listener
dateField.setDatasource(userDs, "updateTs");
dateField.setResolution(DateField.Resolution.SEC);
assertEquals(updateTs, dateField.getValue());
boolean[] valueWasChanged = {false};
Component.ValueChangeListener listener = e -> valueWasChanged[0] = true;
dateField.addValueChangeListener(listener);
Date updateTs2 = new Date();
user.setUpdateTs(updateTs2);
assertEquals(true, valueWasChanged[0]);
assertEquals(updateTs2, dateField.getValue());
// reset state
dateField.removeValueChangeListener(listener);
dateField.setDatasource(null, null);
valueWasChanged[0] = false;
dateField.setValue(updateTs);
// listener before datasource
dateField.addValueChangeListener(listener);
dateField.setDatasource(userDs, "updateTs");
dateField.setResolution(DateField.Resolution.SEC);
assertEquals(true, valueWasChanged[0]);
assertEquals(updateTs2, dateField.getValue());
}
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:42,
注:本文中的com.haulmont.cuba.gui.data.Datasource.getItem方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。