Heng Sin Low 2009-10-28 05:48:38 +00:00
parent a36e013b4a
commit a8fa8b00a7
8 changed files with 287 additions and 6 deletions

View File

@ -355,7 +355,7 @@ public class MQuery implements Serializable
} // MQuery
/** Serialization Info **/
static final long serialVersionUID = 1511402030597166113L;
private static final long serialVersionUID = 4883859385509199305L;
/** Table Name */
private String m_TableName = "";
@ -369,6 +369,12 @@ public class MQuery implements Serializable
private boolean m_newRecord = false;
/** New Record String */
private static final String NEWRECORD = "2=3";
private String m_zoomTable;
private String m_zoomColumn;
private Object m_zoomValue;
/**
* Get Record Count
@ -818,6 +824,54 @@ public class MQuery implements Serializable
public int getAD_PInstance_ID() {
return m_AD_PInstance_ID;
}
/**
*
* @param tableName
*/
public void setZoomTableName(String tableName) {
m_zoomTable = tableName;
}
/**
*
* @return zoom table name
*/
public String getZoomTableName() {
return m_zoomTable;
}
/**
*
* @param column
*/
public void setZoomColumnName(String column) {
m_zoomColumn = column;
}
/**
*
* @return zoom column name
*/
public String getZoomColumnName() {
return m_zoomColumn;
}
/**
*
* @param value
*/
public void setZoomValue(Object value) {
m_zoomValue = value;
}
/**
*
* @return zoom value, usually an integer
*/
public Object getZoomValue() {
return m_zoomValue;
}
} // MQuery
/*****************************************************************************

View File

@ -73,6 +73,7 @@ import org.compiere.model.DataStatusEvent;
import org.compiere.model.DataStatusListener;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.GridTable;
import org.compiere.model.GridWindow;
import org.compiere.model.GridWindowVO;
import org.compiere.model.GridWorkbench;
@ -130,6 +131,9 @@ import org.compiere.util.Util;
* @author Cristina Ghita, www.arhipac.ro
* @see FR [ 2877111 ] See identifiers columns when delete records https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2877111&group_id=176962
*
* @author hengsin, hengsin.low@idalica.com
* @see FR [2887701] https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2887701&group_id=176962
* @sponsor www.metas.de
*/
public final class APanel extends CPanel
implements DataStatusListener, ChangeListener, ActionListener, ASyncProcess
@ -137,7 +141,7 @@ public final class APanel extends CPanel
/**
*
*/
private static final long serialVersionUID = 2886624470773649284L;
private static final long serialVersionUID = 6066778919781303581L;
private boolean isNested = false;
@ -612,6 +616,8 @@ public final class APanel extends CPanel
/** Last Modifier of Action Event */
private int m_lastModifiers;
private HashMap<Integer, GridController> includedMap;
/**************************************************************************
* Dynamic Panel Initialization - either single window or workbench.
@ -694,7 +700,7 @@ public final class APanel extends CPanel
*/
if (wbType == GridWorkbench.TYPE_WINDOW)
{
HashMap<Integer,GridController> includedMap = new HashMap<Integer,GridController>(4);
includedMap = new HashMap<Integer,GridController>(4);
//
GridWindowVO wVO = AEnv.getMWindowVO(m_curWindowNo, m_mWorkbench.getWindowID(wb), 0);
if (wVO == null)
@ -869,12 +875,89 @@ public final class APanel extends CPanel
setPreferredSize(windowSize);
else
revalidate();
if (zoomToDetailTab(query)) {
return true;
}
Dimension size = getPreferredSize();
log.info( "fini - " + size);
m_curWinTab.requestFocusInWindow();
return true;
} // initPanel
private boolean zoomToDetailTab(MQuery query) {
if (query != null && query.getZoomTableName() != null && query.getZoomColumnName() != null)
{
GridTab gTab = m_mWorkbench.getMWindow(0).getTab(0);
if (!query.getZoomTableName().equalsIgnoreCase(gTab.getTableName()))
{
int tabSize = m_mWorkbench.getMWindow(0).getTabCount();
for (int tab = 0; tab < tabSize; tab++)
{
gTab = m_mWorkbench.getMWindow(0).getTab(tab);
if (gTab.isSortTab())
continue;
if (gTab.getTabLevel() == 1 && gTab.getTableName().equalsIgnoreCase(query.getZoomTableName()))
{
GridField[] fields = gTab.getFields();
for (GridField field : fields)
{
if (field.getColumnName().equalsIgnoreCase(query.getZoomColumnName()))
{
if (query.getZoomValue() != null && query.getZoomValue() instanceof Integer)
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
m_mWorkbench.getMWindow(0).initTab(tab);
int index = tabPanel.findTabindex(gTab);
if (index >= 0)
{
GridController gc = (GridController) tabPanel.getComponentAt(index);
gc.activate();
gc.query(false, 0, 0);
}
}
GridTable table = gTab.getTableModel();
int count = table.getRowCount();
for(int i = 0; i < count; i++)
{
int id = table.getKeyID(i);
if (id == ((Integer)query.getZoomValue()).intValue())
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
int index = tabPanel.findTabindex(gTab);
if (index >= 0)
tabPanel.setSelectedIndex(index);
}
gTab.setCurrentRow(i);
return true;
}
}
}
else
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
int index = tabPanel.findTabindex(gTab);
if (index >= 0)
tabPanel.setSelectedIndex(index);
}
return true;
}
break;
}
}
}
}
}
}
return false;
}
/**
* Get Current Window No
* @return win no

View File

@ -137,6 +137,23 @@ public class VTabbedPane extends CTabbedPane
}
}
/**
* @param gridTab
* @return tab index or -1 if not found
*/
public int findTabindex(GridTab gridTab)
{
for (int i = 0; i < gTabs.size(); i++)
{
if (gTabs.get(i) == gridTab)
{
return indexOfTab(tabNames.get(i));
}
}
return -1;
}
/**
* Set Workbench - or Window
* @param isWorkbench

View File

@ -30,7 +30,6 @@ import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -96,6 +95,10 @@ import org.eevolution.model.I_PP_Product_BOMLine;
* <li>BF [ 1979213 ] VLookup.getDirectAccessSQL issue
* <li>BF [ 2552901 ] VLookup: TAB is not working OK
* @author Michael Judd (MultiSelect)
*
* @author hengsin, hengsin.low@idalica.com
* @see FR [2887701] https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2887701&group_id=176962
* @sponsor www.metas.de
*/
public class VLookup extends JComponent
implements VEditor, ActionListener, FocusListener
@ -1334,6 +1337,7 @@ public class VLookup extends JComponent
if (zoomQuery == null || value != null)
{
zoomQuery = new MQuery(); // ColumnName might be changed in MTab.validateQuery
String keyTableName = null;
String keyColumnName = null;
// Check if it is a Table Reference
if (m_lookup != null && m_lookup instanceof MLookup)
@ -1341,10 +1345,11 @@ public class VLookup extends JComponent
int AD_Reference_ID = ((MLookup)m_lookup).getAD_Reference_Value_ID();
if (AD_Reference_ID != 0)
{
String query = "SELECT kc.ColumnName"
String query = "SELECT kc.ColumnName, kt.TableName"
+ " FROM AD_Ref_Table rt"
+ " INNER JOIN AD_Column kc ON (rt.AD_Key=kc.AD_Column_ID)"
+ "WHERE rt.AD_Reference_ID=?";
+ " INNER JOIN AD_Table kt ON (rt.AD_Table_ID=kt.AD_Table_ID)"
+ " WHERE rt.AD_Reference_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
@ -1356,6 +1361,7 @@ public class VLookup extends JComponent
if (rs.next())
{
keyColumnName = rs.getString(1);
keyTableName = rs.getString(2);
}
}
catch (Exception e)
@ -1371,9 +1377,27 @@ public class VLookup extends JComponent
} // MLookup
if(keyColumnName != null && keyColumnName.length() !=0)
{
zoomQuery.addRestriction(keyColumnName, MQuery.EQUAL, value);
zoomQuery.setZoomColumnName(keyColumnName);
zoomQuery.setZoomTableName(keyTableName);
}
else
{
zoomQuery.addRestriction(m_columnName, MQuery.EQUAL, value);
if (m_columnName.indexOf(".") > 0)
{
zoomQuery.setZoomColumnName(m_columnName.substring(m_columnName.indexOf(".")+1));
zoomQuery.setZoomTableName(m_columnName.substring(0, m_columnName.indexOf(".")));
}
else
{
zoomQuery.setZoomColumnName(m_columnName);
//remove _ID to get table name
zoomQuery.setZoomTableName(m_columnName.substring(0, m_columnName.length() - 3));
}
}
zoomQuery.setZoomValue(value);
zoomQuery.setRecordCount(1); // guess
}

View File

@ -451,7 +451,20 @@ public final class AEnv
String column = lookup.getColumnName();
//strip off table name, fully qualify name doesn't work when zoom into detail tab
if (column.indexOf(".") > 0)
{
int p = column.indexOf(".");
String tableName = column.substring(0, p);
column = column.substring(column.indexOf(".")+1);
zoomQuery.setZoomTableName(tableName);
zoomQuery.setZoomColumnName(column);
}
else
{
zoomQuery.setZoomColumnName(column);
//remove _ID to get table name
zoomQuery.setZoomTableName(column.substring(0, column.length() - 3));
}
zoomQuery.setZoomValue(value);
zoomQuery.addRestriction(column, MQuery.EQUAL, value);
zoomQuery.setRecordCount(1); // guess
}

View File

@ -147,4 +147,14 @@ public class CompositeADTab extends AbstractADTab
public void setTabplacement(int tabPlacement) {
tabList.setTabplacement(tabPlacement);
}
@Override
public IADTabpanel findADTabpanel(GridTab gTab) {
for (IADTabpanel tabpanel : tabPanelList) {
if (tabpanel.getGridTab() == gTab) {
return tabpanel;
}
}
return null;
}
}

View File

@ -119,4 +119,10 @@ public interface IADTab extends UIPart {
* @param tabPlacement
*/
public void setTabplacement(int tabPlacement);
/**
* @param gTab
* @return IADTabpanel or null if not found
*/
public IADTabpanel findADTabpanel(GridTab gTab);
}

View File

@ -54,6 +54,7 @@ import org.compiere.model.DataStatusEvent;
import org.compiere.model.DataStatusListener;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.GridTable;
import org.compiere.model.GridWindow;
import org.compiere.model.GridWindowVO;
import org.compiere.model.MLookupFactory;
@ -94,8 +95,13 @@ import org.zkoss.zul.Menupopup;
* @author <a href="mailto:hengsin@gmail.com">Low Heng Sin</a>
* @date Feb 25, 2007
* @version $Revision: 0.10 $
*
* @author Cristina Ghita, www.arhipac.ro
* @see FR [ 2877111 ] See identifiers columns when delete records https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2877111&group_id=176962
*
* @author hengsin, hengsin.low@idalica.com
* @see FR [2887701] https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2887701&group_id=176962
* @sponsor www.metas.de
*/
public abstract class AbstractADWindowPanel extends AbstractUIPart implements ToolbarListener,
EventListener, DataStatusListener, ActionListener, ASyncProcess
@ -320,6 +326,11 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{
toolbar.enableHistoryRecords(true);
}
if (zoomToDetailTab(query))
{
return true;
}
}
else
{
@ -334,6 +345,69 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
return true;
}
private boolean zoomToDetailTab(MQuery query) {
//zoom to detail
if (query != null && query.getZoomTableName() != null && query.getZoomColumnName() != null)
{
GridTab gTab = gridWindow.getTab(0);
if (!query.getZoomTableName().equalsIgnoreCase(gTab.getTableName()))
{
int tabSize = gridWindow.getTabCount();
for (int tab = 0; tab < tabSize; tab++)
{
gTab = gridWindow.getTab(tab);
if (gTab.isSortTab())
continue;
if (gTab.getTabLevel() == 1 && gTab.getTableName().equalsIgnoreCase(query.getZoomTableName()))
{
GridField[] fields = gTab.getFields();
for (GridField field : fields)
{
if (field.getColumnName().equalsIgnoreCase(query.getZoomColumnName()))
{
if (query.getZoomValue() != null && query.getZoomValue() instanceof Integer)
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
IADTabpanel tp = adTab.findADTabpanel(gTab);
tp.createUI();
tp.query();
}
GridTable table = gTab.getTableModel();
int count = table.getRowCount();
for(int i = 0; i < count; i++)
{
int id = table.getKeyID(i);
if (id == ((Integer)query.getZoomValue()).intValue())
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
setActiveTab(tab);
}
gTab.setCurrentRow(i);
return true;
}
}
}
else
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
setActiveTab(tab);
}
return true;
}
break;
}
}
}
}
}
}
return false;
}
private void initEmbeddedTab(MQuery query, int tabIndex) {
GridTab gTab = gridWindow.getTab(tabIndex);
gTab.addDataStatusListener(this);