Search in sources :

Example 1 with SimpleConsoleAdapter

use of com.jsql.view.swing.console.SimpleConsoleAdapter in project jsql-injection by ron190.

the class PanelConsoles method initializeTabsConsoles.

private void initializeTabsConsoles() {
    this.chunkTextArea = new JPopupTextArea(new JTextAreaPlaceholderConsole("Raw data extracted during injection")).getProxy();
    this.chunkTextArea.setEditable(false);
    this.binaryTextArea = new JPopupTextArea(new JTextAreaPlaceholderConsole("Characters extracted during blind or time injection")).getProxy();
    this.binaryTextArea.setEditable(false);
    this.chunkTextArea.setLineWrap(true);
    this.binaryTextArea.setLineWrap(true);
    var consoleTextPane = new SimpleConsoleAdapter("Console", "Event logging");
    // Object creation after customization
    consoleTextPane.getProxy().setEditable(false);
    JTextPaneAppender.register(consoleTextPane);
    this.tabConsoles.setUI(new CustomMetalTabbedPaneUI() {

        @Override
        protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) {
            return Math.max(80, super.calculateTabWidth(tabPlacement, tabIndex, metrics));
        }
    });
    this.tabConsoles.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0));
    this.buildI18nTab("CONSOLE_MAIN_LABEL", "CONSOLE_MAIN_TOOLTIP", UiUtil.ICON_CONSOLE, new LightScrollPane(1, 0, 0, 0, consoleTextPane.getProxy()), 0);
    // Order is important
    var preferences = Preferences.userRoot().node(InjectionModel.class.getName());
    if (preferences.getBoolean(UiUtil.JAVA_VISIBLE, false)) {
        this.insertJavaTab();
    }
    if (preferences.getBoolean(UiUtil.NETWORK_VISIBLE, true)) {
        this.insertNetworkTab();
    }
    if (preferences.getBoolean(UiUtil.CHUNK_VISIBLE, true)) {
        this.insertChunkTab();
    }
    if (preferences.getBoolean(UiUtil.BINARY_VISIBLE, true)) {
        this.insertBooleanTab();
    }
    // Reset Font when tab is selected
    this.tabConsoles.addChangeListener(changeEvent -> {
        JTabbedPane tabs = this.tabConsoles;
        if (tabs.getSelectedIndex() > -1) {
            var currentTabHeader = tabs.getTabComponentAt(tabs.getSelectedIndex());
            if (currentTabHeader != null) {
                currentTabHeader.setFont(currentTabHeader.getFont().deriveFont(Font.PLAIN));
                currentTabHeader.setForeground(Color.BLACK);
            }
        }
    });
}
Also used : InjectionModel(com.jsql.model.InjectionModel) JTextAreaPlaceholderConsole(com.jsql.view.swing.text.JTextAreaPlaceholderConsole) CustomMetalTabbedPaneUI(com.jsql.view.swing.ui.CustomMetalTabbedPaneUI) FontMetrics(java.awt.FontMetrics) JTabbedPane(javax.swing.JTabbedPane) JPopupTextArea(com.jsql.view.swing.text.JPopupTextArea) SimpleConsoleAdapter(com.jsql.view.swing.console.SimpleConsoleAdapter) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane)

Aggregations

InjectionModel (com.jsql.model.InjectionModel)1 SimpleConsoleAdapter (com.jsql.view.swing.console.SimpleConsoleAdapter)1 LightScrollPane (com.jsql.view.swing.scrollpane.LightScrollPane)1 JPopupTextArea (com.jsql.view.swing.text.JPopupTextArea)1 JTextAreaPlaceholderConsole (com.jsql.view.swing.text.JTextAreaPlaceholderConsole)1 CustomMetalTabbedPaneUI (com.jsql.view.swing.ui.CustomMetalTabbedPaneUI)1 FontMetrics (java.awt.FontMetrics)1 JTabbedPane (javax.swing.JTabbedPane)1