Search in sources :

Example 1 with CheckBoxMenuItemIconCustom

use of com.jsql.view.swing.tree.CheckBoxMenuItemIconCustom in project jsql-injection by ron190.

the class NodeModelTable method addCustomLoadItems.

private void addCustomLoadItems(JPopupMenuCustomExtract tablePopupMenu) {
    var menuCustomLoad = new JMenu("Custom load");
    var buttonGroupLoadRows = new ButtonGroup();
    JMenuItem menuItemLoadAllRows = new JRadioButtonMenuItem("Load all rows (default)", true);
    JMenuItem menuItemLoadOneRow = new JRadioButtonMenuItem("Load first row only");
    JMenuItem menuItemDump = new JCheckBoxMenuItem("Dump to a file");
    var panelCustomFromRow = new JPanel(new BorderLayout());
    final JTextField inputCustomFromRow = new JPopupTextField("no.", "1").getProxy();
    inputCustomFromRow.setHorizontalAlignment(SwingConstants.TRAILING);
    var d = new Dimension((int) inputCustomFromRow.getPreferredSize().getWidth() + 50, (int) inputCustomFromRow.getPreferredSize().getHeight());
    inputCustomFromRow.setPreferredSize(d);
    final var radioCustomFromRow = new JCheckBox("<html><pre style=\"font-family:'Segoe UI';padding-left: 1px;\">Load from row no.&#9;</pre></html>");
    radioCustomFromRow.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
    radioCustomFromRow.setIcon(new CheckBoxMenuItemIconCustom());
    radioCustomFromRow.setFocusPainted(false);
    panelCustomFromRow.add(radioCustomFromRow, BorderLayout.LINE_START);
    panelCustomFromRow.add(inputCustomFromRow, BorderLayout.CENTER);
    var panelCustomToRow = new JPanel(new BorderLayout());
    final JTextField inputCustomToRow = new JPopupTextField("no.", "65565").getProxy();
    inputCustomToRow.setHorizontalAlignment(SwingConstants.TRAILING);
    inputCustomToRow.setPreferredSize(d);
    final var radioCustomToRow = new JCheckBox("<html><pre style=\"font-family:'Segoe UI';padding-left: 1px;\">Load to row no.&#9;&#9;&#9;&#9;&#9;&#9;</pre></html>");
    radioCustomToRow.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
    radioCustomToRow.setIcon(new CheckBoxMenuItemIconCustom());
    radioCustomToRow.setFocusPainted(false);
    panelCustomToRow.add(radioCustomToRow, BorderLayout.LINE_START);
    panelCustomToRow.add(inputCustomToRow, BorderLayout.CENTER);
    var panelCustomFromChar = new JPanel(new BorderLayout());
    final JTextField inputCustomFromChar = new JPopupTextField("no.", "1").getProxy();
    inputCustomFromChar.setHorizontalAlignment(SwingConstants.TRAILING);
    inputCustomFromChar.setPreferredSize(d);
    final var radioCustomFromChar = new JCheckBox("<html><pre style=\"font-family:'Segoe UI';padding-left: 1px;\">Load from char no.</pre></html>");
    radioCustomFromChar.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
    radioCustomFromChar.setIcon(new CheckBoxMenuItemIconCustom());
    radioCustomFromChar.setFocusPainted(false);
    panelCustomFromChar.add(radioCustomFromChar, BorderLayout.LINE_START);
    panelCustomFromChar.add(inputCustomFromChar, BorderLayout.CENTER);
    var panelCustomToChar = new JPanel(new BorderLayout());
    final JTextField inputCustomToChar = new JPopupTextField("no.", "65565").getProxy();
    inputCustomToChar.setHorizontalAlignment(SwingConstants.TRAILING);
    inputCustomToChar.setPreferredSize(d);
    final var radioCustomToChar = new JCheckBox("<html><pre style=\"font-family:'Segoe UI';padding-left: 1px;\">Load to char no.&#9;&#9;&#9;&#9;&#9;</pre></html>");
    radioCustomToChar.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
    radioCustomToChar.setIcon(new CheckBoxMenuItemIconCustom());
    radioCustomToChar.setFocusPainted(false);
    panelCustomToChar.add(radioCustomToChar, BorderLayout.LINE_START);
    panelCustomToChar.add(inputCustomToChar, BorderLayout.CENTER);
    buttonGroupLoadRows.add(menuItemLoadAllRows);
    buttonGroupLoadRows.add(menuItemLoadOneRow);
    menuCustomLoad.add(menuItemLoadAllRows);
    menuCustomLoad.add(menuItemLoadOneRow);
    menuCustomLoad.add(new JSeparator());
    menuCustomLoad.add(panelCustomFromRow);
    menuCustomLoad.add(panelCustomToRow);
    menuCustomLoad.add(panelCustomFromChar);
    menuCustomLoad.add(panelCustomToChar);
    menuCustomLoad.add(new JSeparator());
    menuCustomLoad.add(menuItemDump);
    for (JMenuItem menuItem : new JMenuItem[] { menuItemLoadAllRows, menuItemLoadOneRow }) {
        menuItem.setUI(new BasicRadioButtonMenuItemUI() {

            @Override
            protected void doClick(MenuSelectionManager msm) {
                this.menuItem.doClick(0);
            }
        });
    }
    menuItemDump.setUI(new BasicCheckBoxMenuItemUI() {

        @Override
        protected void doClick(MenuSelectionManager msm) {
            this.menuItem.doClick(0);
        }
    });
    tablePopupMenu.add(new JSeparator());
    tablePopupMenu.add(menuCustomLoad);
    tablePopupMenu.setButtonGroupLoadRows(buttonGroupLoadRows);
    tablePopupMenu.setRadioCustomFromChar(radioCustomFromChar);
    tablePopupMenu.setRadioCustomToChar(radioCustomToChar);
    tablePopupMenu.setRadioCustomFromRow(radioCustomFromRow);
    tablePopupMenu.setRadioCustomToRow(radioCustomToRow);
}
Also used : JPanel(javax.swing.JPanel) BasicCheckBoxMenuItemUI(javax.swing.plaf.basic.BasicCheckBoxMenuItemUI) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JSeparator(javax.swing.JSeparator) JCheckBox(javax.swing.JCheckBox) BasicRadioButtonMenuItemUI(javax.swing.plaf.basic.BasicRadioButtonMenuItemUI) BorderLayout(java.awt.BorderLayout) JPopupTextField(com.jsql.view.swing.text.JPopupTextField) CheckBoxMenuItemIconCustom(com.jsql.view.swing.tree.CheckBoxMenuItemIconCustom) ButtonGroup(javax.swing.ButtonGroup) MenuSelectionManager(javax.swing.MenuSelectionManager) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Aggregations

JPopupTextField (com.jsql.view.swing.text.JPopupTextField)1 CheckBoxMenuItemIconCustom (com.jsql.view.swing.tree.CheckBoxMenuItemIconCustom)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 ButtonGroup (javax.swing.ButtonGroup)1 JCheckBox (javax.swing.JCheckBox)1 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 JPanel (javax.swing.JPanel)1 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)1 JSeparator (javax.swing.JSeparator)1 JTextField (javax.swing.JTextField)1 MenuSelectionManager (javax.swing.MenuSelectionManager)1 BasicCheckBoxMenuItemUI (javax.swing.plaf.basic.BasicCheckBoxMenuItemUI)1 BasicRadioButtonMenuItemUI (javax.swing.plaf.basic.BasicRadioButtonMenuItemUI)1