Search in sources :

Example 1 with JTextPaneLexer

use of com.jsql.view.swing.sql.text.JTextPaneLexer in project jsql-injection by ron190.

the class SqlEngine method populateTabError.

/**
 * Dynamically add textPanes to Error tab for current vendor.
 */
private static void populateTabError() {
    SqlEngine.tabbedPaneError.removeAll();
    if (SqlEngine.modelYaml.getStrategy().getError() == null) {
        return;
    }
    for (Method methodError : SqlEngine.modelYaml.getStrategy().getError().getMethod()) {
        var panelError = new JPanel(new BorderLayout());
        final var refMethodError = new Method[] { methodError };
        var textPaneError = new JTextPaneLexer(refMethodError[0]::setQuery, refMethodError[0]::getQuery);
        SqlEngine.resetLexer(textPaneError);
        textPaneError.switchSetterToVendor();
        textPaneError.setText(methodError.getQuery().trim());
        textPaneError.setBorder(SqlEngine.borderRight);
        panelError.add(new LightScrollPane(1, 0, 1, 0, textPaneError), BorderLayout.CENTER);
        var panelLimit = new JPanel();
        panelLimit.setLayout(new BoxLayout(panelLimit, BoxLayout.LINE_AXIS));
        panelLimit.add(new JLabel(" Overflow limit: "));
        panelLimit.add(new JTextField(Integer.toString(methodError.getCapacity())));
        // TODO Integrate Error limit
        panelError.add(panelLimit, BorderLayout.SOUTH);
        SqlEngine.tabbedPaneError.addTab(methodError.getName(), panelError);
        SqlEngine.tabbedPaneError.setTitleAt(SqlEngine.tabbedPaneError.getTabCount() - 1, String.format("<html><div style=\"text-align:left;width:100px;\">%s</div></html>", methodError.getName()));
        SqlEngine.textPanesError.add(textPaneError);
    }
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) BoxLayout(javax.swing.BoxLayout) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) JLabel(javax.swing.JLabel) JTextPaneObjectMethod(com.jsql.view.swing.sql.text.JTextPaneObjectMethod) Method(com.jsql.model.injection.vendor.model.yaml.Method) JTextPaneLexer(com.jsql.view.swing.sql.text.JTextPaneLexer) JTextField(javax.swing.JTextField)

Aggregations

Method (com.jsql.model.injection.vendor.model.yaml.Method)1 LightScrollPane (com.jsql.view.swing.scrollpane.LightScrollPane)1 JTextPaneLexer (com.jsql.view.swing.sql.text.JTextPaneLexer)1 JTextPaneObjectMethod (com.jsql.view.swing.sql.text.JTextPaneObjectMethod)1 BorderLayout (java.awt.BorderLayout)1 BoxLayout (javax.swing.BoxLayout)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JTextField (javax.swing.JTextField)1