Search in sources :

Example 76 with KeyNamePair

use of org.compiere.util.KeyNamePair in project adempiere by adempiere.

the class CreateFrom method getOrderData.

//  initBPartnerOIS
/**
	 *  Load Data - Order
	 *  @param C_Order_ID Order
	 *  @param forInvoice true if for invoice vs. delivery qty
	 */
protected Vector<Vector<Object>> getOrderData(int C_Order_ID, boolean forInvoice) {
    /**
		 *  Selected        - 0
		 *  Qty             - 1
		 *  C_UOM_ID        - 2
		 *  M_Product_ID    - 3
		 *  VendorProductNo - 4
		 *  OrderLine       - 5
		 *  ShipmentLine    - 6
		 *  InvoiceLine     - 7
		 */
    log.config("C_Order_ID=" + C_Order_ID);
    p_order = new MOrder(Env.getCtx(), C_Order_ID, null);
    Vector<Vector<Object>> data = new Vector<Vector<Object>>();
    StringBuffer sql = new StringBuffer("SELECT " + //	1
    "l.QtyOrdered-SUM(COALESCE(m.Qty,0))," + //	2
    "CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END," + //	3..4
    " l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name)," + //	5..7
    " COALESCE(l.M_Product_ID,0),COALESCE(p.Name,c.Name),po.VendorProductNo," + //	8..9
    " l.C_OrderLine_ID,l.Line " + "FROM C_OrderLine l" + " LEFT OUTER JOIN M_Product_PO po ON (l.M_Product_ID = po.M_Product_ID AND l.C_BPartner_ID = po.C_BPartner_ID) " + " LEFT OUTER JOIN M_MatchPO m ON (l.C_OrderLine_ID=m.C_OrderLine_ID AND ");
    sql.append(forInvoice ? "m.C_InvoiceLine_ID" : "m.M_InOutLine_ID");
    sql.append(" IS NOT NULL)").append(" LEFT OUTER JOIN M_Product p ON (l.M_Product_ID=p.M_Product_ID)" + " LEFT OUTER JOIN C_Charge c ON (l.C_Charge_ID=c.C_Charge_ID)");
    if (Env.isBaseLanguage(Env.getCtx(), "C_UOM"))
        sql.append(" LEFT OUTER JOIN C_UOM uom ON (l.C_UOM_ID=uom.C_UOM_ID)");
    else
        sql.append(" LEFT OUTER JOIN C_UOM_Trl uom ON (l.C_UOM_ID=uom.C_UOM_ID AND uom.AD_Language='").append(Env.getAD_Language(Env.getCtx())).append("')");
    //
    sql.append(//	#1
    " WHERE l.C_Order_ID=? " + "GROUP BY l.QtyOrdered,CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END, " + "l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name),po.VendorProductNo, " + "l.M_Product_ID,COALESCE(p.Name,c.Name), l.Line,l.C_OrderLine_ID " + "ORDER BY l.Line");
    //
    log.finer(sql.toString());
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql.toString(), null);
        pstmt.setInt(1, C_Order_ID);
        rs = pstmt.executeQuery();
        while (rs.next()) {
            Vector<Object> line = new Vector<Object>();
            //  0-Selection
            line.add(new Boolean(false));
            BigDecimal qtyOrdered = rs.getBigDecimal(1);
            BigDecimal multiplier = rs.getBigDecimal(2);
            BigDecimal qtyEntered = qtyOrdered.multiply(multiplier);
            //  1-Qty
            line.add(qtyEntered);
            KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(4).trim());
            //  2-UOM
            line.add(pp);
            pp = new KeyNamePair(rs.getInt(5), rs.getString(6));
            //  3-Product
            line.add(pp);
            // 4-VendorProductNo
            line.add(rs.getString(7));
            pp = new KeyNamePair(rs.getInt(8), rs.getString(9));
            //  5-OrderLine
            line.add(pp);
            //  6-Ship
            line.add(null);
            //  7-Invoice
            line.add(null);
            data.add(line);
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, sql.toString(), e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    return data;
}
Also used : MOrder(org.compiere.model.MOrder) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) KeyNamePair(org.compiere.util.KeyNamePair) Vector(java.util.Vector) BigDecimal(java.math.BigDecimal) SQLException(java.sql.SQLException)

Example 77 with KeyNamePair

use of org.compiere.util.KeyNamePair in project adempiere by adempiere.

the class XLookup method getData.

//	get
/**
	 *	Return data as sorted Array
	 * 	@param mandatory mandatory
	 * 	@param onlyValidated only validated
	 * 	@param onlyActive only active
	 * 	@param temporary force load for temporary display
	 * 	@return list of data
	 */
public ArrayList<Object> getData(boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary) {
    ArrayList<Object> list = new ArrayList<Object>(p_data);
    //	Sort Data
    if (m_keyColumn.endsWith("_ID")) {
        KeyNamePair p = new KeyNamePair(-1, "");
        if (!mandatory)
            list.add(p);
        Collections.sort(list, p);
    } else {
        ValueNamePair p = new ValueNamePair(null, "");
        if (!mandatory)
            list.add(p);
        Collections.sort(list, p);
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair)

Example 78 with KeyNamePair

use of org.compiere.util.KeyNamePair in project adempiere by adempiere.

the class WFPanel method loadPanel.

//	dispose
/**
	 * 	Workflow Add & Load Panel
	 */
private void loadPanel() {
    String sql = MRole.getDefault().addAccessSQL("SELECT AD_Workflow_ID, Name FROM AD_Workflow " + (!Util.isEmpty(m_WF_whereClause, true) ? " WHERE " + m_WF_whereClause : "") + " ORDER BY 2", "AD_Workflow", MRole.SQL_NOTQUALIFIED, //	all
    MRole.SQL_RO);
    KeyNamePair[] pp = DB.getKeyNamePairs(sql, true);
    //
    workflow = new CComboBox(pp);
    AutoCompletion.enable(workflow);
    loadPanel.add(workflow);
    workflow.addActionListener(this);
    //
    loadPanel.add(bIgnore);
    bIgnore.addActionListener(this);
    loadPanel.add(bResetLayout);
    bResetLayout.addActionListener(this);
    loadPanel.add(bSaveLayout);
    bSaveLayout.addActionListener(this);
    loadPanel.add(bZoom);
    bZoom.addActionListener(this);
}
Also used : CComboBox(org.compiere.swing.CComboBox) KeyNamePair(org.compiere.util.KeyNamePair)

Example 79 with KeyNamePair

use of org.compiere.util.KeyNamePair in project adempiere by adempiere.

the class RecordAccessDialog method setLine.

//	setLine
/**
	 * 	Set Selection
	 *	@param ra record access
	 */
private void setLine(MRecordAccess ra) {
    int AD_Role_ID = 0;
    boolean active = true;
    boolean exclude = true;
    boolean readonly = false;
    boolean dependent = false;
    //
    if (ra != null) {
        AD_Role_ID = ra.getAD_Role_ID();
        active = ra.isActive();
        exclude = ra.isExclude();
        readonly = ra.isReadOnly();
        dependent = ra.isDependentEntities();
    }
    cbActive.setSelected(active);
    cbExclude.setSelected(exclude);
    cbReadOnly.setSelected(readonly);
    cbDependent.setSelected(dependent);
    bDelete.setEnabled(ra != null);
    //
    KeyNamePair selection = null;
    for (int i = 0; i < roleField.getItemCount(); i++) {
        KeyNamePair pp = (KeyNamePair) roleField.getItemAt(i);
        if (pp.getKey() == AD_Role_ID)
            selection = pp;
    }
    if (selection != null && ra != null) {
        roleField.setSelectedItem(selection);
        m_currentData = ra;
        log.fine("" + ra);
    } else
        m_currentData = null;
}
Also used : KeyNamePair(org.compiere.util.KeyNamePair) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Example 80 with KeyNamePair

use of org.compiere.util.KeyNamePair in project adempiere by adempiere.

the class POSActionPanel method init.

/**
	 * 	Initialize
	 */
@Override
public void init() {
    //	Content
    setLayout(new GridBagLayout());
    //	Button Panel
    buttonPanel = new CPanel(new GridBagLayout());
    topPadding = 0;
    leftPadding = 1;
    bottonPadding = 0;
    rightPadding = 1;
    // NEW
    buttonNew = createButtonAction(ACTION_NEW, KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0));
    buttonNew.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonNew.setToolTipText("F2-" + Msg.translate(ctx, "new.order"));
    buttonPanel.add(buttonNew, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    // Print
    buttonPrint = createButtonAction(ACTION_PRINT, KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0));
    buttonPrint.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonPrint.setToolTipText("F12-" + Msg.translate(ctx, "Print"));
    buttonPanel.add(buttonPrint, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    // DOCTYPE
    buttonDocType = createButtonAction(ACTION_DOCTYPE, KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0));
    buttonDocType.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonDocType.setToolTipText("F10-" + Msg.translate(ctx, "C_DocType_ID"));
    buttonPanel.add(buttonDocType, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    // PRODUCT
    buttonProduct = createButtonAction(ACTION_PRODUCT, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.ALT_MASK));
    buttonProduct.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonProduct.setToolTipText("ALT+I-" + Msg.translate(ctx, "InfoProduct"));
    buttonPanel.add(buttonProduct, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    // BPARTNER
    buttonBPartner = createButtonAction(ACTION_BPARTNER, KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK + Event.ALT_MASK));
    buttonBPartner.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonBPartner.setToolTipText("CTL+ALT+I-" + Msg.translate(ctx, "C_BPartner_ID"));
    buttonPanel.add(buttonBPartner, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    // PROCESS
    buttonProcess = createButtonAction(ACTION_PROCESS, KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.ALT_MASK));
    buttonProcess.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonProcess.setToolTipText("ALT+P-" + Msg.translate(ctx, "Process"));
    buttonPanel.add(buttonProcess, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    // HISTORY
    buttonHistory = createButtonAction(ACTION_HISTORY, KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0));
    buttonHistory.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonHistory.setToolTipText("F9-" + Msg.translate(ctx, "smenu.order.history"));
    buttonPanel.add(buttonHistory, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    // 	BACK
    buttonBack = createButtonAction(ACTION_BACK, KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Event.ALT_MASK));
    buttonBack.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonBack.setToolTipText("ALT-LEFT-" + Msg.translate(ctx, "prev"));
    buttonPanel.add(buttonBack, new GridBagConstraints(7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    buttonBack.setEnabled(true);
    //	NEXT
    buttonNext = createButtonAction(ACTION_NEXT, KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.ALT_MASK));
    buttonNext.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonNext.setToolTipText("ALT-RIGHT-" + Msg.translate(ctx, "next"));
    buttonPanel.add(buttonNext, new GridBagConstraints(8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    buttonNext.setEnabled(true);
    // PAYMENT
    buttonCollect = createButtonAction(ACTION_PAYMENT, KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0));
    buttonCollect.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonCollect.setToolTipText("F4-" + Msg.translate(ctx, "Payment"));
    buttonPanel.add(buttonCollect, new GridBagConstraints(9, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    buttonCollect.setEnabled(false);
    // CANCEL
    buttonCancel = createButtonAction(ACTION_CANCEL, KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));
    buttonCancel.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonCancel.setToolTipText("F3-" + Msg.translate(ctx, "POS.IsCancel"));
    buttonPanel.add(buttonCancel, new GridBagConstraints(10, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    // Logout
    buttonLogout = createButtonAction(ACTION_LOGOUT, KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.ALT_MASK));
    buttonLogout.setPreferredSize(new Dimension(posPanel.getButtonSize(), posPanel.getButtonSize()));
    buttonLogout.setToolTipText("ALT+L-" + Msg.translate(ctx, "LogOut"));
    buttonPanel.add(buttonLogout, new GridBagConstraints(11, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(topPadding, leftPadding, bottonPadding, rightPadding), 0, 0));
    // BP
    String labelName = Msg.translate(Env.getCtx(), I_M_Product.COLUMNNAME_M_Product_ID);
    fieldProductName = new POSTextField(labelName, posPanel.getKeyboard());
    fieldProductName.setPlaceholder(labelName);
    fieldProductName.addActionListener(this);
    fieldProductName.setFont(posPanel.getFont());
    fieldProductName.setPreferredSize(new Dimension(250, posPanel.getFieldHeight()));
    fieldProductName.setMinimumSize(new Dimension(250, posPanel.getFieldHeight()));
    fieldProductName.setFocusable(true);
    fieldProductName.setFocusTraversalKeysEnabled(false);
    lookupProduct = new POSLookupProduct(this, fieldProductName, 0);
    fieldProductName.addKeyListener(lookupProduct);
    //	Add Button Panel
    add(buttonPanel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0));
    add(fieldProductName, new GridBagConstraints(0, 1, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0));
    if (posPanel.isEnableProductLookup() && !posPanel.isVirtualKeyboard()) {
        JComboBox<KeyNamePair> fillingComponent = new JComboBox<KeyNamePair>();
        Font font = new Font("monospaced", Font.PLAIN, 14);
        fillingComponent.setFont(font);
        findProductTimer = new javax.swing.Timer(500, lookupProduct);
        lookupProduct.setFillingComponent(fillingComponent);
        lookupProduct.setPriceListId(posPanel.getM_PriceList_ID());
        lookupProduct.setPartnerId(posPanel.getC_BPartner_ID());
        lookupProduct.setWarehouseId(posPanel.getM_Warehouse_ID());
        findProductTimer.start();
        add(fillingComponent, new GridBagConstraints(0, 2, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 20), 0, 0));
    }
    enableButton();
    actionProcessMenu = new POSActionMenu(posPanel);
    //	List Orders
    posPanel.listOrder();
    getMainFocus();
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) CPanel(org.compiere.swing.CPanel) Dimension(java.awt.Dimension) Font(java.awt.Font) KeyNamePair(org.compiere.util.KeyNamePair)

Aggregations

KeyNamePair (org.compiere.util.KeyNamePair)286 SQLException (java.sql.SQLException)66 ResultSet (java.sql.ResultSet)65 PreparedStatement (java.sql.PreparedStatement)62 BigDecimal (java.math.BigDecimal)46 ArrayList (java.util.ArrayList)38 ValueNamePair (org.compiere.util.ValueNamePair)36 Timestamp (java.sql.Timestamp)32 Vector (java.util.Vector)22 ListItem (org.adempiere.webui.component.ListItem)22 Login (org.compiere.util.Login)22 MProduct (org.compiere.model.MProduct)17 IDColumn (org.compiere.minigrid.IDColumn)13 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)12 AdempiereException (org.adempiere.exceptions.AdempiereException)10 MLookup (org.compiere.model.MLookup)10 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)9 org.apache.ecs.xhtml.p (org.apache.ecs.xhtml.p)8 org.apache.ecs.xhtml.script (org.apache.ecs.xhtml.script)8 MUOM (org.compiere.model.MUOM)7