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;
}
Aggregations