Buttons are not working correctly on included tab

Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2979169
This commit is contained in:
Heng Sin Low 2010-04-08 04:07:09 +00:00
parent dbe819c58b
commit c91726015e
3 changed files with 43 additions and 10 deletions

View File

@ -20,6 +20,7 @@ import javax.swing.table.AbstractTableModel;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.panel.AbstractADWindowPanel;
import org.adempiere.webui.util.SortComparator; import org.adempiere.webui.util.SortComparator;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
@ -52,9 +53,9 @@ import org.zkoss.zul.event.ZulEvents;
public class GridPanel extends Borderlayout implements EventListener public class GridPanel extends Borderlayout implements EventListener
{ {
/** /**
* * generated serial version ID
*/ */
private static final long serialVersionUID = -8735897196875342427L; private static final long serialVersionUID = -7151423393713654553L;
private static final int MIN_COLUMN_WIDTH = 100; private static final int MIN_COLUMN_WIDTH = 100;
@ -91,6 +92,8 @@ public class GridPanel extends Borderlayout implements EventListener
private String columnOnClick; private String columnOnClick;
private AbstractADWindowPanel windowPanel;
public static final String PAGE_SIZE_KEY = "ZK_PAGING_SIZE"; public static final String PAGE_SIZE_KEY = "ZK_PAGING_SIZE";
public static final String MODE_LESS_KEY = "ZK_GRID_EDIT_MODELESS"; public static final String MODE_LESS_KEY = "ZK_GRID_EDIT_MODELESS";
@ -328,6 +331,7 @@ public class GridPanel extends Borderlayout implements EventListener
renderer.stopEditing(false); renderer.stopEditing(false);
renderer = new GridTabRowRenderer(gridTab, windowNo); renderer = new GridTabRowRenderer(gridTab, windowNo);
renderer.setGridPanel(this); renderer.setGridPanel(this);
renderer.setADWindowPanel(windowPanel);
listbox.setRowRenderer(renderer); listbox.setRowRenderer(renderer);
listbox.setModel(listModel); listbox.setModel(listModel);
@ -608,6 +612,9 @@ public class GridPanel extends Borderlayout implements EventListener
return false; return false;
} }
/**
* @param columnName
*/
public void setFocusToField(String columnName) { public void setFocusToField(String columnName) {
boolean found = false; boolean found = false;
for (WEditor editor : renderer.getEditors()) { for (WEditor editor : renderer.getEditors()) {
@ -620,4 +627,13 @@ public class GridPanel extends Borderlayout implements EventListener
} }
} }
} }
/**
* @param winPanel
*/
public void setADWindowPanel(AbstractADWindowPanel winPanel) {
windowPanel = winPanel;
if (renderer != null)
renderer.setADWindowPanel(windowPanel);
}
} }

View File

@ -79,6 +79,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
private Object[] currentValues; private Object[] currentValues;
private boolean editing = false; private boolean editing = false;
private int currentRowIndex = -1; private int currentRowIndex = -1;
private AbstractADWindowPanel m_windowPanel;
/** /**
* *
@ -96,12 +97,19 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
if (editor != null) { if (editor != null) {
if (editor instanceof WButtonEditor) if (editor instanceof WButtonEditor)
{ {
Object window = SessionManager.getAppDesktop().findWindow(windowNo); if (m_windowPanel != null)
if (window != null && window instanceof ADWindow) {
{ ((WButtonEditor)editor).addActionListener(m_windowPanel);
AbstractADWindowPanel windowPanel = ((ADWindow)window).getADWindowPanel(); }
((WButtonEditor)editor).addActionListener(windowPanel); else
} {
Object window = SessionManager.getAppDesktop().findWindow(windowNo);
if (window != null && window instanceof ADWindow)
{
AbstractADWindowPanel windowPanel = ((ADWindow)window).getADWindowPanel();
((WButtonEditor)editor).addActionListener(windowPanel);
}
}
} }
else else
{ {
@ -150,8 +158,6 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
} }
else if (gridField.isLookup()) else if (gridField.isLookup())
{ {
if (value == null) return "";
if (lookupCache != null) if (lookupCache != null)
{ {
Map<Object, String> cache = lookupCache.get(gridField.getColumnName()); Map<Object, String> cache = lookupCache.get(gridField.getColumnName());
@ -583,7 +589,17 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
} }
} }
/**
* @return boolean
*/
public boolean isEditing() { public boolean isEditing() {
return editing; return editing;
} }
/**
* @param windowPanel
*/
public void setADWindowPanel(AbstractADWindowPanel windowPanel) {
this.m_windowPanel = windowPanel;
}
} }

View File

@ -228,6 +228,7 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
this.appendChild(listPanel); this.appendChild(listPanel);
listPanel.setVisible(false); listPanel.setVisible(false);
listPanel.setWindowNo(windowNo); listPanel.setWindowNo(windowNo);
listPanel.setADWindowPanel(winPanel);
gridTab.getTableModel().addVetoableChangeListener(this); gridTab.getTableModel().addVetoableChangeListener(this);
} }