IDEMPIERE-454 Easy import / Improvements (speed, export selected detail tab, bug fixes)
This commit is contained in:
parent
d6179e6297
commit
f6d907ff63
|
@ -32,7 +32,7 @@ public interface IGridTabExporter {
|
||||||
* @param isCurrentRowOnly
|
* @param isCurrentRowOnly
|
||||||
* @param file
|
* @param file
|
||||||
*/
|
*/
|
||||||
public void export(GridTab gridTab, List<GridTab> childs, boolean isCurrentRowOnly, File file);
|
public void export(GridTab gridTab, List<GridTab> childs, boolean isCurrentRowOnly, File file, int indxDetailSelected);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return file extension
|
* @return file extension
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class GridTabCSVExporter implements IGridTabExporter
|
||||||
private static CLogger log = CLogger.getCLogger(GridTabCSVExporter.class);
|
private static CLogger log = CLogger.getCLogger(GridTabCSVExporter.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void export(GridTab gridTab, List<GridTab> childs, boolean currentRowOnly, File file) {
|
public void export(GridTab gridTab, List<GridTab> childs, boolean currentRowOnly, File file,int indxDetailSelected) {
|
||||||
|
|
||||||
ICsvMapWriter mapWriter = null;
|
ICsvMapWriter mapWriter = null;
|
||||||
Map<GridTab,GridField[]> tabMapDetails = new HashMap<GridTab, GridField[]>();
|
Map<GridTab,GridField[]> tabMapDetails = new HashMap<GridTab, GridField[]>();
|
||||||
|
@ -129,6 +129,9 @@ public class GridTabCSVExporter implements IGridTabExporter
|
||||||
int specialDetDispayType = 0;
|
int specialDetDispayType = 0;
|
||||||
int numOfTabs=0;
|
int numOfTabs=0;
|
||||||
for(GridTab detail: childs){
|
for(GridTab detail: childs){
|
||||||
|
|
||||||
|
if(indxDetailSelected != detail.getTabNo())
|
||||||
|
continue;
|
||||||
|
|
||||||
if(!detail.isDisplayed())
|
if(!detail.isDisplayed())
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -459,12 +459,11 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
|
|
||||||
if(isInsertMode())
|
if(isInsertMode())
|
||||||
logMsg = Msg.getMsg(Env.getCtx(), "Inserted")+" "+ po.toString();
|
logMsg = Msg.getMsg(Env.getCtx(), "Inserted")+" "+ po.toString();
|
||||||
else
|
else{
|
||||||
logMsg = Msg.getMsg(Env.getCtx(), "Updated")+" "+ po.toString();
|
logMsg = Msg.getMsg(Env.getCtx(), "Updated")+" "+ po.toString();
|
||||||
|
if(currentGridTab.equals(gridTab) && sortedtTabMapIndexes.size()>1)
|
||||||
//if it's parent record and there are details, parent needs to be refreshed
|
currentGridTab.dataRefresh(true);
|
||||||
if(currentGridTab.equals(gridTab) && sortedtTabMapIndexes.size()>1)
|
}
|
||||||
currentGridTab.dataRefresh(false);
|
|
||||||
} else {
|
} else {
|
||||||
ValueNamePair ppE = CLogger.retrieveWarning();
|
ValueNamePair ppE = CLogger.retrieveWarning();
|
||||||
if (ppE==null)
|
if (ppE==null)
|
||||||
|
@ -482,11 +481,17 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
|
|
||||||
if(currentGridTab.equals(gridTab) && masterRecord==null){
|
if(currentGridTab.equals(gridTab) && masterRecord==null){
|
||||||
isMasterok = false;
|
isMasterok = false;
|
||||||
|
rowResult.append("<"+currentGridTab.getTableName()+">: ");
|
||||||
|
rowResult.append(logMsg);
|
||||||
|
rowResult.append(" / ");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!currentGridTab.equals(gridTab) && masterRecord!=null){
|
if(!currentGridTab.equals(gridTab) && masterRecord!=null){
|
||||||
isDetailok = false;
|
isDetailok = false;
|
||||||
|
rowResult.append("<"+currentGridTab.getTableName()+">: ");
|
||||||
|
rowResult.append(logMsg);
|
||||||
|
rowResult.append(" / ");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -543,7 +548,6 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
row =row.replaceAll("Inserted","RolledBack");
|
row =row.replaceAll("Inserted","RolledBack");
|
||||||
logFileW.write(row);
|
logFileW.write(row);
|
||||||
}
|
}
|
||||||
gridTab.dataRefreshAll();
|
|
||||||
}else{
|
}else{
|
||||||
if(isThereDocAction){
|
if(isThereDocAction){
|
||||||
|
|
||||||
|
@ -581,13 +585,13 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
}
|
}
|
||||||
|
|
||||||
if(masterRecord!=null){
|
if(masterRecord!=null){
|
||||||
gridTab.getTableModel().dataRequery(masterRecord.get_WhereClause(true),false,0,false);
|
gridTab.query(false);
|
||||||
gridTab.navigateCurrent();
|
gridTab.getTableModel().setImportingMode(false,null);
|
||||||
gridTab.getTableModel().setImportingMode(false, null);
|
|
||||||
|
|
||||||
for(GridTab detail: childs)
|
for(GridTab detail: childs)
|
||||||
if(detail.getTableModel().isOpen())
|
if(detail.getTableModel().isOpen()){
|
||||||
|
detail.query(true);
|
||||||
detail.getTableModel().setImportingMode(false,null);
|
detail.getTableModel().setImportingMode(false,null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
trx.close();
|
trx.close();
|
||||||
trx=null;
|
trx=null;
|
||||||
|
@ -1227,7 +1231,7 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
}
|
}
|
||||||
if (isUpdateMode()){
|
if (isUpdateMode()){
|
||||||
if(gridTab.getTableModel().getRowCount()==1){
|
if(gridTab.getTableModel().getRowCount()==1){
|
||||||
gridTab.navigateRelative(gridTab.getCurrentRow());
|
gridTab.navigateCurrent();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if(gridTab.getTableModel().getRowCount()<=0)
|
else if(gridTab.getTableModel().getRowCount()<=0)
|
||||||
|
@ -1237,7 +1241,7 @@ public class GridTabCSVImporter implements IGridTabImporter
|
||||||
}
|
}
|
||||||
if (isMergeMode()){
|
if (isMergeMode()){
|
||||||
if(gridTab.getTableModel().getRowCount()==1){
|
if(gridTab.getTableModel().getRowCount()==1){
|
||||||
gridTab.navigateRelative(gridTab.getCurrentRow());
|
gridTab.navigateCurrent();
|
||||||
m_import_mode = IMPORT_MODE_UPDATE;
|
m_import_mode = IMPORT_MODE_UPDATE;
|
||||||
}else if(gridTab.getTableModel().getRowCount()<=0)
|
}else if(gridTab.getTableModel().getRowCount()<=0)
|
||||||
m_import_mode = IMPORT_MODE_INSERT;
|
m_import_mode = IMPORT_MODE_INSERT;
|
||||||
|
|
|
@ -153,7 +153,7 @@ public class GridTabExcelExporter extends AbstractExcelExporter implements IGrid
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void export(GridTab gridTab, List<GridTab> childs, boolean currentRowOnly, File file) {
|
public void export(GridTab gridTab, List<GridTab> childs, boolean currentRowOnly, File file,int indxDetailSelected) {
|
||||||
m_tab = gridTab;
|
m_tab = gridTab;
|
||||||
setCurrentRowOnly(currentRowOnly);
|
setCurrentRowOnly(currentRowOnly);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -2822,7 +2822,7 @@ public class GridTable extends AbstractTableModel
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql,get_TrxName());
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
// only one row
|
// only one row
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
@ -3681,7 +3681,7 @@ public class GridTable extends AbstractTableModel
|
||||||
String sql = "SELECT " + columns + " FROM " + m_tableName + " WHERE " + m_tableName + "_ID=?";
|
String sql = "SELECT " + columns + " FROM " + m_tableName + " WHERE " + m_tableName + "_ID=?";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||||
pstmt.setInt(1, getKeyID(row));
|
pstmt.setInt(1, getKeyID(row));
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
|
@ -3717,9 +3717,13 @@ public class GridTable extends AbstractTableModel
|
||||||
if (hasProcessed) {
|
if (hasProcessed) {
|
||||||
Boolean memProcessed = null;
|
Boolean memProcessed = null;
|
||||||
memProcessed = (Boolean) getOldValue(row, colProcessed);
|
memProcessed = (Boolean) getOldValue(row, colProcessed);
|
||||||
if (memProcessed == null)
|
if (memProcessed == null){
|
||||||
memProcessed = (Boolean) getValueAt(row, colProcessed);
|
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;
|
Boolean dbProcessed = Boolean.TRUE;
|
||||||
if (! dbProcessedS.equals("Y"))
|
if (! dbProcessedS.equals("Y"))
|
||||||
dbProcessed = Boolean.FALSE;
|
dbProcessed = Boolean.FALSE;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class GridTab2PackExporter implements IGridTabExporter {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
@Override
|
@Override
|
||||||
public void export(GridTab gridTab, List<GridTab> childs, boolean currentRowOnly, File file) {
|
public void export(GridTab gridTab, List<GridTab> childs, boolean currentRowOnly, File file,int indxDetailSelected) {
|
||||||
String tableName = gridTab.getTableName();
|
String tableName = gridTab.getTableName();
|
||||||
PackOut packOut = new PackOut();
|
PackOut packOut = new PackOut();
|
||||||
packOut.setCtx(Env.getCtx());
|
packOut.setCtx(Env.getCtx());
|
||||||
|
|
|
@ -160,6 +160,6 @@ public class AExport
|
||||||
childs.add(gc.getMTab());
|
childs.add(gc.getMTab());
|
||||||
}
|
}
|
||||||
|
|
||||||
exporter.export(tab, childs, currentRowOnly, outFile);
|
exporter.export(tab, childs, currentRowOnly, outFile,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,7 +281,7 @@ ContextMenuListener, IZoomableEditor
|
||||||
//still not in list, reset to zero
|
//still not in list, reset to zero
|
||||||
if (!getComponent().isSelected(value))
|
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);
|
getComponent().setValue(null);
|
||||||
if (curValue == null)
|
if (curValue == null)
|
||||||
|
|
|
@ -205,8 +205,12 @@ public class ExportAction implements EventListener<Event>
|
||||||
tables.add(tableName);
|
tables.add(tableName);
|
||||||
childs.add(adTabPanel.getGridTab());
|
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.onClose();
|
||||||
winExportFile = null;
|
winExportFile = null;
|
||||||
|
|
Loading…
Reference in New Issue