From f6d907ff63260135dd81fccee8da944b7bc48583 Mon Sep 17 00:00:00 2001 From: Juan David Arboleda Date: Sat, 4 May 2013 14:10:19 -0500 Subject: [PATCH] IDEMPIERE-454 Easy import / Improvements (speed, export selected detail tab, bug fixes) --- .../org/adempiere/base/IGridTabExporter.java | 2 +- .../adempiere/impexp/GridTabCSVExporter.java | 5 +++- .../adempiere/impexp/GridTabCSVImporter.java | 30 +++++++++++-------- .../impexp/GridTabExcelExporter.java | 2 +- .../src/org/compiere/model/GridTable.java | 14 +++++---- .../adempiere/pipo2/GridTab2PackExporter.java | 2 +- .../src/org/compiere/apps/AExport.java | 2 +- .../webui/editor/WTableDirEditor.java | 2 +- .../webui/panel/action/ExportAction.java | 8 +++-- 9 files changed, 41 insertions(+), 26 deletions(-) diff --git a/org.adempiere.base/src/org/adempiere/base/IGridTabExporter.java b/org.adempiere.base/src/org/adempiere/base/IGridTabExporter.java index cfcfef6647..b259811269 100644 --- a/org.adempiere.base/src/org/adempiere/base/IGridTabExporter.java +++ b/org.adempiere.base/src/org/adempiere/base/IGridTabExporter.java @@ -32,7 +32,7 @@ public interface IGridTabExporter { * @param isCurrentRowOnly * @param file */ - public void export(GridTab gridTab, List childs, boolean isCurrentRowOnly, File file); + public void export(GridTab gridTab, List childs, boolean isCurrentRowOnly, File file, int indxDetailSelected); /** * @return file extension diff --git a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVExporter.java b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVExporter.java index 74595924c0..cbb4cb39ea 100644 --- a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVExporter.java +++ b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVExporter.java @@ -69,7 +69,7 @@ public class GridTabCSVExporter implements IGridTabExporter private static CLogger log = CLogger.getCLogger(GridTabCSVExporter.class); @Override - public void export(GridTab gridTab, List childs, boolean currentRowOnly, File file) { + public void export(GridTab gridTab, List childs, boolean currentRowOnly, File file,int indxDetailSelected) { ICsvMapWriter mapWriter = null; Map tabMapDetails = new HashMap(); @@ -129,6 +129,9 @@ public class GridTabCSVExporter implements IGridTabExporter int specialDetDispayType = 0; int numOfTabs=0; for(GridTab detail: childs){ + + if(indxDetailSelected != detail.getTabNo()) + continue; if(!detail.isDisplayed()) continue; diff --git a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java index ebcc3b9b51..6fdcbf3161 100644 --- a/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java +++ b/org.adempiere.base/src/org/adempiere/impexp/GridTabCSVImporter.java @@ -459,12 +459,11 @@ public class GridTabCSVImporter implements IGridTabImporter if(isInsertMode()) logMsg = Msg.getMsg(Env.getCtx(), "Inserted")+" "+ po.toString(); - else + else{ logMsg = Msg.getMsg(Env.getCtx(), "Updated")+" "+ po.toString(); - - //if it's parent record and there are details, parent needs to be refreshed - if(currentGridTab.equals(gridTab) && sortedtTabMapIndexes.size()>1) - currentGridTab.dataRefresh(false); + if(currentGridTab.equals(gridTab) && sortedtTabMapIndexes.size()>1) + currentGridTab.dataRefresh(true); + } } else { ValueNamePair ppE = CLogger.retrieveWarning(); if (ppE==null) @@ -482,11 +481,17 @@ public class GridTabCSVImporter implements IGridTabImporter if(currentGridTab.equals(gridTab) && masterRecord==null){ isMasterok = false; + rowResult.append("<"+currentGridTab.getTableName()+">: "); + rowResult.append(logMsg); + rowResult.append(" / "); break; } if(!currentGridTab.equals(gridTab) && masterRecord!=null){ isDetailok = false; + rowResult.append("<"+currentGridTab.getTableName()+">: "); + rowResult.append(logMsg); + rowResult.append(" / "); break; } } @@ -543,7 +548,6 @@ public class GridTabCSVImporter implements IGridTabImporter row =row.replaceAll("Inserted","RolledBack"); logFileW.write(row); } - gridTab.dataRefreshAll(); }else{ if(isThereDocAction){ @@ -581,13 +585,13 @@ public class GridTabCSVImporter implements IGridTabImporter } if(masterRecord!=null){ - gridTab.getTableModel().dataRequery(masterRecord.get_WhereClause(true),false,0,false); - gridTab.navigateCurrent(); - gridTab.getTableModel().setImportingMode(false, null); - + gridTab.query(false); + gridTab.getTableModel().setImportingMode(false,null); for(GridTab detail: childs) - if(detail.getTableModel().isOpen()) + if(detail.getTableModel().isOpen()){ + detail.query(true); detail.getTableModel().setImportingMode(false,null); + } } trx.close(); trx=null; @@ -1227,7 +1231,7 @@ public class GridTabCSVImporter implements IGridTabImporter } if (isUpdateMode()){ if(gridTab.getTableModel().getRowCount()==1){ - gridTab.navigateRelative(gridTab.getCurrentRow()); + gridTab.navigateCurrent(); return null; } else if(gridTab.getTableModel().getRowCount()<=0) @@ -1237,7 +1241,7 @@ public class GridTabCSVImporter implements IGridTabImporter } if (isMergeMode()){ if(gridTab.getTableModel().getRowCount()==1){ - gridTab.navigateRelative(gridTab.getCurrentRow()); + gridTab.navigateCurrent(); m_import_mode = IMPORT_MODE_UPDATE; }else if(gridTab.getTableModel().getRowCount()<=0) m_import_mode = IMPORT_MODE_INSERT; diff --git a/org.adempiere.base/src/org/adempiere/impexp/GridTabExcelExporter.java b/org.adempiere.base/src/org/adempiere/impexp/GridTabExcelExporter.java index e8ffe79949..8b7616a86a 100644 --- a/org.adempiere.base/src/org/adempiere/impexp/GridTabExcelExporter.java +++ b/org.adempiere.base/src/org/adempiere/impexp/GridTabExcelExporter.java @@ -153,7 +153,7 @@ public class GridTabExcelExporter extends AbstractExcelExporter implements IGrid } @Override - public void export(GridTab gridTab, List childs, boolean currentRowOnly, File file) { + public void export(GridTab gridTab, List childs, boolean currentRowOnly, File file,int indxDetailSelected) { m_tab = gridTab; setCurrentRowOnly(currentRowOnly); try { diff --git a/org.adempiere.base/src/org/compiere/model/GridTable.java b/org.adempiere.base/src/org/compiere/model/GridTable.java index ac207738cc..3edd09bed1 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTable.java +++ b/org.adempiere.base/src/org/compiere/model/GridTable.java @@ -2822,7 +2822,7 @@ public class GridTable extends AbstractTableModel ResultSet rs = null; try { - pstmt = DB.prepareStatement(sql, null); + pstmt = DB.prepareStatement(sql,get_TrxName()); rs = pstmt.executeQuery(); // only one row if (rs.next()) @@ -3681,7 +3681,7 @@ public class GridTable extends AbstractTableModel String sql = "SELECT " + columns + " FROM " + m_tableName + " WHERE " + m_tableName + "_ID=?"; try { - pstmt = DB.prepareStatement(sql, null); + pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt.setInt(1, getKeyID(row)); rs = pstmt.executeQuery(); if (rs.next()) { @@ -3717,9 +3717,13 @@ public class GridTable extends AbstractTableModel if (hasProcessed) { Boolean memProcessed = null; memProcessed = (Boolean) getOldValue(row, colProcessed); - if (memProcessed == null) - memProcessed = (Boolean) getValueAt(row, colProcessed); - + if (memProcessed == null){ + if(getValueAt(row, colProcessed) instanceof Boolean ) + memProcessed = (Boolean) getValueAt(row, colProcessed); + else if (getValueAt(row, colProcessed) instanceof String ) + memProcessed = Boolean.valueOf((String)getValueAt(row, colProcessed)); + } + Boolean dbProcessed = Boolean.TRUE; if (! dbProcessedS.equals("Y")) dbProcessed = Boolean.FALSE; diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/GridTab2PackExporter.java b/org.adempiere.pipo/src/org/adempiere/pipo2/GridTab2PackExporter.java index e85da83e52..bd5c21cc0e 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/GridTab2PackExporter.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/GridTab2PackExporter.java @@ -43,7 +43,7 @@ public class GridTab2PackExporter implements IGridTabExporter { */ @SuppressWarnings({ "rawtypes", "unchecked" }) @Override - public void export(GridTab gridTab, List childs, boolean currentRowOnly, File file) { + public void export(GridTab gridTab, List childs, boolean currentRowOnly, File file,int indxDetailSelected) { String tableName = gridTab.getTableName(); PackOut packOut = new PackOut(); packOut.setCtx(Env.getCtx()); diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java b/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java index 002da6a387..972b69db93 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/AExport.java @@ -160,6 +160,6 @@ public class AExport childs.add(gc.getMTab()); } - exporter.export(tab, childs, currentRowOnly, outFile); + exporter.export(tab, childs, currentRowOnly, outFile,0); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java index 93b4875e68..e2a1aa45ec 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java @@ -281,7 +281,7 @@ ContextMenuListener, IZoomableEditor //still not in list, reset to zero if (!getComponent().isSelected(value)) { - if (value instanceof Integer && gridField != null && gridField.getDisplayType() != DisplayType.ID) // for IDs is ok to be out of the list + if (value instanceof Integer && gridField != null && gridField.getDisplayType() != DisplayType.ID && !gridTab.getTableModel().isImporting()) // for IDs is ok to be out of the list { getComponent().setValue(null); if (curValue == null) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java index 5da2684179..306014ef8f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java @@ -205,8 +205,12 @@ public class ExportAction implements EventListener tables.add(tableName); childs.add(adTabPanel.getGridTab()); } - - exporter.export(panel.getActiveGridTab(), childs, currentRowOnly, file); + + int indxDetailSelected = 0; + if( adTab.getSelectedDetailADTabpanel()!=null ) + indxDetailSelected = adTab.getSelectedDetailADTabpanel().getGridTab().getTabNo(); + + exporter.export(panel.getActiveGridTab(), childs, currentRowOnly,file,indxDetailSelected); winExportFile.onClose(); winExportFile = null;