Search in sources :

Example 1 with VCheckBox

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

the class VPaySelect method actionPerformed.

//	dispose
/**************************************************************************
	 *  ActionListener
	 *  @param e event
	 */
public void actionPerformed(ActionEvent e) {
    boolean triggerRefresh = false;
    if (!m_loadedOK)
        return;
    Object source = e.getSource();
    String cmd = e.getActionCommand();
    //  Trigger an update if any criteria change
    if (source instanceof VComboBox && ((VComboBox) source).getParent() instanceof VLookup) {
        source = ((VComboBox) source).getParent();
        VLookup vl = ((VLookup) source);
        //  events that don't have changes from the last action.
        if (cmd.equals("comboBoxChanged")) {
            if (!vl.hasChanged())
                return;
            else
                triggerRefresh = true;
        } else if (cmd.equals("comboBoxEdited")) {
            if (!vl.hasChanged()) {
                vl.requestFocus();
                return;
            }
            triggerRefresh = true;
        }
    } else if (source instanceof CTextField) {
        CTextField tf = ((CTextField) source);
        if (tf.getParent() instanceof VLookup) {
            // instead.
            return;
        } else if (//  The change may have come from another field
        tf.hasChanged()) {
            triggerRefresh = true;
        }
    } else if (e.getSource() instanceof VCheckBox) {
        //  Check box changes generally always cause a refresh
        //  Capture changes that don't 
        triggerRefresh = true;
        VCheckBox cb = (VCheckBox) e.getSource();
        if (cb.getName().equals("AutoQuery")) {
            //  Only trigger a refresh if the check box is selected
            if (!cb.isSelected()) {
                return;
            }
        }
    } else if (cmd.equals("comboBoxChanged")) {
        VComboBox vcb = (VComboBox) source;
        if (!vcb.hasChanged()) {
            return;
        } else {
            triggerRefresh = true;
        }
    } else if (cmd.equals("comboBoxEdited")) {
        VComboBox vcb = (VComboBox) source;
        if (!vcb.hasChanged()) {
            vcb.requestFocus();
            return;
        }
        triggerRefresh = true;
    }
    if (triggerRefresh && e.getSource() == fieldBankAccount) {
        loadBankInfo();
    }
    //  Generate PaySelection
    if (e.getSource() == bGenerate) {
        generatePaySelect();
        dispose();
    } else if (e.getSource() == bCancel)
        dispose();
    // Refresh if the autoquery feature is selected or the refresh button is clicked.
    if (e.getSource() == bRefresh || (checkAutoQuery.isSelected() && triggerRefresh)) {
        setFieldOldValues();
        loadTableInfo();
    }
}
Also used : CTextField(org.compiere.swing.CTextField) VLookup(org.compiere.grid.ed.VLookup) VComboBox(org.compiere.grid.ed.VComboBox) VCheckBox(org.compiere.grid.ed.VCheckBox)

Example 2 with VCheckBox

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

the class VPanel method setMnemonic.

//	setMnemonic
/**
	 * 	Set Mnemonic for Check Box or Button
	 *	@param editor check box or button - other ignored
	 *	@param predefinedMnemonic predefined Mnemonic
	 */
private void setMnemonic(VEditor editor, char predefinedMnemonic) {
    if (editor instanceof VCheckBox) {
        VCheckBox cb = (VCheckBox) editor;
        String text = cb.getText();
        int pos = text.indexOf('&');
        if (pos != -1 && predefinedMnemonic != 0) {
            text = text.substring(0, pos) + text.substring(pos + 1);
            cb.setText(text);
            cb.setSavedMnemonic(predefinedMnemonic);
            m_fields.add(cb);
            log.finest(predefinedMnemonic + " - " + cb.getName());
        } else {
            char mnemonic = getMnemonic(text, cb);
            if (mnemonic != 0)
                cb.setSavedMnemonic(mnemonic);
        //	cb.setMnemonic(mnemonic);
        }
    } else //	Button
    if (editor instanceof VButton) {
        VButton b = (VButton) editor;
        String text = b.getText();
        int pos = text.indexOf('&');
        if (pos != -1 && predefinedMnemonic != 0) {
            text = text.substring(0, pos) + text.substring(pos + 1);
            b.setText(text);
            b.setSavedMnemonic(predefinedMnemonic);
            m_fields.add(b);
            log.finest(predefinedMnemonic + " - " + b.getName());
        } else if (b.getColumnName().equals("DocAction")) {
            b.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, Event.SHIFT_MASK, false), "pressed");
            b.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, Event.SHIFT_MASK, true), "released");
        //	Util.printActionInputMap(b);
        } else if (b.getColumnName().equals("Posted")) {
            b.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, Event.SHIFT_MASK, false), "pressed");
            b.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, Event.SHIFT_MASK, true), "released");
        //	Util.printActionInputMap(b);
        } else {
            char mnemonic = getMnemonic(text, b);
            if (mnemonic != 0)
                b.setSavedMnemonic(mnemonic);
        }
    }
}
Also used : VButton(org.compiere.grid.ed.VButton) VCheckBox(org.compiere.grid.ed.VCheckBox)

Example 3 with VCheckBox

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

the class VPanel method setMnemonics.

/**
	 * 	Set Window level Mnemonics
	 *	@param set true if set otherwise unregister
	 */
public void setMnemonics(boolean set) {
    int size = m_fields.size();
    for (int i = 0; i < size; i++) {
        Component c = m_fields.get(i);
        if (c instanceof CLabel) {
            CLabel l = (CLabel) c;
            if (set)
                l.setDisplayedMnemonic(l.getSavedMnemonic());
            else
                l.setDisplayedMnemonic(0);
        } else if (c instanceof VCheckBox) {
            VCheckBox cb = (VCheckBox) c;
            if (set)
                cb.setMnemonic(cb.getSavedMnemonic());
            else
                cb.setMnemonic(0);
        } else if (c instanceof VButton) {
            VButton b = (VButton) c;
            if (set)
                b.setMnemonic(b.getSavedMnemonic());
            else
                b.setMnemonic(0);
        }
    }
}
Also used : CLabel(org.compiere.swing.CLabel) VButton(org.compiere.grid.ed.VButton) VCheckBox(org.compiere.grid.ed.VCheckBox) Component(java.awt.Component)

Example 4 with VCheckBox

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

the class InfoProduct method actionPerformed.

/**************************************************************************
	 *  Action Listener
	 *	@param e event
	 */
public void actionPerformed(ActionEvent e) {
    if (!p_loadedOK)
        return;
    String cmd = e.getActionCommand();
    Object source = null;
    if (e.getSource() != null) {
        source = e.getSource();
        if (cmd.equals(ConfirmPanel.A_PATTRIBUTE)) {
            // when the attribute window is closed.
            if (p_table.isMultiSelection()) {
                int row = p_table.getSelectionModel().getLeadSelectionIndex();
                p_table.setRowChecked(row, true);
            }
            MProduct mp = MProduct.get(Env.getCtx(), m_M_Product_ID);
            //  Set title and parameters for the PattributeInstance window
            String title = "";
            int wh_id = 0;
            if (isValidVObject(fWarehouse_ID)) {
                title = fWarehouse_ID.getDisplay() + " - " + mp.getName();
                wh_id = ((Integer) (fWarehouse_ID.getValue())).intValue();
            }
            //  Get the business partner from the context - it may be different than the Vendor
            int bp_id = 0;
            String s_bp_id = Env.getContext(Env.getCtx(), p_WindowNo, p_TabNo, "C_BPartner_ID", false);
            if (s_bp_id != null && s_bp_id.length() != 0 && (new Integer(s_bp_id).intValue() > 0))
                bp_id = new Integer(s_bp_id).intValue();
            //  Display the window
            PAttributeInstance pai = new PAttributeInstance(this, title, wh_id, 0, p_table.getLeadRowKey(), bp_id);
            if (!pai.wasCancelled()) {
                //  Get the results and update the fASI criteria field
                m_M_AttributeSetInstance_ID = pai.getM_AttributeSetInstance_ID();
                m_M_Locator_ID = pai.getM_Locator_ID();
                if (m_M_AttributeSetInstance_ID > 0)
                    fASI_ID.setValue(m_M_AttributeSetInstance_ID);
                else
                    //  No instance
                    fASI_ID.setValue(0);
            }
            //  looking around.
            if (//  If the results are saved, we can save now - an ASI is product specific
            p_saveResults && m_M_AttributeSetInstance_ID != -1 && !pai.wasCancelled()) {
                dispose(p_saveResults);
                return;
            }
            return;
        } else if (source instanceof VComboBox) {
            if (((VComboBox) source).getParent() instanceof VLookup) {
                // Works for VLookups using DisplayType.TableDir
                source = ((VComboBox) source).getParent();
                VLookup vl = ((VLookup) source);
                m_heldLastFocus = vl;
                if (cmd.equals("comboBoxEdited")) {
                    if (!vl.hasChanged() && !hasOutstandingChanges()) {
                        vl.requestFocus();
                        return;
                    }
                    p_triggerRefresh = true;
                    //  perform field-specific changes
                    if (vl == fWarehouse_ID) {
                        if (!isValidVObject(fWarehouse_ID)) {
                            //  Disable the stock button
                            checkOnlyStock.setSelected(false);
                            checkOnlyStock.setEnabled(false);
                        } else
                            checkOnlyStock.setEnabled(true);
                    }
                }
            }
        } else if (source instanceof CTextField) {
            CTextField tf = ((CTextField) source);
            if (tf.getParent() instanceof VPAttribute) {
                source = tf.getParent();
                VPAttribute vpa = ((VPAttribute) source);
                //  The VPAttribute field can't hold the focus effectively
                m_heldLastFocus = fieldValue;
                if (vpa.hasChanged()) {
                    p_triggerRefresh = true;
                }
            }
        } else if (e.getSource() instanceof VCheckBox) {
            //  Check box changes generally always cause a refresh
            //  Capture changes that don't 	
            VCheckBox cb = (VCheckBox) e.getSource();
            //  ShowDetail check box
            if (cb.getName().equals("ShowDetail")) {
                // Refresh only the ATP tab 
                refreshAtpTab();
                return;
            }
        }
    }
    //  e.getSource() is null
    //  Let the info class decide what to do.
    super.actionPerformed(e);
}
Also used : MProduct(org.compiere.model.MProduct) VPAttribute(org.compiere.grid.ed.VPAttribute) CTextField(org.compiere.swing.CTextField) VLookup(org.compiere.grid.ed.VLookup) VComboBox(org.compiere.grid.ed.VComboBox) VCheckBox(org.compiere.grid.ed.VCheckBox) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Example 5 with VCheckBox

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

the class Info method actionPerformed.

/**************************************************************************
	 *	(Button) Action Listener & Popup Menu
	 *  @param e event
	 */
public void actionPerformed(ActionEvent e) {
    if (!p_loadedOK)
        return;
    String cmd = e.getActionCommand();
    if (cmd.equals("CausedFocusEvent")) {
        return;
    }
    Object source = null;
    if (e.getSource() != null) {
        source = e.getSource();
        //  Keep the focus on the source field if the table updates
        m_heldLastFocus = this.getFocusOwner();
        //  Popup => Calculator
        if (source.equals(calcMenu)) {
            BigDecimal number = null;
            if (m_popupRow >= 0 && m_popupColumn >= 0) {
                Object data = p_table.getValueAt(m_popupRow, m_popupColumn);
                try {
                    if (data != null) {
                        if (data instanceof BigDecimal)
                            number = (BigDecimal) data;
                        else
                            number = new BigDecimal(data.toString());
                    }
                } catch (Exception ex) {
                }
                Calculator c = new Calculator(null, number);
                c.setVisible(true);
            }
            return;
        } else //  Popup => zoom
        if (e.getSource().equals(zoomMenu)) {
            if (m_popupRow >= 0 && m_popupColumn >= 0) {
                zoom(p_table.getRowKey(m_popupRow));
            }
            return;
        } else if (cmd.equals(ConfirmPanel.A_OK)) {
            //  VLookup fields in the criteria
            if (hasOutstandingChanges()) {
                return;
            } else {
                // We might close
                p_triggerRefresh = false;
            }
        } else if (source instanceof VComboBox) {
            if (((VComboBox) source).getParent() instanceof VLookup) {
                source = ((VComboBox) source).getParent();
                VLookup vl = ((VLookup) source);
                m_heldLastFocus = vl;
                //  events that don't have changes from the last action.
                if (cmd.equals("comboBoxChanged")) {
                    if (!vl.hasChanged())
                        return;
                    else
                        p_triggerRefresh = true;
                } else if (cmd.equals("comboBoxEdited")) {
                    if (!vl.hasChanged() && !hasOutstandingChanges()) {
                        vl.requestFocus();
                        return;
                    }
                    p_triggerRefresh = true;
                }
            }
        } else if (source instanceof CTextField) {
            CTextField tf = ((CTextField) source);
            if (tf.getParent() instanceof VLookup) {
                // instead.
                return;
            } else if (//  The change may have come from another field
            tf.hasChanged() || hasOutstandingChanges()) {
                p_triggerRefresh = true;
            } else {
                // if the dialog was opened from a menu.
                if (p_TabNo == 0)
                    return;
                else
                    //  Save the selection and close;
                    dispose(true);
            }
        } else if (e.getSource() instanceof VCheckBox) {
            //  Check box changes generally always cause a refresh
            //  Capture changes that don't 
            p_triggerRefresh = true;
            VCheckBox cb = (VCheckBox) e.getSource();
            if (cb.getName().equals("AutoQuery")) {
                //  Only trigger a refresh if the check box is selected
                if (!cb.isSelected()) {
                    return;
                }
            }
        }
        // Check if we need to reset the table.  The flag is reset when
        // the table is reset.  The first change triggers the reset.
        p_resetColumns = p_resetColumns || columnIsDynamic(source);
    }
    if (cmd.equals(ConfirmPanel.A_OK)) {
        dispose(p_saveResults);
    } else if (cmd.equals(ConfirmPanel.A_CANCEL)) {
        m_cancel = true;
        dispose(false);
    } else if (cmd.equals(ConfirmPanel.A_REFRESH)) {
        //  Refresh always causes a requery in case there are
        //  changes to the underlying tables - even if the 
        //  criteria haven't changed.
        p_resetColumns = true;
        p_triggerRefresh = true;
        p_refreshNow = true;
    } else if (cmd.equals(ConfirmPanel.A_HISTORY))
        showHistory(p_table.getLeadRowKey());
    else if (cmd.equals(ConfirmPanel.A_CUSTOMIZE))
        customize();
    else if (cmd.equals(ConfirmPanel.A_ZOOM))
        zoom(p_table.getLeadRowKey());
    else if (cmd.equals(ConfirmPanel.A_RESET)) {
        //  Go back to the defaults
        // Prevent other actions
        p_loadedOK = false;
        initInfo();
        p_loadedOK = true;
        //
        p_resetColumns = true;
        p_triggerRefresh = true;
    } else if (cmd.equals(ConfirmPanel.A_PRINT))
        PrintScreenPainter.printScreen(this);
    // Refresh if the autoquery feature is selected or the refresh button is clicked.
    if (p_triggerRefresh && (p_refreshNow || autoQuery())) {
        //  Something changed so save the state and prepare for the query
        executeQuery();
    }
    //  Reset the flags
    p_triggerRefresh = false;
    p_refreshNow = false;
}
Also used : Calculator(org.compiere.grid.ed.Calculator) CTextField(org.compiere.swing.CTextField) VLookup(org.compiere.grid.ed.VLookup) VComboBox(org.compiere.grid.ed.VComboBox) VCheckBox(org.compiere.grid.ed.VCheckBox) BigDecimal(java.math.BigDecimal) SQLException(java.sql.SQLException)

Aggregations

VCheckBox (org.compiere.grid.ed.VCheckBox)5 VComboBox (org.compiere.grid.ed.VComboBox)3 VLookup (org.compiere.grid.ed.VLookup)3 CTextField (org.compiere.swing.CTextField)3 VButton (org.compiere.grid.ed.VButton)2 Component (java.awt.Component)1 BigDecimal (java.math.BigDecimal)1 SQLException (java.sql.SQLException)1 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)1 Calculator (org.compiere.grid.ed.Calculator)1 VPAttribute (org.compiere.grid.ed.VPAttribute)1 MProduct (org.compiere.model.MProduct)1 CLabel (org.compiere.swing.CLabel)1