Search in sources :

Example 86 with ValueNamePair

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

the class VLookupAutoCompleter method setUserObject.

@Override
public void setUserObject(Object userObject) {
    String textOld = textBox.getText();
    int caretPosition = textBox.getCaretPosition();
    //
    super.setUserObject(userObject);
    // Object valueOld = editor.getValue();
    Object value = null;
    if (userObject == null) {
        editor.setValue(null);
    } else if (userObject instanceof ValueNamePair) {
        ValueNamePair vnp = (ValueNamePair) userObject;
        value = vnp.getValue();
    } else if (userObject instanceof KeyNamePair) {
        KeyNamePair knp = (KeyNamePair) userObject;
        value = knp.getKey();
    } else {
        log.warning("Not supported - " + userObject + ", class=" + userObject.getClass());
        return;
    }
    editor.actionCombo(value);
    if (value == null) {
        textBox.setText(textOld);
        textBox.setCaretPosition(caretPosition);
    }
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair) KeyNamePair(org.compiere.util.KeyNamePair)

Example 87 with ValueNamePair

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

the class ADServiceImpl method fillField.

private void fillField(Field f, GridFieldVO fo) {
    ////(griddieldvo) adempiere specific
    f.setADColumnID(fo.AD_Column_ID);
    f.setADProcessID(fo.AD_Process_ID);
    f.setADReferenceValueID(fo.AD_Reference_Value_ID);
    f.setADWindowID(fo.AD_Window_ID);
    f.setCallout(fo.Callout);
    f.setColumnName(fo.ColumnName);
    f.setDefaultValue(fo.DefaultValue);
    f.setDefaultValue2(fo.DefaultValue2);
    f.setDescription(fo.Description);
    f.setDisplayLength(fo.DisplayLength);
    f.setDisplayLogic(fo.DisplayLogic);
    f.setDisplayType(fo.displayType);
    f.setFieldGroup(fo.FieldGroup);
    f.setFieldLength(fo.FieldLength);
    f.setHeader(fo.Header);
    f.setHelp(fo.Help);
    f.setIsAlwaysUpdateable(fo.IsAlwaysUpdateable);
    f.setIsDisplayed(fo.IsDisplayed);
    f.setIsEncryptedColumn(fo.IsEncryptedColumn);
    f.setIsEncryptedField(fo.IsEncryptedField);
    f.setIsFieldOnly(fo.IsFieldOnly);
    f.setIsHeading(fo.IsHeading);
    f.setIsKey(fo.IsKey);
    f.setIsMandatory(fo.IsMandatory);
    f.setIsParent(fo.IsParent);
    f.setIsProcess(fo.isProcess);
    f.setIsRange(fo.IsRange);
    f.setIsReadOnly(fo.IsReadOnly);
    f.setIsSameLine(fo.IsSameLine);
    f.setIsSelectionColumn(fo.IsSelectionColumn);
    f.setIsUpdateable(fo.IsUpdateable);
    if (DisplayType.isLookup(fo.displayType)) {
        GridField ff = new GridField(fo);
        ArrayList<String> deps = ff.getDependentOn();
        Lookup lookup = ff.getLookup();
        LookupInfo li = f.addNewLookupInfo();
        if (fo.lookupInfo != null) {
            li.setZoomWindow(fo.lookupInfo.ZoomWindow);
            li.setZoomWindow(fo.lookupInfo.ZoomWindow);
        }
        //if (deps.size()==0)
        if (lookup != null && (fo.ValidationCode == null || (fo.ValidationCode != null && fo.ValidationCode.length() == 0))) {
            LookupValues lvs = f.addNewLookup();
            //System.out.println( "lookup "+fo.ColumnName+" "+lookup.getSize() );
            //if(lookup.size() == 0) - nie robic tego
            //	System.out.println("lookup refresh ["+fo.ColumnName+"]= "+lookup.refresh());
            /*if(lookup.getSize() > 0)*/
            // the last was false, 2007-05-11
            ArrayList ar = lookup.getData(ff.isMandatory(false), true, !ff.isReadOnly(), true);
            if (ar != null && ar.size() > 0) {
                Object[] list = ar.toArray();
                for (int i = 0; i < list.length; i++) {
                    boolean isNumber = list[0] instanceof KeyNamePair;
                    LookupValue lv = lvs.addNewLv();
                    if (isNumber) {
                        KeyNamePair p = (KeyNamePair) list[i];
                        lv.setKey(Integer.toString(p.getKey()));
                        lv.setVal(p.getName());
                    //System.out.println( "LV " + p.getKey() + " - "+ p.getName() );						
                    } else {
                        ValueNamePair p = (ValueNamePair) list[i];
                        lv.setKey(p.getValue());
                        lv.setVal(p.getName());
                    //System.out.println( "LV " + p.getValue() + " - "+ p.getName());
                    }
                }
            }
        }
    }
}
Also used : LookupInfo(pl.x3E.adInterface.LookupInfo) ArrayList(java.util.ArrayList) GridField(org.compiere.model.GridField) Lookup(org.compiere.model.Lookup) MLookup(org.compiere.model.MLookup) LookupValues(pl.x3E.adInterface.LookupValues) KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair) LookupValue(pl.x3E.adInterface.LookupValue)

Example 88 with ValueNamePair

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

the class VHRPayPrint method cmd_export.

//  loadPaymentRuleInfo
/**************************************************************************
     *  Export payments to file
     */
private void cmd_export() {
    String PaymentRule = ((ValueNamePair) fPaymentRule.getSelectedItem()).getValue();
    log.info(PaymentRule);
    if (!getChecks(PaymentRule))
        return;
    try {
        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle(Msg.getMsg(Env.getCtx(), "Export"));
        fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
        fc.setMultiSelectionEnabled(false);
        fc.setSelectedFile(new java.io.File("paymentExport.txt"));
        if (fc.showSaveDialog(panel) != JFileChooser.APPROVE_OPTION)
            return;
        //  Create File
        int no = 0;
        StringBuffer err = new StringBuffer("");
        if (m_PaymentExportClass == null || m_PaymentExportClass.trim().length() == 0) {
            m_PaymentExportClass = "org.eevolution.util.HRGenericPaymentExport";
        }
        //	Get Payment Export Class
        HRPaymentExport custom = null;
        try {
            Class<?> clazz = Class.forName(m_PaymentExportClass);
            custom = (HRPaymentExport) clazz.newInstance();
            no = custom.exportToFile(m_checks, fc.getSelectedFile(), err);
        } catch (ClassNotFoundException e) {
            no = -1;
            err.append("No custom PaymentExport class " + m_PaymentExportClass + " - " + e.toString());
            log.log(Level.SEVERE, err.toString(), e);
        } catch (Exception e) {
            no = -1;
            err.append("Error in " + m_PaymentExportClass + " check log, " + e.toString());
            log.log(Level.SEVERE, err.toString(), e);
        }
        if (no >= 0) {
            //Filedownload.save(new FileInputStream(fc.getSelectedFile()), "plain/text", "paymentExport.txt");
            ADialog.info(m_WindowNo, panel, "Saved", Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no);
            if (ADialog.ask(m_WindowNo, panel, "VPayPrintSuccess?")) {
                //	int lastDocumentNo =
                MHRPaySelectionCheck.confirmPrint(m_checks, m_batch);
            //	document No not updated
            }
        } else {
            ADialog.error(m_WindowNo, panel, "Error", err.toString());
        }
        dispose();
    } catch (Exception e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
}
Also used : HRPaymentExport(org.eevolution.util.HRPaymentExport) JFileChooser(javax.swing.JFileChooser) ValueNamePair(org.compiere.util.ValueNamePair) HRPayPrint(org.eevolution.service.HRPayPrint)

Example 89 with ValueNamePair

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

the class WHRActionNotice method loadTextMsgLookup.

// dynInit
/**
	 * Load Text Message Lookup
	 * @param referenceId
	 * @return void
	 */
private void loadTextMsgLookup(int referenceId) {
    //	Remove all Items
    fieldTextLookup.removeAllItems();
    isLookupTextMsg = false;
    //	Valid reference
    if (referenceId == 0)
        return;
    //	Set to new
    ArrayList<ValueNamePair> conceptData = getConceptReference(referenceId);
    for (ValueNamePair vp : conceptData) {
        fieldTextLookup.appendItem(vp.getName(), vp);
    }
    //	Set Flag
    isLookupTextMsg = true;
}
Also used : ValueNamePair(org.compiere.util.ValueNamePair)

Example 90 with ValueNamePair

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

the class WAcctViewer method actionTable.

// actionDocument
/**
	 *  Save Table selection (reset Record selection)
	 */
private void actionTable() {
    Listitem listitem = selTable.getSelectedItem();
    ValueNamePair vp = null;
    if (listitem != null)
        vp = (ValueNamePair) listitem.getValue();
    else
        return;
    m_data.AD_Table_ID = ((Integer) m_data.tableInfo.get(vp.getValue())).intValue();
    log.config(vp.getValue() + " = " + m_data.AD_Table_ID);
    //  Reset Record
    m_data.Record_ID = 0;
    selRecord.setLabel("");
    selRecord.setName(vp.getValue() + "_ID");
}
Also used : Listitem(org.zkoss.zul.Listitem) ValueNamePair(org.compiere.util.ValueNamePair)

Aggregations

ValueNamePair (org.compiere.util.ValueNamePair)109 KeyNamePair (org.compiere.util.KeyNamePair)35 SQLException (java.sql.SQLException)22 ArrayList (java.util.ArrayList)22 PreparedStatement (java.sql.PreparedStatement)20 ResultSet (java.sql.ResultSet)19 Timestamp (java.sql.Timestamp)9 GridField (org.compiere.model.GridField)7 BigDecimal (java.math.BigDecimal)5 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)5 MetalTheme (javax.swing.plaf.metal.MetalTheme)5 MInvoice (org.compiere.model.MInvoice)5 MLookup (org.compiere.model.MLookup)5 MLookupInfo (org.compiere.model.MLookupInfo)5 HRPayPrint (org.eevolution.service.HRPayPrint)5 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)4 ListItem (org.adempiere.webui.component.ListItem)4 MCashLine (org.compiere.model.MCashLine)4 AdempiereUserError (org.compiere.util.AdempiereUserError)4 NamePair (org.compiere.util.NamePair)4