Beispiel #1
0
    def set_advisory_tab_pane(self, scanner_issue):
        advisory_pane = JEditorPane()
        advisory_pane.setEditable(False)
        advisory_pane.setEnabled(True)
        advisory_pane.setContentType("text/html")
        link_listener = LinkListener()
        advisory_pane.addHyperlinkListener(link_listener)
        advisory = "<html><b>Location</b>: {}<br><br>{}</html>"
        advisory_pane.setText(
            advisory.format(scanner_issue.getUrl().encode("utf-8"),
                            scanner_issue.getIssueDetail()))

        return JScrollPane(advisory_pane)
Beispiel #2
0
    def set_advisory_tab_pane(self, scanner_issue):
        advisory_pane = JEditorPane()
        advisory_pane.setEditable(False)
        advisory_pane.setEnabled(True)
        advisory_pane.setContentType("text/html")
        link_listener = LinkListener()
        advisory_pane.addHyperlinkListener(link_listener)
        fmt = "<html><b>Location</b>: {}<br><br>{}</html>"
        advisory_pane.setText(fmt.format(scanner_issue.getUrl(),
                                         scanner_issue.getIssueDetail()))

        # Set a context menu
        self.set_context_menu(advisory_pane, scanner_issue)

        return JScrollPane(advisory_pane)
Beispiel #3
0
class HelpPanel(JPanel):
	def __init__(self):
		
		JPanel.__init__(self,BorderLayout())
		self.editor=JEditorPane()
		self.editor.setEditable(0)
		#self.editor.setContentType('text/html')
		self.editor.setContentType('text/html')
		sp=JScrollPane(self.editor,
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
			JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)
		self.add(sp,'Center')
		
		#html="<html><h1>Test</h1></html>"
		#self.editor.setText(html)
		#self.lines='HELP'
		self.editor.setText(HELP_TEXT)
		
	def append(self,line):
		self.lines="%s\n%s"%(self.lines,line)
		self.editor.setText(self.lines)
class DebugPanel(JPanel):
	def __init__(self):
		
		JPanel.__init__(self,BorderLayout())
		self.editor=JEditorPane()
		self.editor.setEditable(0)
		#self.editor.setContentType('text/html')
		self.editor.setContentType('text/plain')
		sp=JScrollPane(self.editor,
			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
			JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED)
		self.add(sp,'Center')
		
		#html="<html><h1>Test</h1></html>"
		#self.editor.setText(html)
		self.lines='DEBUG OUTPUT:'
		self.editor.setText(self.lines)
		
	def append(self,line):
		try:
			self.lines="%s\n%s"%(self.lines,line)
			self.editor.setText(self.lines)
		except Exception,e:
			print e	
Beispiel #5
0
    def build_welcome_panel(self):
        '''
        Construct the welcome panel here.
        '''
        panel = JPanel(GridBagLayout())
        constraints = GridBagConstraints()
        constraints.insets = Insets(10, 10, 10, 10)

        message = ('<html><body>'
                   '<h1>Welcome to Nammu</h1>'
                   '<h2>An editor for the ORACC project<h2>'
                   '<p>'
                   '<a href=\'oracc\'>Click here</a> for help with ORACC.'
                   '</p>'
                   '<p>Learn more about Nammu <a href=\'nammu\'>here</a>.</p>'
                   '</body></html>')

        # Configure a JEditorPane to display HTML for our welcome message
        msg_pane = JEditorPane()
        msg_pane.setEditable(False)
        kit = HTMLEditorKit()
        msg_pane.setEditorKit(kit)
        scrollPane = JScrollPane(msg_pane)

        # This handles the stylesheet applied to the welcome message
        styleSheet = kit.getStyleSheet()
        styleSheet.addRule('body {color:black; font-size: 16 pt; }')
        styleSheet.addRule('h1 {text-align:center; }')
        styleSheet.addRule('h2 {text-align:center; }')

        # Set the JEditorPane background to match the rest of the window
        msg_pane.border = BorderFactory.createEmptyBorder(4, 4, 4, 4)
        msg_pane.background = Color(238, 238, 238)

        # Add the message and the css and to the JEditorPane
        doc = kit.createDefaultDocument()
        msg_pane.setDocument(doc)
        msg_pane.setText(message)

        # Set up a hyperlink listener
        listener = addEventListener(msg_pane, HyperlinkListener,
                                    'hyperlinkUpdate', self.handleEvent)

        # Configure the placement of the JEditorPane
        constraints.gridx = 1
        constraints.gridy = 1
        constraints.fill = GridBagConstraints.BOTH
        constraints.anchor = GridBagConstraints.CENTER

        panel.add(msg_pane, constraints)

        # Build and place the checkbox
        self.checkbox = JCheckBox('Don\'t show this message again.',
                                  selected=False)
        constraints.gridx = 1
        constraints.gridy = 2
        panel.add(self.checkbox, constraints)

        # Build and place the close button
        close_button = JButton('Close', actionPerformed=self.close_action)

        constraints.gridx = 2
        constraints.gridy = 2
        panel.add(close_button, constraints)

        return panel