[ BF 2817358 ] - Can't set locator in CreateFromShipment dialog.
https://sourceforge.net/tracker/?func=detail&aid=2817358&group_id=176962&atid=879332
This commit is contained in:
parent
4629e3dd26
commit
4165725d46
|
@ -14,6 +14,7 @@
|
|||
|
||||
package org.compiere.grid;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -21,11 +22,12 @@ import java.sql.SQLException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.AbstractCellEditor;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
import org.adempiere.plaf.AdempierePLAF;
|
||||
import org.compiere.minigrid.IMiniTable;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MInOut;
|
||||
|
@ -39,6 +41,7 @@ import org.compiere.model.MProduct;
|
|||
import org.compiere.model.MRMA;
|
||||
import org.compiere.model.MRMALine;
|
||||
import org.compiere.model.MWarehouse;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -493,14 +496,64 @@ public class CreateFromShipment extends CreateFrom
|
|||
|
||||
} // infoInvoice
|
||||
|
||||
/**
|
||||
* Custom cell editor for setting locator from minitable.
|
||||
*
|
||||
* @author Daniel Tamm
|
||||
*
|
||||
*/
|
||||
public class InnerLocatorTableCellEditor extends AbstractCellEditor implements TableCellEditor {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7143484413792778213L;
|
||||
KeyNamePair currentValue;
|
||||
JTextField editor;
|
||||
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
String locatorValue = editor.getText();
|
||||
MLocator loc = null;
|
||||
try {
|
||||
// Lookup locator using value
|
||||
loc = new Query(Env.getCtx(), MLocator.Table_Name, "value=?", null)
|
||||
.setParameters(new Object[]{locatorValue})
|
||||
.setClient_ID()
|
||||
.first();
|
||||
// Set new keyNamePair for minitable
|
||||
currentValue = getLocatorKeyNamePair(loc.get_ID());
|
||||
|
||||
} catch (Exception e) {
|
||||
String message = Msg.getMsg(Env.getCtx(), "Invalid") + " " + editor.getText();
|
||||
JOptionPane.showMessageDialog(null, message);
|
||||
}
|
||||
return(currentValue);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table,
|
||||
Object value, boolean isSelected, int row, int column) {
|
||||
|
||||
currentValue = (KeyNamePair)value;
|
||||
editor = new JTextField();
|
||||
editor.setText(currentValue.getName());
|
||||
return(editor);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void configureMiniTable (IMiniTable miniTable)
|
||||
{
|
||||
miniTable.setColumnClass(0, Boolean.class, false); // Selection
|
||||
miniTable.setColumnClass(1, BigDecimal.class, false); // Qty
|
||||
miniTable.setColumnClass(2, String.class, true); // UOM
|
||||
miniTable.setColumnClass(3, String.class, false); // Locator
|
||||
//TableColumn col = miniTable.getColumnModel().getColumn(3);
|
||||
//col.setCellEditor(new InnerLocatorTableCellEditor());
|
||||
// Set custom cell editor to enable editing locators
|
||||
TableColumn col = miniTable.getColumn(3);
|
||||
col.setCellEditor(new InnerLocatorTableCellEditor());
|
||||
miniTable.setColumnClass(4, String.class, true); // Product
|
||||
miniTable.setColumnClass(5, String.class, true); // VendorProductNo
|
||||
miniTable.setColumnClass(6, String.class, true); // Order
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.compiere.minigrid;
|
|||
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import javax.swing.table.TableColumn;
|
||||
|
||||
import org.compiere.model.PO;
|
||||
|
||||
public interface IMiniTable
|
||||
|
@ -36,6 +38,10 @@ public interface IMiniTable
|
|||
|
||||
public ColumnInfo[] getLayoutInfo();
|
||||
|
||||
public TableColumn getColumn(int col);
|
||||
|
||||
public int getColumnCount();
|
||||
|
||||
public int getRowCount();
|
||||
|
||||
public void setMultiSelection(boolean multiSelection);
|
||||
|
|
|
@ -107,7 +107,25 @@ public class MiniTable extends CTable implements IMiniTable
|
|||
private static CLogger log = CLogger.getCLogger(MiniTable.class);
|
||||
/** Is Total Show */
|
||||
private boolean showTotals = false;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the swing column of given index. No index checking
|
||||
* is done.
|
||||
*
|
||||
* @param col
|
||||
* @return
|
||||
*/
|
||||
public TableColumn getColumn(int col) {
|
||||
return(getColumnModel().getColumn(col));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of columns in the mini table
|
||||
*/
|
||||
public int getColumnCount() {
|
||||
return(getColumnModel().getColumnCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Size Columns.
|
||||
* Uses Mimimum Column Size
|
||||
|
|
|
@ -26,6 +26,8 @@ import java.util.List;
|
|||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.swing.table.TableColumn;
|
||||
|
||||
import org.adempiere.webui.event.TableValueChangeEvent;
|
||||
import org.adempiere.webui.event.TableValueChangeListener;
|
||||
import org.adempiere.webui.event.WTableModelEvent;
|
||||
|
@ -1036,4 +1038,16 @@ public class WListbox extends Listbox implements IMiniTable, TableValueChangeLis
|
|||
//no op
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableColumn getColumn(int col) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue