- remove swing dependency from CreateFromShipment, IMiniTable and WListbox
This commit is contained in:
parent
05099dacae
commit
e930ee3960
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
package org.compiere.grid;
|
package org.compiere.grid;
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
@ -22,12 +21,6 @@ import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.logging.Level;
|
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 org.compiere.minigrid.IMiniTable;
|
import org.compiere.minigrid.IMiniTable;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.MInOut;
|
import org.compiere.model.MInOut;
|
||||||
|
@ -41,7 +34,6 @@ import org.compiere.model.MProduct;
|
||||||
import org.compiere.model.MRMA;
|
import org.compiere.model.MRMA;
|
||||||
import org.compiere.model.MRMALine;
|
import org.compiere.model.MRMALine;
|
||||||
import org.compiere.model.MWarehouse;
|
import org.compiere.model.MWarehouse;
|
||||||
import org.compiere.model.Query;
|
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
@ -495,65 +487,13 @@ public class CreateFromShipment extends CreateFrom
|
||||||
{
|
{
|
||||||
|
|
||||||
} // infoInvoice
|
} // 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)
|
protected void configureMiniTable (IMiniTable miniTable)
|
||||||
{
|
{
|
||||||
miniTable.setColumnClass(0, Boolean.class, false); // Selection
|
miniTable.setColumnClass(0, Boolean.class, false); // Selection
|
||||||
miniTable.setColumnClass(1, BigDecimal.class, false); // Qty
|
miniTable.setColumnClass(1, BigDecimal.class, false); // Qty
|
||||||
miniTable.setColumnClass(2, String.class, true); // UOM
|
miniTable.setColumnClass(2, String.class, true); // UOM
|
||||||
miniTable.setColumnClass(3, String.class, false); // Locator
|
miniTable.setColumnClass(3, String.class, false); // Locator
|
||||||
// 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(4, String.class, true); // Product
|
||||||
miniTable.setColumnClass(5, String.class, true); // VendorProductNo
|
miniTable.setColumnClass(5, String.class, true); // VendorProductNo
|
||||||
miniTable.setColumnClass(6, String.class, true); // Order
|
miniTable.setColumnClass(6, String.class, true); // Order
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package org.compiere.grid;
|
package org.compiere.grid;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
@ -28,23 +29,29 @@ import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.swing.AbstractCellEditor;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import javax.swing.table.TableCellEditor;
|
||||||
|
import javax.swing.table.TableColumn;
|
||||||
|
|
||||||
import org.compiere.apps.AEnv;
|
import org.compiere.apps.AEnv;
|
||||||
import org.compiere.grid.ed.VLocator;
|
import org.compiere.grid.ed.VLocator;
|
||||||
import org.compiere.grid.ed.VLookup;
|
import org.compiere.grid.ed.VLookup;
|
||||||
import org.compiere.minigrid.IMiniTable;
|
import org.compiere.minigrid.IMiniTable;
|
||||||
|
import org.compiere.minigrid.MiniTable;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.MDocType;
|
|
||||||
import org.compiere.model.MLocator;
|
import org.compiere.model.MLocator;
|
||||||
import org.compiere.model.MLocatorLookup;
|
import org.compiere.model.MLocatorLookup;
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.model.MLookup;
|
||||||
import org.compiere.model.MLookupFactory;
|
import org.compiere.model.MLookupFactory;
|
||||||
import org.compiere.model.MProduct;
|
import org.compiere.model.MProduct;
|
||||||
|
import org.compiere.model.Query;
|
||||||
import org.compiere.swing.CPanel;
|
import org.compiere.swing.CPanel;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
|
@ -54,8 +61,6 @@ import org.compiere.util.Msg;
|
||||||
|
|
||||||
public class VCreateFromShipmentUI extends CreateFromShipment implements ActionListener, VetoableChangeListener
|
public class VCreateFromShipmentUI extends CreateFromShipment implements ActionListener, VetoableChangeListener
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private VCreateFromDialog dialog;
|
private VCreateFromDialog dialog;
|
||||||
|
|
||||||
public VCreateFromShipmentUI(GridTab mTab)
|
public VCreateFromShipmentUI(GridTab mTab)
|
||||||
|
@ -477,6 +482,61 @@ public class VCreateFromShipmentUI extends CreateFromShipment implements ActionL
|
||||||
}
|
}
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configureMiniTable(IMiniTable miniTable) {
|
||||||
|
super.configureMiniTable(miniTable);
|
||||||
|
// Set custom cell editor to enable editing locators
|
||||||
|
MiniTable swingTable = (MiniTable) miniTable;
|
||||||
|
TableColumn col = swingTable.getColumn(3);
|
||||||
|
col.setCellEditor(new InnerLocatorTableCellEditor());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package org.compiere.minigrid;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
|
||||||
import javax.swing.table.TableColumn;
|
|
||||||
|
|
||||||
import org.compiere.model.PO;
|
import org.compiere.model.PO;
|
||||||
|
|
||||||
public interface IMiniTable
|
public interface IMiniTable
|
||||||
|
@ -37,9 +35,7 @@ public interface IMiniTable
|
||||||
public void setRowCount (int rowCount);
|
public void setRowCount (int rowCount);
|
||||||
|
|
||||||
public ColumnInfo[] getLayoutInfo();
|
public ColumnInfo[] getLayoutInfo();
|
||||||
|
|
||||||
public TableColumn getColumn(int col);
|
|
||||||
|
|
||||||
public int getColumnCount();
|
public int getColumnCount();
|
||||||
|
|
||||||
public int getRowCount();
|
public int getRowCount();
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class MiniTable extends CTable implements IMiniTable
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 2209340448348079989L;
|
private static final long serialVersionUID = 2853772547464132496L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
|
@ -747,14 +747,12 @@ public class MiniTable extends CTable implements IMiniTable
|
||||||
Object[] total = new Object[layout.length];
|
Object[] total = new Object[layout.length];
|
||||||
|
|
||||||
for (int row = 0 ; row < getRowCount(); row ++)
|
for (int row = 0 ; row < getRowCount(); row ++)
|
||||||
{
|
{
|
||||||
|
|
||||||
int colOffset = 1; // columns start with 1
|
|
||||||
for (int col = 0; col < layout.length; col++)
|
for (int col = 0; col < layout.length; col++)
|
||||||
{
|
{
|
||||||
Object data = getModel().getValueAt(row, col);
|
Object data = getModel().getValueAt(row, col);
|
||||||
Class<?> c = layout[col].getColClass();
|
Class<?> c = layout[col].getColClass();
|
||||||
int colIndex = col + colOffset;
|
|
||||||
if (c == BigDecimal.class)
|
if (c == BigDecimal.class)
|
||||||
{
|
{
|
||||||
BigDecimal subtotal = Env.ZERO;
|
BigDecimal subtotal = Env.ZERO;
|
||||||
|
@ -789,11 +787,9 @@ public class MiniTable extends CTable implements IMiniTable
|
||||||
|
|
||||||
int row = getRowCount() + 1;
|
int row = getRowCount() + 1;
|
||||||
setRowCount(row);
|
setRowCount(row);
|
||||||
int colOffset = 1; // columns start with 1
|
|
||||||
for (int col = 0; col < layout.length; col++)
|
for (int col = 0; col < layout.length; col++)
|
||||||
{
|
{
|
||||||
Class<?> c = layout[col].getColClass();
|
Class<?> c = layout[col].getColClass();
|
||||||
int colIndex = col + colOffset;
|
|
||||||
if (c == BigDecimal.class)
|
if (c == BigDecimal.class)
|
||||||
{
|
{
|
||||||
setValueAt(total[col] , row - 1, col);
|
setValueAt(total[col] , row - 1, col);
|
||||||
|
@ -826,14 +822,12 @@ public class MiniTable extends CTable implements IMiniTable
|
||||||
Object[] total = new Object[layout.length];
|
Object[] total = new Object[layout.length];
|
||||||
|
|
||||||
for (int row = 0 ; row < getRowCount(); row ++)
|
for (int row = 0 ; row < getRowCount(); row ++)
|
||||||
{
|
{
|
||||||
|
|
||||||
int colOffset = 1; // columns start with 1
|
|
||||||
for (int col = 0; col < layout.length; col++)
|
for (int col = 0; col < layout.length; col++)
|
||||||
{
|
{
|
||||||
Object data = getModel().getValueAt(row, col);
|
Object data = getModel().getValueAt(row, col);
|
||||||
Class<?> c = layout[col].getColClass();
|
Class<?> c = layout[col].getColClass();
|
||||||
int colIndex = col + colOffset;
|
|
||||||
if (c == BigDecimal.class)
|
if (c == BigDecimal.class)
|
||||||
{
|
{
|
||||||
BigDecimal subtotal = Env.ZERO;
|
BigDecimal subtotal = Env.ZERO;
|
||||||
|
@ -868,11 +862,9 @@ public class MiniTable extends CTable implements IMiniTable
|
||||||
|
|
||||||
int row = getRowCount() + 1;
|
int row = getRowCount() + 1;
|
||||||
setRowCount(row);
|
setRowCount(row);
|
||||||
int colOffset = 1; // columns start with 1
|
|
||||||
for (int col = 0; col < layout.length; col++)
|
for (int col = 0; col < layout.length; col++)
|
||||||
{
|
{
|
||||||
Class<?> c = layout[col].getColClass();
|
Class<?> c = layout[col].getColClass();
|
||||||
int colIndex = col + colOffset;
|
|
||||||
if (c == BigDecimal.class)
|
if (c == BigDecimal.class)
|
||||||
{
|
{
|
||||||
setValueAt(total[col] , row - 1, col);
|
setValueAt(total[col] , row - 1, col);
|
||||||
|
|
|
@ -23,11 +23,8 @@ import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.swing.table.TableColumn;
|
|
||||||
|
|
||||||
import org.adempiere.webui.event.TableValueChangeEvent;
|
import org.adempiere.webui.event.TableValueChangeEvent;
|
||||||
import org.adempiere.webui.event.TableValueChangeListener;
|
import org.adempiere.webui.event.TableValueChangeListener;
|
||||||
import org.adempiere.webui.event.WTableModelEvent;
|
import org.adempiere.webui.event.WTableModelEvent;
|
||||||
|
@ -1038,16 +1035,8 @@ public class WListbox extends Listbox implements IMiniTable, TableValueChangeLis
|
||||||
//no op
|
//no op
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableColumn getColumn(int col) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
// TODO Auto-generated method stub
|
return getModel() != null ? getModel().getNoColumns() : 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue