col/rows support for TextField and TextArea

This commit is contained in:
Dmitry Abramov 2009-03-05 07:22:47 +00:00
parent 1290288900
commit 0ab90b69fa
7 changed files with 123 additions and 2 deletions

View File

@ -10,4 +10,9 @@
package com.haulmont.cuba.gui.components;
public interface TextArea extends Field {
int getRows();
void setRows(int rows);
int getColumns();
void setColumns(int columns);
}

View File

@ -10,4 +10,9 @@
package com.haulmont.cuba.gui.components;
public interface TextField extends Field {
int getRows();
void setRows(int rows);
int getColumns();
void setColumns(int columns);
}

View File

@ -45,8 +45,8 @@ public class LayoutLoaderConfig {
config.registerLoader("groupBox", GroupBoxLoader.class);
config.registerLoader("checkBox", AbstractFieldLoader.class);
config.registerLoader("label", LabelLoader.class);
config.registerLoader("textField", AbstractFieldLoader.class);
config.registerLoader("textArea", AbstractFieldLoader.class);
config.registerLoader("textField", TextFieldLoader.class);
config.registerLoader("textArea", TextAreaLoader.class);
config.registerLoader("dateField", AbstractFieldLoader.class);
config.registerLoader("lookupField", LookupFieldLoader.class);
config.registerLoader("table", TableLoader.class);

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Dmitry Abramov
* Created: 05.03.2009 11:13:20
* $Id$
*/
package com.haulmont.cuba.gui.xml.layout.loaders;
import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.components.TextArea;
import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
import com.haulmont.cuba.gui.xml.layout.LayoutLoaderConfig;
import org.apache.commons.lang.StringUtils;
import org.dom4j.Element;
public class TextAreaLoader extends AbstractFieldLoader {
public TextAreaLoader(Context context, LayoutLoaderConfig config, ComponentsFactory factory) {
super(context, config, factory);
}
@Override
public Component loadComponent(ComponentsFactory factory, Element element) throws InstantiationException, IllegalAccessException {
final TextArea component = (TextArea) super.loadComponent(factory, element);
final String cols = element.attributeValue("cols");
final String rows = element.attributeValue("rows");
if (!StringUtils.isEmpty(cols)) {
component.setColumns(Integer.valueOf(cols));
}
if (!StringUtils.isEmpty(rows)) {
component.setRows(Integer.valueOf(rows));
}
return component;
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Dmitry Abramov
* Created: 05.03.2009 11:13:20
* $Id$
*/
package com.haulmont.cuba.gui.xml.layout.loaders;
import com.haulmont.cuba.gui.xml.layout.*;
import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.components.TextField;
import org.dom4j.Element;
import org.apache.commons.lang.StringUtils;
public class TextFieldLoader extends AbstractFieldLoader {
public TextFieldLoader(Context context, LayoutLoaderConfig config, ComponentsFactory factory) {
super(context, config, factory);
}
@Override
public Component loadComponent(ComponentsFactory factory, Element element) throws InstantiationException, IllegalAccessException {
final TextField component = (TextField) super.loadComponent(factory, element);
final String cols = element.attributeValue("cols");
final String rows = element.attributeValue("rows");
if (!StringUtils.isEmpty(cols)) {
component.setColumns(Integer.valueOf(cols));
}
if (!StringUtils.isEmpty(rows)) {
component.setRows(Integer.valueOf(rows));
}
return component;
}
}

View File

@ -23,4 +23,20 @@ public class TextArea
component.setImmediate(true);
component.setNullRepresentation("");
}
public int getRows() {
return component.getRows();
}
public void setRows(int rows) {
component.setRows(rows);
}
public int getColumns() {
return component.getColumns();
}
public void setColumns(int columns) {
component.setColumns(columns);
}
}

View File

@ -22,4 +22,20 @@ public class TextField
component.setImmediate(true);
component.setNullRepresentation("");
}
public int getRows() {
return component.getRows();
}
public void setRows(int rows) {
component.setRows(rows);
}
public int getColumns() {
return component.getColumns();
}
public void setColumns(int columns) {
component.setColumns(columns);
}
}