Search in sources :

Example 6 with VEditor

use of org.compiere.grid.ed.VEditor in project adempiere by adempiere.

the class Find method dispose.

//  initFindAdvanced
/**
	 *	Dispose window
	 */
public void dispose() {
    log.config("");
    //  Find SQL
    if (m_pstmt != null) {
        try {
            m_pstmt.close();
        } catch (SQLException e) {
        }
    }
    m_pstmt = null;
    // Remove action listener from custom fields - teo_sarca [ 1709292 ]
    for (VEditor editor : m_sEditors) {
        if (editor instanceof CTextField)
            ((CTextField) editor).removeActionListener(this);
    }
    //  TargetFields
    if (m_targetFields != null)
        m_targetFields.clear();
    m_targetFields = null;
    //
    removeAll();
    super.dispose();
}
Also used : SQLException(java.sql.SQLException) CTextField(org.compiere.swing.CTextField) VEditor(org.compiere.grid.ed.VEditor)

Example 7 with VEditor

use of org.compiere.grid.ed.VEditor in project lar_361 by comitsrl.

the class Find method addSelectionColumn.

// initFind
/**
 * 	Add Selection Column to first Tab
 * 	@param mField field
 */
private void addSelectionColumn(GridField mField) {
    log.config(mField.getHeader());
    int displayLength = mField.getDisplayLength();
    if (displayLength > FIELDLENGTH)
        mField.setDisplayLength(FIELDLENGTH);
    else
        displayLength = 0;
    // Editor
    VEditor editor = null;
    if (mField.isLookup()) {
        VLookup vl = new VLookup(mField.getColumnName(), false, false, true, mField.getLookup());
        // setting mField to avoid NPE
        vl.setField(mField);
        vl.setName(mField.getColumnName());
        editor = vl;
    } else {
        editor = VEditorFactory.getEditor(mField, false);
        editor.setMandatory(false);
        editor.setReadWrite(true);
    }
    // Add action listener to custom text fields - teo_sarca [ 1709292 ]
    if (editor instanceof CTextField) {
        ((CTextField) editor).addActionListener(this);
    }
    CLabel label = VEditorFactory.getLabel(mField);
    // 
    if (// set it back
    displayLength > 0)
        mField.setDisplayLength(displayLength);
    // 
    m_sLine++;
    if (// may be null for Y/N
    label != null)
        scontentPanel.add(label, new GridBagConstraints(1, m_sLine, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 5, 5), 0, 0));
    scontentPanel.add((Component) editor, new GridBagConstraints(2, m_sLine, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
    m_sEditors.add(editor);
}
Also used : CLabel(org.compiere.swing.CLabel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) CTextField(org.compiere.swing.CTextField) VLookup(org.compiere.grid.ed.VLookup) VEditor(org.compiere.grid.ed.VEditor)

Example 8 with VEditor

use of org.compiere.grid.ed.VEditor in project lar_361 by comitsrl.

the class Find method dispose.

// initFindAdvanced
/**
 *	Dispose window
 */
public void dispose() {
    log.config("");
    // Find SQL
    if (m_pstmt != null) {
        try {
            m_pstmt.close();
        } catch (SQLException e) {
        }
    }
    m_pstmt = null;
    // Remove action listener from custom fields - teo_sarca [ 1709292 ]
    for (VEditor editor : m_sEditors) {
        if (editor instanceof CTextField)
            ((CTextField) editor).removeActionListener(this);
    }
    // TargetFields
    if (m_targetFields != null)
        m_targetFields.clear();
    m_targetFields = null;
    // 
    removeAll();
    super.dispose();
}
Also used : SQLException(java.sql.SQLException) CTextField(org.compiere.swing.CTextField) VEditor(org.compiere.grid.ed.VEditor)

Example 9 with VEditor

use of org.compiere.grid.ed.VEditor in project lar_361 by comitsrl.

the class Find method cmd_ok_Simple.

// stateChanged
/**
 *	Simple OK Button pressed
 */
private void cmd_ok_Simple() {
    // Create Query String
    m_query = new MQuery(m_tableName);
    m_query.addRestriction(Env.parseContext(Env.getCtx(), m_targetWindowNo, m_whereExtended, false));
    if (hasValue && !valueField.getText().equals("%") && valueField.getText().length() != 0) {
        String value = valueField.getText().toUpperCase();
        if (!value.endsWith("%"))
            value += "%";
        m_query.addRestriction("UPPER(Value)", MQuery.LIKE, value, valueLabel.getText(), value);
    }
    // 
    if (hasDocNo && !docNoField.getText().equals("%") && docNoField.getText().length() != 0) {
        String value = docNoField.getText().toUpperCase();
        if (!value.endsWith("%"))
            value += "%";
        m_query.addRestriction("UPPER(DocumentNo)", MQuery.LIKE, value, docNoLabel.getText(), value);
    }
    // 
    if ((hasName) && !nameField.getText().equals("%") && nameField.getText().length() != 0) {
        String value = nameField.getText().toUpperCase();
        if (!value.endsWith("%"))
            value += "%";
        m_query.addRestriction("UPPER(Name)", MQuery.LIKE, value, nameLabel.getText(), value);
    }
    // 
    if (hasDescription && !descriptionField.getText().equals("%") && descriptionField.getText().length() != 0) {
        String value = descriptionField.getText().toUpperCase();
        if (!value.endsWith("%"))
            value += "%";
        m_query.addRestriction("UPPER(Description)", MQuery.LIKE, value, descriptionLabel.getText(), value);
    }
    // Special Editors
    for (int i = 0; i < m_sEditors.size(); i++) {
        VEditor ved = (VEditor) m_sEditors.get(i);
        Object value = ved.getValue();
        if (value != null && value.toString().length() > 0) {
            String ColumnName = ((Component) ved).getName();
            log.fine(ColumnName + "=" + value);
            // globalqss - Carlos Ruiz - 20060711
            // fix a bug with virtualColumn + isSelectionColumn not yielding results
            GridField field = getTargetMField(ColumnName);
            boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
            String ColumnSQL = field.getColumnSQL(false);
            // Be more permissive for String columns
            if (isSearchLike(field)) {
                String valueStr = value.toString().toUpperCase();
                if (!valueStr.endsWith("%"))
                    valueStr += "%";
                // 
                ColumnSQL = "UPPER(" + ColumnSQL + ")";
                value = valueStr;
            }
            // 
            if (value.toString().indexOf('%') != -1)
                m_query.addRestriction(ColumnSQL, MQuery.LIKE, value, ColumnName, ved.getDisplay());
            else if (isProductCategoryField && value instanceof Integer)
                m_query.addRestriction(getSubCategoryWhereClause(((Integer) value).intValue()));
            else
                m_query.addRestriction(ColumnSQL, MQuery.EQUAL, value, ColumnName, ved.getDisplay());
        /*
				if (value.toString().indexOf('%') != -1)
					m_query.addRestriction(ColumnName, MQuery.LIKE, value, ColumnName, ved.getDisplay());
				else
					m_query.addRestriction(ColumnName, MQuery.EQUAL, value, ColumnName, ved.getDisplay());
				*/
        // end globalqss patch
        }
    }
    // editors
    // teo_sarca [ 1708717 ]
    m_isCancel = false;
    // Test for no records
    if (getNoOfRecords(m_query, true) != 0)
        dispose();
}
Also used : MQuery(org.compiere.model.MQuery) VEditor(org.compiere.grid.ed.VEditor) GridField(org.compiere.model.GridField) Component(java.awt.Component)

Example 10 with VEditor

use of org.compiere.grid.ed.VEditor in project adempiere by adempiere.

the class ProcessPanel method setComponentVisibility.

// Dynamic Display.
@Override
public void setComponentVisibility(int index, Boolean visible, Boolean isRange) {
    VEditor editor = (VEditor) getEditor(index);
    VEditor editorTo = (VEditor) getEditorTo(index);
    if (editor == null)
        return;
    Component[] components = centerPanel.getComponents();
    for (Component comp : components) {
        if (editor.getField().getColumnName().equals(comp.getName())) {
            if (visible) {
                if (!comp.isVisible()) {
                    // visibility
                    comp.setVisible(true);
                    //	FR [ 349 ]
                    if (isRange && editorTo != null) {
                        m_separators.get(index).setVisible(true);
                        editorTo.setVisible(true);
                    }
                }
            } else if (comp.isVisible()) {
                comp.setVisible(false);
                if (isRange && editorTo != null) {
                    m_separators.get(index).setText("");
                    editorTo.setVisible(false);
                }
            }
        }
    }
}
Also used : VEditor(org.compiere.grid.ed.VEditor) Component(java.awt.Component)

Aggregations

VEditor (org.compiere.grid.ed.VEditor)15 Component (java.awt.Component)8 GridField (org.compiere.model.GridField)7 CLabel (org.compiere.swing.CLabel)4 CTextField (org.compiere.swing.CTextField)4 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 SQLException (java.sql.SQLException)2 VLookup (org.compiere.grid.ed.VLookup)2 VString (org.compiere.grid.ed.VString)2 MQuery (org.compiere.model.MQuery)2 Dimension (java.awt.Dimension)1 PropertyVetoException (java.beans.PropertyVetoException)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Box (javax.swing.Box)1 JComboBox (javax.swing.JComboBox)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)1 VChart (org.compiere.grid.ed.VChart)1