本文整理汇总了Python中javax.swing.JTextArea.setText方法的典型用法代码示例。如果您正苦于以下问题:Python JTextArea.setText方法的具体用法?Python JTextArea.setText怎么用?Python JTextArea.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LowHangingFruitUISettingsPanel
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
class LowHangingFruitUISettingsPanel(IngestModuleIngestJobSettingsPanel):
def __init__(self, settings):
self.local_settings = settings
self.initComponents()
def initComponents(self):
self.panel = JPanel()
self.panel.setLayout(BorderLayout())
toolbar = JToolBar()
openb = JButton("Select", actionPerformed=self.onClick)
toolbar.add(openb)
self.area = JTextArea()
self.area.setBorder(BorderFactory.createEmptyBorder(10, 100, 10, 100))
pane = JScrollPane()
pane.getViewport().add(self.area)
self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
self.panel.add(pane)
self.add(self.panel)
self.add(toolbar)
def onClick(self, e):
chooseFile = JFileChooser()
filter = FileNameExtensionFilter("SQLite", ["sqlite"])
chooseFile.addChoosableFileFilter(filter)
ret = chooseFile.showDialog(self.panel, "Select SQLite")
if ret == JFileChooser.APPROVE_OPTION:
file = chooseFile.getSelectedFile()
text = self.readPath(file)
self.area.setText(text)
def readPath(self, file):
global filename
filename = file.getCanonicalPath()
return filename
def getSettings(self):
return self.local_settings
示例2: __init__
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
def __init__(self):
""" generated source for method __init__ """
super(ConsolePanel, self).__init__(BorderLayout())
# Create an output console.
outputConsole = JTextArea()
outputConsole.setEditable(False)
outputConsole.setForeground(Color(125, 0, 0))
outputConsole.setText("(Console output will be displayed here.)\n\n")
outputConsolePane = JScrollPane(outputConsole)
setBorder(TitledBorder("Java Console:"))
add(outputConsolePane, BorderLayout.CENTER)
validate()
# Send the standard out and standard error streams
# to this panel, instead.
out = OutputStream()
System.setOut(PrintStream(out, True))
System.setErr(PrintStream(out, True))
示例3: Tip
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
class Tip(JWindow):
"""
Window which provides the user with information about the method.
For Python, this shows arguments, and the documention
For Java, this shows the signature(s) and return type
"""
MAX_HEIGHT = 300
MAX_WIDTH = 400
def __init__(self, frame):
JWindow.__init__(self, frame)
self.textarea = JTextArea()
# TODO put this color with all the other colors
self.textarea.setBackground(Color(225,255,255))
self.textarea.setEditable(0)
self.jscrollpane = JScrollPane(self.textarea)
self.getContentPane().add(self.jscrollpane)
def setText(self, tip):
self.textarea.setText(tip)
self.textarea.setCaretPosition(0)
#print >> sys.stderr, self.textarea.getPreferredScrollableViewportSize()
self.setSize(self.getPreferredSize())
def getPreferredSize(self):
# need to add a magic amount to the size to avoid scrollbars
# I'm sure there's a better way to do this
MAGIC = 20
size = self.textarea.getPreferredScrollableViewportSize()
height = size.height + MAGIC
width = size.width + MAGIC
if height > Tip.MAX_HEIGHT:
height = Tip.MAX_HEIGHT
if width > Tip.MAX_WIDTH:
width = Tip.MAX_WIDTH
return Dimension(width, height)
def showTip(self, tip, displayPoint):
self.setLocation(displayPoint)
self.setText(tip)
self.show()
示例4: gui
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
class gui(JFrame):
def __init__(self):
#Class variable declarations
self.mainPanel = JPanel(GridLayout(1,2))
self.subPanel1 = JPanel(BorderLayout())
self.subPanel2 = JPanel(GridLayout(5,1))
self.userText = JTextArea(' ')
self.emoticonFeedback = JTextArea('This will consider your emoticon usage.')
self.curseFeedback = JTextArea('This will consider your use of profanity.')
self.styleFeedback = JTextArea('This will consider your general tone.')
self.overallFeedback = JTextArea('This will be your overall score.')
self.button = JButton("Score my email!",
actionPerformed=self.updateScores)
self.initGUI()
self.add(self.mainPanel)
self.setSize(800, 500)
self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
self.setVisible(True)
def initGUI(self):
#Set up subpanel1
appName = JTextArea('Politeness Gauge\n'+'\nSarah Robinson \nAnna Clegg')
appName.setLineWrap(True)
appName.setWrapStyleWord(True)
appName.setEditable(False)
appName.background = 240,240,240
instructions = JTextArea(' Ever agonized over whether or not your emails' +
' are polite enough? \n Never fear! With our politeness gauge' +
' we can provide suggestions on improving your emails' +
' with just the click of a button. \n Just type your email ' +
'into the text box below and hit Score!')
instructions.setLineWrap(True)
instructions.setWrapStyleWord(True)
instructions.background = 240,240,240
northPanel = JPanel(GridLayout(2,1))
northPanel.add(appName)
northPanel.add(instructions)
self.subPanel1.add(northPanel, BorderLayout.NORTH)
self.userText.setEditable(True)
self.userText.setLineWrap(True)
self.userText.setWrapStyleWord(True)
self.userText.setRows(100)
#self.userText.wordWrap = True
self.subPanel1.add(self.userText, BorderLayout.CENTER)
self.subPanel1.add(self.button, BorderLayout.SOUTH)
label = JLabel("Politeness Evaluation")
self.subPanel2.add(label)
self.subPanel2.add(self.emoticonFeedback)
self.subPanel2.add(self.curseFeedback)
self.subPanel2.add(self.styleFeedback)
self.subPanel2.add(self.overallFeedback)
self.mainPanel.add(self.subPanel1)
self.mainPanel.add(self.subPanel2)
def updateScores(self, event):
input = self.userText.getText()
scores = mes.get_scores(input)
overall = mes.get_overall_score()
self.styleFeedback.setText("\n Your politeness score is "+str(scores['politeness'])
+".\n Higher is better. This is relative to the\n length of your email,"
+" so the more sentences you have,\n the higher this score should be.")
self.curseFeedback.setText(" You have about " +str(scores['curses'])+" curses in you email."
+"\n Please try to have 0 curses.")
self.emoticonFeedback.setText(" You have about "+str(scores['emoticons'])+" emoticons in your email."
+"\n Fewer emoticons is considered more professional.")
self.overallFeedback.setText(" Your overall professionality score is "+str(overall)+"."
+"\n The baseline is around 50 for neutral emails."
+"\n Please remember that this is approximate.")
示例5: GUI_PSQLiteUISettingsPanel
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
class GUI_PSQLiteUISettingsPanel(IngestModuleIngestJobSettingsPanel):
# Note, we can't use a self.settings instance variable.
# Rather, self.local_settings is used.
# https://wiki.python.org/jython/UserGuide#javabean-properties
# Jython Introspector generates a property - 'settings' on the basis
# of getSettings() defined in this class. Since only getter function
# is present, it creates a read-only 'settings' property. This auto-
# generated read-only property overshadows the instance-variable -
# 'settings'
# We get passed in a previous version of the settings so that we can
# prepopulate the UI
# TODO: Update this for your UI
def __init__(self, settings):
self.local_settings = settings
self.initComponents()
self.customizeComponents()
# TODO: Update this for your UI
def checkBoxEvent(self, event):
if self.checkbox.isSelected():
self.local_settings.setSetting('Flag', 'true')
self.local_settings.setSetting('plists', self.area.getText());
else:
self.local_settings.setSetting('Flag', 'false')
# TODO: Update this for your UI
def initComponents(self):
self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS))
#self.setLayout(GridLayout(0,1))
self.setAlignmentX(JComponent.LEFT_ALIGNMENT)
self.panel1 = JPanel()
self.panel1.setLayout(BoxLayout(self.panel1, BoxLayout.Y_AXIS))
self.panel1.setAlignmentY(JComponent.LEFT_ALIGNMENT)
self.checkbox = JCheckBox("Check to activate/deactivate TextArea", actionPerformed=self.checkBoxEvent)
self.label0 = JLabel(" ")
self.label1 = JLabel("Input in SQLite DB's in area below,")
self.label2 = JLabel("seperate values by commas.")
self.label3 = JLabel("then check the box above.")
self.label4 = JLabel(" ")
self.panel1.add(self.checkbox)
self.panel1.add(self.label0)
self.panel1.add(self.label1)
self.panel1.add(self.label2)
self.panel1.add(self.label3)
self.panel1.add(self.label4)
self.add(self.panel1)
self.area = JTextArea(5,25)
#self.area.getDocument().addDocumentListener(self.area)
#self.area.addKeyListener(listener)
self.area.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0))
self.pane = JScrollPane()
self.pane.getViewport().add(self.area)
#self.pane.addKeyListener(self.area)
#self.add(self.area)
self.add(self.pane)
# TODO: Update this for your UI
def customizeComponents(self):
self.checkbox.setSelected(self.local_settings.getSetting('Flag') == 'true')
self.area.setText(self.local_settings.getSetting('plists'))
# Return the settings used
def getSettings(self):
return self.local_settings
示例6: BurpExtender
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
#.........这里部分代码省略.........
for cookie in self.cookies:
if cookie.getDomain() in self.originalMsgHost:
self.cookie += cookie.getName() + '=' + cookie.getValue() + '; '
self.textArea.append(cookie.getName() + '=' + cookie.getValue() + '\n')
scrollArea = JScrollPane(self.textArea)
scrollArea.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS)
scrollArea.setPreferredSize(Dimension(400, 200))
self.rightPanel = JPanel()
self.rightPanel.setLayout(BorderLayout(3, 3))
self.rightPanel.add(self.UrlPanelLabel, BorderLayout.NORTH)
self.rightPanel.add(scrollArea, BorderLayout.CENTER)
# Panel for the generate URL list and import URL list buttons
generatePanel = JPanel()
generatePanel.layout = BorderLayout(3, 3)
generateButton = JButton('Generate URL List', actionPerformed=self.generateUrlList)
importButton = JButton('Import URL List to Burp Site Map', actionPerformed=self.confirmImport)
generatePanel.add("North", generateButton)
generatePanel.add("South", importButton)
self.rightPanel.add("South", generatePanel)
# Add the two main panels to the left and right sides
self.window.contentPane.add("East", self.rightPanel)
self.window.contentPane.add("West", self.leftPanel)
# Create a panel to be used for the file chooser window
self.uploadPanel = JPanel()
self.window.pack()
self.window.show()
# JFileChooser and showDialog for the user to specify their directory listing input file
def chooseFile(self, event):
chooseFile = JFileChooser()
filter = FileNameExtensionFilter("c files", ["c"])
chooseFile.addChoosableFileFilter(filter)
chooseFile.showDialog(self.uploadPanel, "Choose File")
chosenFile = chooseFile.getSelectedFile()
self.uploadTextField.text = str(chosenFile)
# Set whether https is enabled. Default is disabled (http)
def radioSsl(self, event):
if self.radioBtnSslEnabled.isSelected():
self.SSL = 'https://'
else:
self.SSL = 'http://'
# Create a parser object and pass the user's specified options. Retrieve the results and print them to a text area
def generateUrlList(self, event):
fileListingType = self.comboListingType.selectedIndex
self.listType = self.types[fileListingType]
urlsMade = 0
if os.path.isfile(self.uploadTextField.text):
parser = ListingParser()
parser.parse(self.hostnameTextField.getText(), self.dirPrefixField.getText().rstrip(), self.SSL, self.portTextField.getText(), self.listType, self.uploadTextField.getText())
self.parsedList = parser.returnList()
self.textArea.setText('')
for item in self.parsedList:
self.textArea.append(item + '\n')
urlsMade = str(len(self.parsedList))
if self.parsedList and urlsMade:
self.textArea.append('\n' + 'Total Directories Found: ' + str(parser.directoryCount))
self.textArea.append('\n' + 'Total URLs Created: ' + urlsMade)
else:
self.textArea.append('Error occurred during parsing.\n')
self.textArea.append('Please make sure the directory listing is a valid format and all input is correct.\n')
self.textArea.append('E-mail [email protected] with errors or for further help.')
else:
JOptionPane.showMessageDialog(None, 'ERROR: File is not valid file or not found!')
def closeUI(self, event):
self.window.setVisible(False)
self.window.dispose()
# This is initiated by the user selecting the 'import to burp' button. Checks each generated URL for a valid response and adds it to the site map
def importList(self):
if self.parsedList:
urlsAdded = 0
# Loop through each URL and check the response. If the response code is less than 404, add to site map
for item in self.parsedList:
# Pass exception if urlopen returns an http error if the URL is not reachable
try:
code = urlopen(item).code
if code < 404:
javaURL = URL(item)
newRequest = self._helpers.buildHttpRequest(javaURL)
stringNewRequest = self._helpers.bytesToString(newRequest).rstrip()
if self.cookie:
stringNewRequest += '\nCookie: ' + self.cookie.rstrip('; ') + '\r\n\r\n'
requestResponse = self._callbacks.makeHttpRequest(self._helpers.buildHttpService(str(javaURL.getHost()), int(javaURL.getPort()), javaURL.getProtocol() == "https"), stringNewRequest)
else:
requestResponse = self._callbacks.makeHttpRequest(self._helpers.buildHttpService(str(javaURL.getHost()), int(javaURL.getPort()), javaURL.getProtocol() == "https"), newRequest)
self._callbacks.addToSiteMap(requestResponse)
urlsAdded += 1
except Exception, e:
print e
pass
JOptionPane.showMessageDialog(None, str(urlsAdded) + " URL(s) added to Burp site map.")
else:
开发者ID:LucaBongiorni,项目名称:Directory-File-Listing-Parser-Importer,代码行数:104,代码来源:Directory-File-Listing-Parser-Importer.py
示例7: getIp
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
#.........这里部分代码省略.........
panel3.add(self.chkbox2)
panel3.add(self.chkbox3)
panel3.add(self.chkbox4)
panel3.add(self.chkbox5)
panel3.add(self.chkbox6)
panel3.add(button3)
panel3.add(self.label4)
panel3.add(JScrollPane(self.textArea3))
#
tabPane.addTab("Sebsitive File", panel3)
#
frame.add(tabPane)
frame.setVisible(True)
#用来在第一个TAB打印nmap信息
def setResult(self,text):
self.textArea.append(text)
#用来在第二个TAB打印获得信息
def setResult2(self,textId, textDomain, textIp):
text = str(textId) + "----------------" + textDomain + "----------------" + str(textIp) + os.linesep
self.textArea2.append(text)
#self.textArea2.append("----------------------------------------" + os.linesep)
#用来在第三个TAB打印文件扫描的结果
def setResult3(self, theMess01):
self.textArea3.append(theMess01)
def setLabel(self, a, b):
hg = str(a) + "/" + str(b)
self.label4.setText(hg)
#C段扫描的主引擎
def cNmapScan(self, event):
self.textArea.setText("")
#-------------------------------------------------------------------------------
def ipRange(ipaddr):
"""
Creates a generator that iterates through all of the IP addresses.
The range can be specified in multiple formats.
"192.168.1.0-192.168.1.255" : beginning-end
"192.168.1.0/24" : CIDR
"192.168.1.*" : wildcard
"""
def ipaddr_to_binary(ipaddr):
"""
A useful routine to convert a ipaddr string into a 32 bit long integer
"""
# from Greg Jorgensens python mailing list message
q = ipaddr.split('.')
return reduce(lambda a,b: long(a)*256 + long(b), q)
#-------------------------------------------------------------------------------
def binary_to_ipaddr(ipbinary):
"""
Convert a 32-bit long integer into an ipaddr dotted-quad string
"""
# This one is from Rikard Bosnjakovic
示例8: BurpExtender
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
#.........这里部分代码省略.........
importProjButton = JButton("Import",actionPerformed=self.importProj)
importProjButton.setBounds(470, 10, 100, 30)
exportProjButton = JButton("Export",actionPerformed=self.exportProj)
exportProjButton.setBounds(575, 10, 100, 30)
openProjButton = JButton("Open Directory",actionPerformed=self.openProj)
openProjButton.setBounds(680, 10, 130, 30)
currentProjectLabel = JLabel("Current:")
currentProjectLabel.setBounds(10, 10, 140, 30)
projects = self.config.options('projects')
self.currentProject = JComboBox(projects)
self.currentProject.addActionListener(projectChangeHandler(self))
self.currentProject.setBounds(140, 10, 140, 30)
self.autoSave = JCheckBox("Auto Save Mode")
self.autoSave.setEnabled(False) # implement this feature
self.autoSave.setBounds(300, 10, 140, 30)
self.autoSave.setToolTipText("Will save any changed value while focus is out")
addProjButton = JButton("Add / Update",actionPerformed=self.addProj)
addProjButton.setBounds(10, 330, 150, 30)
removeProjButton = JButton("Remove Current",actionPerformed=self.rmProj)
removeProjButton.setBounds(315, 330, 146, 30)
generalOptions = self.config.options('general')
if 'default project' in generalOptions:
defaultProj = self.config.get('general','default project')
self.currentProject.getModel().setSelectedItem(defaultProj)
self.projPath.setText(self.config.get('projects',self.currentProject.getSelectedItem()))
self.clearProjTab = True
self.projectSettings = JPanel()
self.projectSettings.setBounds(0, 0, 1000, 1000)
self.projectSettings.setLayout(None)
self.projectSettings.add(reportLabel)
self.projectSettings.add(detailsLabel)
self.projectSettings.add(projPathLabel)
self.projectSettings.add(addProjButton)
self.projectSettings.add(openProjButton)
self.projectSettings.add(projNameLabel)
self.projectSettings.add(projDetailsScroll)
self.projectSettings.add(importProjButton)
self.projectSettings.add(exportProjButton)
self.projectSettings.add(removeProjButton)
self.projectSettings.add(generateReportButton)
self.projectSettings.add(chooseProjPathButton)
self.projectSettings.add(currentProjectLabel)
self.projectSettings.add(self.projPath)
self.projectSettings.add(self.autoSave)
self.projectSettings.add(self.projName)
self.projectSettings.add(self.reportType)
self.projectSettings.add(self.currentProject)
def initTabs(self):
#
## init autorize tabs
#
self._splitpane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT)
self.scrollPane = JScrollPane(self.logTable)
self._splitpane.setLeftComponent(self.scrollPane)
示例9: BurpExtender
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
class BurpExtender(IBurpExtender, ITab, IContextMenuFactory):
#
# implement IBurpExtender
#
def registerExtenderCallbacks(self, callbacks):
# properties
self._title = "Generate Python Template"
self._templatePath = '###### ----> PUT HERE THE ABSOLUTE PATH TO template.py <--- ####'
# set our extension name
callbacks.setExtensionName(self._title)
# keep a reference to our callbacks object
self._callbacks = callbacks
# obtain an extension helpers object
self._helpers = callbacks.getHelpers()
# obtain std streams
self._stdout = PrintWriter(callbacks.getStdout(), True)
self._stderr = PrintWriter(callbacks.getStderr(), True)
# main pane (top/bottom)
self._mainpane = JPanel()
self._mainpane.setLayout( GridLayout(2,1) )
# configure bottom pane for buttons
self._botPane = JPanel()
flowLayout = FlowLayout()
self._botPane.setLayout( flowLayout )
self._botPane.add( JButton("Generate", actionPerformed=self.regeneratePy) )
self._botPane.add( JButton("Export", actionPerformed=self.exportPy) )
# Configure pyViewer (JTextArea) for python output --> top pane
self._pyViewer = JTextArea(5, 20);
scrollPane = JScrollPane(self._pyViewer);
self._pyViewer.setEditable(True);
self._pyViewer.setText( "Waiting request ..." );
### Assign top / bottom components
self._mainpane.add(scrollPane)
self._mainpane.add(self._botPane)
# customize our UI components
callbacks.customizeUiComponent(self._mainpane)
# add the custom tab to Burp's UI
callbacks.addSuiteTab(self)
# register ourselves as a ContextMenuFactory
callbacks.registerContextMenuFactory(self)
return
def regeneratePy(self,event):
pass
def exportPy(self,event):
chooseFile = JFileChooser()
ret = chooseFile.showDialog(self._mainpane, "Choose file")
filename = chooseFile.getSelectedFile().getCanonicalPath()
self._stdout.println("Export to : " + filename )
open(filename, 'w', 0).write( self._pyViewer.getText() )
#
# implement ITab
#
def getTabCaption(self):
return "PyTemplate"
def getUiComponent(self):
return self._mainpane
#
# implement IContextMenuFactory
#
def createMenuItems(self, invocation):
# add a new item executing our action
item = JMenuItem(self._title, actionPerformed=lambda x, inv=invocation: self.loadRequest(inv))
return [ item ]
def loadRequest(self, invocation):
pyCode = self.pythonHeader()
selectedMessages = invocation.getSelectedMessages()
self._numbMessages = len(selectedMessages)
self._currentMessageNumber = 1
for message in selectedMessages:
self._currentlyDisplayedItem = message
pyCode += self.generateRequest()
self._currentMessageNumber += 1
pyCode += '\n' + self.generateMain()
self._pyViewer.setText( pyCode );
#.........这里部分代码省略.........
示例10: ChatClient
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
#.........这里部分代码省略.........
'''
# While the connection is available
while self.tn:
# Try to receive data using "<<<" as the delimiter
try:
message = self.tn.read_until('<<<')
# If a message is received
if message:
garb, message=message.split('>>>')
message, garb = message.split('<<<')
message = ('\n'+message+'\n')
# Call the append text function
self.appendText(message)
# Except if there is no data available
except:
#print('No message')
pass
## Event driven function to retrieve and send data to the server
def grabText(self, event):
'''Function to repeatedly grab new messages entered into the text
area and display them in the main text area. Resets the entry area
'''
# Grab the text from the text area
text=self.message.getText()
# Don't allow an empty string through
if text=='':
return
text=text.strip()
# Call the append text function
self.appendText('\nYou : '+text+'\n', self.username)
# Reset the text to be empty and grab focus so that it is ready for new text input
self.message.requestFocusInWindow()
self.message.setText('')
# Send the message to the server
data=text.encode()
self.tn.write(data+'\r\n')
## Function to handle appending of messages
def appendText(self, message, user=None):
'''This function takes care of appending any new messages to the content area
'''
message_label=JTextArea(message,2,3, font=self.label_2_font)
# If this is a message from the grab text function, create a new label, assign it's colours
if user!=None:
message_label.setBackground(Color(240,240,240))
message_label.setForeground(Color(129,129,129))
# Otherwise set the format for receive function (no user passed in)
else:
message_label.setBackground(Color(215,215,215))
message_label.setForeground(Color(40,153,153))
# Format and style options for the new message labels
message_label.setEditable(False)
message_label.setLineWrap(True)
message_label.setWrapStyleWord(True)
message_label.setBorder(BorderFactory.createLineBorder( Color(247,246,242),4))
# Sets the positioning of messages
self.main_content.setCaretPosition(self.main_content.getDocument().getLength())
doc = self.main_content.getStyledDocument()
attr=SimpleAttributeSet()
self.main_content.insertComponent(message_label)
# Essential for jtextarea to be able to stack message
doc.insertString( self.main_content.getDocument().getLength(),'\n ', attr)
# Not sure if needed
示例11: Config
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
#.........这里部分代码省略.........
labels.add(clear_butt)
labels.add(spider_butt)
labels.add(JLabel(""))
labels.add(save_butt)
labels.add(rest_butt)
labels.add(load_plug_butt)
# Tool tips!
self.delim.setToolTipText("Use to manipulate the final URL. "
"See About tab for example.")
self.ext_white_list.setToolTipText("Define a comma delimited list of"
" file extensions to parse. Use *"
" to parse all files.")
self.url.setToolTipText("Enter the target URL")
checkbox.setToolTipText("Parse files line by line using plugins"
" to enumerate language/framework specific"
" endpoints")
parse_butt.setToolTipText("Attempt to enumerate application endpoints")
clear_butt.setToolTipText("Clear status window and the parse results")
spider_butt.setToolTipText("Process discovered endpoints")
save_butt.setToolTipText("Saves the current config settings")
rest_butt.setToolTipText("<html>Restores previous config settings:"
"<br/>-Input Directory<br/>-String Delim"
"<br/>-Ext WL<br/>-URL<br/>-Plugins")
source_butt.setToolTipText("Select the application's "
"source directory or file to parse")
self.path_vars.setToolTipText("Supply a JSON object with values"
"for dynamically enumerated query"
"string variables")
return labels
def set_url(self, menu_url):
"""Changes the configuration URL to the one from the menu event"""
self.url.setText(menu_url)
# Event functions
def set_parse(self, event):
"""
Handles the click event from the UI checkbox
to attempt code level parsing
"""
self.parse_files = not self.parse_files
if self.parse_files:
if not self.loaded_plugins:
self._plugins_missing_warning()
def restore(self, event):
"""Attempts to restore the previously saved configuration."""
jdump = None
try:
jdump = loads(self._callbacks.loadExtensionSetting("config"))
except Exception as exc: # Generic exception thrown directly to user
self.update_scroll(
"[!!] Error during restore!\n\tException: %s" % str(exc))
if jdump is not None:
self.url.setText(jdump.get('URL'))
# self.cookies.setText(jdump.get('Cookies'))
# self.headers.setText(jdump.get("Headers"))
ewl = ""
for ext in jdump.get('Extension Whitelist'):
ewl += ext + ", "
self.ext_white_list.setText(ewl[:-2])
self.delim.setText(jdump.get('String Delimiter'))
self.source_input = jdump.get("Input Directory")
self.config['Plugin Folder'] = jdump.get("Plugin Folder")
if (self.config['Plugin Folder'] is not None and
示例12: HL7GUIFrame
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
class HL7GUIFrame(JFrame):
outputTextField = None
def __init__(self):
super(HL7GUIFrame, self).__init__()
self.initUI()
def initUI(self):
global outputTextField
self.panel = JPanel()
self.panel.setLayout(BorderLayout())
toolbar = JToolBar()
openb = JButton("Choose input file", actionPerformed=self.onClick)
outputLabel = JLabel(" Enter output file name: ")
outputTextField = JTextField("hl7OutputReport.txt", 5)
print outputTextField.getText()
toolbar.add(openb)
toolbar.add(outputLabel)
toolbar.add(outputTextField)
self.area = JTextArea()
self.area.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
self.area.setText("Select your HL7 ORU messages text file to be converted to tab-delimited flat \nfile with select HL7 fields.\n")
self.area.append("You can enter the path + file name for your output file or it will default to the current \nfile name in the text field above in your current working directory.")
pane = JScrollPane()
pane.getViewport().add(self.area)
self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10))
self.panel.add(pane)
self.add(self.panel)
self.add(toolbar, BorderLayout.NORTH)
self.setTitle("HL7 ORU Results Reporter")
self.setSize(600, 300)
self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
self.setLocationRelativeTo(None)
self.setVisible(True)
return outputTextField.getText()
def onClick(self, e):
print outputTextField.getText()
chooseFile = JFileChooser()
filter = ExampleFileFilter()
filter.addExtension("txt")
filter.setDescription("txt HL7 input files")
chooseFile.setFileFilter(filter)
##ret = chooseFile.showDialog(self.panel, "Choose file")
ret = chooseFile.showOpenDialog(self.panel)
if ret == JFileChooser.APPROVE_OPTION:
file = chooseFile.getSelectedFile()
text = self.readFile(file)
self.area.append(text)
outputFile = outputTextField.getText()
p1 = HL7RepClass.ParseORUClass(file.getCanonicalPath(), outputFile)
p1.parseORU()
print "\noutfile = ", outputFile
def readFile(self, file):
filename = file.getCanonicalPath()
print "filename is now ", filename
f = open(filename, "r")
text = f.read()
return text
示例13: BurpExtender
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
#.........这里部分代码省略.........
finding_array = [urlDetail, name, 134217728, severityRating, confidenceRating, background, remBackground, description, remediation, requestResponse]
issue = ScanIssue(self, finding_array, self.current_message, self.reqMarkers, self.resMarkers, self._helpers, self._callbacks)
self._callbacks.addScanIssue(issue)
# Done
print "[+] Finding Generated!"
def getRequestResponseText(self):
messages = self.ctxMenuInvocation.getSelectedMessages()
# parses currently selected finding to a string
if len(messages) == 1 :
for self.m in messages:
requestResponse = self.m
# add requestResponseWithMarkers to be global so can be included in scanIssue
self.current_message = requestResponse
# get request data and convert to string
requestDetail = requestResponse.getRequest()
try:
requestData = self._helpers.bytesToString(requestDetail) # converts & Prints out the entire request as string
except:
requestData = '[-] No Request Detail in this RequestResponse'
pass
# get response data and convert to string
responseDetail = requestResponse.getResponse()
try:
responseData = self._helpers.bytesToString(responseDetail) # converts & Prints out the entire request as string
except:
responseData = '[-] No Response Detail in this RequestResponse'
pass
requestData = self._helpers.bytesToString(requestDetail) # converts & Prints out the entire request as string
# send request string to 'Supporting Request' tab - 'True' because it is a request!
self._requestViewer.setMessage(requestData, True)
# for higlighting markers..
self._requestHighlight.setText(requestData)
# send response string to 'Supporting Response' tab
self._responseViewer.setMessage(responseData, False) # set False as is a response not request...
# for higlighting markers..
self._responseHighlight.setText(responseData)
def getFindingDetails(self):
messages = self.ctxMenuInvocation.getSelectedMessages()
print "*" * 60
print "[+] Handling selected request: ", self.current_message
if len(messages) == 1:
for m in messages:
# URL
#print "[!] Selected Request's URL: \n", self._helpers.analyzeRequest(m).getUrl()
self.issueURLValue.setText(str(self._helpers.analyzeRequest(m).getUrl())) # update finding info
# Protocol
#print "[!] Request's Protocol: \n", m.getProtocol()
# Request Port
#print "[!] Request's Port: \n", m.getPort()
self.issuePortValue.setText(str(m.getPort())) # update finding info
print "*" * 60
# API hook...
def getHttpMessages(self):
return [self.m]
# Actions on menu click...
def actionPerformed(self, actionEvent):
print "*" * 60
print "[+] Request sent to 'Generate Finding'"
try:
# When clicked!!
self.getRequestResponseText()
self.getFindingDetails()
except:
tb = traceback.format_exc()
print tb
# create Menu
def createMenuItems(self, ctxMenuInvocation):
self.ctxMenuInvocation = ctxMenuInvocation
return [self.menuItem]
示例14: WorkHelper
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
#.........这里部分代码省略.........
categories format.
"""
try:
StartIndex = int(self.iStart.getText())
except ValueError:
StartIndex=1
text=self.area1.getText().rstrip()
counter=StartIndex
lastindex=0
textO=""
for i in range(0,len(text)):
if text[i]=='\n':
textO=textO+("_"+str(counter)+' "'+text[lastindex:i]+'",\n')
lastindex=i+1
counter=counter+1
if len(text[lastindex:len(text)])>0:
textO=textO+("_"+str(counter)+' "'+text[lastindex:len(text)]+'"')
if len(textO)>0:
if self.cCurly.isSelected():
textO = "{\n"+ textO + "\n}"
if self.cSemiC.isSelected():
textO = textO + ";"
self.copyToClipboard(textO)
self.area2.setText(textO)
def copyToClipboard(self, text):
if self.cCtClipB.isSelected():
stringSelection = StringSelection(text)
self.clipboard.setContents(stringSelection, None)
def bCopyToInput(self, e):
"@sig public void setExpression(java.lang.String e)"
"""Copy the Text from the Output Area to the input Area for further operations"""
self.area1.setText(self.area2.getText())
def bRemoveNBSP_L(self, e):
"@sig public void setExpression(java.lang.String e)"
text=self.area1.getText().rstrip()
textO=""
lastindex=0
for i in range(0,len(text)):
if text[i] == '\n':
textO = textO+text[lastindex:i].lstrip()+"\n"
lastindex=i+1
#print(text[0:i].lstrip()+'\n')
if len(text[lastindex:len(text)])>0:
textO=textO+text[lastindex:len(text)].lstrip()
self.area2.setText(textO)
def bRemoveNBSP_R(self, e):
"@sig public void setExpression(java.lang.String e)"
text=self.area1.getText().rstrip()
示例15: WorkHelper
# 需要导入模块: from javax.swing import JTextArea [as 别名]
# 或者: from javax.swing.JTextArea import setText [as 别名]
#.........这里部分代码省略.........
categories format.
"""
try:
StartIndex = int(self.iStart.getText())
except ValueError:
StartIndex=1
text=self.area1.getText().rstrip()
counter=StartIndex
lastindex=0
textO=""
for i in range(0,len(text)):
if text[i]=='\n':
textO=textO+("_"+str(counter)+' "'+text[lastindex:i]+'",\n')
lastindex=i+1
counter=counter+1
if len(text[lastindex:len(text)])>0:
textO=textO+("_"+str(counter)+' "'+text[lastindex:len(text)]+'"')
if len(textO)>0:
if self.cCurly.isSelected():
textO = "{\n"+ textO + "\n}"
if self.cSemiC.isSelected():
textO = textO + ";"
self.copyToClipboard(textO)
self.area2.setText(textO)
def copyToClipboard(self, text):
if self.cCtClipB.isSelected():
stringSelection = StringSelection(text)
self.clipboard.setContents(stringSelection, None)
def bCopyToInput(self, e):
"@sig public void setExpression(java.lang.String e)"
"""Copy the Text from the Output Area to the input Area for further operations"""
self.area1.setText(self.area2.getText())
def bRemoveNBSP_L(self, e):
"@sig public void setExpression(java.lang.String e)"
text=self.area1.getText().rstrip()
textO=""
lastindex=0
for i in range(0,len(text)):
if text[i] == '\n':
textO = textO+text[lastindex:i].lstrip()+"\n"
lastindex=i+1
#print(text[0:i].lstrip()+'\n')
if len(text[lastindex:len(text)])>0:
textO=textO+text[lastindex:len(text)].lstrip()
self.area2.setText(textO)
def bRemoveNBSP_R(self, e):
"@sig public void setExpression(java.lang.String e)"
text=self.area1.getText().rstrip()