Search in sources :

Example 1 with ColumnInfo

use of org.compiere.minigrid.ColumnInfo in project adempiere by adempiere.

the class PaySelect method prepareTable.

public void prepareTable(IMiniTable miniTable) {
    Properties ctx = Env.getCtx();
    /**  prepare MiniTable
		 *
		SELECT i.C_Invoice_ID, i.C_InvoicePaySchedule_ID, i.DateInvoiced+p.NetDays AS DateDue,
		bp.Name, i.DocumentNo, c.ISO_Code, i.GrandTotal,
		paymentTermDiscount(i.GrandTotal, i.C_PaymentTerm_ID, i.DateInvoiced, SysDate) AS Discount,
		SysDate-paymentTermDueDays(i.C_PaymentTerm_ID,i.DateInvoiced) AS DiscountDate,
		i.GrandTotal-paymentTermDiscount(i.GrandTotal,i.C_PaymentTerm_ID,i.DateInvoiced,SysDate) AS DueAmount,
		currencyConvert(i.GrandTotal-paymentTermDiscount(i.GrandTotal,i.C_PaymentTerm_ID,i.DateInvoiced,SysDate,null),
			i.C_Currency_ID,xx100,SysDate) AS PayAmt
		FROM C_Invoice_v i, C_BPartner bp, C_Currency c, C_PaymentTerm p
		WHERE i.IsSOTrx='N'
		AND i.C_BPartner_ID=bp.C_BPartner_ID
		AND i.C_Currency_ID=c.C_Currency_ID
		AND i.C_PaymentTerm_ID=p.C_PaymentTerm_ID
		AND i.DocStatus IN ('CO','CL')
		ORDER BY 2,3
		 */
    //  release/380 Improve speed
    String numPayments = "COALESCE((SELECT COUNT(ps.C_PaymentTerm_ID)" + " 		FROM" + " 			C_PaySchedule ps, C_InvoicePaySchedule cips" + " 		WHERE" + " 			ps.C_PaySchedule_ID = cips.C_PaySchedule_ID" + " 			AND cips.C_INVOICE_ID = i.C_Invoice_ID" + " 			AND cips.duedate <= i.duedate" + " 		GROUP BY ps.C_PaymentTerm_ID),1)  || ' / ' ||" + " 		COALESCE((SELECT COUNT(ps.C_PaymentTerm_ID) AS maxpayno" + " 		    FROM " + " 			C_PaySchedule ps, C_InvoicePaySchedule cips" + " 		WHERE " + " 			ps.C_PaySchedule_ID = cips.C_PaySchedule_ID" + " 			AND cips.C_INVOICE_ID = i.C_Invoice_ID" + " 		GROUP BY ps.C_PaymentTerm_ID),1)";
    m_sql = miniTable.prepareTable(new ColumnInfo[] { //  0..5
    new ColumnInfo(" ", "i.C_Invoice_ID", IDColumn.class, true, false, null), new ColumnInfo(Msg.translate(ctx, "DueDate"), "COALESCE(ips.duedate,paymentTermDueDate(i.C_PaymentTerm_ID, i.DateInvoiced)) AS DateDue", Timestamp.class, true, true, null), new ColumnInfo(Msg.translate(ctx, "C_BPartner_ID"), "bp.Name", KeyNamePair.class, true, false, "i.C_BPartner_ID"), new ColumnInfo(Msg.translate(ctx, "DocumentNo"), "i.DocumentNo", String.class), new ColumnInfo(Msg.getMsg(ctx, "Payment #"), numPayments, KeyNamePair.class, true, false, "i.C_InvoicePaySchedule_ID"), new ColumnInfo(Msg.translate(ctx, "C_Currency_ID"), "c.ISO_Code", KeyNamePair.class, true, false, "i.C_Currency_ID"), // 6..11
    new ColumnInfo(Msg.translate(ctx, "GrandTotal"), "i.GrandTotal", BigDecimal.class), new ColumnInfo(Msg.translate(ctx, "DiscountAmt"), "paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?)", BigDecimal.class), new ColumnInfo(Msg.getMsg(ctx, "DiscountDate"), "SysDate-paymentTermDueDays(i.C_PaymentTerm_ID,i.DateInvoiced,SysDate)", Timestamp.class), new ColumnInfo(Msg.getMsg(ctx, "AmountDue"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class), new ColumnInfo(Msg.getMsg(ctx, "AmountPay"), "currencyConvert(invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID)-paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?),i.C_Currency_ID, ?,?,i.C_ConversionType_ID, i.AD_Client_ID,i.AD_Org_ID)", BigDecimal.class), new ColumnInfo(Msg.translate(ctx, "PaySched_ID"), "i.C_InvoicePaySchedule_ID", Integer.class) }, //	FROM
    "C_Invoice_v i" + " INNER JOIN C_BPartner bp ON (i.C_BPartner_ID=bp.C_BPartner_ID)" + " INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID)" + " INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID)" + " LEFT OUTER JOIN C_InvoicePaySchedule ips ON (i.C_InvoicePaySchedule_ID = ips.C_InvoicePaySchedule_ID)", //	WHERE
    "i.IsSOTrx=? AND IsPaid='N'" + // And a payment is needed
    " AND invoiceOpen(i.C_Invoice_ID,i.C_InvoicePaySchedule_ID)-paymentTermDiscount(i.GrandTotal,i.C_Currency_ID,i.C_PaymentTerm_ID,i.DateInvoiced, ?) != 0.0" + //  BR3450248 - Partially paid invoice does not appear in payment selection
    " AND NOT EXISTS (SELECT * FROM C_PaySelectionLine psl" + " INNER JOIN C_PaySelectionCheck psc ON (psl.C_PaySelectionCheck_ID=psc.C_PaySelectionCheck_ID)" + " LEFT OUTER JOIN C_Payment pmt ON (pmt.C_Payment_ID=psc.C_Payment_ID)" + " WHERE i.C_Invoice_ID=psl.C_Invoice_ID AND (i.C_InvoicePaySchedule_ID IS NULL OR i.C_InvoicePaySchedule_ID=0)" + " AND psl.IsActive='Y'" + " AND (pmt.DocStatus IS NULL OR pmt.DocStatus NOT IN ('VO','RE'))" + " AND psl.differenceamt = 0.0)" + " AND i.DocStatus IN ('CO','CL')" + //	additional where & order in loadTableInfo()
    " AND i.AD_Client_ID=?", true, "i");
}
Also used : ColumnInfo(org.compiere.minigrid.ColumnInfo) Properties(java.util.Properties)

Example 2 with ColumnInfo

use of org.compiere.minigrid.ColumnInfo in project adempiere by adempiere.

the class WMatch method dynInit.

//  jbInit
/**
	 *  Dynamic Init.
	 *  Table Layout, Visual, Listener
	 */
private void dynInit() {
    ColumnInfo[] layout = new ColumnInfo[] { new ColumnInfo(" ", ".", IDColumn.class, false, false, ""), //  1
    new ColumnInfo(Msg.translate(Env.getCtx(), "DocumentNo"), ".", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Date"), ".", Timestamp.class), //  3
    new ColumnInfo(Msg.translate(Env.getCtx(), "C_BPartner_ID"), ".", KeyNamePair.class, "."), new ColumnInfo(Msg.translate(Env.getCtx(), "Line"), ".", KeyNamePair.class, "."), //  5
    new ColumnInfo(Msg.translate(Env.getCtx(), "M_Product_ID"), ".", KeyNamePair.class, "."), new ColumnInfo(Msg.translate(Env.getCtx(), "Qty"), ".", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Matched"), ".", Double.class) };
    xMatchedTable.prepareTable(layout, "", "", false, "");
    xMatchedToTable.prepareTable(layout, "", "", true, "");
    matchFrom.setSelectedIndex(0);
    //  Listener
    matchFrom.addActionListener(this);
    matchTo.addActionListener(this);
    bSearch.addActionListener(this);
    xMatchedTable.addEventListener(Events.ON_SELECT, this);
    xMatchedToTable.getModel().addTableModelListener(this);
    bProcess.addActionListener(this);
    sameBPartner.addActionListener(this);
    sameProduct.addActionListener(this);
    sameQty.addActionListener(this);
    //  Init Yvonne
    String selection = (String) matchFrom.getSelectedItem().getValue();
    SimpleListModel model = new SimpleListModel(cmd_matchFrom((String) matchFrom.getSelectedItem().getLabel()));
    matchTo.setItemRenderer(model);
    matchTo.setModel(model);
    //  Set Title
    xMatchedBorder.setValue(selection);
    //  Reset Table
    xMatchedTable.setRowCount(0);
    //  sync To
    matchTo.setSelectedIndex(0);
    cmd_matchTo();
    statusBar.setStatusLine("");
    statusBar.setStatusDB("0");
}
Also used : SimpleListModel(org.adempiere.webui.component.SimpleListModel) ColumnInfo(org.compiere.minigrid.ColumnInfo)

Example 3 with ColumnInfo

use of org.compiere.minigrid.ColumnInfo in project adempiere by adempiere.

the class InfoProduct method statInit.

/**
	 *	Static Setup - add fields to parameterPanel
	 */
private void statInit() {
    labelValue.setText(Msg.getMsg(Env.getCtx(), "Value"));
    fieldValue.setBackground(AdempierePLAF.getInfoBackground());
    fieldValue.addActionListener(this);
    labelName.setText(Msg.getMsg(Env.getCtx(), "Name"));
    fieldName.setBackground(AdempierePLAF.getInfoBackground());
    fieldName.addActionListener(this);
    labelUPC.setText(Msg.translate(Env.getCtx(), "UPC"));
    fieldUPC.setBackground(AdempierePLAF.getInfoBackground());
    fieldUPC.addActionListener(this);
    labelSKU.setText(Msg.translate(Env.getCtx(), "SKU"));
    fieldSKU.setBackground(AdempierePLAF.getInfoBackground());
    fieldSKU.addActionListener(this);
    labelWarehouse.setText(Msg.getMsg(Env.getCtx(), "Warehouse"));
    fWarehouse_ID = new VLookup("M_Warehouse_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MWarehouse.Table_Name, MWarehouse.COLUMNNAME_M_Warehouse_ID), DisplayType.TableDir));
    fWarehouse_ID.setBackground(AdempierePLAF.getInfoBackground());
    fWarehouse_ID.addActionListener(this);
    checkOnlyStock.setText(Msg.getMsg(Env.getCtx(), "OnlyStock"));
    checkOnlyStock.setName("OnlyStock");
    checkOnlyStock.setToolTipText(Msg.getMsg(Env.getCtx(), "OnlyStockTip"));
    // Info may open when searching for non-stock as well.
    checkOnlyStock.setSelected(false);
    checkOnlyStock.addActionListener(this);
    checkShowDetail.setText(Msg.getMsg(Env.getCtx(), "ShowDetail"));
    checkShowDetail.setName("ShowDetail");
    checkShowDetail.setToolTipText(Msg.getMsg(Env.getCtx(), "ShowAttributeDetails"));
    checkShowDetail.setSelected(false);
    checkShowDetail.setEnabled(false);
    checkShowDetail.addActionListener(this);
    checkAND.setText(Msg.getMsg(Env.getCtx(), "SearchAND"));
    checkAND.setName("SearchAND");
    checkAND.setToolTipText(Msg.getMsg(Env.getCtx(), "SearchANDInfo"));
    checkAND.setSelected(true);
    checkAND.addActionListener(this);
    labelPriceList.setText(Msg.getMsg(Env.getCtx(), "PriceListVersion"));
    fPriceList_ID = new VLookup("M_PriceList_Version_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MPriceListVersion.Table_Name, MPriceListVersion.COLUMNNAME_M_PriceList_Version_ID), DisplayType.TableDir));
    fPriceList_ID.setBackground(AdempierePLAF.getInfoBackground());
    fPriceList_ID.addActionListener(this);
    labelProductCategory.setText(Msg.translate(Env.getCtx(), "M_Product_Category_ID"));
    fProductCategory_ID = new VLookup("M_Product_Category_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MProductCategory.Table_Name, MProductCategory.COLUMNNAME_M_Product_Category_ID), DisplayType.TableDir));
    fProductCategory_ID.setBackground(AdempierePLAF.getInfoBackground());
    fProductCategory_ID.addActionListener(this);
    // @Trifon
    labelAS.setText(Msg.translate(Env.getCtx(), "M_AttributeSet_ID"));
    fAS_ID = new VLookup("M_AttributeSet_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MAttributeSet.Table_Name, MAttributeSet.COLUMNNAME_M_AttributeSet_ID), DisplayType.TableDir));
    fAS_ID.setBackground(AdempierePLAF.getInfoBackground());
    fAS_ID.addActionListener(this);
    //
    labelASI.setText(Msg.translate(Env.getCtx(), "M_AttributeSetInstance_ID"));
    MPAttributeLookup mpaLookup = new MPAttributeLookup(Env.getCtx(), p_WindowNo);
    fASI_ID = new VPAttribute((GridTab) null, false, false, true, p_WindowNo, mpaLookup, true);
    fASI_ID.setBackground(AdempierePLAF.getInfoBackground());
    fASI_ID.addActionListener(this);
    labelVendor.setText(Msg.translate(Env.getCtx(), "Vendor"));
    fVendor_ID = new VLookup("C_BPartner_ID", false, false, true, MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MProductPO.Table_Name, MProductPO.COLUMNNAME_C_BPartner_ID), DisplayType.Search));
    fVendor_ID.setBackground(AdempierePLAF.getInfoBackground());
    fVendor_ID.addActionListener(this);
    // Override the isSOTrx context, Vendors only
    fVendor_ID.setIsSOTrx(true, false);
    //  Setup the Grid
    //	Line 1
    p_criteriaGrid.add(labelValue, new ALayoutConstraint(0, 0));
    p_criteriaGrid.add(fieldValue, null);
    p_criteriaGrid.add(labelWarehouse, null);
    p_criteriaGrid.add(fWarehouse_ID, null);
    p_criteriaGrid.add(checkOnlyStock, new ALayoutConstraint(0, 5));
    //	Line 2
    p_criteriaGrid.add(labelName, new ALayoutConstraint(1, 0));
    p_criteriaGrid.add(fieldName, null);
    p_criteriaGrid.add(labelPriceList, null);
    p_criteriaGrid.add(fPriceList_ID, null);
    // @Trifon
    p_criteriaGrid.add(labelAS, null);
    // @Trifon
    p_criteriaGrid.add(fAS_ID, null);
    // Line 3
    p_criteriaGrid.add(labelUPC, new ALayoutConstraint(2, 0));
    p_criteriaGrid.add(fieldUPC, null);
    p_criteriaGrid.add(labelProductCategory, null);
    p_criteriaGrid.add(fProductCategory_ID, null);
    p_criteriaGrid.add(labelASI, null);
    p_criteriaGrid.add(fASI_ID, null);
    //  Line 4
    p_criteriaGrid.add(labelSKU, new ALayoutConstraint(3, 0));
    p_criteriaGrid.add(fieldSKU, null);
    p_criteriaGrid.add(labelVendor, null);
    p_criteriaGrid.add(fVendor_ID, null);
    p_criteriaGrid.add(checkAND, new ALayoutConstraint(3, 5));
    //	Product Attribute Instance
    m_PAttributeButton = ConfirmPanel.createPAttributeButton(true);
    confirmPanel.addButton(m_PAttributeButton);
    m_PAttributeButton.addActionListener(this);
    m_PAttributeButton.setEnabled(false);
    //Begin - fer_luck @ centuryon
    //add taskpane
    fieldDescription.setBackground(AdempierePLAF.getInfoBackground());
    fieldDescription.setEditable(false);
    fieldDescription.setPreferredSize(new Dimension(INFO_WIDTH - 100, 100));
    fieldPAttributes.setBackground(AdempierePLAF.getInfoBackground());
    fieldPAttributes.setEditable(false);
    fieldPAttributes.setPreferredSize(new Dimension(INFO_WIDTH - 100, 100));
    ColumnInfo[] s_layoutWarehouse = new ColumnInfo[] { new ColumnInfo(" ", "M_Warehouse_ID", IDColumn.class), new ColumnInfo(Msg.translate(Env.getCtx(), "WarehouseName"), "WarehouseName", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "sum(QtyAvailable)", Double.class, true, true, null), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "sum(QtyOnHand)", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "sum(QtyReserved)", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOrdered"), "sum(QtyOrdered)", Double.class) };
    //        		new ColumnInfo(Msg.translate(Env.getCtx(), "DocumentNote"), "DocumentNote", String.class)};
    /**	From Clause							*/
    String s_sqlFrom = " M_PRODUCT_STOCK_V ";
    /** Where Clause						*/
    String s_sqlWhere = "(QtyOnHand <> 0 OR QtyAvailable <> 0 OR QtyReserved <> 0 OR QtyOrdered <> 0) AND M_Product_ID = ?";
    m_sqlWarehouse = warehouseTbl.prepareTable(s_layoutWarehouse, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_STOCK_V");
    m_sqlWarehouse += " Group By M_Warehouse_ID, WarehouseName ";
    m_sqlWarehouse += " Order By sum(QtyOnHand) DESC, WarehouseName ";
    warehouseTbl.setRowSelectionAllowed(true);
    warehouseTbl.setMultiSelection(false);
    warehouseTbl.addMouseListener(this);
    warehouseTbl.setShowTotals(true);
    warehouseTbl.autoSize();
    ColumnInfo[] s_layoutSubstitute = new ColumnInfo[] { new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Description"), "description", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Value"), "value", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class, true, true, null), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class) };
    s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V";
    s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'S'";
    m_sqlSubstitute = substituteTbl.prepareTable(s_layoutSubstitute, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V");
    substituteTbl.setRowSelectionAllowed(false);
    substituteTbl.setMultiSelection(false);
    substituteTbl.addMouseListener(this);
    substituteTbl.setShowTotals(false);
    substituteTbl.autoSize();
    ColumnInfo[] s_layoutRelated = new ColumnInfo[] { new ColumnInfo(Msg.translate(Env.getCtx(), "Warehouse"), "orgname", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Description"), "description", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Value"), "value", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "QtyAvailable", Double.class, true, true, null), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "QtyOnHand", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "QtyReserved", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "PriceStd", Double.class) };
    s_sqlFrom = "M_PRODUCT_SUBSTITUTERELATED_V";
    s_sqlWhere = "M_Product_ID = ? AND M_PriceList_Version_ID = ? and RowType = 'R'";
    m_sqlRelated = relatedTbl.prepareTable(s_layoutRelated, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_SUBSTITUTERELATED_V");
    relatedTbl.setRowSelectionAllowed(false);
    relatedTbl.setMultiSelection(false);
    relatedTbl.addMouseListener(this);
    relatedTbl.setShowTotals(false);
    relatedTbl.autoSize();
    //Available to Promise Tab
    initAtpTab();
    m_tableAtp.setRowSelectionAllowed(false);
    m_tableAtp.setMultiSelection(false);
    //Vendor tab
    ColumnInfo[] s_layoutVendor = new ColumnInfo[] { new ColumnInfo(Msg.translate(Env.getCtx(), "Vendor"), "(SELECT bp.Name FROM C_BPartner bp WHERE bp.C_BPartner_ID = M_PRODUCT_PO.C_BPartner_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "IsCurrentVendor"), "IsCurrentVendor", Boolean.class), new ColumnInfo(Msg.translate(Env.getCtx(), "C_UOM_ID"), "(SELECT Name FROM C_UOM WHERE C_UOM_ID = M_PRODUCT_PO.C_UOM_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "C_Currency_ID"), "(SELECT iso_code FROM C_Currency WHERE C_Currency_ID = M_PRODUCT_PO.C_Currency_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "PriceList"), "PriceList", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "PricePO"), "PricePO", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "VendorProductNo"), "VendorProductNo", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Order_Min"), "Order_Min", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "DeliveryTime_Promised"), "DeliveryTime_Promised", Double.class), new ColumnInfo(Msg.translate(Env.getCtx(), "DeliveryTime_Actual"), "DeliveryTime_Actual", Double.class) };
    s_sqlFrom = "M_PRODUCT_PO";
    s_sqlWhere = "M_Product_ID = ?";
    m_sqlVendor = vendorTbl.prepareTable(s_layoutVendor, s_sqlFrom, s_sqlWhere, false, "M_PRODUCT_PO");
    vendorTbl.setRowSelectionAllowed(false);
    vendorTbl.setMultiSelection(false);
    vendorTbl.addMouseListener(this);
    vendorTbl.setShowTotals(false);
    vendorTbl.autoSize();
    jTab.addTab(Msg.translate(Env.getCtx(), "Warehouse"), new JScrollPane(warehouseTbl));
    jTab.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 250 : 105));
    jTab.addTab(Msg.translate(Env.getCtx(), "Description"), new JScrollPane(fieldDescription));
    jTab.addTab(Msg.translate(Env.getCtx(), "ProductAttribute"), new JScrollPane(fieldPAttributes));
    jTab.addTab(Msg.translate(Env.getCtx(), "Substitute_ID"), new JScrollPane(substituteTbl));
    jTab.addTab(Msg.translate(Env.getCtx(), "RelatedProduct_ID"), new JScrollPane(relatedTbl));
    jTab.addTab(Msg.getMsg(Env.getCtx(), "ATP"), new JScrollPane(m_tableAtp));
    jTab.addTab(Msg.translate(Env.getCtx(), "Vendor"), new JScrollPane(vendorTbl));
    jTab.addChangeListener(this);
    tablePanel.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 255 : 110));
    tablePanel.setLayout(new BorderLayout());
    tablePanel.add(jTab, BorderLayout.CENTER);
    //  Add the details to the p_detailPanel
    p_detailTaskPane.setTitle(Msg.translate(Env.getCtx(), "WarehouseStock"));
    p_detailTaskPane.add(checkShowDetail, BorderLayout.NORTH);
    p_detailTaskPane.add(tablePanel, BorderLayout.CENTER);
    p_detailTaskPane.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) VPAttribute(org.compiere.grid.ed.VPAttribute) BorderLayout(java.awt.BorderLayout) GridTab(org.compiere.model.GridTab) VLookup(org.compiere.grid.ed.VLookup) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) ColumnInfo(org.compiere.minigrid.ColumnInfo) Dimension(java.awt.Dimension) MPAttributeLookup(org.compiere.model.MPAttributeLookup)

Example 4 with ColumnInfo

use of org.compiere.minigrid.ColumnInfo in project adempiere by adempiere.

the class InfoGeneralPanel method initInfoTable.

private boolean initInfoTable() {
    //	Get Query Columns
    String sql = "SELECT c.ColumnName, t.AD_Table_ID, t.TableName, c.ColumnSql " + "FROM AD_Table t" + " INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID)" + "WHERE c.AD_Reference_ID=10" + //	#1
    " AND t.TableName=?" + //	Displayed in Window
    " AND EXISTS (SELECT * FROM AD_Field f " + "WHERE f.AD_Column_ID=c.AD_Column_ID" + " AND f.IsDisplayed='Y' AND f.IsEncrypted='N' AND f.ObscureType IS NULL) " + "ORDER BY c.IsIdentifier DESC, c.SeqNo";
    int AD_Table_ID = 0;
    String tableName = null;
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        pstmt.setString(1, p_tableName);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            m_queryColumns.add(rs.getString(1));
            String columnSql = rs.getString(4);
            if (columnSql != null && columnSql.length() > 0)
                m_queryColumnsSql.add(columnSql);
            else
                m_queryColumnsSql.add(rs.getString(1));
            if (AD_Table_ID == 0) {
                AD_Table_ID = rs.getInt(2);
                tableName = rs.getString(3);
            }
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
        return false;
    }
    //	Miminum check
    if (m_queryColumns.size() == 0) {
        log.log(Level.SEVERE, "No query columns found");
        return false;
    }
    log.finest("Table " + tableName + ", ID=" + AD_Table_ID + ", QueryColumns #" + m_queryColumns.size());
    //	Only 4 Query Columns
    while (m_queryColumns.size() > 4) {
        m_queryColumns.remove(m_queryColumns.size() - 1);
        m_queryColumnsSql.remove(m_queryColumnsSql.size() - 1);
    }
    //  Set Title
    //  best bet
    String title = Msg.translate(Env.getCtx(), tableName + "_ID");
    if (title.endsWith("_ID"))
        //  second best bet
        title = Msg.translate(Env.getCtx(), tableName);
    setTitle(getTitle() + " " + title);
    //	Get Display Columns
    ArrayList<ColumnInfo> list = new ArrayList<ColumnInfo>();
    sql = "SELECT c.ColumnName, c.AD_Reference_ID, c.IsKey, f.IsDisplayed, c.AD_Reference_Value_ID, c.ColumnSql " + "FROM AD_Column c" + " INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID)" + " INNER JOIN AD_Tab tab ON (t.AD_Window_ID=tab.AD_Window_ID)" + " INNER JOIN AD_Field f ON (tab.AD_Tab_ID=f.AD_Tab_ID AND f.AD_Column_ID=c.AD_Column_ID) " + "WHERE t.AD_Table_ID=? " + " AND (c.IsKey='Y' OR " + " (f.IsEncrypted='N' AND f.ObscureType IS NULL)) " + "ORDER BY c.IsKey DESC, f.SeqNo";
    try {
        PreparedStatement pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, AD_Table_ID);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            String columnName = rs.getString(1);
            int displayType = rs.getInt(2);
            boolean isKey = rs.getString(3).equals("Y");
            boolean isDisplayed = rs.getString(4).equals("Y");
            int AD_Reference_Value_ID = rs.getInt(5);
            String columnSql = rs.getString(6);
            if (columnSql == null || columnSql.length() == 0)
                columnSql = columnName;
            //  Default
            StringBuffer colSql = new StringBuffer(columnSql);
            Class<?> colClass = null;
            if (isKey)
                colClass = IDColumn.class;
            else if (!isDisplayed)
                ;
            else if (displayType == DisplayType.YesNo)
                colClass = Boolean.class;
            else if (displayType == DisplayType.Amount)
                colClass = BigDecimal.class;
            else if (displayType == DisplayType.Number || displayType == DisplayType.Quantity)
                colClass = Double.class;
            else if (displayType == DisplayType.Integer)
                colClass = Integer.class;
            else if (displayType == DisplayType.String || displayType == DisplayType.Text || displayType == DisplayType.Memo)
                colClass = String.class;
            else if (DisplayType.isDate(displayType))
                colClass = Timestamp.class;
            else //  ignore Binary, Button, ID, RowID
            if (displayType == DisplayType.List) {
                if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List"))
                    colSql = new StringBuffer("(SELECT l.Name FROM AD_Ref_List l WHERE l.AD_Reference_ID=").append(AD_Reference_Value_ID).append(" AND l.Value=").append(columnSql).append(") AS ").append(columnName);
                else
                    colSql = new StringBuffer("(SELECT t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t " + "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID AND l.AD_Reference_ID=").append(AD_Reference_Value_ID).append(" AND l.Value=").append(columnSql).append(" AND t.AD_Language='").append(Env.getAD_Language(Env.getCtx())).append("') AS ").append(columnName);
                colClass = String.class;
            }
            if (colClass != null) {
                list.add(new ColumnInfo(Msg.translate(Env.getCtx(), columnName), colSql.toString(), colClass));
                log.finest("Added Column=" + columnName);
            } else
                log.finest("Not Added Column=" + columnName);
        }
        rs.close();
        pstmt.close();
    } catch (SQLException e) {
        log.log(Level.SEVERE, sql, e);
        return false;
    }
    if (list.size() == 0) {
        FDialog.error(p_WindowNo, this, "Error", "No Info Columns");
        log.log(Level.SEVERE, "No Info for AD_Table_ID=" + AD_Table_ID + " - " + sql);
        return false;
    }
    log.finest("InfoColumns #" + list.size());
    //  Convert ArrayList to Array
    m_generalLayout = new ColumnInfo[list.size()];
    list.toArray(m_generalLayout);
    return true;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ColumnInfo(org.compiere.minigrid.ColumnInfo) PreparedStatement(java.sql.PreparedStatement) IDColumn(org.compiere.minigrid.IDColumn) ResultSet(java.sql.ResultSet)

Example 5 with ColumnInfo

use of org.compiere.minigrid.ColumnInfo in project adempiere by adempiere.

the class InfoBPartnerPanel method statInit.

private void statInit() {
    initComponents();
    fieldValue.setWidth("100%");
    fieldContact.setWidth("100%");
    fieldPhone.setWidth("100%");
    fieldName.setWidth("100%");
    fieldEMail.setWidth("100%");
    fieldPostal.setWidth("100%");
    Rows rows = new Rows();
    Row row = new Row();
    rows.appendChild(row);
    row.appendChild(labelValue.rightAlign());
    row.appendChild(fieldValue);
    row.appendChild(labelContact.rightAlign());
    row.appendChild(fieldContact);
    row.appendChild(labelPhone.rightAlign());
    row.appendChild(fieldPhone);
    row.appendChild(checkCustomer);
    row = new Row();
    rows.appendChild(row);
    row.appendChild(labelName.rightAlign());
    row.appendChild(fieldName);
    row.appendChild(labelEMail.rightAlign());
    row.appendChild(fieldEMail);
    row.appendChild(labelPostal.rightAlign());
    row.appendChild(fieldPostal);
    row.appendChild(checkAND);
    statusBar.setEastVisibility(false);
    //  Contact Tab
    ColumnInfo[] s_layoutContact = new ColumnInfo[] { new ColumnInfo(" ", "AD_User_ID", IDColumn.class), new ColumnInfo(Msg.translate(Env.getCtx(), "C_Greeting_ID"), "(SELECT g.Greeting from C_Greeting g WHERE g.C_Greeting_ID = AD_User.C_Greeting_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Title"), "Title", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "C_Location_ID"), "(SELECT a.Name from C_BPartner_Location a WHERE AD_User.C_BPartner_Location_ID=a.C_BPartner_Location_ID)", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Phone"), "Phone", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Phone2"), "Phone2", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Fax"), "Fax", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "EMail"), "EMail", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "LastContact"), "LastContact", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "LastResult"), "LastResult", String.class) };
    //  From Clause
    String s_sqlFrom = "AD_User";
    //  Where Clause					
    String s_sqlWhere = "C_BPartner_ID = ?  and IsActive = 'Y'";
    m_sqlContact = contactTbl.prepareTable(s_layoutContact, s_sqlFrom, s_sqlWhere, false, "AD_User");
    contactTbl.setMultiSelection(false);
    contactTbl.autoSize();
    contactTbl.getModel().addTableModelListener(this);
    contactTbl.setAttribute("zk_component_ID", "Lookup_Data_Contact");
    //  Location Tab
    ColumnInfo[] s_layoutAddress = new ColumnInfo[] { new ColumnInfo(" ", "l.C_BPartner_Location_ID", IDColumn.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "l.Name", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Phone"), "l.Phone", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Phone2"), "l.Phone2", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "Fax"), "l.Fax", String.class), // Replaced with parsed value
    new ColumnInfo(Msg.translate(Env.getCtx(), "Address"), "a.Address1", String.class), new ColumnInfo(Msg.translate(Env.getCtx(), "IsShipTo"), "l.IsShipTo", Boolean.class), new ColumnInfo(Msg.translate(Env.getCtx(), "IsBillTo"), "l.IsBillTo", Boolean.class), new ColumnInfo(Msg.translate(Env.getCtx(), "IsRemitTo"), "l.IsRemitTo", Boolean.class), new ColumnInfo(Msg.translate(Env.getCtx(), "IsPayFrom"), "l.IsPayFrom", Boolean.class) };
    ADDRESS_INDEX = 5;
    /**	From Clause							*/
    String s_locationFrom = "C_BPartner_Location l" + " LEFT OUTER JOIN C_Location a ON (l.C_Location_ID=a.C_Location_ID)";
    /** Where Clause						*/
    String s_locationWhere = "l.C_BPartner_ID = ? and l.IsActive = 'Y'";
    m_sqlAddress = addressTbl.prepareTable(s_layoutAddress, s_locationFrom, s_locationWhere, false, "l");
    addressTbl.setMultiSelection(false);
    addressTbl.autoSize();
    addressTbl.getModel().addTableModelListener(this);
    addressTbl.setAttribute("zk_component_ID", "Lookup_Data_Address");
    //
    detailTabBox.setHeight("100%");
    Tabpanels tabPanels = new Tabpanels();
    detailTabBox.appendChild(tabPanels);
    Tabs tabs = new Tabs();
    detailTabBox.appendChild(tabs);
    Tab tab = new Tab(Util.cleanAmp(Msg.translate(Env.getCtx(), "Contact")));
    tab.addEventListener(Events.ON_SELECT, this);
    tabs.appendChild(tab);
    Tabpanel desktopTabPanel = new Tabpanel();
    desktopTabPanel.setHeight("100%");
    desktopTabPanel.appendChild(contactTbl);
    tabPanels.appendChild(desktopTabPanel);
    tab = new Tab(Msg.translate(Env.getCtx(), "Location"));
    tab.addEventListener(Events.ON_SELECT, this);
    tabs.appendChild(tab);
    desktopTabPanel = new Tabpanel();
    desktopTabPanel.setHeight("100%");
    desktopTabPanel.appendChild(addressTbl);
    tabPanels.appendChild(desktopTabPanel);
    tabs.setAttribute("zk_component_ID", "Subordinate_Tabs");
    Borderlayout southSP = new Borderlayout();
    Center center = new Center();
    North north = new North();
    center.appendChild(detailTabBox);
    southSP.appendChild(north);
    southSP.appendChild(center);
    p_centerSouth.setTitle(Msg.translate(Env.getCtx(), "ContactAndAddress"));
    p_centerSouth.setTooltiptext(Msg.translate(Env.getCtx(), "ContactAndAddress"));
    p_centerSouth.appendChild(southSP);
    p_criteriaGrid.appendChild(rows);
    super.setSizes();
    contactTbl.addActionListener(new EventListener<Event>() {

        public void onEvent(Event event) throws Exception {
            int leadRowKey = 0;
            if (contactTbl != null || contactTbl.getRowCount() > 0)
                leadRowKey = contactTbl.getLeadRowKey();
            if (m_AD_User_ID != leadRowKey) {
                //  From the contact table
                m_AD_User_ID = leadRowKey;
            }
        }
    });
    addressTbl.addActionListener(new EventListener<Event>() {

        public void onEvent(Event event) throws Exception {
            int leadRowKey = 0;
            if (addressTbl != null || addressTbl.getRowCount() > 0)
                leadRowKey = addressTbl.getLeadRowKey();
            if (m_C_BPartner_Location_ID != leadRowKey) {
                //  From the main table
                m_C_BPartner_Location_ID = leadRowKey;
            }
        }
    });
}
Also used : Center(org.zkoss.zul.Center) ColumnInfo(org.compiere.minigrid.ColumnInfo) Borderlayout(org.zkoss.zul.Borderlayout) SQLException(java.sql.SQLException) Tab(org.adempiere.webui.component.Tab) Tabpanels(org.adempiere.webui.component.Tabpanels) Tabs(org.adempiere.webui.component.Tabs) Event(org.zkoss.zk.ui.event.Event) North(org.zkoss.zul.North) Row(org.adempiere.webui.component.Row) Tabpanel(org.adempiere.webui.component.Tabpanel) Rows(org.adempiere.webui.component.Rows)

Aggregations

ColumnInfo (org.compiere.minigrid.ColumnInfo)12 SQLException (java.sql.SQLException)5 Dimension (java.awt.Dimension)4 Properties (java.util.Properties)3 JScrollPane (javax.swing.JScrollPane)3 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)3 Event (org.zkoss.zk.ui.event.Event)3 BorderLayout (java.awt.BorderLayout)2 BigDecimal (java.math.BigDecimal)2 ColorUIResource (javax.swing.plaf.ColorUIResource)2 Row (org.adempiere.webui.component.Row)2 Rows (org.adempiere.webui.component.Rows)2 Tab (org.adempiere.webui.component.Tab)2 Tabpanel (org.adempiere.webui.component.Tabpanel)2 Tabpanels (org.adempiere.webui.component.Tabpanels)2 Tabs (org.adempiere.webui.component.Tabs)2 VLookup (org.compiere.grid.ed.VLookup)2 IDColumn (org.compiere.minigrid.IDColumn)2 MLookup (org.compiere.model.MLookup)2 Borderlayout (org.zkoss.zul.Borderlayout)2