Search in sources :

Example 1 with PanelPreferences

use of com.jsql.view.swing.panel.PanelPreferences in project jsql-injection by ron190.

the class Menubar method initializeItemPreferences.

private JMenuItem initializeItemPreferences() {
    JMenuItem itemPreferences = new JMenuItemWithMargin(I18nUtil.valueByKey(KEY_MENU_PREFERENCES), 'P');
    I18nViewUtil.addComponentForKey(KEY_MENU_PREFERENCES, itemPreferences);
    // Render the Preferences dialog behind scene
    var titleTabPreferences = "Preferences";
    // Single rendering
    var panelPreferences = new PanelPreferences();
    itemPreferences.addActionListener(actionEvent -> {
        for (var i = 0; i < MediatorHelper.tabResults().getTabCount(); i++) {
            if (titleTabPreferences.equals(MediatorHelper.tabResults().getTitleAt(i))) {
                MediatorHelper.tabResults().setSelectedIndex(i);
                return;
            }
        }
        CreateTabHelper.initializeSplitOrientation();
        AdjustmentListener singleItemScroll = adjustmentEvent -> {
            // The user scrolled the List (using the bar, mouse wheel or something else):
            if (adjustmentEvent.getAdjustmentType() == AdjustmentEvent.TRACK) {
                // Jump to the next "block" (which is a row".
                adjustmentEvent.getAdjustable().setBlockIncrement(100);
                adjustmentEvent.getAdjustable().setUnitIncrement(100);
            }
        };
        var scroller = new LightScrollPane(1, 0, 0, 0, panelPreferences);
        scroller.scrollPane.getVerticalScrollBar().addAdjustmentListener(singleItemScroll);
        MediatorHelper.tabResults().addTab(titleTabPreferences, scroller);
        // Focus on the new tab
        MediatorHelper.tabResults().setSelectedComponent(scroller);
        // Create a custom tab header with close button
        var header = new TabHeader(I18nViewUtil.valueByKey(KEY_MENU_PREFERENCES), UiUtil.ICON_COG, panelPreferences.getPanelTampering());
        I18nViewUtil.addComponentForKey(KEY_MENU_PREFERENCES, header.getTabTitleLabel());
        // Apply the custom header to the tab
        MediatorHelper.tabResults().setTabComponentAt(MediatorHelper.tabResults().indexOfComponent(scroller), header);
    });
    return itemPreferences;
}
Also used : UIManager(javax.swing.UIManager) I18nViewUtil(com.jsql.view.swing.util.I18nViewUtil) TabHeader(com.jsql.view.swing.tab.TabHeader) CreateTabHelper(com.jsql.view.swing.interaction.CreateTabHelper) JTableHeader(javax.swing.table.JTableHeader) StringUtils(org.apache.commons.lang3.StringUtils) SqlEngine(com.jsql.view.swing.sql.SqlEngine) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) UiUtil(com.jsql.view.swing.util.UiUtil) Locale(java.util.Locale) MouseAdapter(java.awt.event.MouseAdapter) I18nUtil(com.jsql.util.I18nUtil) MediatorHelper(com.jsql.view.swing.util.MediatorHelper) JToolTipI18n(com.jsql.view.swing.text.JToolTipI18n) BorderLayout(java.awt.BorderLayout) InjectionModel(com.jsql.model.InjectionModel) JMenuBar(javax.swing.JMenuBar) KeyStroke(javax.swing.KeyStroke) Font(java.awt.Font) JMenu(javax.swing.JMenu) KeyEvent(java.awt.event.KeyEvent) Collectors(java.util.stream.Collectors) PanelPreferences(com.jsql.view.swing.panel.PanelPreferences) Dimension(java.awt.Dimension) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) NodeModelEmpty(com.jsql.view.swing.tree.model.NodeModelEmpty) BasicCheckBoxMenuItemUI(javax.swing.plaf.basic.BasicCheckBoxMenuItemUI) JSeparator(javax.swing.JSeparator) LogLevel(com.jsql.util.LogLevel) ShowOnConsole(com.jsql.util.GitUtil.ShowOnConsole) JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) JSplitPane(javax.swing.JSplitPane) TableColumnModel(javax.swing.table.TableColumnModel) Language(com.jsql.view.swing.dialog.translate.Language) StyleConstants(javax.swing.text.StyleConstants) MenuSelectionManager(javax.swing.MenuSelectionManager) ArrayUtils(org.apache.commons.lang3.ArrayUtils) AdjustmentListener(java.awt.event.AdjustmentListener) DialogAbout(com.jsql.view.swing.dialog.DialogAbout) PanelTable(com.jsql.view.swing.table.PanelTable) ResourceBundle(java.util.ResourceBundle) JMenuItem(javax.swing.JMenuItem) JTextFieldPlaceholder(com.jsql.view.swing.text.JTextFieldPlaceholder) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) SimpleEntry(java.util.AbstractMap.SimpleEntry) AdjustmentEvent(java.awt.event.AdjustmentEvent) JPopupTextArea(com.jsql.view.swing.text.JPopupTextArea) ButtonGroup(javax.swing.ButtonGroup) DialogTranslate(com.jsql.view.swing.dialog.DialogTranslate) ActionSaveTab(com.jsql.view.swing.action.ActionSaveTab) HotkeyUtil(com.jsql.view.swing.action.HotkeyUtil) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) JTextComponent(javax.swing.text.JTextComponent) MouseEvent(java.awt.event.MouseEvent) ActionNewWindow(com.jsql.view.swing.action.ActionNewWindow) ComponentOrientation(java.awt.ComponentOrientation) Preferences(java.util.prefs.Preferences) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JTextArea(javax.swing.JTextArea) JButtonStateful(com.jsql.view.swing.manager.util.JButtonStateful) LogManager(org.apache.logging.log4j.LogManager) JTextPaneAppender(com.jsql.view.swing.console.JTextPaneAppender) TabHeader(com.jsql.view.swing.tab.TabHeader) AdjustmentListener(java.awt.event.AdjustmentListener) PanelPreferences(com.jsql.view.swing.panel.PanelPreferences) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) JMenuItem(javax.swing.JMenuItem)

Aggregations

InjectionModel (com.jsql.model.InjectionModel)1 ShowOnConsole (com.jsql.util.GitUtil.ShowOnConsole)1 I18nUtil (com.jsql.util.I18nUtil)1 LogLevel (com.jsql.util.LogLevel)1 ActionNewWindow (com.jsql.view.swing.action.ActionNewWindow)1 ActionSaveTab (com.jsql.view.swing.action.ActionSaveTab)1 HotkeyUtil (com.jsql.view.swing.action.HotkeyUtil)1 JTextPaneAppender (com.jsql.view.swing.console.JTextPaneAppender)1 DialogAbout (com.jsql.view.swing.dialog.DialogAbout)1 DialogTranslate (com.jsql.view.swing.dialog.DialogTranslate)1 Language (com.jsql.view.swing.dialog.translate.Language)1 CreateTabHelper (com.jsql.view.swing.interaction.CreateTabHelper)1 JButtonStateful (com.jsql.view.swing.manager.util.JButtonStateful)1 PanelPreferences (com.jsql.view.swing.panel.PanelPreferences)1 LightScrollPane (com.jsql.view.swing.scrollpane.LightScrollPane)1 SqlEngine (com.jsql.view.swing.sql.SqlEngine)1 TabHeader (com.jsql.view.swing.tab.TabHeader)1 PanelTable (com.jsql.view.swing.table.PanelTable)1 JPopupTextArea (com.jsql.view.swing.text.JPopupTextArea)1 JTextFieldPlaceholder (com.jsql.view.swing.text.JTextFieldPlaceholder)1