use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.
the class TablesQueryDesigner method updateQueryText.
private void updateQueryText() {
String query = "";
DefaultTableModel model = (DefaultTableModel) queryTable.getModel();
for (int i = 0; i != model.getRowCount(); i++) {
LogicalOperator logicalOperator = (LogicalOperator) model.getValueAt(i, 1);
QueryField queryField = (QueryField) model.getValueAt(i, 2);
Operator operator = (Operator) model.getValueAt(i, 3);
String value = model.getValueAt(i, 4).toString();
if (queryField == QueryField.Timestamp) {
try {
Date date = new SimpleDateFormat().parse(value);
value = "datetime'" + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(date) + "'";
} catch (ParseException ignored) {
}
} else {
value = "'" + value + "'";
}
query = query + String.format("%s %s %s %s ", (i == 0) ? "" : logicalOperator.toString().toLowerCase(), queryField.toString(), getOperatorWCF(operator), value);
}
queryTextArea.setText(query);
}
use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.
the class AzureSelectDockerHostStep method onViewDockerHostAction.
private void onViewDockerHostAction() {
try {
DefaultTableModel tableModel = (DefaultTableModel) dockerHostsTable.getModel();
String apiURL = (String) tableModel.getValueAt(dockerHostsTable.getSelectedRow(), 4);
DockerHost dockerHost = dockerManager.getDockerHostForURL(apiURL);
if (dockerHost == null) {
throw new RuntimeException(String.format("Unexpected error: can't locate the Docker host for %s!", apiURL));
}
// TODO: Check if dockerHost.certVault and dockerHost.hostVM have valid values and if not warn
AzureViewDockerDialog viewDockerDialog = new AzureViewDockerDialog(model.getProject(), dockerHost, dockerManager);
viewDockerDialog.show();
if (viewDockerDialog.getInternalExitCode() == AzureViewDockerDialog.UPDATE_EXIT_CODE) {
onEditDockerHostAction();
}
} catch (Exception e) {
String msg = "An error occurred while attempting to view the selected Docker host.\n" + e.getMessage();
PluginUtil.displayErrorDialogAndLog("Error", msg, e);
if (AzureDockerUtils.DEBUG)
e.printStackTrace();
LOGGER.error("onViewDockerHostAction", e);
PluginUtil.displayErrorDialog("View Docker Hosts Error", msg);
}
}
use of javax.swing.table.DefaultTableModel in project adempiere by adempiere.
the class RecordInfo method dynInit.
// jbInit
/**
* Dynamic Init
*/
protected void dynInit() {
DefaultTableModel model = new DefaultTableModel(getData(), getColumnNames());
table.setModel(model);
table.autoSize(false);
}
use of javax.swing.table.DefaultTableModel in project adempiere by adempiere.
the class InvoiceHistory method initAtpTab.
// initUnconfirmedTab
/**
* Query ATP
*/
private void initAtpTab() {
// Done already
if (m_modelAtp != null)
return;
// Header
Vector<String> columnNames = new Vector<String>();
columnNames.add(Msg.translate(Env.getCtx(), "Date"));
columnNames.add(Msg.translate(Env.getCtx(), "QtyOnHand"));
columnNames.add(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "QtyOrdered"));
columnNames.add(Msg.translate(Env.getCtx(), "QtyReserved"));
columnNames.add(Msg.translate(Env.getCtx(), "M_Locator_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo"));
columnNames.add(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));
// Fill Storage Data
boolean showDetail = CLogMgt.isLevelFine();
String sql = "SELECT s.QtyOnHand, s.QtyReserved, s.QtyOrdered," + " productAttribute(s.M_AttributeSetInstance_ID), s.M_AttributeSetInstance_ID,";
if (!showDetail)
sql = "SELECT SUM(s.QtyOnHand), SUM(s.QtyReserved), SUM(s.QtyOrdered)," + " productAttribute(s.M_AttributeSetInstance_ID), 0,";
sql += " w.Name, l.Value " + "FROM M_Storage s" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Warehouse w ON (l.M_Warehouse_ID=w.M_Warehouse_ID) " + "WHERE M_Product_ID=?";
if (m_M_Warehouse_ID != 0)
sql += " AND l.M_Warehouse_ID=?";
if (m_M_AttributeSetInstance_ID > 0)
sql += " AND s.M_AttributeSetInstance_ID=?";
sql += " AND (s.QtyOnHand<>0 OR s.QtyReserved<>0 OR s.QtyOrdered<>0)";
if (!showDetail)
sql += " GROUP BY productAttribute(s.M_AttributeSetInstance_ID), w.Name, l.Value";
sql += " ORDER BY l.Value";
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
double qty = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
if (m_M_Warehouse_ID != 0)
pstmt.setInt(2, m_M_Warehouse_ID);
if (m_M_AttributeSetInstance_ID > 0)
pstmt.setInt(3, m_M_AttributeSetInstance_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
Vector<Object> line = new Vector<Object>(9);
// Date
line.add(null);
double qtyOnHand = rs.getDouble(1);
qty += qtyOnHand;
// Qty
line.add(new Double(qtyOnHand));
// BPartner
line.add(null);
// QtyOrdered
line.add(new Double(rs.getDouble(3)));
// QtyReserved
line.add(new Double(rs.getDouble(2)));
// Locator
line.add(rs.getString(7));
String asi = rs.getString(4);
if (showDetail && (asi == null || asi.length() == 0))
asi = "{" + rs.getInt(5) + "}";
// ASI
line.add(asi);
// DocumentNo
line.add(null);
// Warehouse
line.add(rs.getString(6));
data.add(line);
}
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Orders
sql = "SELECT o.DatePromised, ol.QtyReserved," + " productAttribute(ol.M_AttributeSetInstance_ID), ol.M_AttributeSetInstance_ID," + " dt.DocBaseType, bp.Name," + " dt.PrintName || ' ' || o.DocumentNo As DocumentNo, w.Name " + "FROM C_Order o" + " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID)" + " INNER JOIN C_DocType dt ON (o.C_DocType_ID=dt.C_DocType_ID)" + " INNER JOIN M_Warehouse w ON (ol.M_Warehouse_ID=w.M_Warehouse_ID)" + " INNER JOIN C_BPartner bp ON (o.C_BPartner_ID=bp.C_BPartner_ID) " + "WHERE ol.QtyReserved<>0" + " AND ol.M_Product_ID=?";
if (m_M_Warehouse_ID != 0)
sql += " AND ol.M_Warehouse_ID=?";
if (m_M_AttributeSetInstance_ID > 0)
sql += " AND ol.M_AttributeSetInstance_ID=?";
sql += " ORDER BY o.DatePromised";
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
if (m_M_Warehouse_ID != 0)
pstmt.setInt(2, m_M_Warehouse_ID);
if (m_M_AttributeSetInstance_ID > 0)
pstmt.setInt(3, m_M_AttributeSetInstance_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
Vector<Object> line = new Vector<Object>(9);
// Date
line.add(rs.getTimestamp(1));
double oq = rs.getDouble(2);
String DocBaseType = rs.getString(5);
Double qtyReserved = null;
Double qtyOrdered = null;
if (MDocType.DOCBASETYPE_PurchaseOrder.equals(DocBaseType)) {
qtyOrdered = new Double(oq);
qty += oq;
} else {
qtyReserved = new Double(oq);
qty -= oq;
}
// Qty
line.add(new Double(qty));
// BPartner
line.add(rs.getString(6));
// QtyOrdered
line.add(qtyOrdered);
// QtyReserved
line.add(qtyReserved);
// Locator
line.add(null);
String asi = rs.getString(3);
if (showDetail && (asi == null || asi.length() == 0))
asi = "{" + rs.getInt(4) + "}";
// ASI
line.add(asi);
// DocumentNo
line.add(rs.getString(7));
// Warehouse
line.add(rs.getString(8));
data.add(line);
}
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// Table
MiniTable table = null;
m_modelAtp = new DefaultTableModel(data, columnNames);
m_tableAtp.setModel(m_modelAtp);
table = m_tableAtp;
//
// Date
table.setColumnClass(0, Timestamp.class, true);
// Quantity
table.setColumnClass(1, Double.class, true);
// Partner
table.setColumnClass(2, String.class, true);
// Quantity
table.setColumnClass(3, Double.class, true);
// Quantity
table.setColumnClass(4, Double.class, true);
// Locator
table.setColumnClass(5, String.class, true);
// ASI
table.setColumnClass(6, String.class, true);
// DocNo
table.setColumnClass(7, String.class, true);
// Warehouse
table.setColumnClass(8, String.class, true);
//
table.autoSize();
}
use of javax.swing.table.DefaultTableModel in project adempiere by adempiere.
the class InvoiceHistory method dynInit.
// jbInit
/**
* Dynamic Init for Price Tab
*/
private boolean dynInit() {
// Header
Vector<String> columnNames = new Vector<String>();
columnNames.add(Msg.translate(Env.getCtx(), m_C_BPartner_ID == 0 ? "C_BPartner_ID" : "M_Product_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "PriceActual"));
columnNames.add(Msg.translate(Env.getCtx(), "QtyInvoiced"));
columnNames.add(Msg.translate(Env.getCtx(), "Discount"));
columnNames.add(Msg.translate(Env.getCtx(), "DocumentNo"));
columnNames.add(Msg.translate(Env.getCtx(), "DateInvoiced"));
columnNames.add(Msg.translate(Env.getCtx(), "AD_Org_ID"));
// Fill Data
Vector<Vector<Object>> data = null;
if (m_C_BPartner_ID == 0)
// BPartner of Product
data = queryBPartner(true);
else
// Product of BPartner
data = queryProduct(true);
// Table
m_modelPrice = new DefaultTableModel(data, columnNames);
m_tablePrice.setModel(m_modelPrice);
//
// Product/Partner
m_tablePrice.setColumnClass(0, String.class, true);
// Price
m_tablePrice.setColumnClass(1, Double.class, true);
// Quantity
m_tablePrice.setColumnClass(2, Double.class, true);
// Discount (%) to limit precision
m_tablePrice.setColumnClass(3, BigDecimal.class, true);
// DocNo
m_tablePrice.setColumnClass(4, String.class, true);
// Date
m_tablePrice.setColumnClass(5, Timestamp.class, true);
// Org
m_tablePrice.setColumnClass(6, String.class, true);
//
m_tablePrice.autoSize();
//
return data.size() != 0;
}
Aggregations