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