Search in sources :

Example 1 with MenuSelectionManager

use of javax.swing.MenuSelectionManager in project jsql-injection by ron190.

the class NodeModelTable method buildMenu.

@Override
protected void buildMenu(JPopupMenu2 tablePopupMenu, final TreePath path) {
    JMenuItem menuItemCheckAll = new JMenuItem(I18nView.valueByKey("COLUMNS_CHECK_ALL"), 'C');
    I18nView.addComponentForKey("COLUMNS_CHECK_ALL", menuItemCheckAll);
    JMenuItem menuItemUncheckAll = new JMenuItem(I18nView.valueByKey("COLUMNS_UNCHECK_ALL"), 'U');
    I18nView.addComponentForKey("COLUMNS_UNCHECK_ALL", menuItemUncheckAll);
    menuItemCheckAll.setIcon(HelperUi.ICON_EMPTY);
    menuItemUncheckAll.setIcon(HelperUi.ICON_EMPTY);
    if (!this.isLoaded()) {
        menuItemCheckAll.setEnabled(false);
        menuItemUncheckAll.setEnabled(false);
    }
    class ActionCheckbox implements ActionListener {

        private boolean isCheckboxesSelected;

        ActionCheckbox(boolean isCheckboxesSelected) {
            this.isCheckboxesSelected = isCheckboxesSelected;
        }

        @Override
        public void actionPerformed(ActionEvent arg0) {
            final DefaultMutableTreeNode currentTableNode = (DefaultMutableTreeNode) path.getLastPathComponent();
            final AbstractNodeModel currentTableModel = (AbstractNodeModel) currentTableNode.getUserObject();
            DefaultTreeModel treeModel = (DefaultTreeModel) MediatorGui.treeDatabase().getModel();
            int tableChildCount = treeModel.getChildCount(currentTableNode);
            for (int i = 0; i < tableChildCount; i++) {
                DefaultMutableTreeNode currentChild = (DefaultMutableTreeNode) treeModel.getChild(currentTableNode, i);
                if (currentChild.getUserObject() instanceof AbstractNodeModel) {
                    AbstractNodeModel columnTreeNodeModel = (AbstractNodeModel) currentChild.getUserObject();
                    columnTreeNodeModel.setSelected(this.isCheckboxesSelected);
                    currentTableModel.setContainingSelection(this.isCheckboxesSelected);
                }
            }
            treeModel.nodeChanged(currentTableNode);
        }
    }
    class ActionCheckAll extends ActionCheckbox {

        ActionCheckAll() {
            super(true);
        }
    }
    class ActionUncheckAll extends ActionCheckbox {

        ActionUncheckAll() {
            super(false);
        }
    }
    menuItemCheckAll.addActionListener(new ActionCheckAll());
    menuItemUncheckAll.addActionListener(new ActionUncheckAll());
    menuItemCheckAll.setIcon(HelperUi.ICON_EMPTY);
    menuItemUncheckAll.setIcon(HelperUi.ICON_EMPTY);
    tablePopupMenu.add(new JSeparator());
    tablePopupMenu.add(menuItemCheckAll);
    tablePopupMenu.add(menuItemUncheckAll);
    JMenu menuCustomLoad = new JMenu("Custom load");
    ButtonGroup 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");
    JPanel panelCustomFromRow = new JPanel(new BorderLayout());
    final JTextField inputCustomFromRow = new JPopupTextField("no.", "1").getProxy();
    inputCustomFromRow.setHorizontalAlignment(JTextField.TRAILING);
    Dimension d = new Dimension((int) inputCustomFromRow.getPreferredSize().getWidth() + 50, (int) inputCustomFromRow.getPreferredSize().getHeight());
    inputCustomFromRow.setPreferredSize(d);
    final JCheckBox 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);
    JPanel panelCustomToRow = new JPanel(new BorderLayout());
    final JTextField inputCustomToRow = new JPopupTextField("no.", "65565").getProxy();
    inputCustomToRow.setHorizontalAlignment(JTextField.TRAILING);
    inputCustomToRow.setPreferredSize(d);
    final JCheckBox 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);
    JPanel panelCustomFromChar = new JPanel(new BorderLayout());
    final JTextField inputCustomFromChar = new JPopupTextField("no.", "1").getProxy();
    inputCustomFromChar.setHorizontalAlignment(JTextField.TRAILING);
    inputCustomFromChar.setPreferredSize(d);
    final JCheckBox 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);
    JPanel panelCustomToChar = new JPanel(new BorderLayout());
    final JTextField inputCustomToChar = new JPopupTextField("no.", "65565").getProxy();
    inputCustomToChar.setHorizontalAlignment(JTextField.TRAILING);
    inputCustomToChar.setPreferredSize(d);
    final JCheckBox 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) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ActionEvent(java.awt.event.ActionEvent) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) BasicRadioButtonMenuItemUI(javax.swing.plaf.basic.BasicRadioButtonMenuItemUI) BorderLayout(java.awt.BorderLayout) CheckBoxMenuItemIconCustom(com.jsql.view.swing.panel.util.CheckBoxMenuItemIconCustom) MenuSelectionManager(javax.swing.MenuSelectionManager) JMenuItem(javax.swing.JMenuItem) BasicCheckBoxMenuItemUI(javax.swing.plaf.basic.BasicCheckBoxMenuItemUI) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) Dimension(java.awt.Dimension) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) JPopupTextField(com.jsql.view.swing.text.JPopupTextField) ButtonGroup(javax.swing.ButtonGroup) JMenu(javax.swing.JMenu)

Example 2 with MenuSelectionManager

use of javax.swing.MenuSelectionManager 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)

Example 3 with MenuSelectionManager

use of javax.swing.MenuSelectionManager 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)

Example 4 with MenuSelectionManager

use of javax.swing.MenuSelectionManager in project jsql-injection by ron190.

the class Menubar method initializeMenuWindows.

private JMenu initializeMenuWindows() {
    // Window Menu > Preferences
    var menuWindows = new JMenu(I18nUtil.valueByKey("MENUBAR_WINDOWS"));
    menuWindows.setName("menuWindows");
    I18nViewUtil.addComponentForKey("MENUBAR_WINDOWS", menuWindows);
    menuWindows.setMnemonic('W');
    JMenuItem itemNewWindows = new JMenuItemWithMargin(new ActionNewWindow());
    I18nViewUtil.addComponentForKey("NEW_WINDOW_MENU", itemNewWindows);
    menuWindows.add(itemNewWindows);
    var menuAppearance = new JMenu("Appearance");
    JMenuItem itemNewWindows4k = new JMenuItemWithMargin(new ActionNewWindow("New 4K Window", "-Dsun.java2d.uiScale=2.5"));
    menuAppearance.add(itemNewWindows4k);
    menuWindows.add(itemNewWindows);
    menuWindows.add(menuAppearance);
    menuWindows.add(new JSeparator());
    JMenu menuTranslation = this.initializeMenuTranslation();
    menuWindows.add(menuTranslation);
    menuWindows.add(new JSeparator());
    this.menuView = new JMenu(I18nUtil.valueByKey("MENUBAR_VIEW"));
    I18nViewUtil.addComponentForKey("MENUBAR_VIEW", this.menuView);
    this.menuView.setMnemonic('V');
    var database = new JMenuItem(I18nUtil.valueByKey("DATABASE_TAB"), UiUtil.ICON_DATABASE_SERVER);
    I18nViewUtil.addComponentForKey("DATABASE_TAB", database);
    this.menuView.add(database);
    var adminPage = new JMenuItem(I18nUtil.valueByKey("ADMINPAGE_TAB"), UiUtil.ICON_ADMIN_SERVER);
    I18nViewUtil.addComponentForKey("ADMINPAGE_TAB", adminPage);
    this.menuView.add(adminPage);
    var file = new JMenuItem(I18nUtil.valueByKey("FILE_TAB"), UiUtil.ICON_FILE_SERVER);
    I18nViewUtil.addComponentForKey("FILE_TAB", file);
    this.menuView.add(file);
    var webshell = new JMenuItem(I18nUtil.valueByKey("WEBSHELL_TAB"), UiUtil.ICON_SHELL_SERVER);
    I18nViewUtil.addComponentForKey("WEBSHELL_TAB", webshell);
    this.menuView.add(webshell);
    var sqlshell = new JMenuItem(I18nUtil.valueByKey("SQLSHELL_TAB"), UiUtil.ICON_SHELL_SERVER);
    I18nViewUtil.addComponentForKey("SQLSHELL_TAB", sqlshell);
    this.menuView.add(sqlshell);
    var upload = new JMenuItem(I18nUtil.valueByKey("UPLOAD_TAB"), UiUtil.ICON_UPLOAD);
    I18nViewUtil.addComponentForKey("UPLOAD_TAB", upload);
    this.menuView.add(upload);
    var bruteforce = new JMenuItem(I18nUtil.valueByKey("BRUTEFORCE_TAB"), UiUtil.ICON_BRUTER);
    I18nViewUtil.addComponentForKey("BRUTEFORCE_TAB", bruteforce);
    this.menuView.add(bruteforce);
    var coder = new JMenuItem(I18nUtil.valueByKey("CODER_TAB"), UiUtil.ICON_CODER);
    I18nViewUtil.addComponentForKey("CODER_TAB", coder);
    this.menuView.add(coder);
    var scanList = new JMenuItem(I18nUtil.valueByKey("SCANLIST_TAB"), UiUtil.ICON_SCANLIST);
    I18nViewUtil.addComponentForKey("SCANLIST_TAB", scanList);
    this.menuView.add(scanList);
    menuWindows.add(this.menuView);
    Preferences prefs = Preferences.userRoot().node(InjectionModel.class.getName());
    var menuPanel = new JMenu(I18nUtil.valueByKey("MENUBAR_PANEL"));
    I18nViewUtil.addComponentForKey("MENUBAR_PANEL", menuPanel);
    this.menuView.setMnemonic('V');
    this.chunkMenu = new JCheckBoxMenuItem(I18nUtil.valueByKey("CONSOLE_CHUNK_LABEL"), UiUtil.ICON_CHUNK, prefs.getBoolean(UiUtil.CHUNK_VISIBLE, true));
    I18nViewUtil.addComponentForKey("CONSOLE_CHUNK_LABEL", this.chunkMenu);
    menuPanel.add(this.chunkMenu);
    var binaryMenu = new JCheckBoxMenuItem(I18nUtil.valueByKey("CONSOLE_BINARY_LABEL"), UiUtil.ICON_BINARY, prefs.getBoolean(UiUtil.BINARY_VISIBLE, true));
    I18nViewUtil.addComponentForKey("CONSOLE_BINARY_LABEL", binaryMenu);
    menuPanel.add(binaryMenu);
    var networkMenu = new JCheckBoxMenuItem(I18nUtil.valueByKey("CONSOLE_NETWORK_LABEL"), UiUtil.ICON_HEADER, prefs.getBoolean(UiUtil.NETWORK_VISIBLE, true));
    I18nViewUtil.addComponentForKey("CONSOLE_NETWORK_LABEL", networkMenu);
    menuPanel.add(networkMenu);
    this.javaDebugMenu = new JCheckBoxMenuItem(I18nUtil.valueByKey("CONSOLE_JAVA_LABEL"), UiUtil.ICON_CUP, prefs.getBoolean(UiUtil.JAVA_VISIBLE, false));
    I18nViewUtil.addComponentForKey("CONSOLE_JAVA_LABEL", this.javaDebugMenu);
    for (var menuItem : new JCheckBoxMenuItem[] { this.chunkMenu, binaryMenu, networkMenu, this.javaDebugMenu }) {
        menuItem.setUI(new BasicCheckBoxMenuItemUI() {

            @Override
            protected void doClick(MenuSelectionManager msm) {
                this.menuItem.doClick(0);
            }
        });
    }
    this.chunkMenu.addActionListener(actionEvent -> {
        if (this.chunkMenu.isSelected()) {
            MediatorHelper.panelConsoles().insertChunkTab();
        } else {
            MediatorHelper.tabConsoles().remove(MediatorHelper.tabConsoles().indexOfTab(UiUtil.ICON_CHUNK));
        }
    });
    binaryMenu.addActionListener(actionEvent -> {
        if (binaryMenu.isSelected()) {
            MediatorHelper.panelConsoles().insertBooleanTab();
        } else {
            MediatorHelper.tabConsoles().remove(MediatorHelper.tabConsoles().indexOfTab(UiUtil.ICON_BINARY));
        }
    });
    networkMenu.addActionListener(actionEvent -> {
        if (networkMenu.isSelected()) {
            MediatorHelper.panelConsoles().insertNetworkTab();
        } else {
            MediatorHelper.tabConsoles().remove(MediatorHelper.tabConsoles().indexOfTab(UiUtil.ICON_HEADER));
        }
    });
    this.javaDebugMenu.addActionListener(actionEvent -> {
        if (this.javaDebugMenu.isSelected()) {
            MediatorHelper.panelConsoles().insertJavaTab();
        } else {
            MediatorHelper.tabConsoles().remove(MediatorHelper.tabConsoles().indexOfTab(UiUtil.ICON_CUP));
        }
    });
    menuPanel.add(this.javaDebugMenu);
    menuWindows.add(menuPanel);
    menuWindows.add(new JSeparator());
    database.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.CTRL_MASK));
    adminPage.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2, ActionEvent.CTRL_MASK));
    file.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_3, ActionEvent.CTRL_MASK));
    webshell.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_4, ActionEvent.CTRL_MASK));
    sqlshell.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_5, ActionEvent.CTRL_MASK));
    upload.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_6, ActionEvent.CTRL_MASK));
    bruteforce.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_7, ActionEvent.CTRL_MASK));
    coder.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_8, ActionEvent.CTRL_MASK));
    scanList.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_9, ActionEvent.CTRL_MASK));
    for (var position = 0; position < this.menuView.getItemCount(); position++) {
        final JMenuItem itemMenu = this.menuView.getItem(position);
        final int positionFinal = position;
        itemMenu.addActionListener(actionEvent -> MediatorHelper.tabManagers().setSelectedIndex(positionFinal));
    }
    JMenuItem itemPreferences = this.initializeItemPreferences();
    itemPreferences.setName("itemPreferences");
    JMenuItem itemSqlEngine = this.initializeItemSqlEngine();
    itemSqlEngine.setName("itemSqlEngine");
    menuWindows.add(itemSqlEngine);
    menuWindows.add(itemPreferences);
    return menuWindows;
}
Also used : InjectionModel(com.jsql.model.InjectionModel) BasicCheckBoxMenuItemUI(javax.swing.plaf.basic.BasicCheckBoxMenuItemUI) JSeparator(javax.swing.JSeparator) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ActionNewWindow(com.jsql.view.swing.action.ActionNewWindow) MenuSelectionManager(javax.swing.MenuSelectionManager) JMenuItem(javax.swing.JMenuItem) PanelPreferences(com.jsql.view.swing.panel.PanelPreferences) Preferences(java.util.prefs.Preferences) JMenu(javax.swing.JMenu)

Aggregations

JMenu (javax.swing.JMenu)4 JMenuItem (javax.swing.JMenuItem)4 MenuSelectionManager (javax.swing.MenuSelectionManager)4 BorderLayout (java.awt.BorderLayout)3 Dimension (java.awt.Dimension)3 ButtonGroup (javax.swing.ButtonGroup)3 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)3 JPanel (javax.swing.JPanel)3 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)3 JSeparator (javax.swing.JSeparator)3 BasicCheckBoxMenuItemUI (javax.swing.plaf.basic.BasicCheckBoxMenuItemUI)3 BasicRadioButtonMenuItemUI (javax.swing.plaf.basic.BasicRadioButtonMenuItemUI)3 JPopupTextField (com.jsql.view.swing.text.JPopupTextField)2 JCheckBox (javax.swing.JCheckBox)2 JTextField (javax.swing.JTextField)2 InjectionModel (com.jsql.model.InjectionModel)1 Vendor (com.jsql.model.injection.vendor.model.Vendor)1 ActionNewWindow (com.jsql.view.swing.action.ActionNewWindow)1 ComboMenu (com.jsql.view.swing.manager.util.ComboMenu)1 PanelPreferences (com.jsql.view.swing.panel.PanelPreferences)1