details: /erp/devel/pi/rev/1e12e423c779
changeset: 9425:1e12e423c779
user: Iván Perdomo <ivan.perdomo <at> openbravo.com>
date: Mon Dec 27 17:52:27 2010 +0100
summary: [fl] Implemented form layout
- Field positioning is based on the number of column to be use and the flags:
issameline, startinoddcolumn
- If the column is an even one and the field has not issameline or is marked
as startinoddcolumn a spacer in appended to move the field to an odd
column
- The number of columns used by a field (colspan) is based on the reference or
the displaylength. Text fields, or String fields with more than 60
characters wide, use 2 columns.
- Text columns use 2 rows (rowspan)
diffstat:
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
| 10 +-
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
| 105 +++++++--
2 files changed, 88 insertions(+), 27 deletions(-)
diffs (216 lines):
diff -r 467141202544 -r 1e12e423c779
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
Mon Dec 27 17:43:58 2010 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-field.js.ftl
Mon Dec 27 17:52:27 2010 +0100
@@ -21,8 +21,9 @@
{
name: '${fieldDefinition.name?js_string}',
title: '${fieldDefinition.label?js_string}',
- <#if fieldDefinition.standardField>
type: '${fieldDefinition.type}',
+ width: '*',
+ <#if fieldDefinition.standardField>
columnName: '${fieldDefinition.columnName?string}',
inpColumnName: '${fieldDefinition.inpColumnName?string}',
referencedKeyColumnName:
'${fieldDefinition.referencedKeyColumnName?string}',
@@ -31,13 +32,12 @@
rowSpan: ${fieldDefinition.rowSpan},
startRow: ${fieldDefinition.startRow},
endRow: ${fieldDefinition.endRow},
- width: '*',
- <#if fieldDefinition.searchField>
+ <#if fieldDefinition.searchField>
displayField: '${fieldDefinition.name?js_string}._identifier',
valueField: '${fieldDefinition.name?js_string}',
+ </#if>
</#if>
- <#else>
- type: 'OBSectionItem',
+ <#if fieldDefinition.type = "OBSectionItem">
sectionExpanded: true,
defaultValue: '${fieldDefinition.label?js_string}',
itemIds: [
diff -r 467141202544 -r 1e12e423c779
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
---
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
Mon Dec 27 17:43:58 2010 +0100
+++
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFormComponent.java
Mon Dec 27 17:52:27 2010 +0100
@@ -23,6 +23,7 @@
import java.util.Comparator;
import java.util.List;
+import org.apache.log4j.Logger;
import org.jfree.util.Log;
import org.openbravo.base.model.Property;
import org.openbravo.base.model.domaintype.ButtonDomainType;
@@ -48,12 +49,10 @@
private static Long ZERO = new Long(0);
private static final String TEMPLATE_ID = "C1D176407A354A40815DC46D24D70EB8";
+ private static Logger log = Logger.getLogger(OBViewFormComponent.class);
- // Based on WAD implementation legacy code
- // 22 - Half column
- // 44 - One column
- private static final long ONE_COLUMN_MAX_LENGTH = 44;
- private static final long MULTILINE_MIN_LENGTH = 60;
+ private static final long ONE_COLUMN_MAX_LENGTH = 60;
+ private static final String TEXT_AD_REFERENCE_ID = "14";
private Tab tab;
@@ -77,30 +76,35 @@
OBViewFieldGroup currentFieldGroup = null;
FieldGroup currentADFieldGroup = null;
+ int colNum = 1;
for (Field field : adFields) {
- if (field.getColumn() == null) {
- // TODO: throw an error?
+
+ if (field.getColumn() == null || !field.isDisplayed() ||
!field.isActive()) {
continue;
}
- if (!field.isDisplayed()) {
- continue;
- }
- if (!field.isActive()) {
- continue;
- }
+
final Property property =
KernelUtils.getInstance().getPropertyFromColumn(field.getColumn());
- if (property.getDomainType() instanceof ButtonDomainType) {
- continue;
- }
// a button domain type, continue for now
if (property.getDomainType() instanceof ButtonDomainType) {
continue;
}
+ if (colNum % 2 == 0 && (field.isStartinoddcolumn() ||
!field.isDisplayOnSameLine())) {
+
+ final OBViewFieldSpacer spacer = new OBViewFieldSpacer();
+ fields.add(spacer);
+ log.debug("colNum: " + colNum + " - field: [spacer]");
+ colNum++;
+ if (colNum > 4) {
+ colNum = 1;
+ }
+ }
+
final OBViewField viewField = new OBViewField();
viewField.setField(field);
viewField.setProperty(property);
+
// change in fieldgroup
if (field.getFieldGroup() != null && field.getFieldGroup() !=
currentADFieldGroup) {
// start of a fieldgroup use it
@@ -109,12 +113,21 @@
viewFieldGroup.setFieldGroup(field.getFieldGroup());
currentFieldGroup = viewFieldGroup;
currentADFieldGroup = field.getFieldGroup();
- } else {
- fields.add(viewField);
+ colNum = 1;
}
+
+ fields.add(viewField);
+ log.debug("colNum: " + colNum + " - field: " + field.getName() + " -
issameline: "
+ + field.isDisplayOnSameLine() + " - startinoddcolumn: " +
field.isStartinoddcolumn());
+
if (currentFieldGroup != null) {
currentFieldGroup.addChild(viewField);
}
+
+ colNum += viewField.getColSpan();
+ if (colNum > 4) {
+ colNum = 1;
+ }
}
return fields;
}
@@ -256,7 +269,7 @@
}
public long getColSpan() {
- return field.getDisplayedLength() > ONE_COLUMN_MAX_LENGTH ? 2 : 1;
+ return field.getDisplayedLength() > ONE_COLUMN_MAX_LENGTH ||
getRowSpan() == 2 ? 2 : 1;
}
public String getEndRow() {
@@ -264,11 +277,11 @@
}
public long getRowSpan() {
- return field.getDisplayedLength() >= MULTILINE_MIN_LENGTH ? 2 : 1;
+ return
property.getDomainType().getReference().getId().equals(TEXT_AD_REFERENCE_ID) ?
2 : 1;
}
public String getStartRow() {
- return "false";
+ return field.isStartnewline().toString();
}
}
@@ -322,7 +335,7 @@
}
public String getType() {
- return "section";
+ return "OBSectionItem";
}
public String getName() {
@@ -346,6 +359,54 @@
}
}
+ public class OBViewFieldSpacer implements OBViewFieldDefinition {
+
+ public long getColSpan() {
+ return 1;
+ }
+
+ public String getEndRow() {
+ return "false";
+ }
+
+ public String getFieldProperties() {
+ return "";
+ }
+
+ public String getInpColumnName() {
+ return "";
+ }
+
+ public String getLabel() {
+ return "";
+ }
+
+ public String getName() {
+ return "";
+ }
+
+ public String getReferencedKeyColumnName() {
+ return "";
+ }
+
+ public long getRowSpan() {
+ return 1;
+ }
+
+ public boolean getStandardField() {
+ return false;
+ }
+
+ public String getStartRow() {
+ return "false";
+ }
+
+ public String getType() {
+ return "spacer";
+ }
+
+ }
+
public static class FormFieldComparator implements Comparator<Field> {
@Override
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits