mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-05 04:38:10 +08:00
Check security for components according to real property MetaClass #PL-4076
This commit is contained in:
parent
a0d33d303d
commit
6dcf083313
@ -28,6 +28,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author krivopustov
|
||||
* @version $Id$
|
||||
@ -128,11 +130,9 @@ public abstract class DesktopAbstractOptionsField<C extends JComponent>
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
try {
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new RuntimeException("Metaproperty name is possibly wrong: " + property, e);
|
||||
}
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
datasource.addListener(
|
||||
new DsListenerAdapter() {
|
||||
@ -200,6 +200,11 @@ public abstract class DesktopAbstractOptionsField<C extends JComponent>
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue() {
|
||||
Object selectedItem = getSelectedItem();
|
||||
@ -326,7 +331,7 @@ public abstract class DesktopAbstractOptionsField<C extends JComponent>
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof DesktopAbstractOptionsField.MapKeyWrapper) {
|
||||
MapKeyWrapper other = (MapKeyWrapper) obj;
|
||||
DesktopAbstractOptionsField.MapKeyWrapper other = (DesktopAbstractOptionsField.MapKeyWrapper) obj;
|
||||
return StringUtils.equals(this.key, other.key);
|
||||
}
|
||||
return false;
|
||||
@ -363,7 +368,7 @@ public abstract class DesktopAbstractOptionsField<C extends JComponent>
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof DesktopAbstractOptionsField.ObjectWrapper) {
|
||||
ObjectWrapper anotherWrapper = (ObjectWrapper) obj;
|
||||
DesktopAbstractOptionsField.ObjectWrapper anotherWrapper = (DesktopAbstractOptionsField.ObjectWrapper) obj;
|
||||
return ObjectUtils.equals(this.obj, anotherWrapper.obj);
|
||||
}
|
||||
return false;
|
||||
|
@ -32,8 +32,6 @@ import com.haulmont.cuba.gui.data.impl.CollectionDsActionsNotifier;
|
||||
import com.haulmont.cuba.gui.data.impl.CollectionDsListenerAdapter;
|
||||
import com.haulmont.cuba.gui.data.impl.DatasourceImplementation;
|
||||
import com.haulmont.cuba.gui.presentations.Presentations;
|
||||
import com.haulmont.cuba.security.entity.EntityAttrAccess;
|
||||
import com.haulmont.cuba.security.global.UserSession;
|
||||
import net.miginfocom.layout.CC;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -501,7 +499,6 @@ public abstract class DesktopAbstractTable<C extends JXTable>
|
||||
|
||||
@Override
|
||||
public void setDatasource(final CollectionDatasource datasource) {
|
||||
UserSession userSession = AppBeans.get(UserSessionSource.class).getUserSession();
|
||||
MetadataTools metadataTools = AppBeans.get(MetadataTools.class);
|
||||
|
||||
final Collection<Object> properties;
|
||||
@ -587,7 +584,7 @@ public abstract class DesktopAbstractTable<C extends JXTable>
|
||||
if (editableColumns != null && column.isEditable() && (property instanceof MetaPropertyPath)) {
|
||||
MetaPropertyPath propertyPath = (MetaPropertyPath) property;
|
||||
|
||||
if (security.isEntityPropertyPathPermitted(metaClass, propertyPath.toString(), EntityAttrAccess.MODIFY)) {
|
||||
if (security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString())) {
|
||||
editableColumns.add(propertyPath);
|
||||
}
|
||||
}
|
||||
@ -603,7 +600,7 @@ public abstract class DesktopAbstractTable<C extends JXTable>
|
||||
if (column.getId() instanceof MetaPropertyPath) {
|
||||
MetaPropertyPath propertyPath = (MetaPropertyPath) column.getId();
|
||||
|
||||
if (security.isEntityPropertyPathPermitted(metaClass, propertyPath.toString(), EntityAttrAccess.VIEW)) {
|
||||
if (security.isEntityAttrReadPermitted(metaClass, propertyPath.toString())) {
|
||||
columnsOrder.add(column.getId());
|
||||
}
|
||||
} else {
|
||||
@ -788,7 +785,6 @@ public abstract class DesktopAbstractTable<C extends JXTable>
|
||||
return newSelection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void applySelection(Set<Entity> selection) {
|
||||
int minimalSelectionRowIndex = Integer.MAX_VALUE;
|
||||
if (!selection.isEmpty()) {
|
||||
@ -954,11 +950,11 @@ public abstract class DesktopAbstractTable<C extends JXTable>
|
||||
protected void applyPermissions(com.haulmont.cuba.gui.components.Component columnComponent) {
|
||||
if (columnComponent instanceof DatasourceComponent) {
|
||||
DatasourceComponent dsComponent = (DatasourceComponent) columnComponent;
|
||||
MetaProperty metaProperty = dsComponent.getMetaProperty();
|
||||
MetaPropertyPath propertyPath = dsComponent.getMetaPropertyPath();
|
||||
|
||||
if (metaProperty != null) {
|
||||
if (propertyPath != null) {
|
||||
MetaClass metaClass = dsComponent.getDatasource().getMetaClass();
|
||||
dsComponent.setEditable(security.isEntityAttrModificationPermitted(metaClass, metaProperty.getName())
|
||||
dsComponent.setEditable(security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString())
|
||||
&& dsComponent.isEditable());
|
||||
}
|
||||
}
|
||||
@ -1448,7 +1444,7 @@ public abstract class DesktopAbstractTable<C extends JXTable>
|
||||
@Override
|
||||
@Nullable
|
||||
public Printable getPrintable(Column column) {
|
||||
checkArgument(column != null, "column is null");
|
||||
checkNotNullArgument(column, "column is null");
|
||||
|
||||
return getPrintable(String.valueOf(column.getId()));
|
||||
}
|
||||
@ -1965,14 +1961,17 @@ public abstract class DesktopAbstractTable<C extends JXTable>
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedParameters")
|
||||
protected CellProvider getCustomCellView(MetaPropertyPath mpp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedParameters")
|
||||
protected CellProvider getCustomCellEditor(MetaPropertyPath mpp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedParameters")
|
||||
protected boolean isCustomCellEditable(Entity e, MetaPropertyPath mpp) {
|
||||
return false;
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ import java.awt.event.KeyListener;
|
||||
import java.text.ParseException;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author artamonov
|
||||
* @version $Id$
|
||||
@ -144,14 +146,14 @@ public abstract class DesktopAbstractTextField<T extends JTextComponent> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue() {
|
||||
public <V> V getValue() {
|
||||
String text = getImpl().getText();
|
||||
Object rawValue = validateRawValue(text);
|
||||
if (rawValue instanceof String) {
|
||||
rawValue = StringUtils.trimToNull((String) rawValue);
|
||||
}
|
||||
|
||||
return (T) rawValue;
|
||||
return (V) rawValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -185,6 +187,11 @@ public abstract class DesktopAbstractTextField<T extends JTextComponent> extends
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
this.datasource = datasource;
|
||||
@ -196,9 +203,8 @@ public abstract class DesktopAbstractTextField<T extends JTextComponent> extends
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
if (metaPropertyPath == null)
|
||||
throw new DevelopmentException(String.format(
|
||||
"Property '%s' does not exist in entity '%s'", property, metaClass.getName()));
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
|
@ -21,6 +21,8 @@ import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author krivopustov
|
||||
* @version $Id$
|
||||
@ -89,6 +91,11 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
@ -101,9 +108,9 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
if (metaPropertyPath == null) {
|
||||
throw new RuntimeException("Metaproperty name is possibly wrong: " + property);
|
||||
}
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
datasource.addListener(
|
||||
|
@ -40,6 +40,8 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author krivopustov
|
||||
* @version $Id$
|
||||
@ -72,7 +74,7 @@ public class DesktopDateField extends DesktopAbstractField<JPanel> implements Da
|
||||
setResolution(Resolution.MIN);
|
||||
|
||||
Locale locale = AppBeans.get(UserSessionSource.class).getLocale();
|
||||
setDateFormat(Datatypes.getFormatStrings(locale).getDateTimeFormat());
|
||||
setDateFormat(Datatypes.getFormatStringsNN(locale).getDateTimeFormat());
|
||||
DesktopComponentsHelper.adjustDateFieldSize(impl);
|
||||
}
|
||||
|
||||
@ -175,6 +177,7 @@ public class DesktopDateField extends DesktopAbstractField<JPanel> implements Da
|
||||
@Override
|
||||
public void requestFocus() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
datePicker.requestFocus();
|
||||
}
|
||||
@ -225,6 +228,11 @@ public class DesktopDateField extends DesktopAbstractField<JPanel> implements Da
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
this.datasource = datasource;
|
||||
@ -236,6 +244,9 @@ public class DesktopDateField extends DesktopAbstractField<JPanel> implements Da
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
datasource.addListener(
|
||||
@ -421,6 +432,7 @@ public class DesktopDateField extends DesktopAbstractField<JPanel> implements Da
|
||||
c.set(Calendar.SECOND, c2.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
//noinspection UnnecessaryLocalVariable
|
||||
Date time = c.getTime();
|
||||
return time;
|
||||
}
|
||||
|
@ -706,7 +706,7 @@ public class DesktopFieldGroup extends DesktopAbstractComponent<JPanel> implemen
|
||||
|
||||
if (metaProperty != null) {
|
||||
MetaClass metaClass = dsComponent.getDatasource().getMetaClass();
|
||||
dsComponent.setEditable(security.isEntityAttrModificationPermitted(metaClass, metaProperty.getName())
|
||||
dsComponent.setEditable(security.isEntityAttrUpdatePermitted(metaClass, metaProperty.getName())
|
||||
&& dsComponent.isEditable());
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author krivopustov
|
||||
* @version $Id$
|
||||
@ -69,6 +71,11 @@ public class DesktopLabel extends DesktopAbstractComponent<JLabel> implements La
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
this.datasource = datasource;
|
||||
@ -80,6 +87,9 @@ public class DesktopLabel extends DesktopAbstractComponent<JLabel> implements La
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
valueFormatter.setMetaProperty(metaProperty);
|
||||
|
@ -29,6 +29,8 @@ import javax.swing.text.JTextComponent;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author krivopustov
|
||||
* @version $Id$
|
||||
@ -246,6 +248,11 @@ public class DesktopPickerField extends DesktopAbstractField<Picker> implements
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
this.datasource = datasource;
|
||||
@ -257,6 +264,9 @@ public class DesktopPickerField extends DesktopAbstractField<Picker> implements
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
datasource.addListener(
|
||||
@ -326,7 +336,8 @@ public class DesktopPickerField extends DesktopAbstractField<Picker> implements
|
||||
text = ((Instance) value).getInstanceName();
|
||||
} else {
|
||||
Object propertyValue = ((Instance)value).getValue(captionProperty);
|
||||
MetaProperty property = metadata.getClass(value.getClass()).getProperty(captionProperty);
|
||||
MetaClass valueClass = metadata.getClassNN(value.getClass());
|
||||
MetaProperty property = valueClass.getProperty(captionProperty);
|
||||
|
||||
text = metadataTools.format(propertyValue, property);
|
||||
}
|
||||
@ -376,7 +387,7 @@ public class DesktopPickerField extends DesktopAbstractField<Picker> implements
|
||||
}
|
||||
if (!editable && impl.getEditor() instanceof JTextComponent) {
|
||||
JTextComponent editor = (JTextComponent) impl.getEditor();
|
||||
editor.setEditable(editable);
|
||||
editor.setEditable(false);
|
||||
}
|
||||
updateMissingValueState();
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author krivopustov
|
||||
* @version $Id$
|
||||
@ -157,6 +159,11 @@ public class DesktopTimeField extends DesktopAbstractField<JFormattedTextField>
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
this.datasource = datasource;
|
||||
@ -168,6 +175,9 @@ public class DesktopTimeField extends DesktopAbstractField<JFormattedTextField>
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
datasource.addListener(
|
||||
@ -245,7 +255,7 @@ public class DesktopTimeField extends DesktopAbstractField<JFormattedTextField>
|
||||
@Override
|
||||
public <T> T getValue() {
|
||||
try {
|
||||
return (T) new SimpleDateFormat(timeFormat).parse((String) impl.getText());
|
||||
return (T) new SimpleDateFormat(timeFormat).parse(impl.getText());
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ package com.haulmont.cuba.desktop.gui.components;
|
||||
|
||||
import com.haulmont.chile.core.model.Instance;
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.Messages;
|
||||
@ -111,10 +112,16 @@ public class DesktopTokenList extends DesktopAbstractField<DesktopTokenList.Toke
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void setDatasource(CollectionDatasource datasource) {
|
||||
this.datasource = datasource;
|
||||
@ -758,7 +765,7 @@ public class DesktopTokenList extends DesktopAbstractField<DesktopTokenList.Toke
|
||||
tokensContainer.remove(ownComponent);
|
||||
|
||||
if (datasource != null) {
|
||||
List<Instance> usedItems = new ArrayList<Instance>();
|
||||
List<Instance> usedItems = new ArrayList<>();
|
||||
|
||||
// New tokens
|
||||
for (final Object itemId : datasource.getItemIds()) {
|
||||
|
@ -109,6 +109,20 @@ public final class Datatypes {
|
||||
return instance.getFormat(locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns localized format strings.
|
||||
* @param locale selected locale
|
||||
* @return {@link FormatStrings} object. Throws exception if not found.
|
||||
*/
|
||||
@Nonnull
|
||||
public static FormatStrings getFormatStringsNN(Locale locale) {
|
||||
FormatStrings format = instance.getFormat(locale);
|
||||
if (format == null) {
|
||||
throw new IllegalArgumentException("Not found format strings for locale " + locale.toLanguageTag());
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
/** For internal use only. Don't call from application code. */
|
||||
public static void setFormatStrings(Locale locale, FormatStrings formatStrings) {
|
||||
instance.putFormat(locale, formatStrings);
|
||||
|
@ -65,36 +65,36 @@ public interface Security {
|
||||
boolean isEntityAttrPermitted(Class<?> entityClass, String property, EntityAttrAccess access);
|
||||
|
||||
/**
|
||||
* Check if current user can modify an entity attribute. It means that he has the following permissions:
|
||||
* Check if current user can modify an entity attribute which is the last part of the path given.
|
||||
* It means that he has the following permissions:
|
||||
*
|
||||
* <ul>
|
||||
* <li> {@link EntityOp#CREATE} or {@link EntityOp#UPDATE} on the whole entity </li>
|
||||
* <li> {@link EntityAttrAccess#MODIFY} on the attribute </li>
|
||||
* <li> {@link EntityOp#CREATE} or {@link EntityOp#UPDATE} on the whole entity which the attribute belongs to</li>
|
||||
* <li> {@link EntityAttrAccess#MODIFY} on the attribute</li>
|
||||
* </ul>
|
||||
*
|
||||
* Takes into account original metaclass of entity.
|
||||
*
|
||||
* @param metaClass entity meta class
|
||||
* @param propertyName entity attribute's name
|
||||
*/
|
||||
boolean isEntityAttrModificationPermitted(MetaClass metaClass, String propertyName);
|
||||
|
||||
/**
|
||||
* Check if current user has permission to an entity attribute path.
|
||||
*
|
||||
* @param entityClass entity class
|
||||
* @param propertyPath entity attribute path
|
||||
* @param access required access
|
||||
*/
|
||||
boolean isEntityPropertyPathPermitted(Class<?> entityClass, String propertyPath, EntityAttrAccess access);
|
||||
boolean isEntityAttrUpdatePermitted(MetaClass metaClass, String propertyPath);
|
||||
|
||||
/**
|
||||
* Check if current user has permission to an entity attribute path.
|
||||
* Check if current user can read an entity attribute which is the last part of the path given.
|
||||
* It means that he has the following permissions:
|
||||
*
|
||||
* <ul>
|
||||
* <li> {@link EntityOp#READ} on the whole entity which the attribute belongs to</li>
|
||||
* <li> {@link EntityAttrAccess#VIEW} on the attribute</li>
|
||||
* </ul>
|
||||
*
|
||||
* Takes into account original metaclass of entity.
|
||||
*
|
||||
* @param metaClass entity meta class
|
||||
* @param propertyPath entity attribute path
|
||||
* @param access required access
|
||||
*/
|
||||
boolean isEntityPropertyPathPermitted(MetaClass metaClass, String propertyPath, EntityAttrAccess access);
|
||||
boolean isEntityAttrReadPermitted(MetaClass metaClass, String propertyPath);
|
||||
|
||||
/**
|
||||
* Check if current user has a specific permission.
|
||||
|
@ -73,44 +73,44 @@ public class SecurityImpl implements Security {
|
||||
return isEntityAttrPermitted(metaClass, property, access);
|
||||
}
|
||||
|
||||
protected boolean isEntityPropertyPathPermitted(MetaClass metaClass,
|
||||
MetaProperty[] propertyChain, int chainIndex,
|
||||
EntityAttrAccess access) {
|
||||
@Override
|
||||
public boolean isEntityAttrReadPermitted(MetaClass metaClass, String propertyPath) {
|
||||
MetaPropertyPath mpp = metaClass.getPropertyPath(propertyPath);
|
||||
return mpp != null && isEntityAttrReadPermitted(metaClass, mpp.get(), 0);
|
||||
}
|
||||
|
||||
protected boolean isEntityAttrReadPermitted(MetaClass metaClass,
|
||||
MetaProperty[] propertyChain, int chainIndex) {
|
||||
MetaProperty chainProperty = propertyChain[chainIndex];
|
||||
|
||||
if (chainIndex == propertyChain.length - 1) {
|
||||
if (access == EntityAttrAccess.VIEW) {
|
||||
return isEntityOpPermitted(metaClass, EntityOp.READ)
|
||||
&& isEntityAttrPermitted(metaClass, chainProperty.getName(), access);
|
||||
} else if (access == EntityAttrAccess.MODIFY) {
|
||||
return isEntityOpPermitted(metaClass, EntityOp.UPDATE)
|
||||
&& isEntityAttrPermitted(metaClass, chainProperty.getName(), access);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return isEntityOpPermitted(metaClass, EntityOp.READ)
|
||||
&& isEntityAttrPermitted(metaClass, chainProperty.getName(), EntityAttrAccess.VIEW);
|
||||
} else {
|
||||
MetaClass chainMetaClass = chainProperty.getRange().asClass();
|
||||
|
||||
return isEntityPropertyPathPermitted(chainMetaClass, propertyChain, chainIndex + 1, access);
|
||||
return isEntityAttrReadPermitted(chainMetaClass, propertyChain, chainIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEntityPropertyPathPermitted(MetaClass metaClass, String propertyPath, EntityAttrAccess access) {
|
||||
public boolean isEntityAttrUpdatePermitted(MetaClass metaClass, String propertyPath) {
|
||||
MetaPropertyPath mpp = metaClass.getPropertyPath(propertyPath);
|
||||
return mpp != null && isEntityPropertyPathPermitted(metaClass, mpp.get(), 0, access);
|
||||
return mpp != null && isEntityAttrUpdatePermitted(metaClass, mpp.get(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEntityPropertyPathPermitted(Class<?> entityClass, String propertyPath, EntityAttrAccess access) {
|
||||
MetaClass metaClass = metadata.getSession().getClassNN(entityClass);
|
||||
return isEntityPropertyPathPermitted(metaClass, propertyPath, access);
|
||||
}
|
||||
protected boolean isEntityAttrUpdatePermitted(MetaClass metaClass,
|
||||
MetaProperty[] propertyChain, int chainIndex) {
|
||||
MetaProperty chainProperty = propertyChain[chainIndex];
|
||||
|
||||
@Override
|
||||
public boolean isEntityAttrModificationPermitted(MetaClass metaClass, String propertyName) {
|
||||
return (isEntityOpPermitted(metaClass, EntityOp.CREATE) || isEntityOpPermitted(metaClass, EntityOp.UPDATE))
|
||||
&& isEntityAttrPermitted(metaClass, propertyName, EntityAttrAccess.MODIFY);
|
||||
if (chainIndex == propertyChain.length - 1) {
|
||||
return (isEntityOpPermitted(metaClass, EntityOp.CREATE) || isEntityOpPermitted(metaClass, EntityOp.UPDATE))
|
||||
&& isEntityAttrPermitted(metaClass, chainProperty.getName(), EntityAttrAccess.MODIFY);
|
||||
} else {
|
||||
MetaClass chainMetaClass = chainProperty.getRange().asClass();
|
||||
|
||||
return isEntityAttrUpdatePermitted(chainMetaClass, propertyChain, chainIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
package com.haulmont.cuba.gui.components;
|
||||
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.gui.data.Datasource;
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
|
||||
@ -21,10 +22,17 @@ public interface DatasourceComponent extends Component, Component.HasValue {
|
||||
Datasource getDatasource();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getMetaPropertyPath()}
|
||||
* @return datasource property
|
||||
*/
|
||||
@Deprecated
|
||||
MetaProperty getMetaProperty();
|
||||
|
||||
/**
|
||||
* @return datasource property path
|
||||
*/
|
||||
MetaPropertyPath getMetaPropertyPath();
|
||||
|
||||
/**
|
||||
* Set datasource and its property.
|
||||
*/
|
||||
|
@ -11,6 +11,7 @@ import com.haulmont.chile.core.datatypes.Datatypes;
|
||||
import com.haulmont.chile.core.datatypes.impl.*;
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.core.global.*;
|
||||
import com.haulmont.cuba.gui.GuiDevelopmentException;
|
||||
import com.haulmont.cuba.gui.components.*;
|
||||
@ -22,9 +23,6 @@ import com.haulmont.cuba.gui.theme.ThemeConstants;
|
||||
import com.haulmont.cuba.gui.theme.ThemeConstantsManager;
|
||||
import com.haulmont.cuba.gui.xml.DeclarativeAction;
|
||||
import com.haulmont.cuba.gui.xml.DeclarativeTrackingAction;
|
||||
import com.haulmont.cuba.security.entity.EntityAttrAccess;
|
||||
import com.haulmont.cuba.security.entity.EntityOp;
|
||||
import com.haulmont.cuba.security.global.UserSession;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dom4j.Element;
|
||||
@ -49,10 +47,14 @@ public abstract class ComponentLoader implements com.haulmont.cuba.gui.xml.layou
|
||||
protected Scripting scripting = AppBeans.get(Scripting.NAME);
|
||||
protected Resources resources = AppBeans.get(Resources.NAME);
|
||||
protected UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
|
||||
protected ThemeConstants themeConstants = AppBeans.get(ThemeConstantsManager.class).getConstants();
|
||||
|
||||
protected ThemeConstants themeConstants;
|
||||
|
||||
protected ComponentLoader(Context context) {
|
||||
this.context = context;
|
||||
|
||||
ThemeConstantsManager themeConstantsManager = AppBeans.get(ThemeConstantsManager.NAME);
|
||||
this.themeConstants = themeConstantsManager.getConstants();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -106,16 +108,15 @@ public abstract class ComponentLoader implements com.haulmont.cuba.gui.xml.layou
|
||||
if (component instanceof Component.Editable) {
|
||||
if (component instanceof DatasourceComponent
|
||||
&& ((DatasourceComponent) component).getDatasource() != null) {
|
||||
DatasourceComponent dsComponent = (DatasourceComponent) component;
|
||||
if (dsComponent.getMetaProperty() != null) {
|
||||
MetaClass metaClass = dsComponent.getDatasource().getMetaClass();
|
||||
// todo artamonov check security according to meta property path with real property class
|
||||
// #PL-4076
|
||||
|
||||
if (!security.isEntityAttrModificationPermitted(metaClass, dsComponent.getMetaProperty().getName())) {
|
||||
((Component.Editable) component).setEditable(false);
|
||||
return;
|
||||
}
|
||||
DatasourceComponent wiredComponent = (DatasourceComponent) component;
|
||||
MetaClass metaClass = wiredComponent.getDatasource().getMetaClass();
|
||||
MetaPropertyPath propertyPath = wiredComponent.getMetaPropertyPath();
|
||||
|
||||
if (propertyPath != null
|
||||
&& !security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString())) {
|
||||
((Component.Editable) component).setEditable(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,17 +148,13 @@ public abstract class ComponentLoader implements com.haulmont.cuba.gui.xml.layou
|
||||
protected boolean loadVisible(Component component, Element element) {
|
||||
if (component instanceof DatasourceComponent
|
||||
&& ((DatasourceComponent) component).getDatasource() != null) {
|
||||
MetaProperty metaProperty = ((DatasourceComponent) component).getMetaProperty();
|
||||
|
||||
// todo artamonov check security according to meta property path with real property class
|
||||
// #PL-4076
|
||||
MetaClass metaClass = metaProperty != null ?
|
||||
metaProperty.getDomain() : ((DatasourceComponent) component).getDatasource().getMetaClass();
|
||||
DatasourceComponent wiredComponent = (DatasourceComponent) component;
|
||||
MetaClass metaClass = wiredComponent.getDatasource().getMetaClass();
|
||||
MetaPropertyPath propertyPath = wiredComponent.getMetaPropertyPath();
|
||||
|
||||
UserSession userSession = userSessionSource.getUserSession();
|
||||
if (!userSession.isEntityOpPermitted(metaClass, EntityOp.READ)
|
||||
|| ((metaProperty != null) &&
|
||||
!userSession.isEntityAttrPermitted(metaClass, metaProperty.getName(), EntityAttrAccess.VIEW))) {
|
||||
if (propertyPath != null
|
||||
&& !security.isEntityAttrReadPermitted(metaClass, propertyPath.toString())) {
|
||||
component.setVisible(false);
|
||||
return false;
|
||||
}
|
||||
@ -403,7 +400,6 @@ public abstract class ComponentLoader implements com.haulmont.cuba.gui.xml.layou
|
||||
"Component ID", component.attributeValue("id"));
|
||||
}
|
||||
|
||||
|
||||
String trackSelection = element.attributeValue("trackSelection");
|
||||
String shortcut = StringUtils.trimToNull(element.attributeValue("shortcut"));
|
||||
if (Boolean.valueOf(trackSelection)) {
|
||||
|
@ -16,9 +16,7 @@ import com.haulmont.cuba.gui.components.IFrame;
|
||||
import com.haulmont.cuba.gui.data.Datasource;
|
||||
import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
|
||||
import com.haulmont.cuba.gui.xml.layout.LayoutLoaderConfig;
|
||||
import com.haulmont.cuba.security.entity.EntityAttrAccess;
|
||||
import com.haulmont.cuba.security.entity.EntityOp;
|
||||
import com.haulmont.cuba.security.global.UserSession;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@ -28,6 +26,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author gorodnov
|
||||
* @version $Id$
|
||||
@ -289,6 +289,7 @@ public class FieldGroupLoader extends AbstractFieldLoader {
|
||||
} else if (!"timeField".equals(descriptor.attributeValue("field"))) {
|
||||
validator = getDefaultValidator(metaProperty); //In this case we no need to use validator
|
||||
}
|
||||
|
||||
if (validator != null) {
|
||||
component.addValidator(field, validator);
|
||||
}
|
||||
@ -300,9 +301,13 @@ public class FieldGroupLoader extends AbstractFieldLoader {
|
||||
protected void loadRequired(FieldGroup component, FieldGroup.FieldConfig field) {
|
||||
if (!field.isCustom()) {
|
||||
boolean isMandatory = false;
|
||||
MetaClass metaClass = metaClass(component, field);
|
||||
MetaClass metaClass = getMetaClass(component, field);
|
||||
if (metaClass != null) {
|
||||
MetaProperty metaProperty = metaClass.getPropertyPath(field.getId()).getMetaProperty();
|
||||
MetaPropertyPath propertyPath = metaClass.getPropertyPath(field.getId());
|
||||
|
||||
checkNotNullArgument(propertyPath, "Could not resolve property path '%s' in '%s'", field.getId(), metaClass);
|
||||
|
||||
MetaProperty metaProperty = propertyPath.getMetaProperty();
|
||||
isMandatory = metaProperty.isMandatory();
|
||||
}
|
||||
|
||||
@ -315,7 +320,11 @@ public class FieldGroupLoader extends AbstractFieldLoader {
|
||||
|
||||
String requiredMsg = element.attributeValue("requiredMessage");
|
||||
if (StringUtils.isEmpty(requiredMsg) && metaClass != null) {
|
||||
MetaProperty metaProperty = metaClass.getPropertyPath(field.getId()).getMetaProperty();
|
||||
MetaPropertyPath propertyPath = metaClass.getPropertyPath(field.getId());
|
||||
|
||||
checkNotNullArgument(propertyPath, "Could not resolve property path '%s' in '%s'", field.getId(), metaClass);
|
||||
|
||||
MetaProperty metaProperty = propertyPath.getMetaProperty();
|
||||
requiredMsg = messageTools.getDefaultRequiredMessage(metaProperty);
|
||||
}
|
||||
|
||||
@ -340,9 +349,8 @@ public class FieldGroupLoader extends AbstractFieldLoader {
|
||||
FieldGroup fieldGroup = (FieldGroup) component;
|
||||
if (fieldGroup.getDatasource() != null) {
|
||||
MetaClass metaClass = fieldGroup.getDatasource().getMetaClass();
|
||||
UserSession userSession = userSessionSource.getUserSession();
|
||||
boolean editable = (userSession.isEntityOpPermitted(metaClass, EntityOp.CREATE)
|
||||
|| userSession.isEntityOpPermitted(metaClass, EntityOp.UPDATE));
|
||||
boolean editable = (security.isEntityOpPermitted(metaClass, EntityOp.CREATE)
|
||||
|| security.isEntityOpPermitted(metaClass, EntityOp.UPDATE));
|
||||
if (!editable) {
|
||||
((Component.Editable) component).setEditable(false);
|
||||
return;
|
||||
@ -363,18 +371,16 @@ public class FieldGroupLoader extends AbstractFieldLoader {
|
||||
}
|
||||
} else {
|
||||
if (component.isEditable()) {
|
||||
MetaClass metaClass = metaClass(component, field);
|
||||
MetaProperty metaProperty = metaClass.getPropertyPath(field.getId()).getMetaProperty();
|
||||
MetaClass metaClass = getMetaClass(component, field);
|
||||
MetaPropertyPath propertyPath = metaClass.getPropertyPath(field.getId());
|
||||
|
||||
UserSession userSession = userSessionSource.getUserSession();
|
||||
boolean editableFromPermissions = (userSession.isEntityOpPermitted(metaClass, EntityOp.CREATE)
|
||||
|| userSession.isEntityOpPermitted(metaClass, EntityOp.UPDATE))
|
||||
&& userSession.isEntityAttrPermitted(metaClass, metaProperty.getName(), EntityAttrAccess.MODIFY);
|
||||
checkNotNullArgument(propertyPath, "Could not resolve property path '%s' in '%s'", field.getId(), metaClass);
|
||||
|
||||
boolean editableFromPermissions = security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString());
|
||||
|
||||
if (!editableFromPermissions) {
|
||||
component.setEditable(field, false);
|
||||
boolean visible = userSession.isEntityAttrPermitted(metaClass,
|
||||
metaProperty.getName(), EntityAttrAccess.VIEW);
|
||||
boolean visible = security.isEntityAttrReadPermitted(metaClass, propertyPath.toString());
|
||||
|
||||
component.setVisible(field, visible);
|
||||
} else {
|
||||
@ -388,7 +394,7 @@ public class FieldGroupLoader extends AbstractFieldLoader {
|
||||
}
|
||||
}
|
||||
|
||||
protected MetaClass metaClass(FieldGroup component, FieldGroup.FieldConfig field) {
|
||||
protected MetaClass getMetaClass(FieldGroup component, FieldGroup.FieldConfig field) {
|
||||
if (field.isCustom()) return null;
|
||||
Datasource datasource;
|
||||
if (field.getDatasource() != null) {
|
||||
|
@ -9,7 +9,6 @@ import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.DevelopmentException;
|
||||
import com.haulmont.cuba.core.global.MessageTools;
|
||||
import com.haulmont.cuba.gui.components.Field;
|
||||
import com.haulmont.cuba.gui.components.RequiredValueMissingException;
|
||||
@ -29,6 +28,8 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
* @author abramov
|
||||
@ -62,15 +63,19 @@ public abstract class WebAbstractField<T extends com.vaadin.ui.Field>
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
this.datasource = datasource;
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
if (metaPropertyPath == null)
|
||||
throw new DevelopmentException(String.format(
|
||||
"Property '%s' does not exist in entity '%s'", property, metaClass.getName()));
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
@ -118,8 +123,8 @@ public abstract class WebAbstractField<T extends com.vaadin.ui.Field>
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue() {
|
||||
return (T) component.getValue();
|
||||
public <V> V getValue() {
|
||||
return (V) component.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,9 +25,7 @@ import com.haulmont.cuba.gui.data.impl.CollectionDsListenerAdapter;
|
||||
import com.haulmont.cuba.gui.data.impl.DatasourceImplementation;
|
||||
import com.haulmont.cuba.gui.presentations.Presentations;
|
||||
import com.haulmont.cuba.gui.presentations.PresentationsImpl;
|
||||
import com.haulmont.cuba.security.entity.EntityAttrAccess;
|
||||
import com.haulmont.cuba.security.entity.Presentation;
|
||||
import com.haulmont.cuba.security.global.UserSession;
|
||||
import com.haulmont.cuba.web.AppUI;
|
||||
import com.haulmont.cuba.web.gui.CompositionLayout;
|
||||
import com.haulmont.cuba.web.gui.components.presentations.TablePresentations;
|
||||
@ -260,7 +258,7 @@ public abstract class WebAbstractTable<T extends com.vaadin.ui.Table & CubaEnhan
|
||||
|
||||
final List<MetaPropertyPath> editableColumns = new ArrayList<>(propertyIds.size());
|
||||
for (final MetaPropertyPath propertyId : propertyIds) {
|
||||
if (!security.isEntityPropertyPathPermitted(metaClass, propertyId.toString(), EntityAttrAccess.MODIFY)) {
|
||||
if (!security.isEntityAttrUpdatePermitted(metaClass, propertyId.toString())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -642,7 +640,6 @@ public abstract class WebAbstractTable<T extends com.vaadin.ui.Table & CubaEnhan
|
||||
|
||||
@Override
|
||||
public void setDatasource(CollectionDatasource datasource) {
|
||||
UserSession userSession = AppBeans.get(UserSessionSource.class).getUserSession();
|
||||
MessageTools messageTools = AppBeans.get(MessageTools.class);
|
||||
MetadataTools metadataTools = AppBeans.get(MetadataTools.class);
|
||||
|
||||
@ -692,10 +689,6 @@ public abstract class WebAbstractTable<T extends com.vaadin.ui.Table & CubaEnhan
|
||||
|
||||
component.setContainerDataSource(containerDatasource);
|
||||
|
||||
if (columns == null) {
|
||||
throw new NullPointerException("Columns cannot be null");
|
||||
}
|
||||
|
||||
List<MetaPropertyPath> editableColumns = null;
|
||||
if (isEditable()) {
|
||||
editableColumns = new LinkedList<>();
|
||||
@ -718,7 +711,7 @@ public abstract class WebAbstractTable<T extends com.vaadin.ui.Table & CubaEnhan
|
||||
if (editableColumns != null && column.isEditable() && (columnId instanceof MetaPropertyPath)) {
|
||||
MetaPropertyPath propertyPath = ((MetaPropertyPath) columnId);
|
||||
|
||||
if (security.isEntityPropertyPathPermitted(metaClass, propertyPath.toString(), EntityAttrAccess.MODIFY)) {
|
||||
if (security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString())) {
|
||||
editableColumns.add(propertyPath);
|
||||
}
|
||||
}
|
||||
@ -872,7 +865,7 @@ public abstract class WebAbstractTable<T extends com.vaadin.ui.Table & CubaEnhan
|
||||
if (column.getId() instanceof MetaPropertyPath) {
|
||||
String propertyPath = column.getId().toString();
|
||||
|
||||
if (security.isEntityPropertyPathPermitted(metaClass, propertyPath, EntityAttrAccess.VIEW)) {
|
||||
if (security.isEntityAttrReadPermitted(metaClass, propertyPath)) {
|
||||
result.add((MetaPropertyPath)column.getId());
|
||||
}
|
||||
}
|
||||
@ -1424,10 +1417,6 @@ public abstract class WebAbstractTable<T extends com.vaadin.ui.Table & CubaEnhan
|
||||
// Used for properly removing column from table
|
||||
protected Column associatedRuntimeColumn;
|
||||
|
||||
protected CustomColumnGenerator(ColumnGenerator columnGenerator) {
|
||||
this.columnGenerator = columnGenerator;
|
||||
}
|
||||
|
||||
protected CustomColumnGenerator(ColumnGenerator columnGenerator, @Nullable Column associatedRuntimeColumn) {
|
||||
this.columnGenerator = columnGenerator;
|
||||
this.associatedRuntimeColumn = associatedRuntimeColumn;
|
||||
@ -1718,11 +1707,11 @@ public abstract class WebAbstractTable<T extends com.vaadin.ui.Table & CubaEnhan
|
||||
protected void applyPermissions(com.haulmont.cuba.gui.components.Component columnComponent) {
|
||||
if (columnComponent instanceof DatasourceComponent) {
|
||||
DatasourceComponent dsComponent = (DatasourceComponent) columnComponent;
|
||||
MetaProperty metaProperty = dsComponent.getMetaProperty();
|
||||
MetaPropertyPath propertyPath = dsComponent.getMetaPropertyPath();
|
||||
|
||||
if (metaProperty != null) {
|
||||
if (propertyPath != null) {
|
||||
MetaClass metaClass = dsComponent.getDatasource().getMetaClass();
|
||||
dsComponent.setEditable(security.isEntityAttrModificationPermitted(metaClass, metaProperty.getName())
|
||||
dsComponent.setEditable(security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString())
|
||||
&& dsComponent.isEditable());
|
||||
}
|
||||
}
|
||||
@ -1767,6 +1756,7 @@ public abstract class WebAbstractTable<T extends com.vaadin.ui.Table & CubaEnhan
|
||||
}
|
||||
}
|
||||
|
||||
//noinspection ConstantConditions
|
||||
return needReload;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
package com.haulmont.cuba.web.gui.components;
|
||||
|
||||
import com.haulmont.chile.core.datatypes.Datatypes;
|
||||
import com.haulmont.chile.core.datatypes.FormatStrings;
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.chile.core.model.utils.InstanceUtils;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
@ -36,6 +35,8 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author abramov
|
||||
* @version $Id$
|
||||
@ -66,10 +67,7 @@ public class WebDateField extends WebAbstractField<CubaDateFieldWrapper> impleme
|
||||
dateField = new CubaDateField();
|
||||
|
||||
Locale userLocale = AppBeans.get(UserSessionSource.class).getLocale();
|
||||
FormatStrings formats = Datatypes.getFormatStrings(userLocale);
|
||||
if (formats != null) {
|
||||
dateField.setDateFormat(formats.getDateFormat());
|
||||
}
|
||||
dateField.setDateFormat(Datatypes.getFormatStringsNN(userLocale).getDateFormat());
|
||||
|
||||
dateField.setResolution(com.vaadin.shared.ui.datefield.Resolution.DAY);
|
||||
dateField.setWidth("100%");
|
||||
@ -289,11 +287,10 @@ public class WebDateField extends WebAbstractField<CubaDateFieldWrapper> impleme
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
try {
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new RuntimeException("Metaproperty name is possibly wrong: " + property, e);
|
||||
}
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
datasource.addListener(
|
||||
new DsListenerAdapter() {
|
||||
|
@ -5,14 +5,14 @@
|
||||
package com.haulmont.cuba.web.gui.components;
|
||||
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
import com.haulmont.cuba.core.global.*;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.MessageTools;
|
||||
import com.haulmont.cuba.core.global.Messages;
|
||||
import com.haulmont.cuba.core.global.Security;
|
||||
import com.haulmont.cuba.gui.TestIdManager;
|
||||
import com.haulmont.cuba.gui.components.*;
|
||||
import com.haulmont.cuba.gui.components.Component;
|
||||
import com.haulmont.cuba.gui.components.Field;
|
||||
import com.haulmont.cuba.gui.data.CollectionDatasource;
|
||||
import com.haulmont.cuba.gui.data.Datasource;
|
||||
import com.haulmont.cuba.gui.data.DsContext;
|
||||
@ -454,12 +454,12 @@ public class WebFieldGroup
|
||||
protected void applyPermissions(Component c) {
|
||||
if (c instanceof DatasourceComponent) {
|
||||
DatasourceComponent dsComponent = (DatasourceComponent) c;
|
||||
MetaProperty metaProperty = dsComponent.getMetaProperty();
|
||||
MetaPropertyPath propertyPath = dsComponent.getMetaPropertyPath();
|
||||
|
||||
if (metaProperty != null) {
|
||||
if (propertyPath != null) {
|
||||
MetaClass metaClass = dsComponent.getDatasource().getMetaClass();
|
||||
dsComponent.setEditable(security.isEntityAttrModificationPermitted(metaClass, metaProperty.getName())
|
||||
&& dsComponent.isEditable());
|
||||
dsComponent.setEditable(dsComponent.isEditable()
|
||||
&& security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author abramov
|
||||
* @version $Id$
|
||||
@ -59,14 +61,20 @@ public class WebLabel extends WebAbstractComponent<com.vaadin.ui.Label> implemen
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
this.datasource = datasource;
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
if (metaPropertyPath == null)
|
||||
throw new IllegalArgumentException("Property " + property + " is not found in " + metaClass);
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
switch (metaProperty.getType()) {
|
||||
|
@ -9,7 +9,6 @@ import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.DevelopmentException;
|
||||
import com.haulmont.cuba.core.global.MessageTools;
|
||||
import com.haulmont.cuba.gui.components.Field;
|
||||
import com.haulmont.cuba.gui.components.RequiredValueMissingException;
|
||||
@ -28,6 +27,8 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author abramov
|
||||
* @version $Id$
|
||||
@ -60,15 +61,19 @@ public abstract class WebAbstractField<T extends com.vaadin.ui.Field>
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
this.datasource = datasource;
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
if (metaPropertyPath == null)
|
||||
throw new DevelopmentException(String.format(
|
||||
"Property '%s' does not exist in entity '%s'", property, metaClass.getName()));
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
@ -111,8 +116,8 @@ public abstract class WebAbstractField<T extends com.vaadin.ui.Field>
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValue() {
|
||||
return (T) component.getValue();
|
||||
public <V> V getValue() {
|
||||
return (V) component.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,6 @@ import com.haulmont.cuba.gui.data.impl.CollectionDsListenerAdapter;
|
||||
import com.haulmont.cuba.gui.data.impl.DatasourceImplementation;
|
||||
import com.haulmont.cuba.gui.presentations.Presentations;
|
||||
import com.haulmont.cuba.gui.presentations.PresentationsImpl;
|
||||
import com.haulmont.cuba.security.entity.EntityAttrAccess;
|
||||
import com.haulmont.cuba.security.entity.Presentation;
|
||||
import com.haulmont.cuba.security.global.UserSession;
|
||||
import com.haulmont.cuba.web.App;
|
||||
@ -35,7 +34,6 @@ import com.haulmont.cuba.web.gui.components.presentations.TablePresentations;
|
||||
import com.haulmont.cuba.web.gui.data.CollectionDsWrapper;
|
||||
import com.haulmont.cuba.web.gui.data.ItemWrapper;
|
||||
import com.haulmont.cuba.web.gui.data.PropertyWrapper;
|
||||
import com.haulmont.cuba.web.toolkit.VersionedThemeResource;
|
||||
import com.haulmont.cuba.web.toolkit.data.AggregationContainer;
|
||||
import com.haulmont.cuba.web.toolkit.ui.FieldWrapper;
|
||||
import com.vaadin.data.Item;
|
||||
@ -48,7 +46,6 @@ import com.vaadin.terminal.Resource;
|
||||
import com.vaadin.ui.*;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.Embedded;
|
||||
import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.TextArea;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
@ -275,7 +272,7 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
|
||||
final List<MetaPropertyPath> editableColumns = new ArrayList<>(propertyIds.size());
|
||||
for (final MetaPropertyPath propertyId : propertyIds) {
|
||||
if (!security.isEntityPropertyPathPermitted(metaClass, propertyId.toString(), EntityAttrAccess.MODIFY)) {
|
||||
if (!security.isEntityAttrUpdatePermitted(metaClass, propertyId.toString())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -725,10 +722,6 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
|
||||
component.setContainerDataSource(containerDatasource);
|
||||
|
||||
if (columns == null) {
|
||||
throw new NullPointerException("Columns cannot be null");
|
||||
}
|
||||
|
||||
List<MetaPropertyPath> editableColumns = null;
|
||||
if (isEditable()) {
|
||||
editableColumns = new LinkedList<>();
|
||||
@ -751,7 +744,7 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
if (editableColumns != null && column.isEditable() && (columnId instanceof MetaPropertyPath)) {
|
||||
MetaPropertyPath propertyPath = ((MetaPropertyPath) columnId);
|
||||
|
||||
if (security.isEntityPropertyPathPermitted(metaClass, propertyPath.toString(), EntityAttrAccess.MODIFY)) {
|
||||
if (security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString())) {
|
||||
editableColumns.add(propertyPath);
|
||||
}
|
||||
}
|
||||
@ -866,7 +859,7 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
if (column.getId() instanceof MetaPropertyPath) {
|
||||
String propertyPath = column.getId().toString();
|
||||
|
||||
if (security.isEntityPropertyPathPermitted(metaClass, propertyPath, EntityAttrAccess.VIEW)) {
|
||||
if (security.isEntityAttrReadPermitted(metaClass, propertyPath)) {
|
||||
result.add((MetaPropertyPath)column.getId());
|
||||
}
|
||||
}
|
||||
@ -1424,10 +1417,6 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
// Used for properly removing column from table
|
||||
protected Column associatedRuntimeColumn;
|
||||
|
||||
protected CustomColumnGenerator(ColumnGenerator columnGenerator) {
|
||||
this.columnGenerator = columnGenerator;
|
||||
}
|
||||
|
||||
protected CustomColumnGenerator(ColumnGenerator columnGenerator, @Nullable Column associatedRuntimeColumn) {
|
||||
this.columnGenerator = columnGenerator;
|
||||
this.associatedRuntimeColumn = associatedRuntimeColumn;
|
||||
@ -1476,9 +1465,9 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
@Override
|
||||
public void windowClosed(String actionId) {
|
||||
if (Window.COMMIT_ACTION_ID.equals(actionId) && window instanceof Window.Editor) {
|
||||
Object item = ((Window.Editor) window).getItem();
|
||||
if (item instanceof Entity) {
|
||||
datasource.updateItem((Entity) item);
|
||||
Entity item = ((Window.Editor) window).getItem();
|
||||
if (item != null) {
|
||||
datasource.updateItem(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1534,26 +1523,6 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
}
|
||||
}
|
||||
|
||||
protected static class ReadOnlyCheckBox extends Embedded {
|
||||
public final Object columnId;
|
||||
|
||||
public ReadOnlyCheckBox(Object columnId) {
|
||||
this.columnId = columnId;
|
||||
}
|
||||
|
||||
public void updateValue(Boolean value) {
|
||||
if (BooleanUtils.isTrue(value)) {
|
||||
setSource(new VersionedThemeResource("components/table/images/checkbox-checked.png"));
|
||||
} else {
|
||||
setSource(new VersionedThemeResource("components/table/images/checkbox-unchecked.png"));
|
||||
}
|
||||
}
|
||||
|
||||
public Object getColumnId() {
|
||||
return columnId;
|
||||
}
|
||||
}
|
||||
|
||||
protected class AbbreviatedColumnGenerator implements SystemTableColumnGenerator {
|
||||
|
||||
protected Table.Column column;
|
||||
@ -1679,8 +1648,6 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
protected class WebTableFieldFactory extends com.haulmont.cuba.web.gui.components.AbstractFieldFactory
|
||||
implements TableFieldFactory {
|
||||
|
||||
protected Map<MetaClass, CollectionDatasource> optionsDatasources = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public com.vaadin.ui.Field createField(com.vaadin.data.Container container,
|
||||
Object itemId, Object propertyId, Component uiContext) {
|
||||
@ -1742,11 +1709,11 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
protected void applyPermissions(com.haulmont.cuba.gui.components.Component columnComponent) {
|
||||
if (columnComponent instanceof DatasourceComponent) {
|
||||
DatasourceComponent dsComponent = (DatasourceComponent) columnComponent;
|
||||
MetaProperty metaProperty = dsComponent.getMetaProperty();
|
||||
MetaPropertyPath propertyPath = dsComponent.getMetaPropertyPath();
|
||||
|
||||
if (metaProperty != null) {
|
||||
if (propertyPath != null) {
|
||||
MetaClass metaClass = dsComponent.getDatasource().getMetaClass();
|
||||
dsComponent.setEditable(security.isEntityAttrModificationPermitted(metaClass, metaProperty.getName())
|
||||
dsComponent.setEditable(security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString())
|
||||
&& dsComponent.isEditable());
|
||||
}
|
||||
}
|
||||
@ -1790,6 +1757,7 @@ public abstract class WebAbstractTable<T extends com.haulmont.cuba.web.toolkit.u
|
||||
}
|
||||
}
|
||||
|
||||
//noinspection ConstantConditions
|
||||
return needReload;
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,7 @@
|
||||
package com.haulmont.cuba.web.gui.components;
|
||||
|
||||
import com.haulmont.chile.core.datatypes.Datatypes;
|
||||
import com.haulmont.chile.core.datatypes.FormatStrings;
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.utils.InstanceUtils;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
@ -35,6 +33,8 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author abramov
|
||||
* @version $Id$
|
||||
@ -64,10 +64,7 @@ public class WebDateField extends WebAbstractField<DateFieldWrapper> implements
|
||||
dateField = new com.haulmont.cuba.web.toolkit.ui.DateField();
|
||||
|
||||
Locale userLocale = AppBeans.get(UserSessionSource.class).getLocale();
|
||||
FormatStrings formats = Datatypes.getFormatStrings(userLocale);
|
||||
if (formats != null) {
|
||||
dateField.setDateFormat(formats.getDateFormat());
|
||||
}
|
||||
dateField.setDateFormat(Datatypes.getFormatStringsNN(userLocale).getDateFormat());
|
||||
|
||||
dateField.setResolution(com.haulmont.cuba.web.toolkit.ui.DateField.RESOLUTION_DAY);
|
||||
dateField.setWidth("100%");
|
||||
@ -276,16 +273,6 @@ public class WebDateField extends WebAbstractField<DateFieldWrapper> implements
|
||||
fireValueChanged(newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(ValueListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(ValueListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueChangingListener(ValueChangingListener listener) {
|
||||
}
|
||||
@ -294,37 +281,16 @@ public class WebDateField extends WebAbstractField<DateFieldWrapper> implements
|
||||
public void removeValueChangingListener() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addValidator(Validator validator) {
|
||||
validators.add(validator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeValidator(Validator validator) {
|
||||
validators.remove(validator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Datasource getDatasource() {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaProperty getMetaProperty() {
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
this.datasource = datasource;
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
try {
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
throw new RuntimeException("Metaproperty name is possibly wrong: " + property, e);
|
||||
}
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
datasource.addListener(
|
||||
new DsListenerAdapter() {
|
||||
|
@ -5,10 +5,12 @@
|
||||
package com.haulmont.cuba.web.gui.components;
|
||||
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.chile.core.model.MetaProperty;
|
||||
import com.haulmont.chile.core.model.MetaPropertyPath;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
import com.haulmont.cuba.core.global.*;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.MessageTools;
|
||||
import com.haulmont.cuba.core.global.Messages;
|
||||
import com.haulmont.cuba.core.global.Security;
|
||||
import com.haulmont.cuba.gui.components.Component;
|
||||
import com.haulmont.cuba.gui.components.DatasourceComponent;
|
||||
import com.haulmont.cuba.gui.components.Field;
|
||||
@ -273,8 +275,8 @@ public class WebFieldGroup
|
||||
fieldImpl.setCaption(fieldConfig.getCaption());
|
||||
}
|
||||
|
||||
if (fieldConfig.getDescription() != null && fieldImpl instanceof AbstractComponent) {
|
||||
((AbstractComponent) fieldImpl).setDescription(fieldConfig.getDescription());
|
||||
if (fieldConfig.getDescription() != null) {
|
||||
fieldImpl.setDescription(fieldConfig.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@ -428,12 +430,12 @@ public class WebFieldGroup
|
||||
protected void applyPermissions(Component c) {
|
||||
if (c instanceof DatasourceComponent) {
|
||||
DatasourceComponent dsComponent = (DatasourceComponent) c;
|
||||
MetaProperty metaProperty = dsComponent.getMetaProperty();
|
||||
MetaPropertyPath propertyPath = dsComponent.getMetaPropertyPath();
|
||||
|
||||
if (metaProperty != null) {
|
||||
if (propertyPath != null) {
|
||||
MetaClass metaClass = dsComponent.getDatasource().getMetaClass();
|
||||
dsComponent.setEditable(security.isEntityAttrModificationPermitted(metaClass, metaProperty.getName())
|
||||
&& dsComponent.isEditable());
|
||||
dsComponent.setEditable(dsComponent.isEditable()
|
||||
&& security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.haulmont.bali.util.Preconditions.checkNotNullArgument;
|
||||
|
||||
/**
|
||||
* @author abramov
|
||||
* @version $Id$
|
||||
@ -54,12 +56,20 @@ public class WebLabel extends WebAbstractComponent<com.vaadin.ui.Label> implemen
|
||||
return metaProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaPropertyPath getMetaPropertyPath() {
|
||||
return metaPropertyPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDatasource(Datasource datasource, String property) {
|
||||
this.datasource = datasource;
|
||||
|
||||
final MetaClass metaClass = datasource.getMetaClass();
|
||||
metaPropertyPath = metaClass.getPropertyPath(property);
|
||||
|
||||
checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass);
|
||||
|
||||
metaProperty = metaPropertyPath.getMetaProperty();
|
||||
|
||||
final ItemWrapper wrapper = createDatasourceWrapper(datasource, Collections.singleton(metaPropertyPath));
|
||||
|
Loading…
Reference in New Issue
Block a user