Version: 2.5.1 Update
This commit is contained in:
64
src/main/java/burp/ui/board/ColorRenderer.java
Normal file
64
src/main/java/burp/ui/board/ColorRenderer.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package burp.ui.board;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
public class ColorRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
private List<LogEntry> log;
|
||||
private Map<String, Color> colorMap = new HashMap<>();
|
||||
private JTable table; // 保存对表格的引用
|
||||
|
||||
public ColorRenderer(List<LogEntry> log, JTable table) {
|
||||
this.log = log;
|
||||
this.colorMap.put("red", Color.RED);
|
||||
this.colorMap.put("orange", Color.ORANGE);
|
||||
this.colorMap.put("yellow", Color.YELLOW);
|
||||
this.colorMap.put("green", Color.GREEN);
|
||||
this.colorMap.put("cyan", Color.CYAN);
|
||||
this.colorMap.put("blue", Color.BLUE);
|
||||
this.colorMap.put("pink", Color.PINK);
|
||||
this.colorMap.put("magenta", Color.MAGENTA);
|
||||
this.colorMap.put("gray", Color.GRAY);
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
|
||||
boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
|
||||
LogEntry logEntry = log.get(table.convertRowIndexToModel(row)); // 使用convertRowIndexToModel方法转换行索引
|
||||
|
||||
// 设置颜色
|
||||
String colorByLog = logEntry.getColor();
|
||||
Color color = colorMap.get(colorByLog);
|
||||
|
||||
if (isSelected) {
|
||||
// 如果行被选中,设置阴影颜色
|
||||
component.setBackground(new Color(173, 216, 230)); // Light Blue
|
||||
} else {
|
||||
// 否则使用原始颜色
|
||||
component.setBackground(color);
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
|
||||
super.firePropertyChange(propertyName, oldValue, newValue);
|
||||
// 监听表格排序的属性变化
|
||||
if ("tableCellRenderer".equals(propertyName)) {
|
||||
// 更新每一行数据的颜色
|
||||
for (int i = 0; i < table.getRowCount(); i++) {
|
||||
table.repaint(table.getCellRect(i, 0, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,8 @@ package burp.ui.board;
|
||||
import burp.config.ConfigEntry;
|
||||
import burp.core.utils.StringHelper;
|
||||
import burp.ui.board.MessagePanel.Table;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
@@ -15,8 +14,7 @@ import javax.swing.table.TableModel;
|
||||
import javax.swing.table.TableRowSorter;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
@@ -48,21 +46,24 @@ public class Databoard extends JPanel {
|
||||
}
|
||||
|
||||
private void clearActionPerformed(ActionEvent e) {
|
||||
cleanUI();
|
||||
int retCode = JOptionPane.showConfirmDialog(null, "Do you want to clear data?", "Info",
|
||||
JOptionPane.YES_NO_OPTION);
|
||||
if (retCode == JOptionPane.YES_OPTION) {
|
||||
cleanUI();
|
||||
|
||||
String host = hostTextField.getText();
|
||||
String cleanedHost = StringHelper.replaceFirstOccurrence(host, "*.", "");
|
||||
String host = hostTextField.getText();
|
||||
String cleanedHost = StringHelper.replaceFirstOccurrence(host, "*.", "");
|
||||
|
||||
if (host.contains("*")) {
|
||||
ConfigEntry.globalDataMap.keySet().removeIf(i -> i.contains(cleanedHost) || cleanedHost.equals("**"));
|
||||
} else {
|
||||
ConfigEntry.globalDataMap.remove(host);
|
||||
if (host.contains("*")) {
|
||||
ConfigEntry.globalDataMap.keySet().removeIf(i -> i.contains(cleanedHost) || cleanedHost.equals("**"));
|
||||
} else {
|
||||
ConfigEntry.globalDataMap.remove(host);
|
||||
}
|
||||
|
||||
messagePanel.deleteByHost(cleanedHost);
|
||||
}
|
||||
|
||||
messagePanel.deleteByHost(cleanedHost);
|
||||
}
|
||||
|
||||
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
hostLabel = new JLabel();
|
||||
@@ -115,6 +116,7 @@ public class Databoard extends JPanel {
|
||||
final JComboBox hostComboBox = new JComboBox(comboBoxModel) {
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
setMaximumRowCount(5);
|
||||
return new Dimension(super.getPreferredSize().width, 0);
|
||||
}
|
||||
};
|
||||
@@ -130,8 +132,9 @@ public class Databoard extends JPanel {
|
||||
hostComboBox.addActionListener(e -> {
|
||||
if (!isMatchHost) {
|
||||
if (hostComboBox.getSelectedItem() != null) {
|
||||
hostTextField.setText(hostComboBox.getSelectedItem().toString());
|
||||
populateTabbedPaneByHost(hostComboBox);
|
||||
String selectedHost = hostComboBox.getSelectedItem().toString();
|
||||
hostTextField.setText(selectedHost);
|
||||
populateTabbedPaneByHost(selectedHost);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -154,7 +157,7 @@ public class Databoard extends JPanel {
|
||||
if (keyCode == KeyEvent.VK_ENTER) {
|
||||
String selectedItem = hostComboBox.getSelectedItem().toString();
|
||||
hostTextField.setText(selectedItem);
|
||||
populateTabbedPaneByHost(hostComboBox);
|
||||
populateTabbedPaneByHost(selectedItem);
|
||||
hostComboBox.setPopupVisible(false);
|
||||
return;
|
||||
}
|
||||
@@ -172,7 +175,6 @@ public class Databoard extends JPanel {
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
updateList();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,12 +195,7 @@ public class Databoard extends JPanel {
|
||||
for (String host : getHostByList()) {
|
||||
String lowerCaseHost = host.toLowerCase();
|
||||
if (lowerCaseHost.contains(input)) {
|
||||
if (host.length() == input.length()){
|
||||
comboBoxModel.insertElementAt(host,0);
|
||||
comboBoxModel.setSelectedItem(host);
|
||||
} else {
|
||||
comboBoxModel.addElement(host);
|
||||
}
|
||||
comboBoxModel.addElement(host);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,9 +222,8 @@ public class Databoard extends JPanel {
|
||||
messagePanel.applyHostFilter(filterText);
|
||||
}
|
||||
|
||||
private void populateTabbedPaneByHost(JComboBox<String> hostComboBox) {
|
||||
if (hostComboBox.getSelectedItem() != null) {
|
||||
String selectedHost = hostComboBox.getSelectedItem().toString();
|
||||
private void populateTabbedPaneByHost(String selectedHost) {
|
||||
if (!Objects.equals(selectedHost, "")) {
|
||||
Map<String, Map<String, List<String>>> dataMap = ConfigEntry.globalDataMap;
|
||||
Map<String, List<String>> selectedDataMap;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MessagePanel extends AbstractTableModel implements IMessageEditorCo
|
||||
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
||||
|
||||
logTable = new Table(MessagePanel.this);
|
||||
logTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer(filteredLog, logTable));
|
||||
logTable.setDefaultRenderer(Object.class, new ColorRenderer(filteredLog, logTable));
|
||||
logTable.setAutoCreateRowSorter(true);
|
||||
|
||||
// Length字段根据大小进行排序
|
||||
|
||||
Reference in New Issue
Block a user