1- from javax .swing import JTabbedPane , JPanel , JButton , JLabel , SwingConstants , BorderFactory , JOptionPane , GroupLayout , JCheckBox , JSplitPane , JRadioButton , ButtonGroup , JFileChooser
1+ from javax .swing import JTabbedPane , JPanel , JButton , JLabel , SwingConstants , JOptionPane , GroupLayout , JCheckBox , JSplitPane , JRadioButton , ButtonGroup , JFileChooser
22from javax .swing .event import ChangeListener , DocumentListener
33from javax .swing .LayoutStyle .ComponentPlacement import RELATED , UNRELATED
4- from java .awt import BorderLayout , Font , Component , Color
4+ from java .awt import BorderLayout , Font , Component
55from java .beans import PropertyChangeListener
66from org .python .core .util import StringUtil
77from burp import IExtensionStateListener
@@ -119,6 +119,7 @@ def __init__(self, callbacks, script):
119119 self .scriptEditor = callbacks .createTextEditor ()
120120 self .scriptEditor .text = script .content
121121 self .scriptText = self .scriptEditor .component
122+ self .loadButton = JButton ('Load' , actionPerformed = self .load )
122123 self .compileButton = JButton ('Compile' , actionPerformed = self .compile , enabled = False )
123124
124125 editingLayout = GroupLayout (self , autoCreateGaps = True , autoCreateContainerGaps = True )
@@ -129,7 +130,10 @@ def __init__(self, callbacks, script):
129130 )
130131 .addGroup (editingLayout .createParallelGroup ()
131132 .addComponent (self .scriptText )
132- .addComponent (self .compileButton )
133+ )
134+ .addGroup (editingLayout .createSequentialGroup ()
135+ .addComponent (self .loadButton )
136+ .addComponent (self .compileButton )
133137 )
134138 )
135139
@@ -138,8 +142,11 @@ def __init__(self, callbacks, script):
138142 .addComponent (self .enabledCheckbox )
139143 )
140144 .addGroup (editingLayout .createSequentialGroup ()
141- .addComponent (self .scriptText )
142- .addComponent (self .compileButton )
145+ .addComponent (self .scriptText )
146+ )
147+ .addGroup (editingLayout .createParallelGroup ()
148+ .addComponent (self .loadButton )
149+ .addComponent (self .compileButton )
143150 )
144151 )
145152 self .layout = editingLayout
@@ -149,6 +156,13 @@ def __init__(self, callbacks, script):
149156 def enabled_changed (self , event ):
150157 self .script .enabled = self .enabledCheckbox .isSelected ()
151158
159+ def load (self , event ):
160+ file_chooser = JFileChooser ()
161+ choice = file_chooser .showOpenDialog (None )
162+ if choice == JFileChooser .APPROVE_OPTION :
163+ with open (file_chooser .selectedFile .path , 'r' ) as input_file :
164+ self .scriptEditor .text = '' .join (input_file .readlines ())
165+
152166 def compile (self , event ):
153167 self .script .compile ()
154168 self .compileButton .enabled = False
0 commit comments