IDEMPIERE-325 Complete AD based info window ( AD_InfoWindow ) implementation. Ported existing info product panel to the new ad_infowindow implementation.
This commit is contained in:
parent
d8ab6df543
commit
7cc4052caf
|
@ -68,7 +68,7 @@ public class MInfoColumn extends X_AD_InfoColumn
|
|||
public boolean isColumnAccess(TableInfo[] tableInfos)
|
||||
{
|
||||
int index = getSelectClause().indexOf(".");
|
||||
if (index == getSelectClause().lastIndexOf("."))
|
||||
if (index == getSelectClause().lastIndexOf(".") && index >= 0)
|
||||
{
|
||||
String synonym = getSelectClause().substring(0, index);
|
||||
String column = getSelectClause().substring(index+1);
|
||||
|
|
|
@ -379,19 +379,29 @@ public class WListItemRenderer implements ListitemRenderer<Object>, EventListene
|
|||
return;
|
||||
} // updateColumn
|
||||
|
||||
/**
|
||||
* @param header
|
||||
*/
|
||||
public void addColumn(String header)
|
||||
{
|
||||
addColumn(header, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Table Column.
|
||||
* after adding a column, you need to set the column classes again
|
||||
* (DefaultTableModel fires TableStructureChanged, which calls
|
||||
* JTable.tableChanged .. createDefaultColumnsFromModel
|
||||
* @param header The header text for the column
|
||||
* @param description
|
||||
*/
|
||||
public void addColumn(String header)
|
||||
public void addColumn(String header, String description)
|
||||
{
|
||||
WTableColumn tableColumn;
|
||||
|
||||
tableColumn = new WTableColumn();
|
||||
tableColumn.setHeaderValue(Util.cleanAmp(header));
|
||||
tableColumn.setTooltipText(description);
|
||||
m_tableColumns.add(tableColumn);
|
||||
|
||||
return;
|
||||
|
@ -427,12 +437,13 @@ public class WListItemRenderer implements ListitemRenderer<Object>, EventListene
|
|||
* is used to set the header text.
|
||||
*
|
||||
* @param headerValue The object to use for generating the header text.
|
||||
* @param tooltipText
|
||||
* @param headerIndex The column index of the header
|
||||
* @param classType
|
||||
* @return The generated ListHeader
|
||||
* @see #renderListHead(ListHead)
|
||||
*/
|
||||
private Component getListHeaderComponent(Object headerValue, int headerIndex, Class<?> classType)
|
||||
private Component getListHeaderComponent(Object headerValue, String tooltipText, int headerIndex, Class<?> classType)
|
||||
{
|
||||
ListHeader header = null;
|
||||
|
||||
|
@ -450,6 +461,10 @@ public class WListItemRenderer implements ListitemRenderer<Object>, EventListene
|
|||
Comparator<Object> dscComparator = getColumnComparator(false, headerIndex);
|
||||
|
||||
header = new ListHeader(headerText);
|
||||
if (!Util.isEmpty(tooltipText))
|
||||
{
|
||||
header.setTooltiptext(tooltipText);
|
||||
}
|
||||
|
||||
header.setSort("auto");
|
||||
header.setSortAscending(ascComparator);
|
||||
|
@ -471,7 +486,12 @@ public class WListItemRenderer implements ListitemRenderer<Object>, EventListene
|
|||
if (width < 30)
|
||||
width = 30;
|
||||
}
|
||||
else if (width > 0 && width < 100 && (classType == null || !classType.isAssignableFrom(Boolean.class)))
|
||||
else if (classType.isAssignableFrom(Boolean.class))
|
||||
{
|
||||
if (width > 0 && width < 30)
|
||||
width = 30;
|
||||
}
|
||||
else if (width > 0 && width < 100)
|
||||
width = 100;
|
||||
}
|
||||
else if (width > 0 && width < 100)
|
||||
|
@ -567,7 +587,7 @@ public class WListItemRenderer implements ListitemRenderer<Object>, EventListene
|
|||
for (int columnIndex = 0; columnIndex < m_tableColumns.size(); columnIndex++)
|
||||
{
|
||||
column = m_tableColumns.get(columnIndex);
|
||||
header = getListHeaderComponent(column.getHeaderValue(), columnIndex, column.getColumnClass());
|
||||
header = getListHeaderComponent(column.getHeaderValue(), column.getTooltipText(), columnIndex, column.getColumnClass());
|
||||
head.appendChild(header);
|
||||
}
|
||||
head.setSizable(true);
|
||||
|
|
|
@ -371,7 +371,7 @@ public class WListbox extends Listbox implements IMiniTable, TableValueChangeLis
|
|||
}
|
||||
|
||||
// add to model
|
||||
addColumn(layout[columnIndex].getColHeader());
|
||||
addColumn(layout[columnIndex].getColHeader(), layout[columnIndex].getColDescription());
|
||||
|
||||
// set the colour column
|
||||
if (layout[columnIndex].isColorColumn())
|
||||
|
@ -429,16 +429,25 @@ public class WListbox extends Listbox implements IMiniTable, TableValueChangeLis
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param header
|
||||
*/
|
||||
@Override
|
||||
public void addColumn (String header)
|
||||
{
|
||||
addColumn(header, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Table Column and specify the column header.
|
||||
*
|
||||
* @param header name of column header
|
||||
* @param description
|
||||
*/
|
||||
public void addColumn (String header)
|
||||
public void addColumn (String header, String description)
|
||||
{
|
||||
WListItemRenderer renderer = (WListItemRenderer)getItemRenderer();
|
||||
renderer.addColumn(Util.cleanAmp(header));
|
||||
renderer.addColumn(Util.cleanAmp(header), description);
|
||||
getModel().addColumn();
|
||||
|
||||
return;
|
||||
|
|
|
@ -42,6 +42,8 @@ public class WTableColumn
|
|||
protected Object headerValue;
|
||||
|
||||
protected Class<?> columnClass;
|
||||
|
||||
protected String tooltipText;
|
||||
|
||||
/**
|
||||
* Cover method, using a default width of 75
|
||||
|
@ -272,4 +274,18 @@ public class WTableColumn
|
|||
{
|
||||
this.columnClass = columnClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return tooltip text
|
||||
*/
|
||||
public String getTooltipText() {
|
||||
return tooltipText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tooltipText
|
||||
*/
|
||||
public void setTooltipText(String tooltipText) {
|
||||
this.tooltipText = tooltipText;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2013 Heng Sin Low *
|
||||
* Copyright (C) 2013 Trek Global *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.info;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public interface IWhereClauseEditor {
|
||||
/**
|
||||
*
|
||||
* @return where clause
|
||||
*/
|
||||
public String getWhereClause();
|
||||
}
|
|
@ -11,12 +11,10 @@ import java.util.ArrayList;
|
|||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.AdempiereWebUI;
|
||||
import org.adempiere.webui.component.Borderlayout;
|
||||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.ListItem;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.ConfirmPanel;
|
||||
import org.adempiere.webui.component.ListModelTable;
|
||||
import org.adempiere.webui.component.Listbox;
|
||||
import org.adempiere.webui.component.ListboxFactory;
|
||||
import org.adempiere.webui.component.Tab;
|
||||
import org.adempiere.webui.component.Tabbox;
|
||||
|
@ -25,6 +23,10 @@ import org.adempiere.webui.component.Tabpanels;
|
|||
import org.adempiere.webui.component.Tabs;
|
||||
import org.adempiere.webui.component.Textbox;
|
||||
import org.adempiere.webui.component.WListbox;
|
||||
import org.adempiere.webui.editor.WEditor;
|
||||
import org.adempiere.webui.event.DialogEvents;
|
||||
import org.adempiere.webui.panel.InfoPAttributeInstancePanel;
|
||||
import org.adempiere.webui.panel.InvoiceHistory;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.compiere.minigrid.ColumnInfo;
|
||||
import org.compiere.model.MDocType;
|
||||
|
@ -51,11 +53,6 @@ public class InfoProductWindow extends InfoWindow {
|
|||
*/
|
||||
private static final long serialVersionUID = 4939032152860189380L;
|
||||
|
||||
private Label lblWarehouse;
|
||||
private Listbox pickWarehouse;
|
||||
private Label lblPriceList;
|
||||
private Listbox pickPriceList;
|
||||
|
||||
private Tabbox tabbedPane;
|
||||
private WListbox warehouseTbl;
|
||||
private String m_sqlWarehouse;
|
||||
|
@ -77,6 +74,11 @@ public class InfoProductWindow extends InfoWindow {
|
|||
|
||||
private Borderlayout contentBorderLayout;
|
||||
|
||||
/** Instance Button */
|
||||
private Button m_PAttributeButton;
|
||||
|
||||
protected int m_M_Locator_ID;
|
||||
|
||||
/**
|
||||
* @param WindowNo
|
||||
* @param tableName
|
||||
|
@ -119,10 +121,24 @@ public class InfoProductWindow extends InfoWindow {
|
|||
protected void createParameterPanel() {
|
||||
super.createParameterPanel();
|
||||
initParameters();
|
||||
addSearchParameter(lblWarehouse, pickWarehouse);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void renderWindow() {
|
||||
super.renderWindow();
|
||||
// Product Attribute Instance
|
||||
m_PAttributeButton = confirmPanel.createButton(ConfirmPanel.A_PATTRIBUTE);
|
||||
confirmPanel.addComponentsLeft(m_PAttributeButton);
|
||||
m_PAttributeButton.setEnabled(false);
|
||||
m_PAttributeButton.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
onPAttributeClick();
|
||||
}
|
||||
});
|
||||
m_PAttributeButton.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderContentPane(Center center) {
|
||||
ColumnInfo[] s_layoutWarehouse = new ColumnInfo[]{
|
||||
|
@ -262,7 +278,6 @@ public class InfoProductWindow extends InfoWindow {
|
|||
tabPanels.appendChild(desktopTabPanel);
|
||||
//
|
||||
int height = SessionManager.getAppDesktop().getClientInfo().desktopHeight * 90 / 100;
|
||||
// int width = SessionManager.getAppDesktop().getClientInfo().desktopWidth * 80 / 100;
|
||||
|
||||
contentBorderLayout = new Borderlayout();
|
||||
contentBorderLayout.setWidth("100%");
|
||||
|
@ -293,15 +308,9 @@ public class InfoProductWindow extends InfoWindow {
|
|||
public void onEvent(Event event) throws Exception {
|
||||
int row = contentPanel.getSelectedRow();
|
||||
if (row >= 0) {
|
||||
int M_Warehouse_ID = 0;
|
||||
ListItem listitem = pickWarehouse.getSelectedItem();
|
||||
if (listitem != null)
|
||||
M_Warehouse_ID = (Integer)listitem.getValue();
|
||||
int M_Warehouse_ID = getSelectedWarehouseId();
|
||||
|
||||
int M_PriceList_Version_ID = 0;
|
||||
listitem = pickPriceList.getSelectedItem();
|
||||
if (listitem != null)
|
||||
M_PriceList_Version_ID = (Integer)listitem.getValue();
|
||||
int M_PriceList_Version_ID = getSelectedPriceListVersionId();
|
||||
|
||||
for(int i = 0; i < columnInfos.length; i++) {
|
||||
if (columnInfos[i].getGridField() != null && columnInfos[i].getGridField().getColumnName().equals("Value")) {
|
||||
|
@ -309,80 +318,85 @@ public class InfoProductWindow extends InfoWindow {
|
|||
contentBorderLayout.getSouth().setOpen(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object value = contentPanel.getValueAt(row, findColumnIndex("IsInstanceAttribute"));
|
||||
if (value != null && value.toString().equals("true")) {
|
||||
m_PAttributeButton.setEnabled(true);
|
||||
} else {
|
||||
m_PAttributeButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initParameters() {
|
||||
lblWarehouse = new Label();
|
||||
lblWarehouse.setValue(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Warehouse")));
|
||||
|
||||
pickWarehouse = new Listbox();
|
||||
pickWarehouse.setMultiple(false);
|
||||
pickWarehouse.setMold("select");
|
||||
pickWarehouse.setHflex("1");
|
||||
pickWarehouse.addEventListener(Events.ON_SELECT, new EventListener<Event>() {
|
||||
private void onPAttributeClick() {
|
||||
Integer productInteger = getSelectedRowKey();
|
||||
String productName = (String)contentPanel.getValueAt(contentPanel.getSelectedRow(), findColumnIndex("Name"));
|
||||
|
||||
if (productInteger == null || productInteger.intValue() == 0)
|
||||
return;
|
||||
|
||||
int M_Warehouse_ID = getSelectedWarehouseId();
|
||||
if (M_Warehouse_ID <= 0)
|
||||
return;
|
||||
|
||||
String title = getSelectedWarehouseLabel() + " - " + productName;
|
||||
int C_BPartner_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BPartner_ID");;
|
||||
final InfoPAttributeInstancePanel pai = new InfoPAttributeInstancePanel(this, title,
|
||||
M_Warehouse_ID, 0, productInteger.intValue(), C_BPartner_ID);
|
||||
pai.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
ListItem item = InfoProductWindow.this.pickWarehouse.getSelectedItem();
|
||||
if (item != null && item.getValue() != null) {
|
||||
Env.setContext(infoContext, p_WindowNo, "Pick_Warehouse_ID", item.getValue().toString());
|
||||
} else {
|
||||
Env.setContext(infoContext, p_WindowNo, "Pick_Warehouse_ID", "0");
|
||||
}
|
||||
m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
|
||||
m_M_Locator_ID = pai.getM_Locator_ID();
|
||||
}
|
||||
});
|
||||
pickWarehouse.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "warehouse");
|
||||
|
||||
// Warehouse
|
||||
String sql = MRole.getDefault().addAccessSQL (
|
||||
"SELECT M_Warehouse_ID, Value || ' - ' || Name AS ValueName "
|
||||
+ "FROM M_Warehouse "
|
||||
+ "WHERE IsActive='Y'",
|
||||
"M_Warehouse", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO)
|
||||
+ " ORDER BY Value";
|
||||
pickWarehouse.appendItem("", new Integer(0));
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
pickWarehouse.appendItem(rs.getString("ValueName"), new Integer(rs.getInt("M_Warehouse_ID")));
|
||||
}
|
||||
|
||||
private String getSelectedWarehouseLabel() {
|
||||
for(WEditor editor : editors) {
|
||||
if (editor.getGridField() != null && editor.getGridField().getColumnName().equals("M_Warehouse_ID")) {
|
||||
Number value = (Number) editor.getValue();
|
||||
if (value != null)
|
||||
return editor.getDisplay();
|
||||
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
} finally {
|
||||
DB.close(rs, pstmt);
|
||||
}
|
||||
|
||||
lblPriceList = new Label();
|
||||
lblPriceList.setValue(Msg.getMsg(Env.getCtx(), "PriceListVersion"));
|
||||
|
||||
pickPriceList = new Listbox();
|
||||
pickPriceList.setMultiple(false);
|
||||
pickPriceList.setMold("select");
|
||||
pickPriceList.setHflex("1");
|
||||
pickPriceList.addEventListener(Events.ON_SELECT, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
ListItem item = InfoProductWindow.this.pickPriceList.getSelectedItem();
|
||||
if (item != null && item.getValue() != null) {
|
||||
Env.setContext(infoContext, p_WindowNo, "Pick_PriceList_ID", item.getValue().toString());
|
||||
} else {
|
||||
Env.setContext(infoContext, p_WindowNo, "Pick_PriceList_ID", "0");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected int getSelectedPriceListVersionId() {
|
||||
for(WEditor editor : editors) {
|
||||
if (editor.getGridField() != null && editor.getGridField().getColumnName().equals("M_PriceList_Version_ID")) {
|
||||
Number value = (Number) editor.getValue();
|
||||
if (value != null)
|
||||
return value.intValue();
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
pickPriceList.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "priceList");
|
||||
addSearchParameter(lblPriceList, pickPriceList);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getSelectedWarehouseId() {
|
||||
for(WEditor editor : editors) {
|
||||
if (editor.getGridField() != null && editor.getGridField().getColumnName().equals("M_Warehouse_ID")) {
|
||||
Number value = (Number) editor.getValue();
|
||||
if (value != null)
|
||||
return value.intValue();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void initParameters() {
|
||||
int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "M_Warehouse_ID");
|
||||
int M_PriceList_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "M_PriceList_ID");
|
||||
fillPickPriceList(M_PriceList_ID);
|
||||
|
||||
int M_PriceList_Version_ID = findPLV (M_PriceList_ID);
|
||||
// Set Warehouse
|
||||
|
@ -451,7 +465,6 @@ public class InfoProductWindow extends InfoWindow {
|
|||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
Env.setContext(Env.getCtx(), p_WindowNo, "M_PriceList_Version_ID", retValue);
|
||||
return retValue;
|
||||
} // findPLV
|
||||
|
||||
|
@ -462,13 +475,11 @@ public class InfoProductWindow extends InfoWindow {
|
|||
*/
|
||||
private void setWarehouse(int M_Warehouse_ID)
|
||||
{
|
||||
for (int i = 0; i < pickWarehouse.getItemCount(); i++)
|
||||
{
|
||||
Integer key = (Integer) pickWarehouse.getItemAtIndex(i).getValue();
|
||||
if (key == M_Warehouse_ID)
|
||||
{
|
||||
pickWarehouse.setSelectedIndex(i);
|
||||
Env.setContext(infoContext, p_WindowNo, "Pick_Warehouse_ID", M_Warehouse_ID);
|
||||
for(WEditor editor : editors) {
|
||||
if (editor.getGridField() != null && editor.getGridField().getColumnName().equals("M_Warehouse_ID")) {
|
||||
editor.setValue(M_Warehouse_ID);
|
||||
Env.setContext(infoContext, p_WindowNo, "M_Warehouse_ID", M_Warehouse_ID);
|
||||
Env.setContext(infoContext, p_WindowNo, Env.TAB_INFO, "M_Warehouse_ID", Integer.toString(M_Warehouse_ID));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -483,16 +494,16 @@ public class InfoProductWindow extends InfoWindow {
|
|||
{
|
||||
if (log.isLoggable(Level.CONFIG))
|
||||
log.config("M_PriceList_Version_ID=" + M_PriceList_Version_ID);
|
||||
for (int i = 0; i < pickPriceList.getItemCount(); i++)
|
||||
{
|
||||
Integer key = (Integer) pickPriceList.getItemAtIndex(i).getValue();
|
||||
if (key == M_PriceList_Version_ID)
|
||||
{
|
||||
pickPriceList.setSelectedIndex(i);
|
||||
Env.setContext(infoContext, "Pick_PriceList_Version_ID", M_PriceList_Version_ID);
|
||||
|
||||
for(WEditor editor : editors) {
|
||||
if (editor.getGridField() != null && editor.getGridField().getColumnName().equals("M_PriceList_Version_ID")) {
|
||||
editor.setValue(M_PriceList_Version_ID);
|
||||
Env.setContext(infoContext, p_WindowNo, "M_PriceList_Version_ID", M_PriceList_Version_ID);
|
||||
Env.setContext(infoContext, p_WindowNo, Env.TAB_INFO, "M_PriceList_Version_ID", Integer.toString(M_PriceList_Version_ID));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (log.isLoggable(Level.FINE))
|
||||
log.fine("NOT found");
|
||||
} // setPriceListVersion
|
||||
|
@ -751,49 +762,43 @@ public class InfoProductWindow extends InfoWindow {
|
|||
//
|
||||
m_tableAtp.autoSize();
|
||||
} // initAtpTab
|
||||
|
||||
/**
|
||||
* Fill Picks with values
|
||||
*
|
||||
* @param M_PriceList_ID price list
|
||||
*/
|
||||
private void fillPickPriceList (int M_PriceList_ID)
|
||||
{
|
||||
// Price List
|
||||
String SQL = "SELECT M_PriceList_Version.M_PriceList_Version_ID,"
|
||||
+ " M_PriceList_Version.Name || ' (' || c.Iso_Code || ')' AS ValueName "
|
||||
+ "FROM M_PriceList_Version, M_PriceList pl, C_Currency c "
|
||||
+ "WHERE M_PriceList_Version.M_PriceList_ID=pl.M_PriceList_ID"
|
||||
+ " AND pl.C_Currency_ID=c.C_Currency_ID"
|
||||
+ " AND M_PriceList_Version.IsActive='Y' AND pl.IsActive='Y'";
|
||||
// Same PL currency as original one
|
||||
if (M_PriceList_ID != 0)
|
||||
SQL += " AND EXISTS (SELECT * FROM M_PriceList xp WHERE xp.M_PriceList_ID=" + M_PriceList_ID
|
||||
+ " AND pl.C_Currency_ID=xp.C_Currency_ID)";
|
||||
// Add Access & Order
|
||||
SQL = MRole.getDefault().addAccessSQL (SQL, "M_PriceList_Version", true, false) // fully qualidfied - RO
|
||||
+ " ORDER BY M_PriceList_Version.Name";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
|
||||
@Override
|
||||
protected void showHistory() {
|
||||
log.info("");
|
||||
Integer M_Product_ID = getSelectedRowKey();
|
||||
if (M_Product_ID == null)
|
||||
return;
|
||||
int M_Warehouse_ID = getSelectedWarehouseId();
|
||||
int M_AttributeSetInstance_ID = m_M_AttributeSetInstance_ID;
|
||||
if (m_M_AttributeSetInstance_ID < -1) // not selected
|
||||
M_AttributeSetInstance_ID = 0;
|
||||
//
|
||||
InvoiceHistory ih = new InvoiceHistory (this, 0,
|
||||
M_Product_ID.intValue(), M_Warehouse_ID, M_AttributeSetInstance_ID);
|
||||
ih.setVisible(true);
|
||||
ih = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasHistory() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveSelectionDetail() {
|
||||
super.saveSelectionDetail();
|
||||
if (m_M_AttributeSetInstance_ID == -1) // not selected
|
||||
{
|
||||
pickPriceList.appendItem("",new Integer(0));
|
||||
pstmt = DB.prepareStatement(SQL, null);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
pickPriceList.appendItem(rs.getString(2),new Integer(rs.getInt(1)));
|
||||
}
|
||||
Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_AttributeSetInstance_ID", "0");
|
||||
Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_Locator_ID", "0");
|
||||
}
|
||||
catch (SQLException e)
|
||||
else
|
||||
{
|
||||
log.log(Level.SEVERE, SQL, e);
|
||||
setStatusLine(e.getLocalizedMessage(), true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_AttributeSetInstance_ID",
|
||||
String.valueOf(m_M_AttributeSetInstance_ID));
|
||||
Env.setContext(Env.getCtx(), p_WindowNo, Env.TAB_INFO, "M_Locator_ID",
|
||||
String.valueOf(m_M_Locator_ID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener {
|
|||
private Borderlayout layout;
|
||||
private Vbox southBody;
|
||||
/** List of WEditors */
|
||||
private List<WEditor> editors;
|
||||
protected List<WEditor> editors;
|
||||
protected Properties infoContext;
|
||||
|
||||
/** Max Length of Fields */
|
||||
|
@ -257,6 +257,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener {
|
|||
{
|
||||
columnInfo = new ColumnInfo(infoColumn.getName(), infoColumn.getSelectClause(), DisplayType.getClass(infoColumn.getAD_Reference_ID(), true));
|
||||
}
|
||||
columnInfo.setColDescription(infoColumn.getDescription());
|
||||
columnInfo.setGridField(gridFields.get(i));
|
||||
list.add(columnInfo);
|
||||
}
|
||||
|
@ -319,7 +320,17 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener {
|
|||
builder.append(tableInfos[0].getSynonym()).append(".IsActive='Y'");
|
||||
}
|
||||
for(WEditor editor : editors) {
|
||||
if (editor.getGridField() != null && editor.getValue() != null && editor.getValue().toString().trim().length() > 0) {
|
||||
if (editor instanceof IWhereClauseEditor) {
|
||||
String whereClause = ((IWhereClauseEditor) editor).getWhereClause();
|
||||
if (whereClause != null && whereClause.trim().length() > 0) {
|
||||
if (builder.length() > 0) {
|
||||
builder.append(" AND ");
|
||||
} else if (p_whereClause != null && p_whereClause.trim().length() > 0) {
|
||||
builder.append(" AND ");
|
||||
}
|
||||
builder.append(whereClause);
|
||||
}
|
||||
} else if (editor.getGridField() != null && editor.getValue() != null && editor.getValue().toString().trim().length() > 0) {
|
||||
MInfoColumn mInfoColumn = findInfoColumn(editor.getGridField());
|
||||
if (mInfoColumn == null || mInfoColumn.getSelectClause().equals("0")) {
|
||||
continue;
|
||||
|
@ -488,12 +499,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener {
|
|||
|
||||
protected void createParameterPanel() {
|
||||
parameterGrid = GridFactory.newGridLayout();
|
||||
// parameterGrid.setInnerWidth("auto");
|
||||
parameterGrid.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "infoParameterPanel");
|
||||
parameterGrid.setStyle("width: 90%; margin: auto;");
|
||||
Columns columns = new Columns();
|
||||
parameterGrid.appendChild(columns);
|
||||
for(int i = 0; i < 8; i++)
|
||||
for(int i = 0; i < 6; i++)
|
||||
columns.appendChild(new Column());
|
||||
|
||||
Rows rows = new Rows();
|
||||
|
@ -521,12 +531,19 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener {
|
|||
|
||||
// Editor
|
||||
WEditor editor = null;
|
||||
editor = WebEditorFactory.getEditor(mField, false);
|
||||
editor.setMandatory(false);
|
||||
editor.setReadWrite(true);
|
||||
editor.dynamicDisplay();
|
||||
editor.addValueChangeListener(this);
|
||||
editor.fillHorizontal();
|
||||
if (mField.getDisplayType() == DisplayType.PAttribute)
|
||||
{
|
||||
editor = new WInfoPAttributeEditor(infoContext, p_WindowNo, mField);
|
||||
}
|
||||
else
|
||||
{
|
||||
editor = WebEditorFactory.getEditor(mField, false);
|
||||
editor.setMandatory(false);
|
||||
editor.setReadWrite(true);
|
||||
editor.dynamicDisplay();
|
||||
editor.addValueChangeListener(this);
|
||||
editor.fillHorizontal();
|
||||
}
|
||||
Label label = editor.getLabel();
|
||||
Component fieldEditor = editor.getComponent();
|
||||
|
||||
|
@ -552,7 +569,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener {
|
|||
else
|
||||
{
|
||||
panel = (Row) parameterGrid.getRows().getLastChild();
|
||||
if (panel.getChildren().size() >= 8)
|
||||
if (panel.getChildren().size() >= 6)
|
||||
{
|
||||
panel = new Row();
|
||||
parameterGrid.getRows().appendChild(panel);
|
||||
|
@ -566,6 +583,16 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener {
|
|||
}
|
||||
panel.appendChild(fieldEditor);
|
||||
}
|
||||
|
||||
protected int findColumnIndex(String columnName) {
|
||||
for(int i = 0; i < columnInfos.length; i++) {
|
||||
GridField field = columnInfos[i].getGridField();
|
||||
if (field != null && field.getColumnName().equalsIgnoreCase(columnName)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Selection Details
|
||||
|
@ -681,7 +708,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener {
|
|||
if (otherEditor == editor)
|
||||
continue;
|
||||
|
||||
editor.dynamicDisplay();
|
||||
otherEditor.dynamicDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2013 Heng Sin Low *
|
||||
* Copyright (C) 2013 Trek Global *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.info;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.editor.WEditor;
|
||||
import org.adempiere.webui.event.DialogEvents;
|
||||
import org.adempiere.webui.panel.InfoPAttributePanel;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class WInfoPAttributeEditor extends WEditor implements IWhereClauseEditor {
|
||||
|
||||
private String m_pAttributeWhere;
|
||||
private Properties ctx;
|
||||
private int windowNo;
|
||||
|
||||
/**
|
||||
* @param comp
|
||||
* @param gridField
|
||||
*/
|
||||
public WInfoPAttributeEditor(Properties ctx, int windowNo, GridField gridField) {
|
||||
super(new Button(), gridField);
|
||||
this.ctx = ctx;
|
||||
this.windowNo = windowNo;
|
||||
getComponent().addEventListener(Events.ON_CLICK, this);
|
||||
getComponent().setImage("/images/PAttribute16.png");
|
||||
getComponent().setTooltiptext(Msg.getMsg(Env.getCtx(), "PAttribute"));
|
||||
setReadWrite(false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.zkoss.zk.ui.event.EventListener#onEvent(org.zkoss.zk.ui.event.Event)
|
||||
*/
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
if (event.getName().equals(Events.ON_CLICK)) {
|
||||
cmd_InfoPAttribute();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.adempiere.webui.editor.WEditor#setReadWrite(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setReadWrite(boolean readWrite) {
|
||||
getComponent().setEnabled(readWrite);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.adempiere.webui.editor.WEditor#isReadWrite()
|
||||
*/
|
||||
@Override
|
||||
public boolean isReadWrite() {
|
||||
return getComponent().isEnabled();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.adempiere.webui.editor.WEditor#setValue(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.adempiere.webui.editor.WEditor#getValue()
|
||||
*/
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.adempiere.webui.editor.WEditor#getDisplay()
|
||||
*/
|
||||
@Override
|
||||
public String getDisplay() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Button getComponent() {
|
||||
return (Button) super.getComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWhereClause() {
|
||||
return m_pAttributeWhere;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query per Product Attribute.
|
||||
* <code>
|
||||
* Available synonyms:
|
||||
* M_Product p
|
||||
* M_ProductPrice pr
|
||||
* M_AttributeSet pa
|
||||
* </code>
|
||||
*/
|
||||
private void cmd_InfoPAttribute()
|
||||
{
|
||||
int attributeSetId = Env.getContextAsInt(ctx, windowNo, Env.TAB_INFO, "M_AttributeSet_ID");
|
||||
final InfoPAttributePanel ia = new InfoPAttributePanel(attributeSetId);
|
||||
ia.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
m_pAttributeWhere = ia.getWhereClause();
|
||||
if (m_pAttributeWhere != null) {
|
||||
m_pAttributeWhere = m_pAttributeWhere.trim();
|
||||
if (m_pAttributeWhere.startsWith("AND ")) {
|
||||
m_pAttributeWhere = m_pAttributeWhere.substring(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} // cmdInfoAttribute
|
||||
|
||||
@Override
|
||||
public void dynamicDisplay() {
|
||||
int attributeSetId = Env.getContextAsInt(ctx, windowNo, Env.TAB_INFO, "M_AttributeSet_ID");
|
||||
setReadWrite(attributeSetId > 0);
|
||||
}
|
||||
}
|
|
@ -42,9 +42,9 @@ import org.compiere.util.Env;
|
|||
import org.compiere.util.KeyNamePair;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.HtmlBasedComponent;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zul.Cell;
|
||||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Separator;
|
||||
import org.zkoss.zul.Textbox;
|
||||
|
@ -71,11 +71,15 @@ public class InfoPAttributePanel extends Window implements EventListener<Event>
|
|||
* Called from InfoProduct,cmd_InfoPAttribute
|
||||
* @param parent
|
||||
*/
|
||||
public InfoPAttributePanel(Window parent)
|
||||
public InfoPAttributePanel(Object input)
|
||||
{
|
||||
super();
|
||||
if (parent instanceof InfoProductPanel) {
|
||||
p_M_AttributeSet_ID = ((InfoProductPanel)parent).getM_AttributeSet_ID();
|
||||
if (input != null) {
|
||||
if (input instanceof InfoProductPanel) {
|
||||
p_M_AttributeSet_ID = ((InfoProductPanel)input).getM_AttributeSet_ID();
|
||||
} else if (input instanceof Integer) {
|
||||
p_M_AttributeSet_ID = (Integer)input;
|
||||
}
|
||||
}
|
||||
setTitle(Msg.getMsg(Env.getCtx(), "InfoPAttribute"));
|
||||
this.setBorder("normal");
|
||||
|
@ -91,7 +95,10 @@ public class InfoPAttributePanel extends Window implements EventListener<Event>
|
|||
{
|
||||
log.log(Level.SEVERE, "InfoPAttribute", e);
|
||||
}
|
||||
AEnv.showCenterWindow(parent, this);
|
||||
if (input instanceof Window)
|
||||
AEnv.showCenterWindow((Window)input, this);
|
||||
else
|
||||
AEnv.showWindow(this);
|
||||
} // InfoPAttribute
|
||||
|
||||
/** Resulting Query */
|
||||
|
@ -251,22 +258,17 @@ public class InfoPAttributePanel extends Window implements EventListener<Event>
|
|||
{
|
||||
Row row = new Row();
|
||||
rows.appendChild(row);
|
||||
Cell cell = new Cell();
|
||||
cell.setColspan(2);
|
||||
row.appendCellChild(cell);
|
||||
Label group = new Label(Msg.translate(Env.getCtx(), "IsInstanceAttribute"));
|
||||
row.appendChild(group);
|
||||
rows.appendChild(row);
|
||||
Div div = new Div();
|
||||
div.setStyle("text-align: left;width: 100%");
|
||||
Label group = new Label(Msg.translate(Env.getCtx(), "IsInstanceAttribute"));
|
||||
div.appendChild(group);
|
||||
row.appendCellChild(div, 2);
|
||||
|
||||
row = new Row();
|
||||
rows.appendChild(row);
|
||||
cell = new Cell();
|
||||
cell.setColspan(2);
|
||||
row.appendCellChild(cell);
|
||||
Separator separator = new Separator();
|
||||
Separator separator = new Separator();
|
||||
separator.setBar(true);
|
||||
row.appendChild(separator);
|
||||
rows.appendChild(row);
|
||||
row.appendCellChild(separator, 2);
|
||||
|
||||
instanceLine = true;
|
||||
}
|
||||
|
@ -284,14 +286,13 @@ public class InfoPAttributePanel extends Window implements EventListener<Event>
|
|||
div.appendChild(label);
|
||||
row.appendChild(div);
|
||||
|
||||
Component field = null;
|
||||
HtmlBasedComponent field = null;
|
||||
if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attributeValueType))
|
||||
{
|
||||
field = new Listbox();
|
||||
((Listbox) field).setRows(0);
|
||||
((Listbox) field).setMultiple(false);
|
||||
((Listbox) field).setMold("select");
|
||||
((Listbox) field).setWidth("150px");
|
||||
KeyNamePair[] knp = getAttributeList(attribute_ID);
|
||||
for(int i = 0; i < knp.length; i++)
|
||||
((Listbox) field).appendItem(knp[i].getName(), knp[i]);
|
||||
|
@ -299,13 +300,13 @@ public class InfoPAttributePanel extends Window implements EventListener<Event>
|
|||
else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributeValueType))
|
||||
{
|
||||
field = new WNumberEditor(name, false, false, true, DisplayType.Number, name).getComponent();
|
||||
((NumberBox) field).setWidth("150px");
|
||||
}
|
||||
else
|
||||
{
|
||||
field = new WStringEditor(name, false, false, true, 10, 40, null, null).getComponent();
|
||||
((Textbox) field).setWidth("150px");
|
||||
}
|
||||
|
||||
field.setWidth("96%");
|
||||
row.appendChild(field);
|
||||
//
|
||||
field.setId(String.valueOf(attribute_ID));
|
||||
|
@ -357,22 +358,14 @@ public class InfoPAttributePanel extends Window implements EventListener<Event>
|
|||
if (isGuarantee || isSerial || isLot) {
|
||||
Row row = new Row();
|
||||
rows.appendChild(row);
|
||||
Cell cell = new Cell();
|
||||
cell.setColspan(2);
|
||||
row.appendCellChild(cell);
|
||||
Label group = new Label(Msg.translate(Env.getCtx(), "IsInstanceAttribute"));
|
||||
row.appendChild(group);
|
||||
rows.appendChild(row);
|
||||
Label group = new Label(Msg.translate(Env.getCtx(), "IsInstanceAttribute"));
|
||||
row.appendCellChild(group, 2);
|
||||
|
||||
row = new Row();
|
||||
rows.appendChild(row);
|
||||
cell = new Cell();
|
||||
cell.setColspan(2);
|
||||
row.appendCellChild(cell);
|
||||
Separator separator = new Separator();
|
||||
Separator separator = new Separator();
|
||||
separator.setBar(true);
|
||||
row.appendChild(separator);
|
||||
rows.appendChild(row);
|
||||
row.appendCellChild(separator, 2);
|
||||
|
||||
instanceLine = true;
|
||||
}
|
||||
|
|
|
@ -880,6 +880,10 @@ div.simileAjax-bubble-container {
|
|||
z-index: 2800 !important;
|
||||
}
|
||||
|
||||
.info-panel .z-window-overlapped-bl, .info-panel .z-window-highlighted-bl {
|
||||
background-color: #F4F4F4 !important;
|
||||
}
|
||||
|
||||
.info-panel .z-grid {
|
||||
border: none !important;
|
||||
}
|
||||
|
@ -896,7 +900,7 @@ div.simileAjax-bubble-container {
|
|||
.info-panel .z-south {
|
||||
margin-top: 2px;
|
||||
border-top: 1px solid #C5C5C5;
|
||||
background-color: #D2E0EB;
|
||||
background-color: #F4F4F4;
|
||||
}
|
||||
|
||||
.info-panel .z-window-highlighted-cnt {
|
||||
|
@ -1120,8 +1124,8 @@ tbody.z-grid-empty-body td {
|
|||
|
||||
.z-window-overlapped, .z-window-modal, .z-window-highlighted
|
||||
{
|
||||
border-top: 1px solid #c5c5c5;
|
||||
border-bottom: 1px solid #c5c5c5;
|
||||
border-top: 1px solid #c5c5c5 !important;
|
||||
border-bottom: 1px solid #c5c5c5 !important;
|
||||
}
|
||||
|
||||
.z-window-overlapped-hl, .z-window-popup-hl, .z-window-modal-hl, .z-window-highlighted-hl, .z-window-embedded-hl,
|
||||
|
|
|
@ -80,6 +80,8 @@ public class ColumnInfo
|
|||
private boolean m_colorColumn;
|
||||
private String m_keyPairColSQL = "";
|
||||
private GridField m_gridField;
|
||||
|
||||
private String colDescription;
|
||||
|
||||
/**
|
||||
* Get Col Class
|
||||
|
@ -204,4 +206,12 @@ public class ColumnInfo
|
|||
{
|
||||
return m_gridField;
|
||||
}
|
||||
|
||||
public String getColDescription() {
|
||||
return colDescription;
|
||||
}
|
||||
|
||||
public void setColDescription(String colDescription) {
|
||||
this.colDescription = colDescription;
|
||||
}
|
||||
} // infoColumn
|
||||
|
|
Loading…
Reference in New Issue