|
| 1 | +package burp; |
| 2 | + |
| 3 | +import javax.swing.*; |
| 4 | +import java.awt.*; |
| 5 | +import java.awt.event.ActionEvent; |
| 6 | +import java.awt.event.ActionListener; |
| 7 | + |
| 8 | +public class ConfigDlg extends JDialog { |
| 9 | + private final JPanel mainPanel = new JPanel(); |
| 10 | + private final JPanel topPanel = new JPanel(); |
| 11 | + private final JPanel centerPanel = new JPanel(); |
| 12 | + private final JPanel bottomPanel = new JPanel();; |
| 13 | + private final JLabel lbSplitLen = new JLabel("Split length:");; |
| 14 | + private final JSpinner spSplitLen = new JSpinner(new SpinnerNumberModel(2, 1, 100, 1)); |
| 15 | + private final JLabel lbRange = new JLabel("(1-100)"); |
| 16 | + private final JCheckBox cbComment = new JCheckBox("Is Comment"); |
| 17 | + private final JLabel lbActOnModel = new JLabel("Act on:"); |
| 18 | + private final JCheckBox chkAllTools = new JCheckBox("All Tools"); |
| 19 | + private final JCheckBox chkSpider = new JCheckBox("Spider"); |
| 20 | + private final JCheckBox chkIntruder = new JCheckBox("Intruder"); |
| 21 | + private final JCheckBox chkScanner = new JCheckBox("Scanner"); |
| 22 | + private final JCheckBox chkRepeater = new JCheckBox("Repeater"); |
| 23 | + private final JCheckBox chkSequencer = new JCheckBox("Sequencer"); |
| 24 | + private final JCheckBox chkProxy = new JCheckBox("Proxy"); |
| 25 | + private final JCheckBox chkExtender = new JCheckBox("Extender"); |
| 26 | + private final JCheckBox chkTarget = new JCheckBox("Target"); |
| 27 | + private final JButton btCancel = new JButton("Cancel"); |
| 28 | + private final JButton btSave = new JButton("Save"); |
| 29 | + |
| 30 | + public ConfigDlg(){ |
| 31 | + initGUI(); |
| 32 | + initEvent(); |
| 33 | + initValue(); |
| 34 | + } |
| 35 | + private void initGUI(){ |
| 36 | + topPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
| 37 | + topPanel.add(lbSplitLen); |
| 38 | + topPanel.add(spSplitLen); |
| 39 | + topPanel.add(lbRange); |
| 40 | + topPanel.add(cbComment); |
| 41 | + cbComment.setSelected(true); |
| 42 | + |
| 43 | + centerPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
| 44 | + centerPanel.add(lbActOnModel); |
| 45 | + centerPanel.add(chkAllTools); |
| 46 | + centerPanel.add(chkTarget); |
| 47 | + centerPanel.add(chkProxy); |
| 48 | + centerPanel.add(chkSpider); |
| 49 | + centerPanel.add(chkIntruder); |
| 50 | + centerPanel.add(chkRepeater); |
| 51 | + centerPanel.add(chkScanner); |
| 52 | + centerPanel.add(chkSequencer); |
| 53 | + centerPanel.add(chkExtender); |
| 54 | + |
| 55 | + bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); |
| 56 | + bottomPanel.add(btCancel); |
| 57 | + bottomPanel.add(btSave); |
| 58 | + |
| 59 | + mainPanel.setLayout(new BorderLayout()); |
| 60 | + mainPanel.add(topPanel,BorderLayout.NORTH); |
| 61 | + mainPanel.add(centerPanel,BorderLayout.CENTER); |
| 62 | + mainPanel.add(bottomPanel,BorderLayout.SOUTH); |
| 63 | + |
| 64 | + this.setModal(true); |
| 65 | + this.setSize(580,140); |
| 66 | + Dimension screensize=Toolkit.getDefaultToolkit().getScreenSize(); |
| 67 | + this.setBounds(screensize.width/2-this.getWidth()/2,screensize.height/2-this.getHeight()/2,this.getWidth(),this.getHeight()); |
| 68 | + this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); |
| 69 | + this.add(mainPanel); |
| 70 | + } |
| 71 | + |
| 72 | + private void initEvent(){ |
| 73 | + chkAllTools.addActionListener(new ActionListener() { |
| 74 | + @Override |
| 75 | + public void actionPerformed(ActionEvent e) { |
| 76 | + if(chkAllTools.isSelected()){ |
| 77 | + chkTarget.setSelected(true); |
| 78 | + chkProxy.setSelected(true); |
| 79 | + chkSpider.setSelected(true); |
| 80 | + chkIntruder.setSelected(true); |
| 81 | + chkRepeater.setSelected(true); |
| 82 | + chkScanner.setSelected(true); |
| 83 | + chkExtender.setSelected(true); |
| 84 | + }else{ |
| 85 | + chkTarget.setSelected(false); |
| 86 | + chkProxy.setSelected(false); |
| 87 | + chkSpider.setSelected(false); |
| 88 | + chkIntruder.setSelected(false); |
| 89 | + chkRepeater.setSelected(false); |
| 90 | + chkScanner.setSelected(false); |
| 91 | + chkExtender.setSelected(false); |
| 92 | + } |
| 93 | + |
| 94 | + } |
| 95 | + }); |
| 96 | + |
| 97 | + btCancel.addActionListener(new ActionListener() { |
| 98 | + @Override |
| 99 | + public void actionPerformed(ActionEvent e) { |
| 100 | + ConfigDlg.this.dispose(); |
| 101 | + } |
| 102 | + }); |
| 103 | + |
| 104 | + btSave.addActionListener(new ActionListener() { |
| 105 | + @Override |
| 106 | + public void actionPerformed(ActionEvent e) { |
| 107 | + Config.splite_len = (int)spSplitLen.getValue(); |
| 108 | + Config.isComment = cbComment.isSelected(); |
| 109 | + Config.act_on_all_tools = chkAllTools.isSelected(); |
| 110 | + Config.act_on_target = chkTarget.isSelected(); |
| 111 | + Config.act_on_proxy = chkProxy.isSelected(); |
| 112 | + Config.act_on_spider = chkSpider.isSelected(); |
| 113 | + Config.act_on_intruder = chkIntruder.isSelected(); |
| 114 | + Config.act_on_repeater = chkRepeater.isSelected(); |
| 115 | + Config.act_on_scanner = chkScanner.isSelected(); |
| 116 | + Config.act_on_sequencer = chkSequencer.isSelected(); |
| 117 | + Config.act_on_extender = chkExtender.isSelected(); |
| 118 | + ConfigDlg.this.dispose(); |
| 119 | + } |
| 120 | + }); |
| 121 | + |
| 122 | + } |
| 123 | + |
| 124 | + public void initValue(){ |
| 125 | + spSplitLen.setValue(Config.splite_len); |
| 126 | + cbComment.setSelected(Config.isComment); |
| 127 | + chkAllTools.setSelected(Config.act_on_all_tools); |
| 128 | + chkTarget.setSelected(Config.act_on_target); |
| 129 | + chkProxy.setSelected(Config.act_on_proxy); |
| 130 | + chkSpider.setSelected(Config.act_on_spider); |
| 131 | + chkIntruder.setSelected(Config.act_on_intruder); |
| 132 | + chkRepeater.setSelected(Config.act_on_repeater); |
| 133 | + chkScanner.setSelected(Config.act_on_scanner); |
| 134 | + chkSequencer.setSelected(Config.act_on_sequencer); |
| 135 | + chkExtender.setSelected(Config.act_on_extender); |
| 136 | + } |
| 137 | +} |
0 commit comments