Search in sources :

Example 11 with MLookup

use of org.compiere.model.MLookup in project adempiere by adempiere.

the class GridTabExcelExporter method getButtonLookup.

private MLookup getButtonLookup(GridField mField) {
    MLookup lookup = m_buttonLookups.get(mField.getColumnName());
    if (lookup != null)
        return lookup;
    // TODO: refactor with org.compiere.grid.ed.VButton.setField(GridField)
    if (mField.getColumnName().endsWith("_ID") && !mField.getColumnName().equals("Record_ID")) {
        lookup = MLookupFactory.get(Env.getCtx(), mField.getWindowNo(), 0, mField.getAD_Column_ID(), DisplayType.Search);
    } else if (mField.getAD_Reference_Value_ID() != 0) {
        //	Assuming List
        lookup = MLookupFactory.get(Env.getCtx(), mField.getWindowNo(), 0, mField.getAD_Column_ID(), DisplayType.List);
    }
    //
    m_buttonLookups.put(mField.getColumnName(), lookup);
    return lookup;
}
Also used : MLookup(org.compiere.model.MLookup)

Example 12 with MLookup

use of org.compiere.model.MLookup in project adempiere by adempiere.

the class VInOutGen method dynInit.

//	jbInit
/**
	 *	Fill Picks.
	 *		Column_ID from C_Order
	 *  @throws Exception if Lookups cannot be initialized
	 */
public void dynInit() throws Exception {
    //	C_OrderLine.M_Warehouse_ID
    MLookup orgL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 2223, DisplayType.TableDir);
    fWarehouse = new VLookup("M_Warehouse_ID", true, false, true, orgL);
    lWarehouse.setText(Msg.translate(Env.getCtx(), "M_Warehouse_ID"));
    fWarehouse.addVetoableChangeListener(this);
    setM_Warehouse_ID(fWarehouse.getValue());
    //   Document Action Prepared/ Completed
    MLookup docActionL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 4324, /* M_InOut.DocStatus */
    DisplayType.List, Env.getLanguage(Env.getCtx()), "DocAction", 135, /* _Document Action */
    false, "AD_Ref_List.Value IN ('CO','PR')");
    docAction = new VLookup("DocAction", true, false, true, docActionL);
    docAction.addVetoableChangeListener(this);
    //@Trifon - Pre-select "Prepare"
    docAction.setValue("PR");
    //		C_Order.C_BPartner_ID
    MLookup bpL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 2762, DisplayType.Search);
    fBPartner = new VLookup("C_BPartner_ID", false, false, true, bpL);
    lBPartner.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
    fBPartner.addVetoableChangeListener(this);
    //Document Type Sales Order/Vendor RMA
    lDocType.setText(Msg.translate(Env.getCtx(), "C_DocType_ID"));
    cmbDocType.addItem(new KeyNamePair(MOrder.Table_ID, Msg.translate(Env.getCtx(), "Order")));
    cmbDocType.addItem(new KeyNamePair(MRMA.Table_ID, Msg.translate(Env.getCtx(), "VendorRMA")));
    cmbDocType.addActionListener(this);
    //@@
    panel.getStatusBar().setStatusLine(Msg.getMsg(Env.getCtx(), "InOutGenerateSel"));
}
Also used : MLookup(org.compiere.model.MLookup) VLookup(org.compiere.grid.ed.VLookup) KeyNamePair(org.compiere.util.KeyNamePair)

Example 13 with MLookup

use of org.compiere.model.MLookup in project adempiere by adempiere.

the class VStocktake method dynParameter.

//  jbInit
/**
	 *  Initialize Parameter fields
	 *  @throws Exception if Lookups cannot be initialized
	 */
private void dynParameter() throws Exception {
    Properties ctx = Env.getCtx();
    //  Physical Inventory Document
    String vcode = "M_Inventory.IsStocktake='Y' ";
    MLookup inventoryLookup = MLookupFactory.get(ctx, m_WindowNo, 3563, DisplayType.TableDir, Env.getLanguage(Env.getCtx()), "M_Inventory_ID", 53249, true, vcode);
    inventoryField = new VLookup("M_Inventory_ID", false, false, true, inventoryLookup);
    //  Locator
    MLocatorLookup locatorLookup = new MLocatorLookup(ctx, m_WindowNo);
    locatorField = new VLocator("M_Locator_ID", false, false, true, locatorLookup, m_WindowNo);
    //  Product
    MLookup productLookup = MLookupFactory.get(ctx, m_WindowNo, 0, 3668, DisplayType.Search);
    productField = new VLookup("M_Product_ID", false, false, true, productLookup);
    //  Aisle(X)
    MLookup aislexLookup = MLookupFactory.get(ctx, m_WindowNo, 1399, DisplayType.Table, Env.getLanguage(Env.getCtx()), "X", 53562, false, null);
    aislexField = new VLookup("X", false, false, true, aislexLookup);
    //  lines
    lineFField = new VNumber();
    lineTField = new VNumber();
    //
    confirmPanel.addActionListener(this);
    statusBar.setStatusLine("");
}
Also used : MLocatorLookup(org.compiere.model.MLocatorLookup) MLookup(org.compiere.model.MLookup) VLookup(org.compiere.grid.ed.VLookup) VLocator(org.compiere.grid.ed.VLocator) VNumber(org.compiere.grid.ed.VNumber) Properties(java.util.Properties)

Example 14 with MLookup

use of org.compiere.model.MLookup in project adempiere by adempiere.

the class VCreateFromShipmentUI method initBPartner.

//  vetoableChange
/**************************************************************************
	 *  Load BPartner Field
	 *  @param forInvoice true if Invoices are to be created, false receipts
	 *  @throws Exception if Lookups cannot be initialized
	 */
protected void initBPartner(boolean forInvoice) throws Exception {
    //  load BPartner
    //  C_Invoice.C_BPartner_ID
    int AD_Column_ID = 3499;
    MLookup lookup = MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.Search);
    bPartnerField = new VLookup("C_BPartner_ID", true, false, true, lookup);
    //
    int C_BPartner_ID = getC_BPartner_ID();
    bPartnerField.setValue(new Integer(C_BPartner_ID));
    //  initial loading
    initBPOrderDetails(C_BPartner_ID, forInvoice);
}
Also used : MLookup(org.compiere.model.MLookup) VLookup(org.compiere.grid.ed.VLookup)

Example 15 with MLookup

use of org.compiere.model.MLookup in project adempiere by adempiere.

the class Browser method getInfoColumnForAxisField.

/**
	 * Get Info_Column for Axis Field
	 * @param field defined as Axis
	 * @return Info_Column with Axis Field
	 */
public List<MBrowseField> getInfoColumnForAxisField(MBrowseField field) {
    List<MBrowseField> list = new ArrayList<MBrowseField>();
    axisParameters = new ArrayList<>();
    axisParametersValues = new ArrayList<>();
    try {
        I_AD_View_Column xcol, pcol, ycol;
        xcol = field.getAD_View_Column();
        pcol = field.getAxis_Parent_Column();
        ycol = field.getAxis_Column();
        String columnName = xcol.getAD_Column().getColumnName();
        MBrowseField fieldKey = ((MBrowse) field.getAD_Browse()).getFieldKey();
        if (fieldKey == null)
            throw new AdempiereException("@NotFound@ @IsKey@");
        MTable xTable = (MTable) ycol.getAD_View_Definition().getAD_Table();
        String xTableName = xTable.getTableName();
        String keyColumn = MQuery.getZoomColumnName(columnName);
        String tableName = MQuery.getZoomTableName(columnName);
        String whereClause = "";
        if (pcol != null && pcol.getAD_View_Column_ID() > 0) {
            MTable parentTable = MTable.get(field.getCtx(), tableName);
            MColumn parentColumn = getParentColumn(parentTable.getAD_Table_ID());
            if (parentColumn == null)
                throw new AdempiereException("@NotFound@ @IsParent@");
            //	BR [ 242 ]
            if (field.getAD_Val_Rule_ID() > 0)
                whereClause = Env.parseContext(Env.getCtx(), getWindowNo(), field.getAD_Val_Rule().getCode(), false);
        }
        MLookup lookup = MLookupFactory.get(Env.getCtx(), 0, xcol.getAD_Column_ID(), field.getAD_Reference_ID(), m_language, keyColumn, field.getAD_Reference_Value_ID(), false, whereClause);
        int cols = 0;
        StringBuilder axisSql = new StringBuilder("(SELECT ");
        axisSql.append("SUM(").append(ycol.getAD_Column().getColumnName()).append(") FROM  ").append(ycol.getAD_View_Definition().getAD_Table().getTableName()).append(" WHERE ").append(xTableName).append(".").append(fieldKey.getAD_View_Column().getAD_Column().getColumnName()).append("=").append(fieldKey.getAD_View_Column().getColumnSQL());
        for (int id : getAxisRecordIds(tableName, whereClause)) {
            cols++;
            String display = lookup.getDisplay(id).trim();
            display = display.length() > 12 ? display.substring(1, 12) + "_" + cols : display;
            String joinColumn = Msg.translate(m_language, ycol.getAD_Column().getColumnName());
            joinColumn = joinColumn.length() > 15 ? joinColumn.substring(1, 15) : joinColumn;
            String sqlColName = display + "/" + joinColumn;
            String colName = lookup.getDisplay(id).trim() + "/" + Msg.translate(m_language, ycol.getAD_Column().getColumnName());
            StringBuilder axisWhere = new StringBuilder(" ");
            axisWhere.append(getAxisSQLWhere(ycol)).append(" AND ").append(xcol.getAD_View_Definition().getTableAlias()).append(".").append(xcol.getAD_Column().getColumnName());
            StringBuffer select = new StringBuffer();
            select.append(axisSql).append(axisWhere);
            select.append("=").append(id).append(")");
            MViewColumn viewColumn = new MViewColumn(field.getCtx(), 0, field.get_TrxName());
            MViewColumn.copyValues((MViewColumn) ycol, viewColumn);
            viewColumn.setAD_View_Column_ID(ycol.getAD_View_Column_ID());
            viewColumn.setAD_Column_ID(ycol.getAD_Column_ID());
            viewColumn.setColumnSQL(select.toString());
            viewColumn.setColumnName("\"" + sqlColName + "\"");
            MBrowseField browseField = new MBrowseField((MBrowse) field.getAD_Browse(), viewColumn);
            browseField.setAD_Browse_ID(field.getAD_Browse_ID());
            browseField.setAD_Element_ID(field.getAD_Element_ID());
            browseField.setName(colName);
            browseField.setDescription(viewColumn.getDescription());
            browseField.setHelp(viewColumn.getHelp());
            if (viewColumn.get_ID() > 0)
                browseField.setAD_View_Column_ID(viewColumn.getAD_View_Column_ID());
            browseField.setIsActive(true);
            browseField.setIsIdentifier(viewColumn.isIdentifier());
            browseField.setIsRange(false);
            browseField.setIsQueryCriteria(false);
            browseField.setAD_Reference_ID(ycol.getAD_Column().getAD_Reference_ID());
            browseField.setAD_Reference_Value_ID(ycol.getAD_Column().getAD_Reference_Value_ID());
            browseField.setIsKey(false);
            browseField.setIsDisplayed(true);
            browseField.setAxis_Column_ID(field.getAxis_Column_ID());
            browseField.setAxis_Parent_Column_ID(field.getAxis_Parent_Column_ID());
            browseField.setIsReadOnly(field.isReadOnly());
            browseField.setAD_Element_ID(field.getAD_Element_ID());
            list.add(browseField);
            log.finest("Added Column=" + sqlColName + " SQL = " + select);
        }
    } catch (Exception e) {
        throw new AdempiereException(e);
    }
    return list;
}
Also used : MColumn(org.compiere.model.MColumn) MBrowseField(org.adempiere.model.MBrowseField) MLookup(org.compiere.model.MLookup) ArrayList(java.util.ArrayList) I_AD_View_Column(org.adempiere.model.I_AD_View_Column) MBrowse(org.adempiere.model.MBrowse) SQLException(java.sql.SQLException) IOException(java.io.IOException) DBException(org.adempiere.exceptions.DBException) AdempiereException(org.adempiere.exceptions.AdempiereException) MViewColumn(org.adempiere.model.MViewColumn) MTable(org.compiere.model.MTable) AdempiereException(org.adempiere.exceptions.AdempiereException)

Aggregations

MLookup (org.compiere.model.MLookup)62 VLookup (org.compiere.grid.ed.VLookup)25 WSearchEditor (org.adempiere.webui.editor.WSearchEditor)17 Properties (java.util.Properties)14 SQLException (java.sql.SQLException)9 WTableDirEditor (org.adempiere.webui.editor.WTableDirEditor)9 KeyNamePair (org.compiere.util.KeyNamePair)9 Language (org.compiere.util.Language)7 MLocatorLookup (org.compiere.model.MLocatorLookup)6 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 Dimension (java.awt.Dimension)4 Insets (java.awt.Insets)4 BigDecimal (java.math.BigDecimal)4 Row (org.adempiere.webui.component.Row)4 Rows (org.adempiere.webui.component.Rows)4 GridField (org.compiere.model.GridField)4 MColumn (org.compiere.model.MColumn)4 CPanel (org.compiere.swing.CPanel)4 GridBagConstraints (java.awt.GridBagConstraints)3