PL-6998 Add ability to set stylename for fieldGroup fields from XML descriptor

This commit is contained in:
Nikita Petunin 2016-04-07 12:20:31 +04:00
parent 0fa63651bb
commit 4945aa9c45
5 changed files with 32 additions and 0 deletions

View File

@ -46,6 +46,7 @@ import java.awt.*;
import java.util.*;
import java.util.List;
/**
*/
public class DesktopFieldGroup extends DesktopAbstractComponent<JPanel> implements FieldGroup, AutoExpanding {
@ -782,6 +783,11 @@ public class DesktopFieldGroup extends DesktopAbstractComponent<JPanel> implemen
impl.repaint();
}
String stylename = fieldConfig.getStyleName();
if (StringUtils.isNotEmpty(stylename)) {
fieldComponent.setStyleName(stylename);
}
if (App.getInstance().isTestMode()) {
jComponent.setName(fieldConfig.getId());
}

View File

@ -116,6 +116,7 @@ public interface FieldGroup extends Component, Component.BelongToFrame, Componen
private Formatter formatter;
private Element element;
private String width;
private String stylename;
private Datasource datasource;
private String requiredError;
private MetaPropertyPath metaPropertyPath;
@ -191,6 +192,14 @@ public interface FieldGroup extends Component, Component.BelongToFrame, Componen
this.width = width;
}
public String getStyleName() {
return stylename;
}
public void setStyleName(String stylename) {
this.stylename = stylename;
}
public Datasource getDatasource() {
return datasource;
}

View File

@ -1187,6 +1187,8 @@
<xs:attribute name="cols" type="xs:int"/>
<xs:attribute name="rows" type="xs:int"/>
<xs:attribute name="stylename" type="xs:string"/>
<xs:attribute name="optionsDatasource" type="xs:string"/>
<xs:attribute name="captionProperty" type="xs:string"/>
<xs:attribute name="descriptionProperty" type="xs:string"/>

View File

@ -177,6 +177,11 @@ public class FieldGroupLoader extends AbstractComponentLoader<FieldGroup> {
field.setDatasource(datasource);
}
String stylename = element.attributeValue("stylename");
if (StringUtils.isNotEmpty(stylename)) {
field.setStyleName(stylename);
}
String propertyName = metaPropertyPath != null ? metaPropertyPath.getMetaProperty().getName() : null;
if (metaPropertyPath != null && DynamicAttributesUtils.isDynamicAttribute(metaPropertyPath.getMetaProperty())) {
CategoryAttribute categoryAttribute = DynamicAttributesUtils.getCategoryAttribute(metaPropertyPath.getMetaProperty());

View File

@ -305,6 +305,11 @@ public class WebFieldGroup extends WebAbstractComponent<CubaFieldGroup>
}
}
String stylename = fieldConfig.getStyleName();
if (StringUtils.isNotEmpty(stylename)) {
fieldComponent.setStyleName(stylename);
}
applyPermissions(fieldComponent);
registerFieldComponent(fieldConfig, fieldComponent);
@ -465,6 +470,11 @@ public class WebFieldGroup extends WebAbstractComponent<CubaFieldGroup>
((HasFormatter) fieldComponent).setFormatter(fieldConf.getFormatter());
}
String stylename = fieldConf.getStyleName();
if (StringUtils.isNotEmpty(stylename)) {
fieldComponent.setStyleName(stylename);
}
// some components (e.g. LookupPickerField) have width from the creation, so I commented out this check
if (/*f.getWidth() == -1f &&*/ fieldConf.getWidth() != null) {
fieldComponent.setWidth(fieldConf.getWidth());