Search in sources :

Example 11 with Lookup

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

the class EMailDialog method commonInit.

//	EmailDialog
/**
	 * 	Common Init
	 *	@param from from
	 *	@param to to 
	 *	@param subject subject
	 *	@param message message
	 *	@param attachment optional attachment
	 */
private void commonInit(MUser from, String to, String subject, String message, File attachment) {
    m_client = MClient.get(Env.getCtx());
    try {
        int WindowNo = 0;
        int AD_Column_ID = 0;
        Lookup lookup = MLookupFactory.get(Env.getCtx(), WindowNo, AD_Column_ID, DisplayType.Search, Env.getLanguage(Env.getCtx()), "AD_User_ID", 0, false, "EMail IS NOT NULL");
        fUser = new VLookup("AD_User_ID", false, false, true, lookup);
        fUser.addVetoableChangeListener(this);
        fCcUser = new VLookup("AD_User_ID", false, false, true, lookup);
        fCcUser.addVetoableChangeListener(this);
        jbInit();
    } catch (Exception ex) {
        log.log(Level.SEVERE, "EMailDialog", ex);
    }
    set(from, to, subject, message);
    setAttachment(attachment);
    AEnv.showCenterScreen(this);
}
Also used : VLookup(org.compiere.grid.ed.VLookup) Lookup(org.compiere.model.Lookup) VLookup(org.compiere.grid.ed.VLookup) PropertyVetoException(java.beans.PropertyVetoException)

Example 12 with Lookup

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

the class FindValueRenderer method setValue.

//	getTableCellRendererComponent
/**************************************************************************
	 *	Format Display Value
	 *  @param value value
	 */
protected void setValue(Object value) {
    boolean enabled = !m_valueToColumn || (m_valueToColumn && m_between);
    //	Log.trace (Log.l4_Data, "FindValueRenderer.setValue (" + value + ") - Enabled=" + enabled);
    if (value == null || !enabled) {
        super.setValue(null);
        return;
    }
    String retValue = null;
    //	Strip ' '
    if (value != null) {
        String str = value.toString();
        if (str.startsWith("'") && str.endsWith("'")) {
            str = str.substring(1, str.length() - 1);
            value = str;
        }
    }
    int displayType = 0;
    GridField field = getMField();
    if (field != null)
        displayType = field.getDisplayType();
    else
        log.log(Level.SEVERE, "FindValueRenderer.setValue (" + value + ") ColumnName=" + m_columnName + " No Target Column");
    setHorizontalAlignment(JLabel.LEFT);
    //	Number
    if (DisplayType.isNumeric(displayType)) {
        setHorizontalAlignment(JLabel.RIGHT);
        retValue = DisplayType.getNumberFormat(displayType).format(value);
    } else //	Date
    if (DisplayType.isDate(displayType)) {
        if (value instanceof Date) {
            retValue = DisplayType.getDateFormat(displayType).format(value);
            setHorizontalAlignment(JLabel.RIGHT);
        } else if (//	JDBC format
        value instanceof String) {
            try {
                java.util.Date date = DisplayType.getDateFormat_JDBC().parse((String) value);
                retValue = DisplayType.getDateFormat(displayType).format(date);
                setHorizontalAlignment(JLabel.RIGHT);
            } catch (Exception e) {
                //	log.log(Level.SEVERE, "FindValueRenderer.setValue", e);
                retValue = value.toString();
            }
        } else
            retValue = value.toString();
    } else //	Row ID
    if (displayType == DisplayType.RowID)
        retValue = "";
    else //	Lookup
    if (DisplayType.isLookup(displayType) && field != null) {
        Lookup lookup = field.getLookup();
        if (lookup != null)
            retValue = lookup.getDisplay(value);
    } else //	other
    {
        super.setValue(value);
        return;
    }
    //	log.config( "FindValueRenderer.setValue (" + retValue + ") - DT=" + displayType);
    super.setValue(retValue);
}
Also used : Lookup(org.compiere.model.Lookup) GridField(org.compiere.model.GridField) Date(java.sql.Date)

Example 13 with Lookup

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

the class VTableExcelAdapter method actionPerformed.

/**
	 * This method is activated on the Keystrokes we are listening to
	 * in this implementation. Here it listens for Copy and Paste ActionCommands.
	 * 
	 * @param e event 
	 */
public void actionPerformed(ActionEvent e) {
    // Only GridTable model is supported
    if (!(table.getModel() instanceof GridTable)) {
        if (CLogMgt.isLevelFine())
            log.fine("Not supported - " + table.getModel());
        return;
    }
    boolean isCopy = CMD_Copy.equals(e.getActionCommand());
    boolean isCopyWithHeaders = CMD_CopyWithHeaders.equals(e.getActionCommand());
    if (isCopy || isCopyWithHeaders) {
        try {
            int[] selectedRows = table.getSelectedRows();
            if (selectedRows == null || selectedRows.length == 0) {
                return;
            }
            int colscount = table.getColumnCount();
            StringBuffer sb = new StringBuffer();
            GridTable model = (GridTable) table.getModel();
            GridField[] fields = model.getFields();
            // Header
            if (isCopyWithHeaders) {
                for (int col = 0; col < colscount; col++) {
                    String value = "";
                    try {
                        GridField field = fields[col];
                        if (!field.isDisplayed(false)) {
                            continue;
                        }
                        value = field.getHeader();
                    } catch (Exception ex) {
                        log.log(Level.WARNING, "Copy-headers", ex);
                    }
                    value = fixString(value);
                    sb.append(value).append("\t");
                }
                sb.append(Env.NL);
            }
            // Selected rows
            for (int row : selectedRows) {
                for (int col = 0; col < colscount; col++) {
                    Lookup lookup = null;
                    String value = null;
                    Object key = null;
                    GridField field = null;
                    try {
                        key = table.getValueAt(row, col);
                        field = fields[col];
                        if (!field.isDisplayed(false))
                            continue;
                        if (field.isEncryptedColumn() || field.isEncryptedField()) {
                            value = "*";
                        } else if (key instanceof Boolean) {
                            value = Msg.getMsg(Env.getCtx(), ((Boolean) key).booleanValue() ? "Yes" : "No");
                        } else if (key instanceof BigDecimal) {
                            try {
                                value = sysNumberFormat.format(key != null ? key : Env.ZERO);
                            } catch (Exception ex) {
                            }
                        } else if (key instanceof Date) {
                            try {
                                value = sysDateFormat.format(key);
                            } catch (Exception ex) {
                            }
                        } else {
                            lookup = (field != null ? field.getLookup() : null);
                            value = (lookup != null && key != null ? lookup.getDisplay(key) : null);
                            if (value == null && key != null)
                                value = key.toString();
                        }
                    } catch (Exception ex) {
                        log.log(Level.WARNING, "Copy-rows", ex);
                    }
                    value = fixString(value);
                    sb.append(value).append("\t");
                    if (CLogMgt.isLevelFinest())
                        log.finest("col=" + col + ", row=" + row + ": key=" + key + " => value=" + value + ", " + field + ", " + lookup);
                }
                sb.append(Env.NL);
            }
            StringSelection stsel = new StringSelection(sb.toString());
            system = Toolkit.getDefaultToolkit().getSystemClipboard();
            system.setContents(stsel, stsel);
        } catch (Exception ex) {
            log.log(Level.WARNING, "Copy", ex);
        }
    }
}
Also used : GridTable(org.compiere.model.GridTable) GridField(org.compiere.model.GridField) BigDecimal(java.math.BigDecimal) Date(java.util.Date) StringSelection(java.awt.datatransfer.StringSelection) Lookup(org.compiere.model.Lookup)

Example 14 with Lookup

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

the class WAccount method fillTable.

private table fillTable(WWindowStatus ws, GridField mField, String target) {
    table table = new table("1");
    tr line = new tr();
    line.addElement(new th("&nbsp")).addElement(new th(Msg.translate(ws.ctx, "Name")));
    table.addElement(line);
    Lookup lookup = mField.getLookup();
    lookup.fillComboBox(mField.isMandatory(false), true, true, true);
    int size = lookup.getSize();
    for (int i = 0; i < size; i++) {
        Object lValue = lookup.getElementAt(i);
        if (!(lValue != null && lValue instanceof KeyNamePair))
            continue;
        KeyNamePair np = (KeyNamePair) lValue;
        button button = new button();
        button.addElement("&gt;");
        StringBuffer script = new StringBuffer(target);
        script.append("D.value='").append(np.getKey()).append("';").append(target).append("F.value='").append(np.getName()).append("';window.close();");
        button.setOnClick(script.toString());
        line = new tr();
        line.addElement(new td(button));
        String name = np.getName();
        if (name == null || name.length() == 0)
            name = "&nbsp";
        line.addElement(new td(name));
        table.addElement(line);
    }
    lookup.fillComboBox(true);
    return table;
}
Also used : org.apache.ecs.xhtml.button(org.apache.ecs.xhtml.button) org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) org.apache.ecs.xhtml.th(org.apache.ecs.xhtml.th) Lookup(org.compiere.model.Lookup) KeyNamePair(org.compiere.util.KeyNamePair) org.apache.ecs.xhtml.table(org.apache.ecs.xhtml.table) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr)

Example 15 with Lookup

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

the class WEMailDialog method commonInit.

//	EmailDialog
/**
	 * 	Common Init
	 *	@param from from
	 *	@param to to 
	 *	@param subject subject
	 *	@param message message
	 *	@param attachment optional attachment
	 */
private void commonInit(MUser from, String to, String subject, String message, File attachment) {
    m_client = MClient.get(Env.getCtx());
    try {
        int WindowNo = 0;
        int AD_Column_ID = 0;
        Lookup lookup = MLookupFactory.get(Env.getCtx(), WindowNo, AD_Column_ID, DisplayType.Search, Env.getLanguage(Env.getCtx()), "AD_User_ID", 0, false, "EMail IS NOT NULL");
        fUser = new WSearchEditor(lookup, "AD_User_ID", "", false, false, true);
        fUser.addValueChangeListener(this);
        fCcUser = new WSearchEditor(lookup, "AD_User_ID", "", false, false, true);
        fCcUser.addValueChangeListener(this);
        jbInit();
    } catch (Exception ex) {
        log.log(Level.SEVERE, "EMailDialog", ex);
    }
    set(from, to, subject, message);
    setAttachment(attachment);
    AEnv.showCenterScreen(this);
}
Also used : WSearchEditor(org.adempiere.webui.editor.WSearchEditor) Lookup(org.compiere.model.Lookup) PropertyVetoException(java.beans.PropertyVetoException)

Aggregations

Lookup (org.compiere.model.Lookup)15 GridField (org.compiere.model.GridField)8 MLookup (org.compiere.model.MLookup)5 LookupValues (pl.x3E.adInterface.LookupValues)4 DataField (pl.x3E.adInterface.DataField)3 PropertyVetoException (java.beans.PropertyVetoException)2 IOException (java.io.IOException)2 BigDecimal (java.math.BigDecimal)2 SQLException (java.sql.SQLException)2 JasperPrint (net.sf.jasperreports.engine.JasperPrint)2 WSearchEditor (org.adempiere.webui.editor.WSearchEditor)2 MProcessPara (org.compiere.model.MProcessPara)2 KeyNamePair (org.compiere.util.KeyNamePair)2 StringSelection (java.awt.datatransfer.StringSelection)1 Date (java.sql.Date)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Label (org.adempiere.webui.component.Label)1