mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-04-25 17:25:17 +02:00
GP-6612 - Updated the Data Settings dialog to not have to click OK twice with an active edit
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package ghidra.app.plugin.core.data;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
@@ -23,6 +24,7 @@ import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.table.TableCellEditor;
|
||||
|
||||
import docking.DialogComponentProvider;
|
||||
@@ -66,7 +68,7 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
||||
*/
|
||||
protected AbstractSettingsDialog(String title, SettingsDefinition[] settingDefinitions,
|
||||
Settings originalSettings) {
|
||||
super(title, true, false, true, false);
|
||||
super(title, true, true, true, false);
|
||||
this.settingsDefinitions = settingDefinitions;
|
||||
settings = new SettingsImpl(originalSettings) {
|
||||
@Override
|
||||
@@ -143,6 +145,21 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
||||
addButton(newApplyButton);
|
||||
|
||||
addCancelButton();
|
||||
|
||||
MouseAdapter listener = new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
||||
if (settingsTable.isEditing()) {
|
||||
settingsTable.editingStopped(new ChangeEvent(this));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
okButton.addMouseListener(listener);
|
||||
newApplyButton.addMouseListener(listener);
|
||||
cancelButton.addMouseListener(listener);
|
||||
}
|
||||
|
||||
private String getHexModePropertyName(SettingsDefinition settingsDef) {
|
||||
@@ -207,6 +224,21 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
||||
settingsTable.setDefaultRenderer(Settings.class, new SettingsRenderer());
|
||||
settingsTable.setDefaultEditor(Settings.class, new SettingsEditor());
|
||||
|
||||
settingsTable.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
||||
if (clickedUseDefaultWhileSelected(e)) {
|
||||
setStatusText("'Use Default' can only be selected, not de-selected");
|
||||
return;
|
||||
}
|
||||
|
||||
clearStatusText();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
JScrollPane scrollpane = new JScrollPane(settingsTable);
|
||||
scrollpane.setPreferredSize(new Dimension(WIDTH, HEIGHT));
|
||||
|
||||
@@ -226,6 +258,19 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
||||
return workPanel;
|
||||
}
|
||||
|
||||
private boolean clickedUseDefaultWhileSelected(MouseEvent e) {
|
||||
|
||||
Point p = e.getPoint();
|
||||
int col = settingsTable.columnAtPoint(p);
|
||||
if (!settingsTableModel.isUseDefaultColumn(col)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int row = settingsTable.rowAtPoint(p);
|
||||
Object value = settingsTable.getValueAt(row, col);
|
||||
return (Boolean) value;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cancelCallback() {
|
||||
settingsTable.editingStopped(null);
|
||||
@@ -513,6 +558,10 @@ public abstract class AbstractSettingsDialog extends DialogComponentProvider {
|
||||
return defaultSettings != null ? 3 : 2;
|
||||
}
|
||||
|
||||
boolean isUseDefaultColumn(int col) {
|
||||
return col == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int col) {
|
||||
switch (col) {
|
||||
|
||||
Reference in New Issue
Block a user