From 34267029f47f4241fec14cf0b31ff1746afaf31b Mon Sep 17 00:00:00 2001 From: Juan David Arboleda Date: Wed, 14 Nov 2012 16:32:44 -0500 Subject: [PATCH 1/2] IDEMPIERE-457 Tab Editor (to ease positioning of fields) --- .../oracle/201211141558_IDEMPIERE-457.sql | 8 +++ .../postgresql/201211141558_IDEMPIERE-457.sql | 8 +++ .../adempiere/webui/apps/form/WTabEditor.java | 54 +++++++++---------- .../webui/editor/WPaymentEditor.java | 46 ++++++++-------- .../src/org/compiere/apps/form/TabEditor.java | 28 +++++----- 5 files changed, 79 insertions(+), 65 deletions(-) create mode 100644 migration/i1.0a-release/oracle/201211141558_IDEMPIERE-457.sql create mode 100644 migration/i1.0a-release/postgresql/201211141558_IDEMPIERE-457.sql diff --git a/migration/i1.0a-release/oracle/201211141558_IDEMPIERE-457.sql b/migration/i1.0a-release/oracle/201211141558_IDEMPIERE-457.sql new file mode 100644 index 0000000000..4be1aba874 --- /dev/null +++ b/migration/i1.0a-release/oracle/201211141558_IDEMPIERE-457.sql @@ -0,0 +1,8 @@ +-- IDEMPIERE-457 - hide tab editor for inactive tabs +UPDATE AD_ToolBarButton SET DisplayLogic='@IsSortTab@=N & @IsActive@=Y ',Updated=TO_DATE('2012-11-07 14:29:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200068 + +; + +SELECT register_migration_script('201211141558_IDEMPIERE-457.sql') FROM dual +; + diff --git a/migration/i1.0a-release/postgresql/201211141558_IDEMPIERE-457.sql b/migration/i1.0a-release/postgresql/201211141558_IDEMPIERE-457.sql new file mode 100644 index 0000000000..7680e9be67 --- /dev/null +++ b/migration/i1.0a-release/postgresql/201211141558_IDEMPIERE-457.sql @@ -0,0 +1,8 @@ +-- IDEMPIERE-457 - hide tab editor for inactive tabs +UPDATE AD_ToolBarButton SET DisplayLogic='@IsSortTab@=N & @IsActive@=Y ',Updated=TO_TIMESTAMP('2012-11-07 14:29:45','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_ToolBarButton_ID=200068 + +; + +SELECT register_migration_script('201211141558_IDEMPIERE-457.sql') FROM dual +; + diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTabEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTabEditor.java index a07d4f33be..9454719bcd 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTabEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WTabEditor.java @@ -122,6 +122,8 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe Grid form; Vlayout centerVLayout; Vlayout westVLayout ; + + private static final int POSSEQMULTIPLIER = 10000000; public WTabEditor() { @@ -351,7 +353,7 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe private void setLastCellProps(Cell lastCell, int actualxpos, int seqNo) { lastCell.setDroppable("true"); lastCell.addEventListener(Events.ON_DROP, this); - int value = (actualxpos+1) * 10000000 + seqNo; + int value = (actualxpos+1) * POSSEQMULTIPLIER + seqNo; mapEmptyCellField.put(lastCell, value); } @@ -547,8 +549,8 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe MField field = getMField(fieldid); if (field != null) { setActiveMField(field); - setBackgroundField(field); setProperties(field); + setBackgroundField(field); } } } @@ -560,13 +562,14 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe MField field = getMField(gridField.getAD_Field_ID()); if (field != null) { setActiveMField(field); - setBackgroundField(field); setProperties(field); - } - // select the field on the visible list and set focus - for (Listitem item : visible.getItems()) { - if (field.getAD_Field_ID() == (Integer) item.getValue()) { - visible.setSelectedItem(item); + setBackgroundField(field); + // select the field on the visible list and set focus + for (Listitem item : visible.getItems()) { + if (field.getAD_Field_ID() == (Integer) item.getValue()) { + visible.setSelectedItem(item); + break; + } } } } @@ -588,22 +591,17 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe } else { field.setColumnSpan(field.getColumnSpan()+mult); } - setProperties(field); - resortArrays(); - setProperties(field); // seqno could change - updateLists(field); - repaintGrid(); - if (field != null) { - setActiveMField(field); - setBackgroundField(field); - setProperties(field); - } // select the field on the visible list and set focus for (Listitem item : visible.getItems()) { if (field.getAD_Field_ID() == (Integer) item.getValue()) { visible.setSelectedItem(item); + break; } } + setActiveMField(field); + setProperties(field); + repaintGrid(); + setBackgroundField(field); } } @@ -624,13 +622,12 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe // check empty cells Integer posseq = mapEmptyCellField.get(me.getTarget()); if (posseq != null) { - int actualxpos = posseq / 10000000; - int seqno = posseq - (actualxpos * 10000000); + int actualxpos = posseq / POSSEQMULTIPLIER; + int seqno = posseq - (actualxpos * POSSEQMULTIPLIER); MField field = getMField((Integer) startItem.getValue()); field.setSeqNo(seqno-5); field.setIsDisplayed(true); field.setXPosition(actualxpos); - setProperties(field); resortArrays(); setProperties(field); // seqno could change updateLists(field); @@ -646,17 +643,16 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe // item moved from visible to invisible MField field = getMField((Integer) startItem.getValue()); setActiveMField(field); - setBackgroundField(field); field.setSeqNo(0); field.setIsDisplayed(false); field.setXPosition(1); - setProperties(field); resortArrays(); setProperties(field); // seqno could change updateLists(field); repaintGrid(); + setBackgroundField(field); } - else if (startItem.getListbox() == invisible && endItem.getListbox() == visible) + else if (startItem.getListbox() == invisible && endItem.getListbox() == visible && (Integer) startItem.getValue() != 0) { // item moved from invisible to visible MField field = getMField((Integer) startItem.getValue()); @@ -664,7 +660,6 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe field.setSeqNo(fieldTo.getSeqNo()-5); field.setIsDisplayed(true); field.setXPosition(fieldTo.getXPosition()); - setProperties(field); resortArrays(); setProperties(field); // seqno could change updateLists(field); @@ -680,7 +675,6 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe field.setSeqNo(fieldTo.getSeqNo()-5); field.setIsDisplayed(true); field.setXPosition(fieldTo.getXPosition()); - setProperties(field); resortArrays(); setProperties(field); // seqno could change updateLists(field); @@ -766,9 +760,10 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe visible.removeAllItems(); invisible.removeAllItems(); - for(MField field : getMFields()) + for (MField field : getMFields()) { - if (!field.isActive()) + GridField gridField = getGridField(field); + if (!field.isActive() || gridField.isToolbarButton()) continue; KeyNamePair pair = new KeyNamePair(field.getAD_Field_ID(), field.getName()); if (field.isDisplayed()) { @@ -781,6 +776,9 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe invisible.setSelectedKeyNamePair(pair); } } + if (invisible.getItems().isEmpty()){ + invisible.addItem(new KeyNamePair(0, "...")); + } } @Override diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java index 7af2b0ae92..8db6fc405e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WPaymentEditor.java @@ -155,29 +155,31 @@ public class WPaymentEditor extends WEditor implements ListDataListener { @Override public void setReadWrite(boolean readWrite) { GridTab m_mTab = gridField.getGridTab(); - String m_DocStatus = (String) m_mTab.getValue("DocStatus"); - // DocStatus - if (m_DocStatus == null) - m_DocStatus = ""; - // Is the Trx closed? Reversed / Voided / Cloased - if (m_DocStatus.equals("RE") || m_DocStatus.equals("VO") || m_DocStatus.equals("CL")) - { - getComponent().setEnabled(readWrite, false); - return; - } - boolean m_onlyRule = false; - // Document is not complete - allow to change the Payment Rule only - if (m_DocStatus.equals("CO") || m_DocStatus.equals("WP")) - m_onlyRule = false; - else - m_onlyRule = true; - - boolean m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), gridField.getWindowNo(), "IsSOTrx")); - // PO only Rule - if (!m_onlyRule // Only order has Warehouse - && !m_isSOTrx && m_mTab.getValue("M_Warehouse_ID") != null) - m_onlyRule = true; + if (m_mTab != null) { + String m_DocStatus = (String) m_mTab.getValue("DocStatus"); + // DocStatus + if (m_DocStatus == null) + m_DocStatus = ""; + // Is the Trx closed? Reversed / Voided / Cloased + if (m_DocStatus.equals("RE") || m_DocStatus.equals("VO") || m_DocStatus.equals("CL")) + { + getComponent().setEnabled(readWrite, false); + return; + } + + // Document is not complete - allow to change the Payment Rule only + if (m_DocStatus.equals("CO") || m_DocStatus.equals("WP")) + m_onlyRule = false; + else + m_onlyRule = true; + + boolean m_isSOTrx = "Y".equals(Env.getContext(Env.getCtx(), gridField.getWindowNo(), "IsSOTrx")); + // PO only Rule + if (!m_onlyRule // Only order has Warehouse + && !m_isSOTrx && m_mTab.getValue("M_Warehouse_ID") != null) + m_onlyRule = true; + } getComponent().setEnabled(readWrite, readWrite && !m_onlyRule); } diff --git a/org.adempiere.ui/src/org/compiere/apps/form/TabEditor.java b/org.adempiere.ui/src/org/compiere/apps/form/TabEditor.java index 83e9d23a2c..b2e37d27bf 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/TabEditor.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/TabEditor.java @@ -17,7 +17,9 @@ package org.compiere.apps.form; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.compiere.model.GridField; import org.compiere.model.MField; @@ -40,10 +42,14 @@ public class TabEditor public static CLogger log = CLogger.getCLogger(TabEditor.class); private List fields = new ArrayList(); - - private MField m_activeField; - + private List gridFields = new ArrayList(); + + private MField m_activeField; + + private Map mapField = new HashMap(); + + private Map mapGridField = new HashMap(); public List getGridFields() { return gridFields; @@ -62,8 +68,10 @@ public class TabEditor GridField[] l_gridFields = GridField.createFields(Env.getCtx(), windowNo, 0, tabid); for (GridField gridField : l_gridFields) { gridFields.add(gridField); + mapGridField.put(gridField.getAD_Field_ID(), gridField); MField field = new MField(Env.getCtx(), gridField.getAD_Field_ID(), null); fields.add(field); + mapField.put(field.getAD_Field_ID(), field); gridField.getVO().IsReadOnly = true; gridField.getVO().IsMandatory = false; gridField.getVO().IsUpdateable = false; @@ -81,21 +89,11 @@ public class TabEditor } protected MField getMField(int fieldid) { - for (MField field : fields) { - if (field.getAD_Field_ID() == fieldid) { - return field; - } - } - return null; + return mapField.get(fieldid); } protected GridField getGridField(MField field) { - for (GridField gridfield : gridFields) { - if (gridfield.getAD_Field_ID() == field.getAD_Field_ID()) { - return gridfield; - } - } - return null; + return mapGridField.get( field.getAD_Field_ID()); } public MField getActiveMField() { From 39ecc6f10ef0b3daa69eb372e447864b6fc27f79 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 14 Nov 2012 16:49:36 -0500 Subject: [PATCH 2/2] IDEMPIERE-378 - register migration script --- migration/i1.0a-release/oracle/201211140148_IDEMPIERE-378.sql | 3 +++ .../i1.0a-release/postgresql/201211140148_IDEMPIERE-378.sql | 3 +++ 2 files changed, 6 insertions(+) diff --git a/migration/i1.0a-release/oracle/201211140148_IDEMPIERE-378.sql b/migration/i1.0a-release/oracle/201211140148_IDEMPIERE-378.sql index 3357f7e7be..602b0b03ad 100644 --- a/migration/i1.0a-release/oracle/201211140148_IDEMPIERE-378.sql +++ b/migration/i1.0a-release/oracle/201211140148_IDEMPIERE-378.sql @@ -133,3 +133,6 @@ INSERT INTO AD_ToolBarButton (Action,AD_Tab_ID,SeqNo,AD_Process_ID,AD_ToolBarBut INSERT INTO AD_ToolBarButton (Action,AD_Tab_ID,SeqNo,AD_Process_ID,AD_ToolBarButton_ID,Updated,IsActive,IsCustomization,Name,AD_Client_ID,AD_ToolBarButton_UU,ComponentName,Created,CreatedBy,UpdatedBy,AD_Org_ID) VALUES ('W',692,10,200016,200072,TO_DATE('2012-11-12 18:37:49','YYYY-MM-DD HH24:MI:SS'),'Y','N','Reverse PO Matching',0,'99e7e98d-a600-4174-9b55-923b790d03ba','ReverseMatchPO',TO_DATE('2012-11-12 18:37:49','YYYY-MM-DD HH24:MI:SS'),100,100,0) ; +SELECT register_migration_script('201211140148_IDEMPIERE-378.sql') FROM dual +; + diff --git a/migration/i1.0a-release/postgresql/201211140148_IDEMPIERE-378.sql b/migration/i1.0a-release/postgresql/201211140148_IDEMPIERE-378.sql index 08f457d656..750acb1b6a 100644 --- a/migration/i1.0a-release/postgresql/201211140148_IDEMPIERE-378.sql +++ b/migration/i1.0a-release/postgresql/201211140148_IDEMPIERE-378.sql @@ -133,3 +133,6 @@ INSERT INTO AD_ToolBarButton ("action",AD_Tab_ID,SeqNo,AD_Process_ID,AD_ToolBarB INSERT INTO AD_ToolBarButton ("action",AD_Tab_ID,SeqNo,AD_Process_ID,AD_ToolBarButton_ID,Updated,IsActive,IsCustomization,Name,AD_Client_ID,AD_ToolBarButton_UU,ComponentName,Created,CreatedBy,UpdatedBy,AD_Org_ID) VALUES ('W',692,10,200016,200072,TO_TIMESTAMP('2012-11-12 18:37:49','YYYY-MM-DD HH24:MI:SS'),'Y','N','Reverse PO Matching',0,'99e7e98d-a600-4174-9b55-923b790d03ba','ReverseMatchPO',TO_TIMESTAMP('2012-11-12 18:37:49','YYYY-MM-DD HH24:MI:SS'),100,100,0) ; +SELECT register_migration_script('201211140148_IDEMPIERE-378.sql') FROM dual +; +