Example #1
0
    def __init__(self, extender, namespace=None):
        self.extender = extender
        self.callbacks = extender.callbacks
        self.helpers = extender.helpers

        self._locals = dict(Burp=extender, items=[])
        self._buffer = []
        self.history = History(self)

        if namespace is not None:
            self._locals.update(namespace)

        self.interp = JythonInterpreter(self, self._locals)

        self.textpane = JTextPane(keyTyped=self.keyTyped,
                                  keyPressed=self.keyPressed)

        self.textpane.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.callbacks.customizeUiComponent(self.textpane)

        self.initKeyMap()

        self.document.remove(0, self.document.getLength())
        self.write('Burp Extender Jython Shell', prefix='')
        self.write(self.PS1)

        self.textpane.requestFocus()
        self.callbacks.getStdout().write('Interactive interpreter ready...\n')
Example #2
0
    def __init__(self, burp, namespace=None):
        self.burp = burp
        self.log = burp.log
        self._locals = dict(Burp=burp)
        self._buffer = []
        self.history = History(self)

        if namespace is not None:
            self._locals.update(namespace)

        self.interp = JythonInterpreter(self, self._locals)

        self.textpane = JTextPane(keyTyped=self.keyTyped,
                                  keyPressed=self.keyPressed)

        self.textpane.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.burp.customizeUiComponent(self.textpane)

        self.initKeyMap()

        self.document.remove(0, self.document.getLength())
        self.write('Burp Extender Jython Shell', prefix='')
        self.write(self.PS1)

        self.textpane.requestFocus()
        burp.log.info('Interactive interpreter ready...')
Example #3
0
    def __init__(self, frame, namespace=None):
        """
            Create a Jython Console.
            namespace is an optional and should be a dictionary or Map
        """
        self.frame = frame
        self.history = History(self)

        if namespace != None:
            self.locals = namespace
        else:
            self.locals = {}

        self.buffer = [] # buffer for multi-line commands                    

        self.interp = Interpreter(self, self.locals)
        sys.stdout = StdOutRedirector(self)

        self.text_pane = JTextPane(keyTyped = self.keyTyped, keyPressed = self.keyPressed)
        self.__initKeyMap()

        self.doc = self.text_pane.document
        self.__propertiesChanged()
        self.__inittext()
        self.initialLocation = self.doc.createPosition(self.doc.length-1)

        # Don't pass frame to popups. JWindows with null owners are not focusable
        # this fixes the focus problem on Win32, but make the mouse problem worse
        self.popup = Popup(None, self.text_pane)
        self.tip = Tip(None)

        # get fontmetrics info so we can position the popup
        metrics = self.text_pane.getFontMetrics(self.text_pane.getFont())
        self.dotWidth = metrics.charWidth('.')
        self.textHeight = metrics.getHeight()
Example #4
0
    def __init__(self):
        super(AboutDialog, self).__init__()

        # Open the files and build a tab pane
        self.tabbedPane = tabs = JTabbedPane()

        for title, path in self.INFO_FILES:
            textPane = JTextPane()
            textPane.editable = False
            scrollPane = JScrollPane(textPane)
            scrollPane.preferredSize = (32767, 32767)  # just a large number

            with open(path, 'r') as fd:
                infoText = fd.read().decode('utf8')
                textPane.text = infoText

            textPane.caretPosition = 0
            tabs.addTab(title, scrollPane)

        # Load this tabbed pane into the layout
        self.add(tabs, BorderLayout.CENTER)

        # Add a label at the top
        versionLabel = JLabel(JESVersion.TITLE + " version " +
                              JESVersion.RELEASE)
        versionLabel.alignmentX = Component.CENTER_ALIGNMENT

        versionPanel = JPanel()
        versionPanel.add(versionLabel)
        self.add(versionPanel, BorderLayout.PAGE_START)

        # Make an OK button
        self.okButton = JButton(self.ok)
        self.buttonPanel.add(self.okButton)
Example #5
0
    def registerExtenderCallbacks(self, callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.helpers

        self.scriptpane = JTextPane()
        self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11))

        self.scrollpane = JScrollPane()
        self.scrollpane.setViewportView(self.scriptpane)

        self._code = compile('', '<string>', 'exec')
        self._script = ''

        script = callbacks.loadExtensionSetting('script')

        if script:
            script = base64.b64decode(script)

            self.scriptpane.document.insertString(
                self.scriptpane.document.length, script, SimpleAttributeSet())

            self._script = script
            try:
                self._code = compile(script, '<string>', 'exec')
            except Exception as e:
                traceback.print_exc(file=self.callbacks.getStderr())

        callbacks.registerExtensionStateListener(self)
        callbacks.registerHttpListener(self)
        callbacks.customizeUiComponent(self.getUiComponent())
        callbacks.addSuiteTab(self)

        self.scriptpane.requestFocus()
    def registerExtenderCallbacks(self, callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.helpers

        callbacks.setExtensionName("Burp Scripter Plus")

        stdout = PrintWriter(callbacks.getStdout(), True)
        stdout.println(
            """Successfully loaded Burp Scripter Plus v"""
            + VERSION
            + """\n
Repository @ https://github.com/Acceis/BurpScripterPlus
Send feedback or bug reports on twitter @G4N4P4T1"""
        )

        self.scriptpane = JTextPane()
        self.scriptpane.setFont(
            Font("Monospaced", Font.PLAIN, 12)
        )

        self.scrollpane = JScrollPane()
        self.scrollpane.setViewportView(self.scriptpane)

        self._code = compile("", "<string>", "exec")
        self._script = ""

        script = callbacks.loadExtensionSetting("script")

        if script:
            script = base64.b64decode(script)

            self.scriptpane.document.insertString(
                self.scriptpane.document.length,
                script,
                SimpleAttributeSet(),
            )

            self._script = script
            try:
                self._code = compile(
                    script, "<string>", "exec"
                )
            except Exception as e:
                traceback.print_exc(
                    file=self.callbacks.getStderr()
                )

        callbacks.registerExtensionStateListener(self)
        callbacks.registerHttpListener(self)
        callbacks.customizeUiComponent(
            self.getUiComponent()
        )
        callbacks.addSuiteTab(self)

        self.scriptpane.requestFocus()
Example #7
0
 def __init__(self):
     self.textpane = JTextPane()
     self.doc = self.textpane.getStyledDocument()
     self.textpane.editable = False
     default_style = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE)
     parent_style = self.doc.addStyle("parent", default_style)
     StyleConstants.setFontFamily(parent_style, "Monospaced")
     input_style = self.doc.addStyle("input", parent_style)
     output_style = self.doc.addStyle("output", parent_style)
     StyleConstants.setForeground(output_style, Color.BLUE)
     error_style = self.doc.addStyle("error", parent_style)
     StyleConstants.setForeground(error_style, Color.RED)
Example #8
0
    def getUiComponent(self):
        """Burp uses this method to obtain the component that should be used as
        the contents of the custom tab when it is displayed.
        Returns a awt.Component.
        """
        # GUI happens here
        from javax.swing import (JPanel, JSplitPane, JList, JTextPane,
                                 JScrollPane, ListSelectionModel, JLabel,
                                 JTabbedPane, JEditorPane)
        from java.awt import BorderLayout
        panel = JPanel(BorderLayout())

        # create a list and then JList out of it.
        colors = [
            "red", "orange", "yellow", "green", "cyan", "blue", "pink",
            "magenta", "gray", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
        ]

        def listSelect(event):
            """Add the selected index to the label. Called twice when
            selecting the list item by mouse. So we need to use
            getValueIsAdjusting inside.
            """
            if not event.getValueIsAdjusting():
                doc1.insertString(0, colors[list1.selectedIndex] + "-", None)

        # create a list and assign the valueChanged
        list1 = JList(colors, valueChanged=listSelect)
        list1.selectionMode = ListSelectionModel.SINGLE_SELECTION

        # create a StyledDocument.
        from javax.swing.text import DefaultStyledDocument
        doc1 = DefaultStyledDocument()
        # create a JTextPane from doc1
        tab1 = JTextPane(doc1)

        # create a JEditorPane for tab 2
        tab2 = JEditorPane("https://example.net")
        tab2.editable = False

        # create the tabbedpane
        tabs = JTabbedPane()

        tabs.addTab("Tab 1", tab1)
        tabs.addTab("Tab 2", tab2)

        # create splitpane - horizontal split
        spl = JSplitPane(JSplitPane.HORIZONTAL_SPLIT, JScrollPane(list1), tabs)

        panel.add(spl)
        return panel
Example #9
0
    def registerExtenderCallbacks(self, callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.helpers

        self.checkboxEnable = JCheckBox('Enabled')
        self.checkboxEnable.setSelected(False)
        self.checkboxEnable.setEnabled(True)

        self.scriptpane = JTextPane()
        self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11))

        self.scrollpane = JScrollPane()
        self.scrollpane.setViewportView(self.scriptpane)

        self.tab = JPanel()
        layout = GroupLayout(self.tab)
        self.tab.setLayout(layout)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)

        layout.setHorizontalGroup(layout.createParallelGroup().addComponent(
            self.checkboxEnable).addComponent(self.scrollpane))
        layout.setVerticalGroup(layout.createSequentialGroup().addComponent(
            self.checkboxEnable).addComponent(self.scrollpane))

        self._code = compile('', '<string>', 'exec')
        self._script = ''

        script = callbacks.loadExtensionSetting('script')

        if script:
            script = base64.b64decode(script)

            self.scriptpane.document.insertString(
                self.scriptpane.document.length, script, SimpleAttributeSet())

            self._script = script
            try:
                self._code = compile(script, '<string>', 'exec')
            except Exception as e:
                traceback.print_exc(file=self.callbacks.getStderr())

        callbacks.setExtensionName("Python Scripter (modified)")
        callbacks.registerSessionHandlingAction(self)
        callbacks.registerExtensionStateListener(self)
        callbacks.registerHttpListener(self)
        callbacks.customizeUiComponent(self.getUiComponent())
        callbacks.addSuiteTab(self)

        self.scriptpane.requestFocus()
        return
Example #10
0
    def initUI(self):
        self.manImage = ImageIcon('bin/gui/media/' + "danglewood.gif")
        self.manImageSilent = ImageIcon('bin/gui/media/' +
                                        "danglewood-silent.png")
        self.manLabel = JLabel(self.manImage)

        self.dialogText = JTextPane()
        self.dialogText.setEditable(False)
        self.dialogTextScroller = JScrollPane(self.dialogText)

        self.dialogText.setBackground(Color(0, 24, 0))
        self.dialogText.setForeground(Color.WHITE)
        self.dialogText.setFont(Font("Arial", Font.BOLD, 15))

        self.buttonsPanel = ButtonPanel(self.consolePanel, self)

        self.dialogText.setText("Welcome to BashED!!!")
Example #11
0
    def registerExtenderCallbacks(self, callbacks):
        self.callbacks = callbacks
        self.helpers = callbacks.helpers

        self.scriptpane = JTextPane()
        self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11))

        self.scrollpane = JScrollPane()
        self.scrollpane.setViewportView(self.scriptpane)

        self._code = compile('', '<string>', 'exec')
        self._script = ''

        callbacks.registerExtensionStateListener(self)
        callbacks.registerProxyListener(self)
        callbacks.customizeUiComponent(self.getUiComponent())
        callbacks.addSuiteTab(self)

        self.scriptpane.requestFocus()
 def __init__(self):
     FormPanel.__init__(
         self, gvsig.getResource(__file__, "reportbypointpanelreport.xml"))
     i18Swing = ToolsSwingLocator.getToolsSwingManager()
     self.setPreferredSize(400, 300)
     self.txt = JTextPane()
     self.txt.setEditable(False)
     self.txt.setCaretPosition(0)
     i18Swing.setDefaultPopupMenu(self.txt)
     self.txt.setContentType("text/html")
     self.pane = JScrollPane(self.txt)
     #self.setInitHorizontalScroll()
     self.pane.setVerticalScrollBarPolicy(
         ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS)
     #self.setInitHorizontalScroll()
     #self.pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS)
     #self.setInitHorizontalScroll()
     self.jplReport.setLayout(BorderLayout())
     self.jplReport.add(self.pane, BorderLayout.CENTER)
     self.setInitHorizontalScroll()
Example #13
0
    def __init__(self):
        super(IntroDialog, self).__init__()

        # Open the text file and make a text pane
        textPane = JTextPane()
        textPane.editable = False

        scrollPane = JScrollPane(textPane)
        scrollPane.preferredSize = (32767, 32767)   # just a large number

        with open(self.INFO_FILE, 'r') as fd:
            infoText = fd.read().decode('utf8').replace(
                "@version@", JESVersion.VERSION
            )
            textPane.text = infoText

        # Load the scroll pane into the layout
        self.add(scrollPane, BorderLayout.CENTER)

        # Make an OK button
        self.okButton = JButton(self.ok)
        self.buttonPanel.add(self.okButton)
Example #14
0
    def __init__(self):
        super(BugReportDialog, self).__init__()

        # Add a message
        textPane = JTextPane()
        textPane.editable = False

        version = "\n".join("    " + line
                            for line in JESVersion.getMessage().splitlines())
        textPane.text = MESSAGE % version

        scrollPane = JScrollPane(textPane)
        scrollPane.preferredSize = (32767, 32767)  # just a large number

        # Load it into the layout
        self.add(scrollPane, BorderLayout.CENTER)

        # Make buttons
        self.sendButton = JButton(self.send)
        self.buttonPanel.add(self.sendButton)

        self.closeButton = JButton(self.close)
        self.buttonPanel.add(self.closeButton)
    def registerExtenderCallbacks(self, callbacks):

        callbacks.registerExtensionStateListener(self)
        # keep a reference to our callbacks object
        self._callbacks = callbacks
        # obtain an extension helpers object
        self._helpers = callbacks.getHelpers()
        # set our extension name
        callbacks.setExtensionName("Super Payload")
        # register ourselves as a payload generator factory
        callbacks.registerIntruderPayloadGeneratorFactory(self)

        # the Super Payload UI
        self.scriptpane = JTextPane()
        self.scriptpane.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.scrollpane = JScrollPane()
        self.scrollpane.setViewportView(self.scriptpane)
        callbacks.customizeUiComponent(self.getUiComponent())
        callbacks.addSuiteTab(self)
        self.scriptpane.requestFocus()

        # Compile the init script content
        self._code = compile('', '<string>', 'exec')
        self._script = ''

        script = callbacks.loadExtensionSetting('script')

        if script:
            script = base64.b64decode(script)

            self.scriptpane.document.insertString(
                self.scriptpane.document.length, script, SimpleAttributeSet())

            self._script = script
            self._code = compile(script, '<string>', 'exec')

        return
Example #16
0
    def menuItemClicked(self, caption, messageInfo):
        response = messageInfo[0].getResponse()
        strResponse = ''.join([chr(c%256) for c in response])
        frame = JFrame('DOM XSS',size = (300,300))
        parentPanel = JPanel()


        #printedCode = JTextPane(text = strResponse)
        #'''
        #colored code
        printedCode = JTextPane()
        styledDoc = printedCode.getStyledDocument()
        style = printedCode.addStyle('ColoredCode',None)
        self.filter2(strResponse,styledDoc,style)
        #'''
        #Scroll Bar
        scrollPanel = JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)
        scrollPanel.preferredSize = 1500,800
        scrollPanel.viewport.view = printedCode

        #Final Inclusion of Panels
        parentPanel.add(scrollPanel)
        frame.add(parentPanel)
        frame.visible = True
Example #17
0
    def registerExtenderCallbacks(self, callbacks):
        print "Load:" + self._name + " " + self._version

        self.callbacks = callbacks
        self.helpers = callbacks.helpers

        #Create Tab layout
        self.jVarsPane = JTextPane()
        self.jVarsPane.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.jVarsPane.addFocusListener(self)

        self.jMenuPanel = JPanel()
        self.jLeftUpPanel = JPanel()

        self.jEnable = JCheckBox()
        self.jEnable.setFont(Font('Monospaced', Font.BOLD, 11))
        self.jEnable.setForeground(Color(0, 0, 204))
        self.jEnable.setText(self._name)
        self.jEnable.addActionListener(self)

        self.jDocs = JLabel()
        self.jDocs.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.jDocs.setForeground(Color(51, 102, 255))
        self.jDocs.setText(Strings.docs_titel)
        self.jDocs.setToolTipText(Strings.docs_tooltip)
        self.jDocs.addMouseListener(self)

        self.jConsoleText = JTextArea()
        self.jConsoleText.setFont(Font('Monospaced', Font.PLAIN, 10))
        self.jConsoleText.setBackground(Color(244, 246, 247))
        self.jConsoleText.setEditable(0)
        self.jConsoleText.setWrapStyleWord(1)
        self.jConsoleText.setRows(10)
        self.jScrollConsolePane = JScrollPane()
        self.jScrollConsolePane.setViewportView(self.jConsoleText)
        #set initial text
        self.jConsoleText.setText(Strings.console_disable)

        self.jMenuPanelLayout = GroupLayout(self.jMenuPanel)
        self.jMenuPanel.setLayout(self.jMenuPanelLayout)
        self.jMenuPanelLayout.setHorizontalGroup(
            self.jMenuPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    self.jMenuPanelLayout.createSequentialGroup().addComponent(
                        self.jEnable).addPreferredGap(
                            LayoutStyle.ComponentPlacement.RELATED, 205,
                            32767).addComponent(self.jDocs)))

        self.jMenuPanelLayout.setVerticalGroup(
            self.jMenuPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    self.jMenuPanelLayout.createSequentialGroup().addGroup(
                        self.jMenuPanelLayout.createParallelGroup(
                            GroupLayout.Alignment.BASELINE).addComponent(
                                self.jEnable).addComponent(self.jDocs)).addGap(
                                    0, 7, 32767)))

        self.jConsolePane = JPanel()
        self.jConsoleLayout = GroupLayout(self.jConsolePane)
        self.jConsolePane.setLayout(self.jConsoleLayout)
        self.jConsoleLayout.setHorizontalGroup(
            self.jConsoleLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    self.jScrollConsolePane))
        self.jConsoleLayout.setVerticalGroup(
            self.jConsoleLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    GroupLayout.Alignment.TRAILING,
                    self.jConsoleLayout.createSequentialGroup().addComponent(
                        self.jScrollConsolePane, GroupLayout.DEFAULT_SIZE, 154,
                        32767).addContainerGap()))
        self.jLeftUpPanelLayout = GroupLayout(self.jLeftUpPanel)
        self.jLeftUpPanel.setLayout(self.jLeftUpPanelLayout)
        self.jLeftUpPanelLayout.setHorizontalGroup(
            self.jLeftUpPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    self.jConsolePane, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    32767).addComponent(self.jMenuPanel,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE))
        self.jLeftUpPanelLayout.setVerticalGroup(
            self.jLeftUpPanelLayout.
            createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                GroupLayout.Alignment.TRAILING,
                self.jLeftUpPanelLayout.createSequentialGroup().addComponent(
                    self.jMenuPanel, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE).addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED).addComponent(
                            self.jConsolePane, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, 32767)))

        self.jScrollpaneLeftDown = JScrollPane()
        self.jScrollpaneLeftDown.setViewportView(self.jVarsPane)

        self.jSplitPaneLeft = JSplitPane(JSplitPane.VERTICAL_SPLIT,
                                         self.jLeftUpPanel,
                                         self.jScrollpaneLeftDown)
        self.jSplitPaneLeft.setDividerLocation(300)

        self.jScriptPane = JTextPane()
        self.jScriptPane.setFont(Font('Monospaced', Font.PLAIN, 11))
        self.jScriptPane.addMouseListener(self)

        self.JScrollPaneRight = JScrollPane()
        self.JScrollPaneRight.setViewportView(self.jScriptPane)

        self.jSplitPane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
                                     self.jSplitPaneLeft,
                                     self.JScrollPaneRight)
        self.jSplitPane.setDividerLocation(400)

        #Load saved saved settings
        ##Load vars
        vars = callbacks.loadExtensionSetting(self._varsStorage)
        if vars:
            vars = base64.b64decode(vars)
        else:
            # try to load the example
            try:
                with open("examples/Simple-CSRF-vars.py") as fvars:
                    vars = fvars.read()
            # load the default text
            except:
                vars = Strings.vars

        ## initiate the persistant variables
        locals_ = {}
        try:
            exec(vars, {}, locals_)
        except Exception as e:
            print e
        self._vars = locals_

        ## update the vars screen
        self.jVarsPane.document.insertString(self.jVarsPane.document.length,
                                             vars, SimpleAttributeSet())

        ##Load script
        script = callbacks.loadExtensionSetting(self._scriptStorage)
        if script:
            script = base64.b64decode(script)
        else:
            # try to load the example
            try:
                with open("examples/Simple-CSRF-script.py") as fscript:
                    script = fscript.read()
            # load the default text
            except:
                script = Strings.script

        ## compile the rules
        self._script = script
        self._code = ''

        try:
            self._code = compile(script, '<string>', 'exec')
        except Exception as e:
            print(
                '{}\nReload extension after you correct the error.'.format(e))

        ## update the rules screen
        self.jScriptPane.document.insertString(
            self.jScriptPane.document.length, script, SimpleAttributeSet())

        #Register Extension
        callbacks.customizeUiComponent(self.getUiComponent())
        callbacks.addSuiteTab(self)
        callbacks.registerExtensionStateListener(self)
        callbacks.registerHttpListener(self)

        self.jScriptPane.requestFocus()
Example #18
0
    def getUiComponent(self):
        """Burp uses this method to obtain the component that should be used as
        the contents of the custom tab when it is displayed.
        Returns a awt.Component.
        """
        # GUI happens here
        from javax.swing import (JPanel, JSplitPane, JList, JTextPane,
                                 JScrollPane, ListSelectionModel, JLabel,
                                 JTabbedPane, JEditorPane)
        from java.awt import BorderLayout
        panel = JPanel(BorderLayout())

        # create a list and then JList out of it.
        colors = [
            "red", "orange", "yellow", "green", "cyan", "blue", "pink",
            "magenta", "gray", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
        ]

        # create a list - the list is not used in this example
        list1 = JList(colors)
        list1.selectionMode = ListSelectionModel.SINGLE_SELECTION

        # create a StyledDocument for tab 1
        from javax.swing.text import DefaultStyledDocument
        doc = DefaultStyledDocument()
        # create a JTextPane from doc
        tab1 = JTextPane(doc)
        tab1.editable = False

        # we can add more styles
        # new styles can be a child of previous styles
        # our first style is a child of the default style
        from javax.swing.text import StyleContext, StyleConstants
        defaultStyle = StyleContext.getDefaultStyleContext().getStyle(
            StyleContext.DEFAULT_STYLE)

        # returns a Style
        regular = doc.addStyle("regular", defaultStyle)
        StyleConstants.setFontFamily(defaultStyle, "Times New Roman")

        # make different styles from regular
        style1 = doc.addStyle("italic", regular)
        StyleConstants.setItalic(style1, True)

        style1 = doc.addStyle("bold", regular)
        StyleConstants.setBold(style1, True)

        style1 = doc.addStyle("small", regular)
        StyleConstants.setFontSize(style1, 10)

        style1 = doc.addStyle("large", regular)
        StyleConstants.setFontSize(style1, 16)

        # insert text
        doc.insertString(doc.length, "This is regular\n",
                         doc.getStyle("regular"))
        doc.insertString(doc.length, "This is italic\n",
                         doc.getStyle("italic"))
        doc.insertString(doc.length, "This is bold\n", doc.getStyle("bold"))
        doc.insertString(doc.length, "This is small\n", doc.getStyle("small"))
        doc.insertString(doc.length, "This is large\n", doc.getStyle("large"))

        # create the tabbedpane
        tabs = JTabbedPane()

        tabs.addTab("Tab 1", tab1)

        # create splitpane - horizontal split
        spl = JSplitPane(JSplitPane.HORIZONTAL_SPLIT, JScrollPane(list1), tabs)

        panel.add(spl)
        return panel
Example #19
0
    def __init__(self, frame):

        self.frame = frame  # TODO do I need a reference to frame after the constructor?
        self.history = History(self)
        self.bs = 0  # what is this?

        # command buffer
        self.buffer = []
        self.locals = {"gvSIG": sys.gvSIG}

        self.interp = Interpreter(self, self.locals)
        sys.stdout = StdOutRedirector(self)

        # create a textpane
        self.output = JTextPane(keyTyped=self.keyTyped,
                                keyPressed=self.keyPressed)
        # TODO rename output to textpane

        # CTRL UP AND DOWN don't work
        keyBindings = [
            (KeyEvent.VK_ENTER, 0, "jython.enter", self.enter),
            (KeyEvent.VK_DELETE, 0, "jython.delete", self.delete),
            (KeyEvent.VK_HOME, 0, "jython.home", self.home),
            (KeyEvent.VK_UP, 0, "jython.up", self.history.historyUp),
            (KeyEvent.VK_DOWN, 0, "jython.down", self.history.historyDown),
            (KeyEvent.VK_PERIOD, 0, "jython.showPopup", self.showPopup),
            (KeyEvent.VK_ESCAPE, 0, "jython.hide", self.hide),
            ('(', 0, "jython.showTip", self.showTip),
            (')', 0, "jython.hideTip", self.hideTip),

            #(KeyEvent.VK_UP, InputEvent.CTRL_MASK, DefaultEditorKit.upAction, self.output.keymap.getAction(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0))),
            #(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK, DefaultEditorKit.downAction, self.output.keymap.getAction(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)))
        ]
        # TODO rename newmap to keymap
        newmap = JTextComponent.addKeymap("jython", self.output.keymap)
        for (key, modifier, name, function) in keyBindings:
            newmap.addActionForKeyStroke(KeyStroke.getKeyStroke(key, modifier),
                                         ActionDelegator(name, function))

        self.output.keymap = newmap

        self.doc = self.output.document
        #self.panel.add(BorderLayout.CENTER, JScrollPane(self.output))
        self.__propertiesChanged()
        self.__inittext()
        self.initialLocation = self.doc.createPosition(self.doc.length - 1)

        # Don't pass frame to popups. JWindows with null owners are not focusable
        # this fixes the focus problem on Win32, but make the mouse problem worse
        self.popup = Popup(None, self.output)
        self.tip = Tip(None)

        # get fontmetrics info so we can position the popup
        metrics = self.output.getFontMetrics(self.output.getFont())
        self.dotWidth = metrics.charWidth('.')
        self.textHeight = metrics.getHeight()

        # add some handles to our objects
        self.locals['console'] = self

        self.caret = self.output.getCaret()
Example #20
0
    def run(self):
        frame = JFrame('WSAShelp_05',
                       layout=BorderLayout(),
                       defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

        #-----------------------------------------------------------------------
        # RegExp used to locate the method name portion of the help text
        #-----------------------------------------------------------------------
        methRE = re.compile(r'^(\w+)(?:\s+.*)$', re.MULTILINE)
        monoFont = Font('Courier', Font.PLAIN, 12)

        #-----------------------------------------------------------------------
        # Create & Populate the JTabbedPane
        #-----------------------------------------------------------------------
        objs = [
            ('wsadmin', None),  # Special case
            ('Help', Help),
            ('AdminApp', AdminApp),
            ('AdminConfig', AdminConfig),
            ('AdminControl', AdminControl),
            ('AdminTask', AdminTask)
        ]
        self.tPanes = {}
        highlighters = {}
        self.tabs = tabs = JTabbedPane(stateChanged=self.tabPicked)
        for name, obj in objs:
            #-------------------------------------------------------------------
            # Use a single ScrollPane for the AdminTask help
            #-------------------------------------------------------------------
            if name in ['wsadmin', 'AdminTask']:
                if obj:
                    data = obj.help().expandtabs()
                else:
                    data = Help.wsadmin().expandtabs()
                pane = JTextPane(text=data, editable=0, font=monoFont)
                pane.moveCaretPosition(0)
                tabs.addTab(name, JScrollPane(pane))
                self.tPanes[name] = [pane]
#               print 'tPanes[ "%s" ]' % name
            else:
                #---------------------------------------------------------------
                # Use a RegExp to identify where the 1st method starts.
                #---------------------------------------------------------------
                text = obj.help().expandtabs()
                mo = re.search(methRE, text)  # Match Object
                desc = text[:mo.start(1)].strip()
                meth = text[mo.start(1):].strip()
                #---------------------------------------------------------------
                # The description section is before the 1st method
                #---------------------------------------------------------------
                topPane = JTextPane(text=desc, editable=0, font=monoFont)
                topPane.moveCaretPosition(0)
                top = JScrollPane(topPane)
                #---------------------------------------------------------------
                # The method section starts at the 1st method
                #---------------------------------------------------------------
                botPane = JTextPane(text=meth, editable=0, font=monoFont)
                botPane.moveCaretPosition(0)
                bot = JScrollPane(botPane)
                #---------------------------------------------------------------
                # For the other scripting objects, use a vertically split pane
                # with the top containing the description section, and the
                # bottom containing the method details.
                #---------------------------------------------------------------
                tabs.addTab(
                    name,
                    JSplitPane(
                        JSplitPane.VERTICAL_SPLIT,
                        top,
                        bot,
                        resizeWeight=0.5,  # divider position = 50%
                        oneTouchExpandable=1))
                self.tPanes[name] = [topPane, botPane]
#               print 'tPanes[ "%s" ]' % name

#-----------------------------------------------------------------------
# Add the tabbed pane to the frame & show the result
#-----------------------------------------------------------------------
        frame.add(tabs, 'Center')

        #-----------------------------------------------------------------------
        # Label & input field for user input
        #-----------------------------------------------------------------------
        info = JPanel(BorderLayout())
        info.add(JLabel('Highlight text:'), 'West')
        self.textField = JTextField(actionPerformed=self.lookFor)
        info.add(self.textField, 'Center')
        frame.add(info, 'South')

        frame.pack()
        self.center(frame)
        frame.setVisible(1)
        self.textField.requestFocusInWindow()
Example #21
0
    def registerExtenderCallbacks(self, callbacks):
        print "Loading..."

        self._callbacks = callbacks
        self._callbacks.setExtensionName('Burp SSL Scanner')
        # self._callbacks.registerScannerCheck(self)
        # self._callbacks.registerExtensionStateListener(self)
        self._helpers = callbacks.getHelpers()

        # initialize the main scanning event and thread
        self.scanningEvent = Event()
        self.scannerThread = None
        self.targetURL = None

        # main split pane
        self._splitpane = JSplitPane(JSplitPane.VERTICAL_SPLIT)
        self._splitpane.setBorder(EmptyBorder(20, 20, 20, 20))
        
        # sub split pane (top)
        self._topPanel = JPanel(BorderLayout(10, 10))
        self._topPanel.setBorder(EmptyBorder(0, 0, 10, 0))

        # Setup Panel :    [Target: ] [______________________] [START BUTTON]
        self.setupPanel = JPanel(FlowLayout(FlowLayout.LEADING, 10, 10))

        self.setupPanel.add(
            JLabel("Target:", SwingConstants.LEFT), BorderLayout.LINE_START)

        self.hostField = JTextField('', 50)
        self.setupPanel.add(self.hostField)

        self.toggleButton = JButton(
            'Start scanning', actionPerformed=self.startScan)
        self.setupPanel.add(self.toggleButton)

        if 'Professional' in callbacks.getBurpVersion()[0] :
            self.addToSitemapCheckbox = JCheckBox('Add to sitemap', True)
        else :
            self.addToSitemapCheckbox = JCheckBox('Add to sitemap (requires Professional version)', False)
            self.addToSitemapCheckbox.setEnabled(False)
        self.setupPanel.add(self.addToSitemapCheckbox)

        self.scanSiteMapHostCheckbox = JCheckBox('Scan sitemap hosts', True)
        self.setupPanel.add(self.scanSiteMapHostCheckbox)

        self._topPanel.add(self.setupPanel, BorderLayout.PAGE_START)
        
        # Status bar
        self.scanStatusPanel = JPanel(FlowLayout(FlowLayout.LEADING, 10, 10))

        self.scanStatusPanel.add(JLabel("Status: ", SwingConstants.LEFT))

        self.scanStatusLabel = JLabel("Ready to scan", SwingConstants.LEFT)
        self.scanStatusPanel.add(self.scanStatusLabel)

        self._topPanel.add(self.scanStatusPanel, BorderLayout.LINE_START)

        self._splitpane.setTopComponent(self._topPanel)

        # bottom panel 
        self._bottomPanel = JPanel(BorderLayout(10, 10))
        self._bottomPanel.setBorder(EmptyBorder(10, 0, 0, 0))

        self.initialText = ('<h1 style="color: red;">Burp SSL Scanner<br />'
                            'Please note that TLS1.3 is still not supported by this extension.</h1>')
        self.currentText = self.initialText

        self.textPane = JTextPane()
        self.textScrollPane = JScrollPane(self.textPane)
        self.textPane.setContentType("text/html")
        self.textPane.setText(self.currentText)
        self.textPane.setEditable(False)

        self._bottomPanel.add(self.textScrollPane, BorderLayout.CENTER)

        self.savePanel = JPanel(FlowLayout(FlowLayout.LEADING, 10, 10))
        self.saveButton = JButton('Save to file', actionPerformed=self.saveToFile)
        self.saveButton.setEnabled(False)
        self.savePanel.add(self.saveButton)

        self.clearScannedHostButton = JButton('Clear scanned host', actionPerformed=self.clearScannedHost)
        self.savePanel.add(self.clearScannedHostButton)
        self.savePanel.add(JLabel("Clear hosts that were scanned by active scan to enable rescanning", SwingConstants.LEFT))

        self._bottomPanel.add(self.savePanel, BorderLayout.PAGE_END)

        self._splitpane.setBottomComponent(self._bottomPanel)

        callbacks.customizeUiComponent(self._splitpane)

        callbacks.addSuiteTab(self)
        
        print "SSL Scanner tab loaded"


        self.scannerMenu = ScannerMenu(self)
        callbacks.registerContextMenuFactory(self.scannerMenu)
        print "SSL Scanner custom menu loaded"


        self.scannerCheck = ScannerCheck(self, self.scanSiteMapHostCheckbox.isSelected)
        callbacks.registerScannerCheck(self.scannerCheck)
        print "SSL Scanner check registered"

        projectConfig = json.loads(self._callbacks.saveConfigAsJson())
        scanAccuracy = projectConfig['scanner']['active_scanning_optimization']['scan_accuracy']
        scanSpeed = projectConfig['scanner']['active_scanning_optimization']['scan_speed']

        print(scanAccuracy, scanSpeed)

        self.scannedHost = []

        print 'SSL Scanner loaded'
Example #22
0
    def __init__(self, ui):
        JSplitPane.__init__(self, JSplitPane.HORIZONTAL_SPLIT)
        self._ui = ui

        # create the executor object
        self._executor = Executor(self, ui.callbacks)

        ####
        # start Left Top split layout
        jLeftTopPanel = JPanel()
        jMenuPanel = JPanel()

        #Load button
        self.jLoad = JButton(Strings.jLoad_text)
        self.jLoad.addActionListener(self)
        #File name text field
        self.jFileName = JTextField(Strings.jFileName_default, 30)
        self.jFileName.setHorizontalAlignment(JTextField.CENTER)
        self.jFileName.setEditable(False)
        #Save button
        self.jSave = JButton(Strings.jSave_text)
        self.jSave.addActionListener(self)
        #Exit button
        self.jExit = JButton(Strings.jExit_text)
        self.jExit.addActionListener(self)
        #Wiki button (URL)
        self.jWiki = JButton(Strings.jWiki_title)
        self.jWiki.setToolTipText(Strings.jWiki_tooltip)
        self.jWiki.addActionListener(self)
        # make it borderless
        self.jWiki.setBorder(EmptyBorder(0, 0, 0, 0))
        self.jWiki.setBorderPainted(False)
        self.jWiki.setContentAreaFilled(False)

        #Console text area
        jConsoleText = JTextArea()
        jConsoleText.setEditable(0)
        jConsoleText.setWrapStyleWord(1)
        jConsoleText.setRows(10)
        #set initial text
        jConsoleText.setText(Strings.jConsoleText_help)
        #make scrollable
        jScrollConsolePane = JScrollPane()
        jScrollConsolePane.setViewportView(jConsoleText)

        jMenuPanelLayout = GroupLayout(jMenuPanel)
        jMenuPanel.setLayout(jMenuPanelLayout)
        jMenuPanelLayout.setHorizontalGroup(
            jMenuPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).
            addGroup(jMenuPanelLayout.createSequentialGroup().addContainerGap(
            ).addComponent(self.jLoad).addComponent(
                self.jFileName).addPreferredGap(
                    LayoutStyle.ComponentPlacement.RELATED).addComponent(
                        self.jSave).addPreferredGap(
                            LayoutStyle.ComponentPlacement.RELATED).
                     addComponent(self.jWiki).addPreferredGap(
                         LayoutStyle.ComponentPlacement.RELATED).addComponent(
                             self.jExit).addContainerGap()))
        jMenuPanelLayout.setVerticalGroup(
            jMenuPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    jMenuPanelLayout.createSequentialGroup().addGroup(
                        jMenuPanelLayout.createParallelGroup(
                            GroupLayout.Alignment.BASELINE).addComponent(
                                self.jLoad).addComponent(
                                    self.jFileName, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE).addComponent(
                                        self.jSave).addComponent(
                                            self.jWiki).addComponent(
                                                self.jExit))))

        jLeftTopPanelLayout = GroupLayout(jLeftTopPanel)
        jLeftTopPanel.setLayout(jLeftTopPanelLayout)
        jLeftTopPanelLayout.setHorizontalGroup(
            jLeftTopPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    jMenuPanel, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE).addComponent(
                        jScrollConsolePane, GroupLayout.DEFAULT_SIZE,
                        GroupLayout.DEFAULT_SIZE, 32767))
        jLeftTopPanelLayout.setVerticalGroup(
            jLeftTopPanelLayout.
            createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                GroupLayout.Alignment.TRAILING,
                jLeftTopPanelLayout.createSequentialGroup().addComponent(
                    jMenuPanel, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE).addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED).addComponent(
                            jScrollConsolePane, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, 32767)))
        # end Left Top split layout
        ####

        ####
        # start Left Down split layout
        jLeftDownPanel = JPanel()
        jMenu2Panel = JPanel()

        #Clear button
        self.jClear = JButton(Strings.jClear_text)
        self.jClear.setToolTipText(Strings.jClear_tooltip)
        self.jClear.addActionListener(self)

        #Run button
        self.jRun = JButton(Strings.jRun_text)
        self.jRun.setToolTipText(Strings.jRun_tooltip)
        self.jRun.addActionListener(self)

        #Variables text area
        jVarsPane = JTextPane()
        jVarsPane.setFont(Font('Monospaced', Font.PLAIN, 11))
        jVarsPane.addFocusListener(self)
        # set initial value
        jVarsPane.setText(Strings.jVarsPane_header)
        # make scrollable
        jScrollpaneLeftDown = JScrollPane()
        jScrollpaneLeftDown.setViewportView(jVarsPane)

        jMenu2PanelLayout = GroupLayout(jMenu2Panel)
        jMenu2Panel.setLayout(jMenu2PanelLayout)
        jMenu2PanelLayout.setHorizontalGroup(
            jMenu2PanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    jMenu2PanelLayout.createSequentialGroup().addContainerGap(
                    ).addComponent(self.jClear).addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED, 100,
                        32767).addComponent(self.jRun).addContainerGap()))
        jMenu2PanelLayout.setVerticalGroup(
            jMenu2PanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addGroup(
                    jMenu2PanelLayout.createSequentialGroup().addGroup(
                        jMenu2PanelLayout.createParallelGroup(
                            GroupLayout.Alignment.BASELINE).addComponent(
                                self.jClear).addComponent(self.jRun))))
        jLeftDownPanelLayout = GroupLayout(jLeftDownPanel)
        jLeftDownPanel.setLayout(jLeftDownPanelLayout)
        jLeftDownPanelLayout.setHorizontalGroup(
            jLeftDownPanelLayout.createParallelGroup(
                GroupLayout.Alignment.LEADING).addComponent(
                    jMenu2Panel, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.DEFAULT_SIZE).addComponent(
                        jScrollpaneLeftDown, GroupLayout.DEFAULT_SIZE,
                        GroupLayout.DEFAULT_SIZE, 32767))
        jLeftDownPanelLayout.setVerticalGroup(
            jLeftDownPanelLayout.
            createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(
                GroupLayout.Alignment.TRAILING,
                jLeftDownPanelLayout.createSequentialGroup().addComponent(
                    jMenu2Panel, GroupLayout.PREFERRED_SIZE,
                    GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE).addPreferredGap(
                        LayoutStyle.ComponentPlacement.RELATED).addComponent(
                            jScrollpaneLeftDown, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, 32767)))
        # end Left Down split layout
        ####

        ####
        # start Left layout
        jSplitPaneLeft = JSplitPane(JSplitPane.VERTICAL_SPLIT, jLeftTopPanel,
                                    jLeftDownPanel)
        jSplitPaneLeft.setDividerLocation(300)
        # end Left layout
        ####

        ####
        # start Right layout
        jScriptPane = JTextPane()
        jScriptPane.setFont(Font('Monospaced', Font.PLAIN, 11))
        # set initial value
        jScriptPane.setText(Strings.jScriptPane_header)
        #jScriptPane.addMouseListener(self)

        jScrollPaneRight = JScrollPane()
        jScrollPaneRight.setViewportView(jScriptPane)
        # end Right layout
        ####

        self.setLeftComponent(jSplitPaneLeft)
        self.setRightComponent(jScrollPaneRight)
        self.setDividerLocation(450)

        #Exported variables
        self.jConsoleText = jConsoleText
        self.jScrollConsolePane = jScrollConsolePane
        self.jScriptPane = jScriptPane
        self.jVarsPane = jVarsPane
Example #23
0
    def run(self):
        self.frame = frame = JFrame('WSAShelp_09',
                                    layout=BorderLayout(),
                                    componentResized=self.frameResized,
                                    defaultCloseOperation=JFrame.EXIT_ON_CLOSE)

        #-----------------------------------------------------------------------
        # RegExp used to locate method names
        #-----------------------------------------------------------------------
        methRE = re.compile(r'^(\w+)(?:\s+.*)$', re.MULTILINE)

        #-----------------------------------------------------------------------
        # Add our menu bar to the frame
        #-----------------------------------------------------------------------
        frame.setJMenuBar(self.MenuBar())

        #-----------------------------------------------------------------------
        # Create & Populate the JTabbedPane
        #-----------------------------------------------------------------------
        WASobjs = [
            ('wsadmin', None),  # Special case
            ('Help', Help),
            ('AdminApp', AdminApp),
            ('AdminConfig', AdminConfig),
            ('AdminControl', AdminControl),
            ('AdminTask', AdminTask)
        ]
        tabs = self.tabs
        for name, WASobj in WASobjs:
            #-------------------------------------------------------------------
            # Use a single ScrollPane for the AdminTask help
            #-------------------------------------------------------------------
            if name in ['wsadmin', 'AdminTask']:
                if WASobj:
                    data = WASobj.help().expandtabs()
                else:
                    data = Help.wsadmin().expandtabs()
                pane = JTextPane(text=data, editable=0, font=monoFont)
                #---------------------------------------------------------------
                # Move the caret to ensure that the starting text is shown
                #---------------------------------------------------------------
                pane.moveCaretPosition(0)
                tabs.addTab(name, JScrollPane(pane))
                self.tPanes[name] = [pane]
            else:
                #---------------------------------------------------------------
                # Use a RegExp to identify where the 1st method starts.
                #---------------------------------------------------------------
                text = WASobj.help().expandtabs()
                mo = re.search(methRE, text)  # Match Object
                desc = text[:mo.start(1)].strip()
                meth = text[mo.start(1):].strip()
                #---------------------------------------------------------------
                # The description section is before the 1st method
                #---------------------------------------------------------------
                topPane = JTextPane(text=desc, editable=0, font=monoFont)
                topPane.moveCaretPosition(0)
                top = JScrollPane(topPane)
                #---------------------------------------------------------------
                # For the other scripting objects, use a vertically split pane
                # with the top containing the description section, and the
                # bottom (eventually) containing the method details.
                #---------------------------------------------------------------
                splitPane = JSplitPane(
                    JSplitPane.VERTICAL_SPLIT,
                    top,
                    JLabel('One moment please...'),
                    resizeWeight=0.5,  # divider position = 50%
                    oneTouchExpandable=1)
                #---------------------------------------------------------------
                # Start a separate thread to parse the method text and build a
                # a JTable to be put into the bottom part of this splitPane
                #---------------------------------------------------------------
                self.tPanes[name] = [topPane]
                tableTask(
                    meth,  # Help text to be parsed / processed
                    splitPane,  # SplitPane to be updated
                    self.tPanes[name],  # tPanes entry to be updated
                    WASobj  # WAS scripting object
                ).execute()
                tabs.addTab(name, splitPane)

        #-----------------------------------------------------------------------
        # Add the tabbed pane to the frame & show the result
        #-----------------------------------------------------------------------
        frame.add(tabs, 'Center')

        frame.pack()
        self.center(frame)
        frame.setVisible(1)
Example #24
0
    def __init__(self, view):
        """ Constructor, initialized all the main variables and layout """
        # Initializes variables
        self.view = view
        self.history = History(self)
        self.bs = 0
        self.indenter = TabIndenter()
        self.exporterConsole = None
        self.executor = JythonExecutor.getExecutor()

        # Creates toolbar
        actions = [ ("Run.png", "jython.tooltip-run", self.runBuffer), \
         ("RunToBuffer.png", "jython.tooltip-run-another", self.runBufferToWindow), \
         ("RunAgain.png", "jython.tooltip-import", self.importBuffer), \
         ("MultipleResults.png", "jython.tooltip-path", self.path), \
         ("Open.png", "jython.tooltip-browse-path", self.browse), \
         ("CopyToBuffer.png", "jython.tooltip-save-session", self.savesession), \
         ("separator", None, None), \
         ("Clear.png", "jython.tooltip-restart", self.restart),
         ("separator", None, None),
         ("Parse.png", "jython.tooltip-tabnanny", self.tabnanny),
         ("separator", None, None),
         ("Help.png", "jython.tooltip-about", self.about)]
        self.panel = JPanel(BorderLayout())
        self.panel.add(BorderLayout.NORTH,
                       ToolbarHandler(actions).createToolbar())

        # Creates text pane and make keybindings
        # self.output = JTextPane(keyTyped = self.keyTyped, keyPressed = self.keyPressed, keyReleased = self.keyReleased)
        self.output = JTextPane(keyTyped=self.keyTyped,
                                keyPressed=self.keyPressed)
        if jEdit.getBooleanProperty("options.jython.upDownFlag"):
            keyBindings = [
                (KeyEvent.VK_ENTER, 0, "jython.enter", self.enter),
                (KeyEvent.VK_DELETE, 0, "jython.delete", self.delete),
                (KeyEvent.VK_HOME, 0, "jython.home", self.home),
                (KeyEvent.VK_UP, 0, "jython.up", self.history.historyUp),
                (KeyEvent.VK_DOWN, 0, "jython.down", self.history.historyDown),
                (KeyEvent.VK_UP, InputEvent.CTRL_MASK,
                 DefaultEditorKit.upAction,
                 self.output.keymap.getAction(
                     KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0))),
                (KeyEvent.VK_DOWN, InputEvent.CTRL_MASK,
                 DefaultEditorKit.downAction,
                 self.output.keymap.getAction(
                     KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0)))
            ]
        else:
            keyBindings = [
             (KeyEvent.VK_ENTER, 0, "jython.enter", self.enter),
             (KeyEvent.VK_DELETE, 0, "jython.delete", self.delete),
             (KeyEvent.VK_HOME, 0, "jython.home", self.home),
             (KeyEvent.VK_UP, InputEvent.CTRL_MASK, "jython.historyup", \
              self.history.historyUp),
             (KeyEvent.VK_DOWN, InputEvent.CTRL_MASK, "jython.historydown", \
              self.history.historyDown)
            ]
        newmap = JTextComponent.addKeymap("jython", self.output.keymap)
        for (key, modifier, name, function) in keyBindings:
            newmap.addActionForKeyStroke(KeyStroke.getKeyStroke(key, modifier),
                                         ActionDelegator(name, function))
        self.output.keymap = newmap
        self.doc = self.output.document
        self.panel.add(BorderLayout.CENTER, JScrollPane(self.output))
        self.__propertiesChanged()
        self.__inittext()
        self.initialLocation = self.doc.createPosition(self.doc.length - 1)