Search in sources :

Example 1 with CTextField

use of org.compiere.swing.CTextField in project adempiere by adempiere.

the class VNumber method setColumns.

/**
	 * 	Set no of Columns
	 *	@param columns columns
	 *  @param height 0 to use default
	 */
public void setColumns(int columns, int height) {
    m_text.setPreferredSize(null);
    m_text.setMinimumSize(null);
    m_text.setColumns(columns);
    if (height > 0) {
        Dimension size = m_text.getPreferredSize();
        if (//	default 16
        height > size.height)
            size.height = height;
        if (CComboBox.FIELD_HIGHT - 4 > size.height)
            size.height = VLookup.FIELD_HIGHT - 4;
        m_text.setPreferredSize(size);
        m_text.setMinimumSize(size);
    } else {
        StringBuffer s = new StringBuffer();
        for (int i = 0; i < SIZE; i++) {
            s.append("0");
        }
        CTextField f = new CTextField(s.toString());
        m_text.setPreferredSize(f.getPreferredSize());
        m_text.setMinimumSize(f.getMinimumSize());
    }
    //	causes r/o to be the same length
    this.setPreferredSize(m_text.getPreferredSize());
    this.setMinimumSize(m_text.getMinimumSize());
    int h = m_text.getPreferredSize().height;
    m_button.setPreferredSize(new Dimension(h, h));
}
Also used : CTextField(org.compiere.swing.CTextField) Dimension(java.awt.Dimension)

Example 2 with CTextField

use of org.compiere.swing.CTextField 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 3 with CTextField

use of org.compiere.swing.CTextField in project adempiere by adempiere.

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;
    //#221
    VEditor editor2 = null;
    CLabel label = 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;
        //
        if (//	set it back
        displayLength > 0)
            mField.setDisplayLength(displayLength);
        //
        label = VEditorFactory.getLabel(mField);
        //m_sLine++;
        int lpos = 1;
        int fpos = 2;
        if (isTwoColumns) {
            if (!isPair) {
                lpos = 1;
                fpos = 2;
                m_sLine++;
            } else {
                lpos = 3;
                fpos = 4;
            }
        } else {
            lpos = 1;
            fpos = 2;
            m_sLine++;
        }
        if (//	may be null for Y/N
        label != null)
            scontentPanel.add(label, new GridBagConstraints(lpos, 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(fpos, m_sLine, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
    } else {
        if (mField.isRangeLookup()) {
            new Box(BoxLayout.X_AXIS);
            Box box = Box.createHorizontalBox();
            editor = VEditorFactory.getEditor(mField, false);
            label = VEditorFactory.getLabel(mField);
            editor.setMandatory(false);
            editor.setReadWrite(true);
            box.add((Component) editor);
            //#221
            editor2 = VEditorFactory.getEditor(mField, false);
            editor2.setMandatory(false);
            editor2.setReadWrite(true);
            if (editor2 instanceof CTextField) {
                ((CTextField) editor2).addActionListener(this);
            }
            CLabel separator = new CLabel(" - ");
            box.add(separator);
            box.add((Component) editor2);
            if (//	set it back
            displayLength > 0)
                mField.setDisplayLength(displayLength);
            int lpos = 1;
            int fpos = 2;
            if (isTwoColumns) {
                if (!isPair) {
                    lpos = 1;
                    fpos = 2;
                    m_sLine++;
                } else {
                    lpos = 3;
                    fpos = 4;
                }
            } else {
                lpos = 1;
                fpos = 2;
                m_sLine++;
            }
            if (//	may be null for Y/N
            label != null)
                scontentPanel.add(label, new GridBagConstraints(lpos, m_sLine, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(7, 5, 5, 5), 0, 0));
            scontentPanel.add((Component) box, new GridBagConstraints(fpos, m_sLine, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
        } else {
            editor = VEditorFactory.getEditor(mField, false);
            editor.setMandatory(false);
            editor.setReadWrite(true);
            label = VEditorFactory.getLabel(mField);
            //
            if (//	set it back
            displayLength > 0)
                mField.setDisplayLength(displayLength);
            int lpos = 1;
            int fpos = 2;
            if (isTwoColumns) {
                if (!isPair) {
                    lpos = 1;
                    fpos = 2;
                    m_sLine++;
                } else {
                    lpos = 3;
                    fpos = 4;
                }
            } else {
                lpos = 1;
                fpos = 2;
                m_sLine++;
            }
            //
            label = VEditorFactory.getLabel(mField);
            //m_sLine++;
            if (//	may be null for Y/N
            label != null)
                scontentPanel.add(label, new GridBagConstraints(lpos, 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(fpos, m_sLine, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 5), 0, 0));
        }
    }
    // Add action listener to custom text fields - teo_sarca [ 1709292 ]
    if (editor instanceof CTextField) {
        ((CTextField) editor).addActionListener(this);
    }
    m_sEditors.add(editor);
    // #221
    m_sEditors2.add(editor2);
}
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) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) CComboBox(org.compiere.swing.CComboBox) VEditor(org.compiere.grid.ed.VEditor)

Example 4 with CTextField

use of org.compiere.swing.CTextField 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 5 with CTextField

use of org.compiere.swing.CTextField in project adempiere by adempiere.

the class PreviewPanel method setupPreview.

/**
	 * Create the preview UI components 
	 */
private void setupPreview() {
    JRootPane rootPane = new JRootPane();
    previewPanel.setLayout(new BorderLayout());
    previewPanel.add(rootPane, BorderLayout.CENTER);
    previewPanel.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1));
    GridLayout gridLayout = new GridLayout(1, 3);
    gridLayout.setHgap(4);
    rootPane.getContentPane().setLayout(gridLayout);
    rootPane.setGlassPane(new GlassPane());
    rootPane.getGlassPane().setVisible(true);
    CPanel column1 = new CPanel();
    rootPane.getContentPane().add(column1);
    CPanel column2 = new CPanel();
    rootPane.getContentPane().add(column2);
    CPanel column3 = new CPanel();
    rootPane.getContentPane().add(column3);
    column1.setLayout(new GridBagLayout());
    JTree jtree = new JTree();
    jtree.setFocusable(false);
    jtree.setBorder(BorderFactory.createLineBorder(AdempierePLAF.getSecondary1(), 1));
    column1.add(jtree, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 2, 2), 0, 0));
    CTextField normal = new CTextField("Text Field");
    normal.setFocusable(false);
    column1.add(normal, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 5, 2), 0, 0));
    error.setBackground(true);
    error.setFocusable(false);
    column1.add(error, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 5, 2), 0, 0));
    column2.setLayout(new GridBagLayout());
    JTable jtable = new JTable(s_data, s_columns);
    JScrollPane scrollPane = new JScrollPane(jtable);
    jtable.setFocusable(false);
    scrollPane.setPreferredSize(jtable.getPreferredSize());
    column2.add(scrollPane, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 2, 2, 2), 0, 0));
    mandatory.setMandatory(true);
    mandatory.setFocusable(false);
    column2.add(mandatory, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 5, 2), 0, 0));
    CTextField inactive = new CTextField(s_res.getString("Inactive"));
    inactive.setEnabled(false);
    column2.add(inactive, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 5, 2), 0, 0));
    column3.setLayout(new GridBagLayout());
    CTabbedPane tab = new CTabbedPane();
    column3.add(tab, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 2, 2, 5), 0, 0));
    CComboBox editable = new CComboBox(new Object[] { "Editable" });
    editable.setEditable(true);
    editable.setFocusable(false);
    column3.add(editable, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 5, 2), 0, 0));
    CComboBox choice = new CComboBox(new Object[] { "Choice" });
    choice.setEditable(false);
    choice.setFocusable(false);
    column3.add(choice, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 5, 5), 0, 0));
    tabPage1.setLayout(new BoxLayout(tabPage1, BoxLayout.Y_AXIS));
    JRadioButton radio = new JRadioButton("Radio");
    radio.setSelected(true);
    radio.setMargin(new Insets(5, 5, 5, 5));
    radio.setFocusable(false);
    radio.setOpaque(false);
    tabPage1.add(radio);
    CCheckBox checkBox = new CCheckBox("Checkbox");
    checkBox.setSelected(true);
    checkBox.setMargin(new Insets(5, 5, 5, 5));
    checkBox.setFocusable(false);
    tabPage1.add(checkBox);
    CLabel label = new CLabel("Label");
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    tabPage1.add(label);
    button.setMargin(new Insets(5, 5, 5, 5));
    button.setFocusable(false);
    tabPage1.add(button);
    tab.add(tabPage1, "tab1");
    tab.add(new CPanel(), "tab2");
}
Also used : JScrollPane(javax.swing.JScrollPane) CLabel(org.compiere.swing.CLabel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) CComboBox(org.compiere.swing.CComboBox) CTextField(org.compiere.swing.CTextField) BoxLayout(javax.swing.BoxLayout) CPanel(org.compiere.swing.CPanel) CTabbedPane(org.compiere.swing.CTabbedPane) GridLayout(java.awt.GridLayout) JTree(javax.swing.JTree) BorderLayout(java.awt.BorderLayout) JTable(javax.swing.JTable) CCheckBox(org.compiere.swing.CCheckBox) JRootPane(javax.swing.JRootPane)

Aggregations

CTextField (org.compiere.swing.CTextField)7 VLookup (org.compiere.grid.ed.VLookup)4 VCheckBox (org.compiere.grid.ed.VCheckBox)3 VComboBox (org.compiere.grid.ed.VComboBox)3 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 SQLException (java.sql.SQLException)2 VEditor (org.compiere.grid.ed.VEditor)2 CComboBox (org.compiere.swing.CComboBox)2 CLabel (org.compiere.swing.CLabel)2 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 GridBagLayout (java.awt.GridBagLayout)1 GridLayout (java.awt.GridLayout)1 BigDecimal (java.math.BigDecimal)1 Box (javax.swing.Box)1 BoxLayout (javax.swing.BoxLayout)1 JComboBox (javax.swing.JComboBox)1 JRadioButton (javax.swing.JRadioButton)1 JRootPane (javax.swing.JRootPane)1