本文整理汇总了Python中javax.swing.JTable.getSelectedRows方法的典型用法代码示例。如果您正苦于以下问题:Python JTable.getSelectedRows方法的具体用法?Python JTable.getSelectedRows怎么用?Python JTable.getSelectedRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.getSelectedRows方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BurpExtender
# 需要导入模块: from javax.swing import JTable [as 别名]
# 或者: from javax.swing.JTable import getSelectedRows [as 别名]
class BurpExtender(IBurpExtender,ITab,IHttpListener):
def registerExtenderCallbacks(self,callbacks):
self.callbacks = callbacks
self.helpers = callbacks.getHelpers()
self.callbacks.setExtensionName("KkMultiProxy")
self.PROXY_LIST = []
self.jPanel = JPanel()
boxVertical = Box.createVerticalBox()
boxHorizontal = Box.createHorizontalBox()
boxHorizontal.add(JButton("File",actionPerformed=self.getFile))
self.FileText = JTextField("")
boxHorizontal.add(self.FileText)
boxVertical.add(boxHorizontal)
TableHeader = ('IP','PORT')
TableModel = DefaultTableModel(self.PROXY_LIST,TableHeader)
self.Table = JTable(TableModel)
boxVertical.add(self.Table)
boxHorizontal = Box.createHorizontalBox()
boxHorizontal.add(JButton("Add",actionPerformed=self.addIP))
boxHorizontal.add(JButton("Delete",actionPerformed=self.deleteIP))
boxHorizontal.add(JButton("Save",actionPerformed=self.saveIP))
boxVertical.add(boxHorizontal)
self.jPanel.add(boxVertical)
self.callbacks.addSuiteTab(self)
self.callbacks.registerHttpListener(self)
return
def getFile(self,button):
dlg = JFileChooser()
result = dlg.showOpenDialog(None)
if result == JFileChooser.APPROVE_OPTION:
f = dlg.getSelectedFile()
path = f.getPath()
self.FileText.setText(path)
try:
self.getIPList(path)
except:
exit(0)
def addIP(self,button):
#chooser = JFileChooser()
#chooser.showOpenDialog(None)
demo = DialogDemo(self.Table)
def deleteIP(self,button):
selectRows = len(self.Table.getSelectedRows())
TableModel = self.Table.getModel()
if selectRows:
selectedRowIndex = self.Table.getSelectedRow()
TableModel.removeRow(selectedRowIndex)
def saveIP(self,button):
TableModel = self.Table.getModel()
rowCount = TableModel.getRowCount()
result_str = ""
for i in range(rowCount):
if i == 0:
result_str+=TableModel.getValueAt(i,0)+':'+TableModel.getValueAt(i,1)
else:
result_str+='|'+TableModel.getValueAt(i,0)+':'+TableModel.getValueAt(i,1)
print result_str
f = open(self.FileText.getText(),'w+')
f.write(result_str)
f.close()
def getTabCaption(self):
return "MultiProxy"
def getUiComponent(self):
return self.jPanel
def processHttpMessage(self,toolFlag,messageIsRequest,messageInfo):
if messageIsRequest:
httpService = messageInfo.getHttpService()
print httpService.getHost()
# if the host is HOST_FROM, change it to HOST_TO
i = randint(0,len(self.TableDatas)-1)
messageInfo.setHttpService(self.helpers.buildHttpService(self.PROXY_LIST[i]['ip'], self.PROXY_LIST[i]['port'], httpService.getProtocol()))
print messageInfo.getHttpService().getHost()
def getIPList(self,path):
f = open(path,'r+')
content = f.read()
f.close()
if content:
ip_array = content.split('|')
for _ip in ip_array:
ip = _ip.split(':')[0]
port = _ip.split(':')[1]
self.PROXY_LIST.append([ip,port])
print self.PROXY_LIST
示例2: BurpExtender
# 需要导入模块: from javax.swing import JTable [as 别名]
# 或者: from javax.swing.JTable import getSelectedRows [as 别名]
class BurpExtender(IBurpExtender, ITab, IScannerCheck, IContextMenuFactory, IParameter, IIntruderPayloadGeneratorFactory):
def registerExtenderCallbacks(self, callbacks):
self.callbacks = callbacks
self.helpers = callbacks.getHelpers()
callbacks.setExtensionName("Session Authentication Tool")
self.out = callbacks.getStdout()
# definition of suite tab
self.tab = JPanel(GridBagLayout())
self.tabledata = MappingTableModel(callbacks)
self.table = JTable(self.tabledata)
#self.table.getColumnModel().getColumn(0).setPreferredWidth(50);
#self.table.getColumnModel().getColumn(1).setPreferredWidth(100);
self.tablecont = JScrollPane(self.table)
c = GridBagConstraints()
c.fill = GridBagConstraints.HORIZONTAL
c.anchor = GridBagConstraints.FIRST_LINE_START
c.gridx = 0
c.gridy = 0
c.gridheight = 6
c.weightx = 0.3
c.weighty = 0.5
self.tab.add(self.tablecont, c)
c = GridBagConstraints()
c.weightx = 0.1
c.anchor = GridBagConstraints.FIRST_LINE_START
c.gridx = 1
c.gridy = 0
label_id = JLabel("Identifier:")
self.tab.add(label_id, c)
self.input_id = JTextField(20)
self.input_id.setToolTipText("Enter the identifier which is used by the application to identifiy a particular test user account, e.g. a numerical user id or a user name.")
c.gridy = 1
self.tab.add(self.input_id, c)
c.gridy = 2
label_content = JLabel("Content:")
self.tab.add(label_content, c)
self.input_content = JTextField(20, actionPerformed=self.btn_add_id)
self.input_content.setToolTipText("Enter some content which is displayed in responses of the application and shows that the current session belongs to a particular user, e.g. the full name of the user.")
c.gridy = 3
self.tab.add(self.input_content, c)
self.btn_add = JButton("Add/Edit Identity", actionPerformed=self.btn_add_id)
c.gridy = 4
self.tab.add(self.btn_add, c)
self.btn_del = JButton("Delete Identity", actionPerformed=self.btn_del_id)
c.gridy = 5
self.tab.add(self.btn_del, c)
callbacks.customizeUiComponent(self.tab)
callbacks.customizeUiComponent(self.table)
callbacks.customizeUiComponent(self.tablecont)
callbacks.customizeUiComponent(self.btn_add)
callbacks.customizeUiComponent(self.btn_del)
callbacks.customizeUiComponent(label_id)
callbacks.customizeUiComponent(self.input_id)
callbacks.addSuiteTab(self)
callbacks.registerScannerCheck(self)
callbacks.registerIntruderPayloadGeneratorFactory(self)
callbacks.registerContextMenuFactory(self)
def btn_add_id(self, e):
ident = self.input_id.text
self.input_id.text = ""
content = self.input_content.text
self.input_content.text = ""
self.tabledata.add_mapping(ident, content)
self.input_id.requestFocusInWindow()
def btn_del_id(self, e):
rows = self.table.getSelectedRows().tolist()
self.tabledata.del_rows(rows)
### ITab ###
def getTabCaption(self):
return("SessionAuth")
def getUiComponent(self):
return self.tab
### IContextMenuFactory ###
def createMenuItems(self, invocation):
menuitems = list()
msgs = invocation.getSelectedMessages()
if msgs != None:
if len(msgs) == 1: # "add as object id/as content to last id" context menu items
bounds = invocation.getSelectionBounds()
if bounds != None and bounds[0] != bounds[1]:
msg = None
if invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST or invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_REQUEST:
msg = msgs[0].getRequest().tostring()
if invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_RESPONSE or invocation.getInvocationContext() == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_RESPONSE:
msg = msgs[0].getResponse().tostring()
if msg != None:
selection = msg[bounds[0]:bounds[1]]
shortSelection = selection[:20]
#.........这里部分代码省略.........
示例3: PreferencesFrame
# 需要导入模块: from javax.swing import JTable [as 别名]
# 或者: from javax.swing.JTable import getSelectedRows [as 别名]
#.........这里部分代码省略.........
#2 Tab
#favourite area
self.update_favourite_area_gui_from_preferences()
self.app.dlg.update_statsPanel_status()
#3 Tab
#tools preferences
for tool in self.app.allTools:
if hasattr(tool, 'prefs') and tool.prefsGui is not None:
tool.prefsGui.update_gui(tool.prefs)
def update_favourite_area_gui_from_preferences(self):
#status
self.favZoneStatusCBtn.setSelected(self.app.favouriteZoneStatus)
#table
#store zones to a temporary list, used to store changes
#and save them when preferences dialog is closed
self.app.tempZones = list(self.app.zones)
self.zonesTable.getModel().setNumRows(0)
for zone in self.app.tempZones:
self.zonesTable.getModel().addRow([zone.country,
zone.icon,
zone.name])
if self.app.favZone is not None:
selectedRow = self.app.tempZones.index(self.app.favZone)
self.zonesTable.setRowSelectionInterval(selectedRow, selectedRow)
self.zonesTable.getColumnModel().getColumn(0).setMaxWidth(30)
self.zonesTable.getColumnModel().getColumn(1).setMaxWidth(50)
#enable or disable favourite zone buttons
self.actionPerformed()
### fav area editing buttons ###########################################
def on_removeBtn_clicked(self, e):
rowsNum = self.zonesTable.getSelectedRows()
rowsNum.reverse()
for rowNum in rowsNum:
del self.app.tempZones[rowNum]
self.zonesTable.getModel().removeRow(rowNum)
if len(self.app.tempZones) != 0:
if rowNum == 0:
self.zonesTable.setRowSelectionInterval(0, 0)
else:
self.zonesTable.setRowSelectionInterval(rowNum - 1, rowNum - 1)
self.check_removeBtn_status()
def check_removeBtn_status(self):
if self.app.tempZones != [] and len(self.zonesTable.getSelectedRows()) != 0:
self.removeBtn.setEnabled(True)
else:
self.removeBtn.setEnabled(False)
self.clean_map()
def on_newBtn_clicked(self, e):
try:
self.newZoneDialog
except AttributeError:
self.newZoneDialog = NewZoneDialog(self.app)
bbox = self.app.get_frame_bounds()
self.app.newZone = Zone(self.app,
self.app.strings.getString("New_zone"),
"rectangle",
",".join(["%0.4f" % x for x in bbox]),
"")
self.newZoneDialog.update_gui_from_preferences()
self.newZoneDialog.show()