Search in sources :

Example 6 with JButtonStateful

use of com.jsql.view.swing.manager.util.JButtonStateful in project jsql-injection by ron190.

the class ManagerScan method initializeRunButton.

private void initializeRunButton(final DnDList dndListScan) {
    this.defaultText = "SCAN_RUN_BUTTON_LABEL";
    this.run = new JButtonStateful(this.defaultText);
    I18nViewUtil.addComponentForKey("SCAN_RUN_BUTTON_LABEL", this.run);
    this.run.setToolTipText(I18nUtil.valueByKey("SCAN_RUN_BUTTON_TOOLTIP"));
    this.run.setContentAreaFilled(false);
    this.run.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8));
    this.run.setBackground(new Color(200, 221, 242));
    this.run.addMouseListener(new FlatButtonMouseAdapter(this.run));
    this.run.addActionListener(actionEvent -> {
        if (dndListScan.getSelectedValuesList().isEmpty()) {
            LOGGER.log(LogLevel.CONSOLE_ERROR, "Select URL(s) to scan");
            return;
        }
        new Thread(() -> {
            if (ManagerScan.this.run.getState() == StateButton.STARTABLE) {
                ManagerScan.this.run.setText(I18nViewUtil.valueByKey("SCAN_RUN_BUTTON_STOP"));
                ManagerScan.this.run.setState(StateButton.STOPPABLE);
                ManagerScan.this.loader.setVisible(true);
                DefaultListModel<ItemList> listModel = (DefaultListModel<ItemList>) dndListScan.getModel();
                for (var i = 0; i < listModel.getSize(); i++) {
                    listModel.get(i).reset();
                }
                this.scan(dndListScan.getSelectedValuesList());
            } else {
                MediatorHelper.model().getResourceAccess().setScanStopped(true);
                MediatorHelper.model().setIsStoppedByUser(true);
                ManagerScan.this.run.setEnabled(false);
                ManagerScan.this.run.setState(StateButton.STOPPING);
            }
        }, "ThreadScan").start();
    });
}
Also used : JButtonStateful(com.jsql.view.swing.manager.util.JButtonStateful) Color(java.awt.Color) ItemList(com.jsql.view.swing.list.ItemList) FlatButtonMouseAdapter(com.jsql.view.swing.ui.FlatButtonMouseAdapter) DefaultListModel(javax.swing.DefaultListModel)

Aggregations

JButtonStateful (com.jsql.view.swing.manager.util.JButtonStateful)6 FlatButtonMouseAdapter (com.jsql.view.swing.ui.FlatButtonMouseAdapter)6 Color (java.awt.Color)6 BoxLayout (javax.swing.BoxLayout)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JSqlException (com.jsql.model.exception.JSqlException)1 ItemList (com.jsql.view.swing.list.ItemList)1 ActionBruteForce (com.jsql.view.swing.manager.util.ActionBruteForce)1 Dimension (java.awt.Dimension)1 ExecutionException (java.util.concurrent.ExecutionException)1 DefaultListModel (javax.swing.DefaultListModel)1