Search in sources :

Example 1 with ComboMenu

use of com.jsql.view.swing.manager.util.ComboMenu in project jsql-injection by ron190.

the class SqlEngine method initializeMenuVendor.

private static JPanel initializeMenuVendor() {
    var panelCombo = new JPanel();
    panelCombo.setLayout(new BorderLayout());
    panelCombo.setOpaque(false);
    // Disable overlap with zerosizesplitter
    panelCombo.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0));
    panelCombo.setPreferredSize(new Dimension(Integer.MAX_VALUE, 25));
    panelCombo.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
    var menuBarVendor = new JMenuBar();
    menuBarVendor.setOpaque(false);
    menuBarVendor.setBorder(null);
    JMenu comboMenuVendor = new ComboMenu(MediatorHelper.model().getMediatorVendor().getVendor().toString());
    menuBarVendor.add(comboMenuVendor);
    var groupVendor = new ButtonGroup();
    List<Vendor> listVendors = new LinkedList<>(MediatorHelper.model().getMediatorVendor().getVendors());
    listVendors.removeIf(vendor -> vendor == MediatorHelper.model().getMediatorVendor().getAuto());
    for (final Vendor vendor : listVendors) {
        JMenuItem itemRadioVendor = new JRadioButtonMenuItem(vendor.toString(), vendor == MediatorHelper.model().getMediatorVendor().getVendor());
        itemRadioVendor.addActionListener(actionEvent -> {
            SqlEngine.modelYaml = vendor.instance().getModelYaml();
            SqlEngine.initializeTextComponents();
            comboMenuVendor.setText(vendor.toString());
        });
        itemRadioVendor.setUI(new BasicRadioButtonMenuItemUI() {

            @Override
            protected void doClick(MenuSelectionManager msm) {
                this.menuItem.doClick(0);
            }
        });
        comboMenuVendor.add(itemRadioVendor);
        groupVendor.add(itemRadioVendor);
    }
    panelCombo.add(menuBarVendor, BorderLayout.LINE_END);
    // Do Overlay
    panelCombo.setAlignmentX(FlowLayout.TRAILING);
    panelCombo.setAlignmentY(Component.BOTTOM_ALIGNMENT);
    return panelCombo;
}
Also used : JPanel(javax.swing.JPanel) ComboMenu(com.jsql.view.swing.manager.util.ComboMenu) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Dimension(java.awt.Dimension) Vendor(com.jsql.model.injection.vendor.model.Vendor) LinkedList(java.util.LinkedList) BasicRadioButtonMenuItemUI(javax.swing.plaf.basic.BasicRadioButtonMenuItemUI) BorderLayout(java.awt.BorderLayout) ButtonGroup(javax.swing.ButtonGroup) MenuSelectionManager(javax.swing.MenuSelectionManager) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Aggregations

Vendor (com.jsql.model.injection.vendor.model.Vendor)1 ComboMenu (com.jsql.view.swing.manager.util.ComboMenu)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 LinkedList (java.util.LinkedList)1 ButtonGroup (javax.swing.ButtonGroup)1 JMenu (javax.swing.JMenu)1 JMenuBar (javax.swing.JMenuBar)1 JMenuItem (javax.swing.JMenuItem)1 JPanel (javax.swing.JPanel)1 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)1 MenuSelectionManager (javax.swing.MenuSelectionManager)1 BasicRadioButtonMenuItemUI (javax.swing.plaf.basic.BasicRadioButtonMenuItemUI)1