コード例 #1
0
 def changeFontSize(self, fontSize):
     newFontSize = int(fontSize)
     swing.text.StyleConstants.setFontSize(self.textAttrib, newFontSize)
     text = DefaultStyledDocument.getText(
         self, 0, DefaultStyledDocument.getLength(self))
     DefaultStyledDocument.remove(self, 0,
                                  DefaultStyledDocument.getLength(self))
     DefaultStyledDocument.insertString(self, 0, text, self.textAttrib)
コード例 #2
0
    def addString(self,offset,str):


        if str == '\t':
            str = JESConstants.TAB
            
        if self.command.getIsSystem() != FALSE:
            DefaultStyledDocument.insertString(self,
                                               offset,
                                               str,
                                               self.textAttrib)
            
        else:
            #When insertString is called by Jython, check to make sure the
            #string is to be inserted after the most recent prompt

            
            if self.command.getCaretPosition() >= self.command.getOldPos():

                DefaultStyledDocument.insertString(self,
                                                   offset,
                                                   str,
                                                   self.textAttrib)
            else:
                # if an absent minded user has put the cursor
                # behind the current ">>>" command start point,
                # and he starts typing, we move the cursor to the right
                # place, and insert the text at the end of the text.
                self.command.setCaretPosition( self.getLength() )
                DefaultStyledDocument.insertString(self,
                                                   #offset,
                                                   self.getLength(),
                                                   str,
                                                   self.textAttrib)
            # sort of a hack
            # if a backspace is pressed from the initial cursor position,
            # getCaretPosition becomes less than old position, and the system
            # locks up
            if self.command.getCaretPosition() + 1 == self.command.getOldPos():
                DefaultStyledDocument.insertString(self,
                                                   offset,
                                                   ' ',
                                                   self.textAttrib)
                
                DefaultStyledDocument.insertString(self,
                                                   offset + 1,
                                                   str,
                                                   self.textAttrib)
コード例 #3
0
    def addString(self, offset, str):

        if str == '\t':
            str = JESConstants.TAB

        if self.command.getIsSystem() != FALSE:
            DefaultStyledDocument.insertString(self, offset, str,
                                               self.textAttrib)

        else:
            #When insertString is called by Jython, check to make sure the
            #string is to be inserted after the most recent prompt

            if self.command.getCaretPosition() >= self.command.getOldPos():

                DefaultStyledDocument.insertString(self, offset, str,
                                                   self.textAttrib)
            else:
                # if an absent minded user has put the cursor
                # behind the current ">>>" command start point,
                # and he starts typing, we move the cursor to the right
                # place, and insert the text at the end of the text.
                self.command.setCaretPosition(self.getLength())
                DefaultStyledDocument.insertString(
                    self,
                    #offset,
                    self.getLength(),
                    str,
                    self.textAttrib)
            # sort of a hack
            # if a backspace is pressed from the initial cursor position,
            # getCaretPosition becomes less than old position, and the system
            # locks up
            if self.command.getCaretPosition() + 1 == self.command.getOldPos():
                DefaultStyledDocument.insertString(self, offset, ' ',
                                                   self.textAttrib)

                DefaultStyledDocument.insertString(self, offset + 1, str,
                                                   self.textAttrib)
コード例 #4
0
 def changeFontSize(self, fontSize):
     newFontSize = int(fontSize)
     swing.text.StyleConstants.setFontSize(self.textAttrib, newFontSize)
     text = DefaultStyledDocument.getText(self, 0, DefaultStyledDocument.getLength(self))
     DefaultStyledDocument.remove(self, 0, DefaultStyledDocument.getLength(self))
     DefaultStyledDocument.insertString(self, 0, text, self.textAttrib)
コード例 #5
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