Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to delete multiple histories. #71

Merged
merged 1 commit into from Jun 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions src/main/java/core/packetproxy/gui/GUIHistory.java
Original file line number Diff line number Diff line change
@@ -304,13 +304,40 @@ public void tableChanged(TableModelEvent e) {
public Component prepareRenderer(TableCellRenderer tcr, int row, int column) {
Component c = super.prepareRenderer(tcr, row, column);
try {
boolean selected = (table.getSelectedRow() == row);
int[] selected_rows = table.getSelectedRows();
boolean selected = false;
boolean first_selected = false;
if(selected_rows.length>=2)
{
for (int i = 0; i < selected_rows.length; i++)
{
if(selected_rows[i]==row)
{
selected=true;
first_selected = (table.getSelectedRow() == row);
break;
}
}
}
else
{
selected = (table.getSelectedRow() == row);
first_selected = selected;
}
int packetId = (int)table.getValueAt(row, 0);
boolean modified = (boolean)table.getValueAt(row, table.getColumnModel().getColumnIndex("Modified"));
boolean resend = (boolean)table.getValueAt(row, table.getColumnModel().getColumnIndex("Resend"));
if (selected) {
c.setForeground(new Color(0xff, 0xff, 0xff));
c.setBackground(new Color(0x80, 0x80, 0xff));
if(first_selected)
{
c.setForeground(new Color(0xff, 0xff, 0xff));
c.setBackground(new Color(0x80, 0x80, 0xff));
}
else
{
c.setForeground(new Color(0xff, 0xff, 0xff));
c.setBackground(new Color(0xc0, 0xc0, 0xff));
}
} else if (colorManager.contains(packetId)) {
c.setForeground(new Color(0x00, 0x00, 0x00));
c.setBackground(colorManager.getColor(packetId));
@@ -550,6 +577,23 @@ public void actionPerformed(ActionEvent actionEvent) {
}
});

JMenuItem delete_select_items = createMenuItem ("delete select items", -1, null, new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
try {
int[] selected_rows = table.getSelectedRows();
for (int i = 0; i < selected_rows.length; i++)
{
Integer id = (Integer) table.getValueAt(selected_rows[i], 0);
colorManager.clear(id);
packets.delete(packets.query(id));
}
updateAll();
} catch (Exception e2) {
e2.printStackTrace();
}
}
});

JMenuItem delete_all = createMenuItem ("delete all items", -1, null, new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
try {
@@ -626,6 +670,7 @@ public void actionPerformed(ActionEvent actionEvent) {
menu.add(clearColor);
menu.add(copyAsCurl);
menu.add(delete_item);
menu.add(delete_select_items);
menu.add(delete_all);

table.addKeyListener(new KeyAdapter() {