IDEMPIERE-457 Tab Editor
This commit is contained in:
parent
ea5cadb162
commit
190e3c0767
|
|
@ -108,12 +108,10 @@ import org.compiere.util.ValueNamePair;
|
||||||
*/
|
*/
|
||||||
public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -6259178346327832664L;
|
private static final long serialVersionUID = 336562925897569888L;
|
||||||
|
|
||||||
public static final String DEFAULT_STATUS_MESSAGE = "NavigateOrUpdate";
|
public static final String DEFAULT_STATUS_MESSAGE = "NavigateOrUpdate";
|
||||||
|
|
||||||
|
|
@ -3239,17 +3237,25 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
||||||
return m_window.getTab(parentTabNo);
|
return m_window.getTab(parentTabNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColumns(){
|
public int getNumColumns() {
|
||||||
int col=0;
|
int maxcol=0;
|
||||||
|
for (GridField gridField : getFields())
|
||||||
String sql="SELECT MAX(f.XPosition+f.ColumnSpan-case when f.isfieldonly='Y' OR c.ad_reference_id in (20/*yesno*/,28/*button*/) then 1 else 0 end)"
|
{
|
||||||
+" FROM AD_Field f JOIN AD_Column c ON (f.AD_Column_ID=c.AD_Column_ID)"
|
if (!gridField.isDisplayed() || gridField.isToolbarButton())
|
||||||
+" WHERE f.isdisplayed='Y' AND f.isactive='Y' AND c.isactive='Y' AND f.AD_Tab_ID=?";
|
continue;
|
||||||
col=DB.getSQLValue(null, sql, getAD_Tab_ID());
|
int col = gridField.getXPosition() + gridField.getColumnSpan();
|
||||||
|
if (gridField.isFieldOnly()
|
||||||
return col;
|
|| gridField.getDisplayType() == DisplayType.Button
|
||||||
|
|| gridField.getDisplayType() == DisplayType.YesNo) {
|
||||||
|
col--;
|
||||||
|
}
|
||||||
|
if (col > maxcol) {
|
||||||
|
maxcol = col;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxcol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNew() {
|
public boolean isNew() {
|
||||||
return isOpen() && getCurrentRow() >= 0 && getCurrentRow() == m_mTable.getNewRow();
|
return isOpen() && getCurrentRow() >= 0 && getCurrentRow() == m_mTable.getNewRow();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -364,7 +364,7 @@ DataStatusListener, IADTabpanel
|
||||||
|
|
||||||
uiCreated = true;
|
uiCreated = true;
|
||||||
|
|
||||||
int numCols=gridTab.getColumns();
|
int numCols=gridTab.getNumColumns();
|
||||||
if (numCols <= 0) {
|
if (numCols <= 0) {
|
||||||
numCols=4;
|
numCols=4;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ import org.compiere.model.MField;
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.model.MLookup;
|
||||||
import org.compiere.model.MLookupFactory;
|
import org.compiere.model.MLookupFactory;
|
||||||
import org.compiere.model.X_AD_FieldGroup;
|
import org.compiere.model.X_AD_FieldGroup;
|
||||||
import org.compiere.util.DB;
|
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
|
|
@ -181,7 +180,7 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
||||||
form.setHeight(null);
|
form.setHeight(null);
|
||||||
form.setVflex(false);
|
form.setVflex(false);
|
||||||
|
|
||||||
int numCols = getMaxColumns(getMTab().getAD_Tab_ID());
|
int numCols = getNumColumns();
|
||||||
if (numCols <= 0) {
|
if (numCols <= 0) {
|
||||||
numCols=4;
|
numCols=4;
|
||||||
}
|
}
|
||||||
|
|
@ -201,19 +200,15 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
||||||
Rows rows = form.newRows();
|
Rows rows = form.newRows();
|
||||||
Row row = new Row();
|
Row row = new Row();
|
||||||
int actualxpos = 0;
|
int actualxpos = 0;
|
||||||
|
int lastseq = 0;
|
||||||
String currentFieldGroup = null;
|
String currentFieldGroup = null;
|
||||||
for (GridField gridField : getGridFields())
|
for (GridField gridField : getGridFields())
|
||||||
{
|
{
|
||||||
MField field = getMField(gridField.getAD_Field_ID());
|
MField field = getMField(gridField.getAD_Field_ID());
|
||||||
|
|
||||||
if (!gridField.isDisplayed())
|
if (!gridField.isDisplayed() || gridField.isToolbarButton())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (gridField.isToolbarButton()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// field group
|
// field group
|
||||||
String fieldGroup = gridField.getFieldGroup();
|
String fieldGroup = gridField.getFieldGroup();
|
||||||
if (!Util.isEmpty(fieldGroup) && !fieldGroup.equals(currentFieldGroup)) // group changed
|
if (!Util.isEmpty(fieldGroup) && !fieldGroup.equals(currentFieldGroup)) // group changed
|
||||||
|
|
@ -331,10 +326,14 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
||||||
row.appendCellChild(div);
|
row.appendCellChild(div);
|
||||||
setLastCellProps(row.getLastCell(), gridField);
|
setLastCellProps(row.getLastCell(), gridField);
|
||||||
}
|
}
|
||||||
|
lastseq = field.getSeqNo();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numCols - actualxpos + 1 > 0)
|
if (numCols - actualxpos + 1 > 0){
|
||||||
row.appendCellChild(createSpacer(), numCols - actualxpos + 1);
|
row.appendCellChild(createSpacer(), numCols - actualxpos + 1);
|
||||||
|
// make last empty space droppable
|
||||||
|
setLastCellProps(row.getLastCell(), actualxpos, lastseq + 10);
|
||||||
|
}
|
||||||
row.setGroup(currentGroup);
|
row.setGroup(currentGroup);
|
||||||
rows.appendChild(row);
|
rows.appendChild(row);
|
||||||
if (rowList != null)
|
if (rowList != null)
|
||||||
|
|
@ -361,15 +360,23 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
|
||||||
return new Space();
|
return new Space();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMaxColumns(int ad_Tab_ID) {
|
private int getNumColumns() {
|
||||||
int col=0;
|
int maxcol=0;
|
||||||
|
for (GridField gridField : getGridFields())
|
||||||
String sql="SELECT MAX(f.XPosition+f.ColumnSpan-case when f.isfieldonly='Y' OR c.ad_reference_id in (20/*yesno*/,28/*button*/) then 1 else 0 end)"
|
{
|
||||||
+" FROM AD_Field f JOIN AD_Column c ON (f.AD_Column_ID=c.AD_Column_ID)"
|
if (!gridField.isDisplayed() || gridField.isToolbarButton())
|
||||||
+" WHERE f.isdisplayed='Y' AND f.isactive='Y' AND c.isactive='Y' AND f.AD_Tab_ID=?";
|
continue;
|
||||||
col = DB.getSQLValue(null, sql, ad_Tab_ID);
|
int col = gridField.getXPosition() + gridField.getColumnSpan();
|
||||||
|
if (gridField.isFieldOnly()
|
||||||
return col;
|
|| (gridField.getDisplayType() == DisplayType.Button && !gridField.isToolbarButton())
|
||||||
|
|| gridField.getDisplayType() == DisplayType.YesNo) {
|
||||||
|
col--;
|
||||||
|
}
|
||||||
|
if (col > maxcol) {
|
||||||
|
maxcol = col;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxcol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue