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