Search in sources :

Example 66 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 67 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 68 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 69 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)

Example 70 with ValueNamePair

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

the class WAcctViewer method actionAcctSchema.

// onEvent
/**
	 * 	New Acct Schema
	 */
private void actionAcctSchema() {
    Listitem listitem = selAcctSchema.getSelectedItem();
    KeyNamePair kp = null;
    if (listitem != null)
        kp = (KeyNamePair) listitem.getValue();
    if (kp == null)
        return;
    m_data.C_AcctSchema_ID = kp.getKey();
    m_data.ASchema = MAcctSchema.get(Env.getCtx(), m_data.C_AcctSchema_ID);
    log.info(m_data.ASchema.toString());
    //  Sort Options
    sortBy1.getChildren().clear();
    sortBy2.getChildren().clear();
    sortBy3.getChildren().clear();
    sortBy4.getChildren().clear();
    sortAddItem(new ValueNamePair("", ""));
    sortAddItem(new ValueNamePair("DateAcct", Msg.translate(Env.getCtx(), "DateAcct")));
    sortAddItem(new ValueNamePair("DateTrx", Msg.translate(Env.getCtx(), "DateTrx")));
    sortAddItem(new ValueNamePair("C_Period_ID", Msg.translate(Env.getCtx(), "C_Period_ID")));
    Label[] labels = new Label[] { lsel1, lsel2, lsel3, lsel4, lsel5, lsel6, lsel7, lsel8 };
    Button[] buttons = new Button[] { sel1, sel2, sel3, sel4, sel5, sel6, sel7, sel8 };
    int selectionIndex = 0;
    MAcctSchemaElement[] elements = m_data.ASchema.getAcctSchemaElements();
    for (int i = 0; i < elements.length && selectionIndex < labels.length; i++) {
        MAcctSchemaElement acctSchemaElement = elements[i];
        String columnName = acctSchemaElement.getColumnName();
        String displayColumnName;
        if (columnName.equals("User1_ID") || columnName.equals("User2_ID") || columnName.equals("User3_ID") || columnName.equals("User4_ID"))
            displayColumnName = acctSchemaElement.getName();
        else
            displayColumnName = acctSchemaElement.getDisplayColumnName();
        //  Add Sort Option
        sortAddItem(new ValueNamePair(columnName, Msg.translate(Env.getCtx(), displayColumnName)));
        if (!acctSchemaElement.isElementType(X_C_AcctSchema_Element.ELEMENTTYPE_Organization) && !acctSchemaElement.isElementType(X_C_AcctSchema_Element.ELEMENTTYPE_Account)) {
            labels[selectionIndex].setValue(Msg.translate(Env.getCtx(), displayColumnName));
            labels[selectionIndex].setVisible(true);
            // actionCommand
            buttons[selectionIndex].setName(columnName);
            buttons[selectionIndex].addEventListener(Events.ON_CLICK, this);
            buttons[selectionIndex].setImage(ServletFns.resolveThemeURL("~./images/Find16.png"));
            buttons[selectionIndex].setLabel("");
            buttons[selectionIndex].setVisible(true);
            selectionIndex++;
        }
    }
    while (selectionIndex < labels.length) {
        labels[selectionIndex].setVisible(false);
        buttons[selectionIndex++].setVisible(false);
    }
}
Also used : Button(org.adempiere.webui.component.Button) Listitem(org.zkoss.zul.Listitem) Label(org.adempiere.webui.component.Label) KeyNamePair(org.compiere.util.KeyNamePair) ValueNamePair(org.compiere.util.ValueNamePair) MAcctSchemaElement(org.compiere.model.MAcctSchemaElement)

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