def initComponents(self): dataModel = DefaultTableModel(self.regTableData, self.regCols) self.regTable = JTable(dataModel) scrollPaneReg = JScrollPane() scrollPaneReg.getViewport().setView((self.regTable)) self.regTab.add(scrollPaneReg) # self.logTabbedPane.addTab('Registred',self.regTab) self.logTabbedPane.insertTab("Registred", None, self.regTab, None, 0) dataModel = DefaultTableModel(self.parkTableData, self.parkCols) self.parkTable = JTable(dataModel) scrollPanePark = JScrollPane() scrollPanePark.getViewport().setView((self.parkTable)) self.parkedTab.add(scrollPanePark) # self.logTabbedPane.addTab('Parked',self.parkedTab) self.logTabbedPane.insertTab("Parked", None, self.parkedTab, None, 1) dataModel = DefaultTableModel(self.bypassTableData, self.bypassCol) self.bypassTable = JTable(dataModel) scrollPaneBypass = JScrollPane() scrollPaneBypass.getViewport().setView((self.bypassTable)) self.bypassTab.add(scrollPaneBypass) # self.logTabbedPane.addTab('Bypassed',self.bypassTab) self.logTabbedPane.insertTab("Bypassed", None, self.bypassTab, None, 2) self.add(self.logTabbedPane, BorderLayout.CENTER) innerBorder = BorderFactory.createTitledBorder('View Logs ') outerBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5) self.setBorder( BorderFactory.createCompoundBorder(outerBorder, innerBorder))
def __init__(self): head = 'Name,Value'.split(',') self.data = [ ['This', 'Bacon'], ['That', 'Eggs'], ] DefaultTableModel.__init__(self, self.data, head)
def setValueAt(self, value, row, col): if 0 <= value <= 65535: index = (self, row) DefaultTableModel.setValueAt(self, value, row, col) else: DefaultTableModel.setValueAt(self, self.getValueAt(row, col), row, col) self.fireTableCellUpdated(row, col)
def __init__(self, *args, **kwargs): savemode = False if 'savemode' in kwargs: savemode = kwargs.pop('savemode') DefaultTableModel.__init__(self, *args, **kwargs) if savemode: self.checkbox_column = 3 else: self.checkbox_column = 4
def __private_init__(self, text="Property Editor", columns=None, data=None, empty=None, add_actions=True, actions=None): if not actions: actions = [] if not columns: columns = [] if data == None: data = [] if not empty: empty = [] self._text = text self.this = JFrame(text) self._table = JTable() self._dtm = DefaultTableModel(0, 0) self._dtm.setColumnIdentifiers(columns) self._table.setModel(self._dtm) self._data = data for d in data: self._dtm.addRow(d) self._pane = JScrollPane(self._table) self.this.add(self._pane) self._empty = empty self.this.addWindowListener(self) self._dtm.addTableModelListener(lambda _: self._update_model()) self.this.setLocation(PropertyEditor.NEW_WINDOW_OFFSET, PropertyEditor.NEW_WINDOW_OFFSET) if add_actions: self._popup = JPopupMenu() self._pane.setComponentPopupMenu(self._popup) inherits_popup_menu(self._pane) self._actions = actions self._actions.append( ExecutorAction('Remove Selected Rows', action=lambda e: self._remove_row())) self._actions.append( ExecutorAction('Add New Row', action=lambda e: self._add_row())) for action in self._actions: self._popup.add(action.menuitem) self.this.setForeground(Color.black) self.this.setBackground(Color.lightGray) self.this.pack() self.this.setVisible(True) self.this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE) return self
def __init__( self, data, headings ) : info = [] df = DateFormat.getDateInstance( DateFormat.SHORT ) for date, size, path in data : info.append( [ df.parse( date ), Integer( size.strip().replace( ',', '' ) ), String( path ) ] ) DefaultTableModel.__init__( self, info, headings )
def __init__(self, data, headings): info = [] df = DateFormat.getDateInstance(DateFormat.SHORT) for tf, date, size, f, d in data: info.append([ Boolean(tf == '1'), df.parse(date), Integer(size.strip().replace(',', '')), Float(f), Double(d) ]) DefaultTableModel.__init__(self, info, headings)
def __init__(self, extender): self._callbacks = extender._callbacks self._helpers = extender._callbacks.getHelpers() self._callbacks.registerScannerCheck(self) # Creamos el contenedor de paneles. self.contenedor = JTabbedPane() # Campos del sub-tab 1 (mash up) self._tab1_nombre = JTextField() self._tab1_apellido = JTextField() self._tab1_FNacimiento = JTextField() self._tab1_mascota = JTextField() self._tab1_otro = JTextField() self._tab1_feedback_ta = JTextArea('This may take a while . . .') self._tab1_feedback_ta.setEditable(False) self._tab1_feedback_sp = JScrollPane(self._tab1_feedback_ta) self._tab1_minsize = JSlider(4, 16, 6) self._tab1_minsize.setMajorTickSpacing(1) self._tab1_minsize.setPaintLabels(True) self._tab1_maxsize = JSlider(4, 16, 10) self._tab1_maxsize.setMajorTickSpacing(1) self._tab1_maxsize.setPaintLabels(True) self._tab1_specialchars = JTextField('!,@,#,$,&,*') self._tab1_transformations = JCheckBox('1337 mode') self._tab1_firstcapital = JCheckBox('first capital letter') # Campos del sub-tab 2 (redirect) self._tab2_JTFa = JTextField() self._tab2_JTFaa = JTextField() self._tab2_JTFb = JTextField() self._tab2_JTFbb = JTextField() self._tab2_boton = JButton(' Redirect is Off ', actionPerformed=self.switch_redirect) self._tab2_boton.background = Color.lightGray self._tab2_encendido = False # Campos del sub-tab 3 (loader) self._tab3_urls_ta = JTextArea(15, 5) self._tab3_urls_sp = JScrollPane(self._tab3_urls_ta) # Campos del sub-tab 4 (headers) self._tab4_tabla_model = DefaultTableModel() self._tab4_headers_dict = {} # Campos del sub-tab 5 (reverse ip) self._tab5_target = JTextArea(15, 5) self._tab5_target_sp = JScrollPane(self._tab5_target)
def __init__(self, data, headings): DefaultTableModel.__init__(self, data, headings) L = len(data) self.visible = [1] * L self.sectionNumber = [0] * L self.sections = 0 section = -1 for i in range(L): row = data[i] if row[0].startswith('_'): self.sections += 1 section += 1 self.sectionNumber[i] = section self.sectionVisible = [1] * self.sections self.findText = None
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 __init__(self, view): JPanel.__init__(self) self.view = view self.background = Color.white self.layout = BorderLayout() self.popup = JPopupMenu() self.popup_items = {} self.add(self.make_controls(), BorderLayout.SOUTH) data, title = self.extract_data() self.table = JTable(DefaultTableModel(data, title)) scroll = JScrollPane(self.table) self.add(scroll) scroll.addMouseListener(self) self.table.tableHeader.addMouseListener(self) self.table.addMouseListener(self) self.fileChooser = JFileChooser() self.fileChooser.setFileFilter(CSVFilter()) self.fileChooser.setSelectedFile( File('%s.csv' % self.view.network.name))
def _createPeerPanel(self): label = JLabel("Peers") self.uiFunction(label) addPeerButton = JButton("Add") self.uiFunction(addPeerButton) delPeerButton = JButton("Remove") self.uiFunction(delPeerButton) buttonPanel = JPanel() buttonPanel.layout = BoxLayout(buttonPanel, BoxLayout.Y_AXIS) buttonPanel.add(addPeerButton) buttonPanel.add(delPeerButton) peerColNames = ('Host', 'Name', 'Key') dataModel = DefaultTableModel(self.peerList, peerColNames) peerTable = JTable(dataModel) self.uiFunction(peerTable) peerPanel = JPanel() peerPanel.layout = BoxLayout(peerPanel, BoxLayout.X_AXIS) #peerPanel.add(label) peerPanel.add(buttonPanel) #peerPanel.add(addPeerButton) peerPanel.add(JScrollPane(peerTable)) #peerPanel.add(delPeerButton) return peerPanel
def update_table(self): """Updates the table with new data""" columns = ["Type", "Action", "Name", "Value"] data = [] for param in self._extender.sm.selected_session.params: data.append(param.as_table_row()) data.append([ Parameter.type_mapping[Parameter.PARAM_COOKIE], Parameter.ACTION_MODIFY, "", "" ]) data_model = DefaultTableModel(data, columns, tableChanged=self.tableChanged) self.modification_table.setModel(data_model) # type combobox type_combo = JComboBox(self._types) type_column = self.modification_table.getColumnModel().getColumn(0) type_column.setCellEditor(DefaultCellEditor(type_combo)) type_column.setMaxWidth(75) # action combobox action_combo = JComboBox(self._actions) action_column = self.modification_table.getColumnModel().getColumn(1) action_column.setCellEditor(DefaultCellEditor(action_combo)) action_column.setMaxWidth(75) action_combo.setSelectedItem("replace")
def gui(self): xnode = self.xdoc.getDocumentElement() tnode = self.createTree(xnode) # create tree and display jt = JTree(tnode) jsp = JScrollPane(jt) tree_box = Box(BoxLayout.Y_AXIS) tree_box.add(jsp) tree_box.add(Box.createHorizontalStrut(10)) headerSorter = TableSorter(DefaultTableModel()) jtb = JTable(headerSorter) headerSorter.addMouseListenerToHeaderInTable(jtb) jtb.setAutoResizeMode(JTable.AUTO_RESIZE_OFF) jsp2 = JScrollPane(jtb) table_box = Box(BoxLayout.Y_AXIS) table_box.add(jsp2) table_box.add(Box.createHorizontalStrut(500)) mp = JPanel() mp.setLayout(BoxLayout(mp,BoxLayout.X_AXIS)) mp.add(tree_box) mp.add(table_box) # add listeners nsl = NodeSelectionListener(jtb,xnode) jt.addTreeSelectionListener(nsl) # return mp
def start(self): self.frame = JDialog() #self.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.frame.setLocation(0, 1500) self.frame.setSize(1000, 200) self.tableDataModel = DefaultTableModel([], [ "URL", "Code", "Content-Length", "Location", "Mutated Id", "Orig Id" ]) self.jtable = JTable(self.tableDataModel) scrollPane = JScrollPane(self.jtable) self.jtable.setFillsViewportHeight(True) messageEditorOrig = self.callbacks.createMessageEditor(None, False) messageEditorModified = self.callbacks.createMessageEditor( None, False) self.editorSplitPane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT, messageEditorOrig.getComponent(), messageEditorModified.getComponent()) self.editorSplitPane.setResizeWeight(0.5) splitPane = JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, self.editorSplitPane) splitPane.setResizeWeight(0.5) class TableSelector(ListSelectionListener): def __init__(self, plugin): self.plugin = plugin def valueChanged(self, event): if not event.getValueIsAdjusting(): selectedRowIndex = self.plugin.jtable.getSelectedRows()[0] self.plugin._rowSelected(selectedRowIndex) self.jtable.getSelectionModel().addListSelectionListener( TableSelector(self)) self.frame.add(splitPane) self.frame.setVisible(True) self.callbacks.registerHttpListener(self) self.callbacks.setExtensionName("Custom Plugin") return
def __init__(self): """ generated source for method __init__ """ super(HumanDetailPanel, self).__init__(GridBagLayout()) model = DefaultTableModel() model.addColumn("Legal Moves") self.moveTable = JZebraTable(model) self.selectButton = JButton(selectButtonMethod()) self.moveTextField = JTextField() self.timerBar = JTimerBar() self.selection = None self.moveTable.setShowHorizontalLines(True) self.moveTable.setShowVerticalLines(True) self.moveTextField.setEditable(False) self.add(JScrollPane(self.moveTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(5, 5, 5, 5), 5, 5)) self.add(self.selectButton, GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, Insets(5, 5, 5, 5), 0, 0)) self.add(self.moveTextField, GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(5, 5, 5, 5), 5, 5)) self.add(self.timerBar, GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(5, 5, 5, 5), 5, 5))
def __init__(self): head = 'Byte,Double,Float,Integer,Long,Short'.split(',') self.data = [[ Byte(Byte.MIN_VALUE), Double(Double.MIN_VALUE), Float(Float.MIN_VALUE), Integer(Integer.MIN_VALUE), Long(Long.MIN_VALUE), Short(Short.MIN_VALUE) ], [ Byte(Byte.MAX_VALUE), Double(Double.MAX_VALUE), Float(Float.MAX_VALUE), Integer(Integer.MAX_VALUE), Long(Long.MAX_VALUE), Short(Short.MAX_VALUE) ]] DefaultTableModel.__init__(self, self.data, head)
def _updateListDuplicates(self): # DUPLICATES TABLE count = self._getCountValues(self.cmbDuplicates) if count == None: return dict_list=[] for i,j in count.iteritems(): dict_list.append ((i,j)) sorted_list = sorted(dict_list,key=lambda x: x[1],reverse=True) tableModel = DefaultTableModel(sorted_list, ["Field", "Count"]) self.tblFilter.setModel(tableModel)
def updateTable(self): model = DefaultTableModel() #self.tblMunicipalities.getModel() manager = DALLocator.getDataManager() model.addColumn("CODMUN") model.addColumn("MUN") model.addColumn("FECHA") storeParameters = manager.createStoreParameters("H2Spatial") database_file = gvsig.getResource(__file__, "data", "municipalities.mv.db") storeParameters.setDynValue("database_file", database_file) storeParameters.setDynValue("Table", "Muni") storeH2 = manager.openStore("H2Spatial", storeParameters) muns = {} for f in storeH2: if not f.get("CODMUN") in muns.keys(): muns[f.get("CODMUN")] = [f.get("MUN"), f.get("CODMUN"), ''] for k in muns.keys(): model.addRow(muns[k]) storeH2.dispose() self.tblMunicipalities.setModel(model)
def cmbLayers_change(self, *args): #self.layer = self.view.getLayer(self.cmbLayers.getSelectedItem()) self.layer = self.cmbLayers.getSelectedItem().getValue() self._updateFields() self._updateAdvancedFilter() #self._updateListValues() self.valuesList.getModel().removeAllElements() tableModel = DefaultTableModel([["",""]], ["Field", "Count"]) self.tblFilter.setModel(tableModel) self.tblFilter.revalidate() self.tblFilter.repaint()
def __init__(self): """ generated source for method __init__ """ super(ConfigurableDetailPanel, self).__init__(GridBagLayout()) model = DefaultTableModel() model.addColumn("Step") model.addColumn("My Move") model.addColumn("Time spent") model.addColumn("Out of time?") self.moveTable = JZebraTable(model) self.moveTable.setShowHorizontalLines(True) self.moveTable.setShowVerticalLines(True) sidePanel = JPanel() self.memUsage = TimeSeries("Used Memory") self.memTotal = TimeSeries("Total Memory") self.memUsage.setMaximumItemCount(36000) self.memTotal.setMaximumItemCount(36000) memory = TimeSeriesCollection() memory.addSeries(self.memUsage) memory.addSeries(self.memTotal) memChart = ChartFactory.createTimeSeriesChart(None, None, "Megabytes", memory, True, True, False) memChart.setBackgroundPaint(getBackground()) memChartPanel = ChartPanel(memChart) memChartPanel.setPreferredSize(Dimension(500, 175)) sidePanel.add(memChartPanel) self.counters = HashSet() self.countersCollection = TimeSeriesCollection() counterChart = ChartFactory.createTimeSeriesChart(None, None, None, self.countersCollection, True, True, False) counterChart.getXYPlot().setRangeAxis(LogarithmicAxis("Count per 100ms")) counterChart.getXYPlot().getRangeAxis().setAutoRangeMinimumSize(1.0) counterChart.setBackgroundPaint(getBackground()) counterChartPanel = ChartPanel(counterChart) counterChartPanel.setPreferredSize(Dimension(500, 175)) sidePanel.add(counterChartPanel) self.scoreCountersCollection = TimeSeriesCollection() scoreCounterChart = ChartFactory.createTimeSeriesChart(None, None, "Score", self.scoreCountersCollection, True, True, False) scoreCounterChart.getXYPlot().getRangeAxis().setRange(0, 100) scoreCounterChart.setBackgroundPaint(getBackground()) scoreCounterChartPanel = ChartPanel(scoreCounterChart) scoreCounterChartPanel.setPreferredSize(Dimension(500, 175)) sidePanel.add(scoreCounterChartPanel) self.add(JScrollPane(self.moveTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(0, 0, 0, 0), 0, 0)) self.add(sidePanel, GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, Insets(0, 0, 0, 0), 0, 0)) self.add(JButton(resetButtonMethod()), GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, Insets(0, 0, 0, 0), 0, 0))
def valueChanged(self,evt): tnode = evt.getPath().getLastPathComponent() xnode_name = tnode.getUserObject() tw=TreeWalker(self.xroot) xnode=tw.getNextElement(xnode_name) if not xnode: return if isinstance(xnode,ElementNode): headerSorter = TableSorter(NodeTableModel(xnode)) else: headerSorter = TableSorter(DefaultTableModel()) headerSorter.addMouseListenerToHeaderInTable(self.jtb) self.jtb.setModel(headerSorter) #self.sizeColumns() self.jtb.sizeColumnsToFit(-1)
def lstPreviewForms_change(self, event): if event.getValueIsAdjusting(): return form = self.lstPreviewForms.getSelectedValue() if form == None or form.isEmpty(): self.tableSetVisible(self.tblPreviewForm, False) return model = DefaultTableModel() model.addColumn("") for item in form: row = jarray.array((item, ), Object) model.addRow(row) self.tblPreviewForm.setModel(model) renderer = FormItemPreviewCellRenderer() renderer.setForm(form) editor = FormItemPreviewCellEditor() editor.setForm(form) model = DefaultTableColumnModel() model.addColumn(TableColumn(0, 100, renderer, editor)) self.tblPreviewForm.setColumnModel(model) self.tblPreviewForm.getTableHeader().setUI(None) self.tableSetVisible(self.tblPreviewForm, True) self.cboForms.setSelectedItem(form)
def create_table(self, opt, panel): self._select_table = {"row": -1, "col": -1} table_name = opt['funcopt']['tableName'] coloNames = opt['funcopt']['coloName'] ContentData.content_data[table_name] = DefaultTableModel(coloNames, 0) self._content_table = swing.JTable( ContentData.content_data[table_name]) self._content_table.setAutoCreateRowSorter(True) self._content_table.addMouseListener( AddAction(self, opt['type'], opt['funcopt'])) column_model = self._content_table.getColumnModel() for i in xrange(column_model.getColumnCount()): column = column_model.getColumn(i) if '#' == self._content_table.getColumnName(i): column.setPreferredWidth(3) else: column.setPreferredWidth(200) self._content_table.fillsViewportHeight = True dtcr = self._content_table.getTableHeader().getDefaultRenderer() dtcr.setHorizontalAlignment(swing.SwingConstants.CENTER) return swing.JScrollPane(self._content_table)
def _updateUI(self): # Fill dialog layers = self.view.getLayers() self.cmbLayers.removeAllItems() for layer in layers: #print getIconFromLayer(layer) self.cmbLayers.addItem(ListElement(layer.getName(),layer)) # Advanced dialog item = self.cmbLayers.getSelectedItem() #self.valuesList = self.lstValues if item != None and item.getValue()!=None: self.layer = item.getValue() if self.layer!=None: self._updateAdvancedFilter() # Duplicates table tableModel = DefaultTableModel(None, ["Field", "Count"]) self.tblFilter.setModel(tableModel)
def __init__(self): frame = JFrame("Jython JTable Example") frame.setSize(500, 250) frame.setLayout(BorderLayout()) self.tableData = [ ['Mouse 1', eventNames[0], eventScriptType[0]], ['Mouse 2', eventNames[1], eventScriptType[1]], ['Mouse 3', eventNames[2], eventScriptType[2]], ['Mouse 1 Shift', eventNames[3], eventScriptType[3]], ['Mouse 2 Shift', eventNames[4], eventScriptType[4]], ['Mouse 3 Shift', eventNames[5], eventScriptType[5]], ['Mouse 1 Control', eventNames[6], eventScriptType[6]], ['Mouse 2 Control', eventNames[7], eventScriptType[7]], ['Mouse 3 Control', eventNames[8], eventScriptType[8]], ] colNames = ('Script/Event', 'Name', 'Type') dataModel = DefaultTableModel(self.tableData, colNames) self.table = JTable(dataModel) scrollPane = JScrollPane() scrollPane.setPreferredSize(Dimension(400, 200)) scrollPane.getViewport().setView((self.table)) panel = JPanel() panel.add(scrollPane) frame.add(panel, BorderLayout.CENTER) self.label = JLabel('Hello from Jython') frame.add(self.label, BorderLayout.NORTH) button = JButton('Save Settings', actionPerformed=self.setText) frame.add(button, BorderLayout.SOUTH) exitButton = JButton('Exit', actionPerformed=self.myExit) frame.add(exitButton, BorderLayout.EAST) frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE) frame.setVisible(True)
def registerExtenderCallbacks(self, callbacks): sys.stdout = callbacks.getStdout() self.callbacks = callbacks self.helpers = callbacks.getHelpers() self.callbacks.setExtensionName("H1 Report Finder") callbacks.registerContextMenuFactory(self) # Create the tab self.tab = JPanel(BorderLayout()) #Create an empty Table self.tableData = [] self.colNames = ('Vendor', 'Hunter', 'Vulnerability', 'Report', 'Date') self.dataModel = DefaultTableModel(self.tableData, self.colNames) self.table = Table(self.dataModel) self.scrollPane = JScrollPane(self.table) self.scrollPane.setPreferredSize(Dimension(500, 500)) self.tab.add(self.scrollPane, BorderLayout.NORTH) callbacks.customizeUiComponent(self.tab) callbacks.addSuiteTab(self) return
def __init__(self, dic_books, mat_sim): # Propriétés de la fenêtre frame = JFrame("EbookMining") frame.setSize(window_height, window_width) frame.setLayout(BorderLayout()) # Variables de classe self.dic_books = dic_books self.mat_sim = mat_sim # Tri des livres en fonction du titre sorted_dic_books = sorted(dic_books.items(), key=lambda x: x[1]) self.tableData = [] for book in sorted_dic_books: id_book = book[0] title, author = book[1] self.tableData.append([id_book, title, author]) colNames = ('id_book', 'Titre', 'Auteur') self.dataModel = DefaultTableModel(self.tableData, colNames) self.table = JTable(self.dataModel) # Suppression de la colonne des identifiants dans l'affichage column = self.table.getColumnModel().getColumn(0) self.table.removeColumn(column) scrollPane = JScrollPane() scrollPane.setPreferredSize(Dimension(window_height - 100, window_width - 100)) scrollPane.getViewport().setView((self.table)) panel = JPanel() panel.add(scrollPane) button = JButton("Chercher", actionPerformed=self.recommand) panel.add(button) frame.add(panel, BorderLayout.CENTER) frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) frame.setVisible(True)
def __init__(self, data, headings): DefaultTableModel.__init__(self, data, headings)
def __init__(self,jtb,xroot): self.jtb = jtb self.xroot = xroot self.empty_model = DefaultTableModel()
def output(self, value): eingabe = value.getString() if eingabe == "Lexikon": # Falls "Lexikon" an den Clienten übergeben wird, wird die GUI geöffnet, # in der man deutsche Wörter eingeben kann, die einem dann auf Englisch # vorgelesen werden. def change_text(event): text = feld.getText() x = suche(text) self.send(x) frame.visible = False frame = JFrame( 'Woerterbuch', defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(380, 350), ) frame.setLayout(None) frame.visible = True hintergrund = ImageIcon("Hintergrund.jpg") hintergrundlabel = JLabel(hintergrund) frame.setContentPane(hintergrundlabel) uebersetzerlabel = JLabel() uebersetzerlabel.setForeground(Color(025, 025, 112)) uebersetzerlabel.setText( "<html><font size=+1>Welches Wort soll ich uebersetzen?</font></html>" ) uebersetzerlabel.setBounds(10, 20, 500, 50) frame.add(uebersetzerlabel) feld = JTextField() feld.setText("") feld.setBounds(20, 80, 300, 25) frame.add(feld) button = JButton('Uebersetzen', actionPerformed=change_text, size=(10, 20)) button.setBounds(20, 110, 300, 30) frame.add(button) if eingabe == "neue Lektion": # Falls dem Clienten "neue Lektion" übergeben wird, öffnet er er die # GUI für das Verwalten der Lektionen frame = JFrame('Lektion erstellen', defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(1000, 1000)) frame.setLayout(None) def auflisten_in(ort): font = Font("Verdana", Font.BOLD, 15) liste_mit_Lektionen = [] with open(pfad, "r") as f: for line in f: liste_mit_Lektionen.append(line.strip()) liste_mit_Lektionen.sort() text = "" for lektion in liste_mit_Lektionen: text += lektion text += "\n" ort.setText(text) ort.setFont(font) frame.setLayout(None) uebersichtLabel = JLabel() def uebersetzen(event): frage = feld_frage.getText() x = suche(frage) feld_frage.setText(x) liste = [] with open(pfad, "r") as lektionen: for lektion in lektionen: if "nachgeschlagen" in lektion: liste.append(lektion) if liste: name = liste[-1] words = [] sql = "SELECT deutsch, englisch, symbol FROM " + name zeile = stmt.executeQuery(sql) while zeile.next(): d = zeile.getString("deutsch") e = zeile.getString("englisch") symb = zeile.getString("symbol") words.append((d, e, symb)) if len(words) < 50: sql = "INSERT INTO " + name + " (deutsch, englisch, symbol) VALUES(?,?,?);" pstmt = conn.prepareStatement(sql) pstmt.setString(1, frage) pstmt.setString(2, x) pstmt.setString(3, "X") pstmt.executeUpdate() else: namensteile = name.split("_") nummer = int(namensteile[1].strip()) + 1 name = "nachgeschlagen_" + str(nummer) test = "" with open(pfad, "r") as f: for line in f: test += line if not name in test: with open(pfad, "a") as f: f.write(name + "\n") sql = "CREATE TABLE " + name + " (deutsch text, englisch text, symbol text);" stmt.execute(sql) sql = "INSERT INTO " + name + " (deutsch, englisch, symbol) VALUES(?,?,?);" pstmt = conn.prepareStatement(sql) pstmt.setString(1, frage) pstmt.setString(2, x) pstmt.setString(3, "X") pstmt.executeUpdate() else: name = "nachgeschlagen_1" test = "" with open(pfad, "r") as f: for line in f: test += line if not name in test: with open(pfad, "a") as f: f.write(name + "\n") sql = "CREATE TABLE " + name + " (deutsch text, englisch text, symbol text);" stmt.execute(sql) sql = "INSERT INTO " + name + " (deutsch, englisch, symbol) VALUES(?,?,?);" pstmt = conn.prepareStatement(sql) pstmt.setString(1, frage) pstmt.setString(2, x) pstmt.setString(3, "X") pstmt.executeUpdate() auflisten_in(uebersicht) def delete(event): name = feld.getText() print name print self.geladen if name == self.geladen: count = 0 while tabelle.getValueAt(count, 0) != None: tabelle.setValueAt(None, count, 0) tabelle.setValueAt(None, count, 1) count += 1 stmt.execute("DROP TABLE " + name + ";") lektionen = [] with open(pfad, "r") as f: for line in f: lektion = line.strip() if not name == lektion: lektionen.append(lektion) with open(pfad, "w") as f: for lektion in lektionen: f.write(lektion + "\n") auflisten_in(uebersicht) def laden(event): name = feld.getText() self.geladen = name sql = "SELECT deutsch, englisch FROM " + name results = stmt.executeQuery(sql) count = 0 while results.next(): d = results.getString("deutsch") e = results.getString("englisch") tabelle.setValueAt(d, count, 0) tabelle.setValueAt(e, count, 1) count += 1 while tabelle.getValueAt(count, 0) != None: tabelle.setValueAt(None, count, 0) tabelle.setValueAt(None, count, 1) count += 1 def erstelle_Lektionstabelle(event): reihen = [] for i in range(0, 50): deutsch = tabelle.getValueAt(i, 0) englisch = tabelle.getValueAt(i, 1) if deutsch != None: symbol = "X" reihen.append([deutsch, englisch, symbol]) else: break z = 0 name = feld.getText() sql = "CREATE TABLE " + name + " (deutsch text, englisch text, symbol text);" try: stmt.execute(sql) except SQLError: stmt.execute("DROP TABLE " + name + ";") stmt.execute(sql) for reihe in reihen: print(reihe) deutsch = reihe[0] englisch = reihe[1] symbol = reihe[2] sql = "INSERT INTO " + name + " (deutsch, englisch, symbol) VALUES(?,?,?);" pstmt = conn.prepareStatement(sql) pstmt.setString(1, deutsch) pstmt.setString(2, englisch) pstmt.setString(3, symbol) pstmt.executeUpdate() test = "" with open(pfad, "r") as f: for line in f: test += line if not name in test: with open(pfad, "a") as f: f.write(name + "\n") self.send(name) frame.setVisible(False) frame = JFrame('Vokabel Listen', defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(1000, 1000)) frame.setLayout(None) label_enter = JLabel() label_enter.setText( "<html><font size=+0.5 color = 000000>Bitte vor dem Speichern<br>die Entertaste bedienen</font></html>" ) label_enter.setBounds(20, 720, 250, 50) uebersichtLabel = JLabel() uebersichtLabel.setText( "<html><font size=+1 color=#191970>Bereits vorhandene Lektionen:</font></html>" ) uebersichtLabel.setBounds(450, 230, 250, 50) uebersicht = JTextArea() uebersicht.editable = False uebersicht_scroll = JScrollPane(uebersicht) uebersicht_scroll.viewport.view = uebersicht uebersicht_scroll.setBounds(450, 300, 250, 380) auflisten_in(uebersicht) button = JButton('Lektion speichern/Lektion reseten', actionPerformed=erstelle_Lektionstabelle, size=(10, 20)) button.setBounds(20, 700, 300, 30) button_laden = JButton('vorhandene Lektion laden', actionPerformed=laden, size=(10, 20)) button_laden.setBounds(20, 110, 210, 30) button_delete = JButton("Lektion entfernen", actionPerformed=delete) button_delete.setBounds(20, 140, 210, 30) hintergrund = ImageIcon("Hintergrund.jpg") pnl = JPanel() hintergrundlabel = JLabel(hintergrund) frame.setContentPane(hintergrundlabel) lektionsnamensLabel = JLabel() lektionsnamensLabel.setForeground(Color(025, 025, 112)) lektionsnamensLabel.setText( "<html><font size=+1>Hier bitte Namen der Lektion eingeben<br>(Nur ein Wort lang)</font></html>" ) lektionsnamensLabel.setBounds(10, 20, 500, 50) frame.add(lektionsnamensLabel) feld = JTextField() feld.setText("") feld.setBounds(20, 80, 210, 25) frame.add(feld) column_names = [ "<html><font size=+1 color=#191970><b>Deutsch</b></font></html>", "<html><font size=+1 color=#191970><b>Englisch</b></font></html>" ] table_model = DefaultTableModel(column_names, 50) tabelle = JTable(table_model) lektionsnamensLabel.setForeground(Color(025, 025, 112)) scrollbar = JScrollPane(tabelle) scrollbar.viewport.view = tabelle scrollbar.setVerticalScrollBarPolicy( scrollbar.VERTICAL_SCROLLBAR_ALWAYS) scrollbar.setVisible(True) tabelle.setVisible(True) scrollbar.setBounds(20, 190, 300, 490) feld_frage = JTextField() feld_frage.setText("") feld_frage.setBounds(450, 30, 300, 50) uebersetzerlabel = JLabel() uebersetzerlabel.setForeground(Color(025, 025, 112)) uebersetzerlabel.setText( "<html><font size=+1>Hier kannst Du ein deutsches Wort eintragen,<br>dass ich fuer Dich nachschlage</font></html>" ) uebersetzerlabel.setBounds(450, 80, 500, 50) button_uebersetzen = JButton('Uebersetzen', actionPerformed=uebersetzen, size=(10, 20)) button_uebersetzen.setBounds(450, 130, 300, 30) frame.add(button_uebersetzen) frame.add(uebersetzerlabel) frame.add(feld_frage) frame.add(feld) frame.add(scrollbar) frame.add(button) frame.add(button_laden) frame.setVisible(True) frame.add(uebersicht_scroll) frame.add(uebersichtLabel) frame.add(button_delete) frame.add(label_enter) elif eingabe == "alle Lektionen auflisten": # Hier erstellt der Client eine dynamische Grammatik # mit den vorhandenen Lektionen, die man sich abfragen lassen kann # und gibt diese wieder an DialogOS zurück. # Außerdem wird der Feedback Frame geöffnet. def auflisten_in2(ort): font = Font("Verdana", Font.BOLD, 15) liste_mit_Lektionen = [] with open(pfad, "r") as f: for line in f: liste_mit_Lektionen.append(line.strip()) liste_mit_Lektionen.sort() text = "" for lektion in liste_mit_Lektionen: text += lektion text += "\n" ort.setText(text) ort.setFont(font) frame_feedback.setVisible(True) auflisten_in2(uebersicht2) grammatik = "" grammatik = "root $NamevonLektion;\n" grammatik += "$NamevonLektion = " with open(pfad, "r") as f: z = 0 for line in f: if z == 0: if not "_" in line: grammatik += line else: zeile = line.split("_") grammatik += zeile[0] + " " grammatik += zeile[1].strip() else: if not "_" in line: grammatik += "|" + line else: zeile = line.split("_") grammatik += "|" + zeile[0] + " " grammatik += zeile[1].strip() if line != "\n": z += 1 grammatik += ";" self.send(grammatik) elif "sende" in eingabe: # DialogOS sagt dem Clienten, welche Lektion der User abgefragt # werden möchte. Der Client ließt dann die entsprechende Lektion # aus der Datenbank aus und gibt eine Liste mit 2 Listen zurück. # In der ersten Liste befinden sich die deutschen Bedeutungen, der # noch nicht gewussten Wörter, in der 2. Liste die englsichen Bedeutungen. # Falls alle Wörter bereits gekonnt wurden, wird stattdessen eine entsprechende # Anmerkung an DialogOS geschickt und DialogOS informiert den User darüber. z = 0 if "nachgeschlagen" in eingabe: bestandteile = eingabe.split() name = bestandteile[1] + "_" + bestandteile[2] else: name = eingabe.split()[1] sql = "SELECT deutsch, englisch, symbol FROM " + name vokabelliste = stmt.executeQuery(sql) deutsch = [] englisch = [] symbol = [] while (vokabelliste.next()): deutsch.append(vokabelliste.getString("deutsch")) englisch.append(vokabelliste.getString("englisch")) symbol.append(vokabelliste.getString("symbol")) indices = range(0, len(deutsch)) random.shuffle(indices) vokabeln = [[], []] for index in indices: d = deutsch[index] e = englisch[index] s = symbol[index] if s == "X": vokabeln[0].append(d) vokabeln[1].append(e) if vokabeln[0]: self.send(vokabeln) else: self.send([ "Du kannst diese Lektion schon komplett. Wenn Du sie wieder abgefragt werden willst, resete sie bitte unter Wokabeln verwalten." ]) else: # Dieser Teil des Codes wird während der Abfrage ausgeführt. # Nach jeder neuen Vokabel wird dann in ein Feld im Feedback # Frame die deutsche, die englische Vokabel und ein Symbol angezeigt, # welches einen darüber informiert, ob man die Vokabel wusste, oder nicht. # (O für gewusst und X für nicht gewusst) nametext = eingabe.split(":") name = nametext[0] text = nametext[1] feld_feedback.setText(text) zeilen = text.split("\n") symb = zeilen[-2].split("\t")[-1] d = zeilen[-2].split("\t")[-3] print d sql = "UPDATE " + name + " SET symbol = ? WHERE deutsch = ?" pstmt = conn.prepareStatement(sql) pstmt.setString(1, symb) pstmt.setString(2, d) pstmt.executeUpdate()
def getColumnClass(self, column): if column == self.checkbox_column: return Boolean return DefaultTableModel.getColumnClass(self, column)
class MainFrame: def __init__(self, dic_books, mat_sim): # Propriétés de la fenêtre frame = JFrame("EbookMining") frame.setSize(window_height, window_width) frame.setLayout(BorderLayout()) # Variables de classe self.dic_books = dic_books self.mat_sim = mat_sim # Tri des livres en fonction du titre sorted_dic_books = sorted(dic_books.items(), key=lambda x: x[1]) self.tableData = [] for book in sorted_dic_books: id_book = book[0] title, author = book[1] self.tableData.append([id_book, title, author]) colNames = ('id_book', 'Titre', 'Auteur') self.dataModel = DefaultTableModel(self.tableData, colNames) self.table = JTable(self.dataModel) # Suppression de la colonne des identifiants dans l'affichage column = self.table.getColumnModel().getColumn(0) self.table.removeColumn(column) scrollPane = JScrollPane() scrollPane.setPreferredSize(Dimension(window_height - 100, window_width - 100)) scrollPane.getViewport().setView((self.table)) panel = JPanel() panel.add(scrollPane) button = JButton("Chercher", actionPerformed=self.recommand) panel.add(button) frame.add(panel, BorderLayout.CENTER) frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) frame.setVisible(True) def getSelectedBooks(self): """Retourne la liste des identifiants des livres sélectionnés""" # index = self.table.getSelectedRow() # return self.dataModel.getValueAt(index, 0) indexes = self.table.getSelectedRows() result = [] for index in indexes: result.append(self.dataModel.getValueAt(index, 0)) return result def recommand(self, event): """Trie les livres par ordre de similarité et les envoie dans une table""" id_books = self.getSelectedBooks() dic_sim = mat_sim[id_books[0]] # Suppression des entrées correspondant aux identifiants recherchés for id_book in id_books: try: del dic_sim[id_book] except: () # Somme des similarités pour chaque livre for id_book in id_books[1:]: cur_dic_sim = mat_sim[id_book] for key in dic_sim: dic_sim[key] += cur_dic_sim[key] # Tri des valeurs en fonction de la similarité sorted_dic_sim = sorted(dic_sim.items(), key=lambda x: x[1], reverse=True) result = [] for sim in sorted_dic_sim: cur_id_book = sim[0] title, author = dic_books[cur_id_book] result.append([cur_id_book, title, author]) if len(id_books) > 1: ResultFrame(result) else: title, author = dic_books[id_book] ResultFrame(result, title, author)
def __init__(self): frame = JFrame("S1riu5 Spy") frame.setSize(700, 690) frame.setLocationRelativeTo(None) frame.setLayout(BorderLayout()) tabPane = JTabbedPane(JTabbedPane.TOP) #第一个Tab用来做C段查询 eachIp = self.getIp(HOSTDOMAIN) iList = eachIp.split(".") theIP = iList[0] + "." + iList[1] + "." + iList[2] + ".1/24" panel1 = JPanel() label = JLabel("IP CIDR:") self.textfield1 = JTextField(theIP, 15) button = JButton("SCAN", actionPerformed=self.cNmapScan) self.textArea = JTextArea(40, 65) self.textArea.append("IP: " + eachIp) self.textArea.setLineWrap(True) #激活自动换行功能 self.textArea.setWrapStyleWord(True) # 激活断行不断字功能 panel1.add(label) panel1.add(self.textfield1) panel1.add(button) panel1.add(JScrollPane(self.textArea)) #设置自动滚动条 tabPane.addTab("C segment query ", panel1) #第二个Tab用来做子域名查询 theName = self.getDomain1(HOSTDOMAIN) self.textArea2 = JTextArea(40, 65) #self.textArea.append("IP: " + eachIp) self.textArea2.setLineWrap(True) #激活自动换行功能 self.textArea2.setWrapStyleWord(True) # 激活断行不断字功能 label2 = JLabel("Domain: ") self.textfield2 = JTextField(theName, 15) button2 = JButton("SCAN", actionPerformed=self.subDomain) self.panel2 = JPanel() self.panel2.add(label2) self.panel2.add(self.textfield2) self.panel2.add(button2) #self.panel2.add(scrollPane) self.panel2.add(JScrollPane(self.textArea2)) tabPane.addTab("subDomains", self.panel2) #第三个Tab用来做敏感文件扫描 self.tableData0 = [["1", "2"]] colNames2 = ('url', 'http code') dataModel3 = DefaultTableModel(self.tableData0, colNames2) self.table3 = JTable(dataModel3) ## label3 = JLabel("URL: ") self.textfield3 = JTextField(HOSTDOMAIN, 15) self.textArea3 = JTextArea(40, 65) #self.textArea.append("IP: " + eachIp) self.textArea3.setLineWrap(True) #激活自动换行功能 self.textArea3.setWrapStyleWord(True) # 激活断行不断字功能 a = 0 b = 0 self.label4 = JLabel(str(a) + "/" + str(b)) # self.chkbox1 = JCheckBox('ASP') self.chkbox2 = JCheckBox('ASPX') self.chkbox3 = JCheckBox('JSP') self.chkbox4 = JCheckBox('PHP') self.chkbox5 = JCheckBox('MDB') self.chkbox6 = JCheckBox('DIR') button3 = JButton("SCAN", actionPerformed=self.senFileScan) panel3 = JPanel() panel3.add(label3) panel3.add(self.textfield3) panel3.add(self.chkbox1) 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)