Search in sources :

Example 16 with MLookup

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

the class SmallViewController method verifyChangedField.

//  processDependencies
/**
	 * Verify if a field should change because a dependent field has changed.  This
	 * mainly affects the lookup values but may change the selected value if the 
	 * current value is no longer valid.
	 * @param field
	 * @param columnName
	 */
private void verifyChangedField(GridField field, String columnName) {
    ArrayList<String> list = field.getDependentOn();
    if (list.contains(columnName)) {
        Object value = field.getValue();
        if (field.getLookup() instanceof MLookup) {
            MLookup mLookup = (MLookup) field.getLookup();
            //  if the lookup is dynamic (i.e. contains this columnName as variable)
            if (mLookup.getValidation().indexOf("@" + columnName + "@") != -1) {
                log.fine(columnName + " changed - " + field.getColumnName() + " set to null");
                //  invalidate current selection
                mLookup.refresh();
            }
            if (mLookup.containsKey(value)) {
                // Try to select the value
                mLookup.setSelectedItem(mLookup.get(value));
            } else {
                field.setValue(field.getDefault(), false);
            }
        }
    }
}
Also used : MLookup(org.compiere.model.MLookup)

Example 17 with MLookup

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

the class Graph method loadData.

private void loadData() {
    list = builder.loadData();
    JFreeChart chart = builder.createChart(builder.getMGoal().getChartType());
    if (chartPanel != null)
        remove(chartPanel);
    chartPanel = new ChartPanel(chart);
    chartPanel.setSize(getSize());
    chartPanel.addChartMouseListener(this);
    add(chartPanel, BorderLayout.CENTER);
    if (m_userSelection) {
        int AD_Reference_Value_ID = DB.getSQLValue(null, "SELECT AD_Reference_ID FROM AD_Reference WHERE Name = ?", "PA_Goal ChartType");
        MLookupInfo info = MLookupFactory.getLookup_List(Env.getLanguage(Env.getCtx()), AD_Reference_Value_ID);
        MLookup mLookup = new MLookup(info, 0);
        VLookup lookup = new VLookup("ChartType", false, false, true, mLookup);
        lookup.addVetoableChangeListener(new VetoableChangeListener() {

            public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
                Object value = evt.getNewValue();
                if (value == null)
                    return;
                JFreeChart chart = null;
                chart = builder.createChart(value.toString());
                if (chart != null) {
                    if (chartPanel != null)
                        remove(chartPanel);
                    chartPanel = new ChartPanel(chart);
                    chartPanel.setSize(getSize());
                    chartPanel.addChartMouseListener(Graph.this);
                    add(chartPanel, BorderLayout.CENTER);
                    getParent().validate();
                }
            }
        });
        add(lookup, BorderLayout.NORTH);
    }
    this.setMinimumSize(paneldimension);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) MLookupInfo(org.compiere.model.MLookupInfo) PropertyChangeEvent(java.beans.PropertyChangeEvent) ChartPanel(org.jfree.chart.ChartPanel) MLookup(org.compiere.model.MLookup) VLookup(org.compiere.grid.ed.VLookup) VetoableChangeListener(java.beans.VetoableChangeListener) JFreeChart(org.jfree.chart.JFreeChart) Point(java.awt.Point)

Example 18 with MLookup

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

the class VInvoiceGenFromShipment method dynInit.

/**
	 *	Fill Picks.
	 *		Column_ID from C_Order
	 *  @throws Exception if Lookups cannot be initialized
	 */
public void dynInit() throws Exception {
    MLookup orgL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 2163, DisplayType.TableDir);
    fOrg = new VLookup("AD_Org_ID", false, false, true, orgL);
    //	lOrg.setText(Msg.translate(Env.getCtx(), "AD_Org_ID"));
    fOrg.addVetoableChangeListener(this);
    MLookup docActionL = MLookupFactory.get(Env.getCtx(), m_WindowNo, 3494, /* C_Invoice.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);
    //  lDcoACtion.setText((Msg.translate(Env.getCtx(), "DocAction")););
    docAction.addVetoableChangeListener(this);
    //@Trifon - Pre-select "Prepare"
    docAction.setValue("PR");
    //
    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: Shipment/Vendor RMA
    lDocType.setText(Msg.translate(Env.getCtx(), "C_DocType_ID"));
    cmbDocType.addItem(new KeyNamePair(MInOut.Table_ID, Msg.translate(Env.getCtx(), "M_InOut_ID")));
    //cmbDocType.addItem(new KeyNamePair(MRMA.Table_ID, Msg.translate(Env.getCtx(), "CustomerRMA")));
    cmbDocType.addActionListener(this);
    //@@
    panel.getStatusBar().setStatusLine(Msg.getMsg(Env.getCtx(), "InvGenerateSel"));
}
Also used : MLookup(org.compiere.model.MLookup) VLookup(org.compiere.grid.ed.VLookup) KeyNamePair(org.compiere.util.KeyNamePair)

Example 19 with MLookup

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

the class GridController method dataStatusChanged.

/**
	 *  Data Status Listener - for MTab events.
	 *  <p>
	 *  Callouts are processed here for GUI changes
	 *  - same as in MTab.setValue for batch changes
	 *  <p>
	 *  calls dynamicDisplay
	 *  @param e event
	 */
public void dataStatusChanged(DataStatusEvent e) {
    //	if (e.getChangedColumn() == 0)
    //		return;
    int col = e.getChangedColumn();
    log.config("(" + m_mTab + ") Col=" + col + ": " + e.toString());
    //  Process Callout
    GridField mField = m_mTab.getField(col);
    if (mField != null && (mField.getCallout().length() > 0 || m_mTab.hasDependants(mField.getColumnName()))) {
        //  Dependencies & Callout
        String msg = m_mTab.processFieldChange(mField);
        if (msg.length() > 0)
            ADialog.error(m_WindowNo, this, msg);
    }
    if (mField != null && mField.isLookup()) {
        Lookup lookup = (Lookup) mField.getLookup();
        if (lookup != null && lookup instanceof MLookup) {
            MLookup mlookup = (MLookup) lookup;
            Object value = mField.getValue();
            if (mlookup.isAlert() && value != null && value instanceof Integer) {
                String alert = MMemo.getAlerts(Env.getCtx(), mlookup.getTableName(), (Integer) value);
                if (!Util.isEmpty(alert)) {
                    VAlert memo = new VAlert(Env.getWindow(m_WindowNo));
                    memo.setAlwaysOnTop(true);
                    memo.setText(alert);
                    AEnv.showCenterScreen(memo);
                    memo = null;
                }
            }
        }
    }
    //if (col >= 0)
    dynamicDisplay(col);
}
Also used : MLookup(org.compiere.model.MLookup) Lookup(org.compiere.model.Lookup) MLookup(org.compiere.model.MLookup) GridField(org.compiere.model.GridField) VString(org.compiere.grid.ed.VString)

Example 20 with MLookup

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

the class VCollectDetail method loadCreditPanel.

/**
	 * Load for Credit Card
	 * @return void
	 */
private void loadCreditPanel() {
    creditPanel = new CPanel(layout);
    //	For Credit Card
    //C_Payment_v.CreditCardType
    int columnId = 8374;
    MLookup cardlookup = MLookupFactory.get(Env.getCtx(), 0, 0, columnId, DisplayType.List);
    fieldCreditCardType = new VLookup("CreditCardType", true, false, true, cardlookup);
    //	For Credit Card Type
    ((VComboBox) fieldCreditCardType.getCombo()).setRenderer(new POSLookupListCellRenderer(font));
    fieldCreditCardType.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    ((VComboBox) fieldCreditCardType.getCombo()).setFont(font);
    fieldCreditCardType.addVetoableChangeListener(this);
    //	For Months
    //	For Card No
    String creditCardNumber = Msg.translate(ctx, "CreditCardNumber");
    fieldCreditCardNumber = new POSTextField(creditCardNumber, parentCollect.getKeyboard());
    fieldCreditCardNumber.setPlaceholder(creditCardNumber);
    fieldCreditCardNumber.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    fieldCreditCardNumber.setFont(font);
    fieldCreditCardNumber.addKeyListener(this);
    fieldCreditCardNumber.addActionListener(this);
    //	For Card Name
    String name = Msg.translate(ctx, "A_Name");
    fieldName = new POSTextField(name, parentCollect.getKeyboard());
    fieldName.setPlaceholder(name);
    fieldName.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    fieldName.setFont(font);
    fieldName.addKeyListener(this);
    fieldName.addActionListener(this);
    //	For Card Month
    fieldCreditCardExpMM = new VComboBox(getCCMonths());
    fieldCreditCardExpMM.setName("CreditCardExpMM");
    fieldCreditCardExpMM.setValue(-1);
    fieldCreditCardExpMM.setMandatory(true);
    fieldCreditCardExpMM.setPreferredSize(new Dimension(FIELD_WIDTH / 2, FIELD_HEIGHT));
    fieldCreditCardExpMM.setRenderer(new POSLookupListCellRenderer(font));
    fieldCreditCardExpMM.setFont(font);
    fieldCreditCardExpMM.addActionListener(this);
    //	For Card Year
    fieldCreditCardExpYY = new VComboBox(getCCYears());
    fieldCreditCardExpYY.setName("CreditCardExpYY");
    fieldCreditCardExpYY.setValue(-1);
    fieldCreditCardExpYY.setMandatory(true);
    fieldCreditCardExpYY.setPreferredSize(new Dimension(FIELD_WIDTH / 2, FIELD_HEIGHT));
    fieldCreditCardExpYY.setRenderer(new POSLookupListCellRenderer(font));
    fieldCreditCardExpYY.setFont(font);
    fieldCreditCardExpYY.addActionListener(this);
    //	For Card VV
    String creditCardVV = Msg.translate(ctx, "CreditCardVV");
    fieldCreditCardVV = new POSTextField(creditCardVV, parentCollect.getKeyboard());
    fieldCreditCardVV.setPlaceholder(creditCardVV);
    fieldCreditCardVV.setPreferredSize(new Dimension(FIELD_WIDTH, FIELD_HEIGHT));
    fieldCreditCardVV.setFont(font);
    fieldCreditCardVV.addKeyListener(this);
    fieldCreditCardVV.addActionListener(this);
    //	Add to Panel
    creditPanel.add(fieldCreditCardType, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    creditPanel.add(fieldName, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    creditPanel.add(fieldCreditCardNumber, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    creditPanel.add(fieldCreditCardVV, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    creditPanel.add(fieldCreditCardExpMM, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    creditPanel.add(fieldCreditCardExpYY, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NORTH, new Insets(2, 0, 2, 2), 0, 0));
    //	Default visible false
    creditPanel.setVisible(false);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) MLookup(org.compiere.model.MLookup) CPanel(org.compiere.swing.CPanel) VLookup(org.compiere.grid.ed.VLookup) VComboBox(org.compiere.grid.ed.VComboBox) Dimension(java.awt.Dimension)

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