mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-23 13:16:48 +08:00
Merge remote-tracking branch
'origin/GP-4172_ghidragon_theme_switch_dialog--SQUASHED' (Closes #6024)
This commit is contained in:
@@ -32,10 +32,10 @@
|
||||
<P align="center"><IMG alt="" src="images/ThemeChooserDialog.png"><BR>
|
||||
</P>
|
||||
|
||||
<P>The Theme Chooser dialog displays a list of all the know themes, both built-in and custom.
|
||||
As you pick different themes, the application will switch to that theme. Press the "OK" button
|
||||
when the desired theme is selected. Pressing the "Cancel" button will restore the theme to
|
||||
the what it was when the dialog was invoked.</P>
|
||||
<P>The Theme Chooser dialog displays a list of all the known themes, both built-in and custom.
|
||||
Select the desired theme and press the "OK" button to have the application switch to that
|
||||
theme. Pressing the "Cancel" button will exit the dialog without changing the theme. You
|
||||
can also double click on a theme to switch to that theme and exit the dialog.</P>
|
||||
|
||||
</BlOCKQUOTE>
|
||||
|
||||
|
||||
+6
-17
@@ -35,22 +35,21 @@ public class ThemeChooserDialog extends DialogComponentProvider {
|
||||
public ThemeChooserDialog(ThemeManager themeManager) {
|
||||
super("Change Theme");
|
||||
this.themeManager = themeManager;
|
||||
|
||||
addWorkPanel(buildMainPanel());
|
||||
addOKButton();
|
||||
addApplyButton();
|
||||
addCancelButton();
|
||||
setRememberSize(false);
|
||||
setHelpLocation(new HelpLocation("Theming", "Switch_Theme"));
|
||||
updateOkApplyButtons();
|
||||
updateButtonEnablement();
|
||||
}
|
||||
|
||||
private void updateOkApplyButtons() {
|
||||
private void updateButtonEnablement() {
|
||||
|
||||
GTheme selectedValue = listPanel.getSelectedValue();
|
||||
GTheme currentTheme = themeManager.getActiveTheme();
|
||||
boolean canApplyTheme = selectedValue != null && !currentTheme.equals(selectedValue);
|
||||
setOkEnabled(canApplyTheme);
|
||||
setApplyEnabled(canApplyTheme);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,22 +58,12 @@ public class ThemeChooserDialog extends DialogComponentProvider {
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCallback() {
|
||||
applyTheme();
|
||||
}
|
||||
|
||||
private void applyTheme() {
|
||||
GTheme selectedValue = listPanel.getSelectedValue();
|
||||
if (selectedValue == null) {
|
||||
return;
|
||||
}
|
||||
GTheme activeTheme = themeManager.getActiveTheme();
|
||||
if (selectedValue != activeTheme) {
|
||||
if (selectedValue != null && selectedValue != activeTheme) {
|
||||
Swing.runLater(() -> themeManager.setTheme(selectedValue));
|
||||
}
|
||||
setOkEnabled(false);
|
||||
setApplyEnabled(false);
|
||||
}
|
||||
|
||||
protected void cancelCallback() {
|
||||
@@ -93,12 +82,12 @@ public class ThemeChooserDialog extends DialogComponentProvider {
|
||||
listPanel.setSelectedValue(activeTheme);
|
||||
listPanel.addListSelectionListener(e -> selectionChanged());
|
||||
panel.add(listPanel);
|
||||
|
||||
listPanel.setDoubleClickActionListener(e -> okCallback());
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void selectionChanged() {
|
||||
updateOkApplyButtons();
|
||||
updateButtonEnablement();
|
||||
}
|
||||
|
||||
private class ThemeListModel extends AbstractListModel<GTheme> {
|
||||
|
||||
Reference in New Issue
Block a user