mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch 'origin/GT-2891-dragonmacher-optiondialog-to-swing'
This commit is contained in:
commit
f3a7cb0490
16 changed files with 380 additions and 313 deletions
|
@ -1,41 +0,0 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.merge;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import docking.widgets.OptionDialog;
|
||||
|
||||
public class CancelMergeDialog extends OptionDialog {
|
||||
|
||||
public CancelMergeDialog(Icon icon) {
|
||||
super("Confirm Cancel Merge",
|
||||
"Warning! Cancel causes the entire merge process to be canceled.\n" +
|
||||
"Do you want to cancel the Merge Process?",
|
||||
"Yes", null, OptionDialog.PLAIN_MESSAGE, icon, true, "No");
|
||||
setFocusComponent(cancelButton);
|
||||
}
|
||||
|
||||
public static int showYesNoDialog(Component parent, ImageIcon icon) {
|
||||
CancelMergeDialog dialog = new CancelMergeDialog(icon);
|
||||
dialog.show(parent);
|
||||
return dialog.getResult();
|
||||
}
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
package ghidra.app.merge;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
@ -35,7 +35,6 @@ import ghidra.framework.plugintool.ComponentProviderAdapter;
|
|||
import ghidra.framework.project.tool.ToolIconURL;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.UniversalIdGenerator;
|
||||
import ghidra.util.layout.VerticalLayout;
|
||||
import resources.ResourceManager;
|
||||
|
||||
|
@ -60,14 +59,9 @@ class MergeManagerProvider extends ComponentProviderAdapter {
|
|||
private JButton cancelButton;
|
||||
private boolean wasCanceled;
|
||||
|
||||
private ImageIcon WARNING_ICON = ResourceManager.loadImage("images/warning.png");
|
||||
private ImageIcon MERGE_ICON = ResourceManager.loadImage("images/Merge.png");
|
||||
private long instanceID = UniversalIdGenerator.nextID().getValue();
|
||||
private JPanel mainPanel;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public MergeManagerProvider(MergeManagerPlugin plugin, String title) {
|
||||
super(plugin.getTool(), "Merge Manager", plugin.getName());
|
||||
this.plugin = plugin;
|
||||
|
@ -157,7 +151,7 @@ class MergeManagerProvider extends ComponentProviderAdapter {
|
|||
|
||||
/**
|
||||
* Sets the merge description at the top of the merge tool.
|
||||
* @param description
|
||||
* @param description the description
|
||||
*/
|
||||
void updateMergeDescription(String description) {
|
||||
nameLabel.setText(description);
|
||||
|
@ -186,12 +180,18 @@ class MergeManagerProvider extends ComponentProviderAdapter {
|
|||
setApplyEnabled(false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see ghidra.util.bean.GhidraDialog#cancelCallback()
|
||||
*/
|
||||
void cancelCallback(boolean force) {
|
||||
if (force ||
|
||||
CancelMergeDialog.showYesNoDialog(mainPanel, WARNING_ICON) == OptionDialog.OPTION_ONE) {
|
||||
|
||||
boolean cancel = force;
|
||||
if (!force) {
|
||||
int choice =
|
||||
OptionDialog.showYesNoDialogWithNoAsDefaultButton(null, "Confirm Cancel Merge",
|
||||
"Warning! Cancel causes the entire merge process to be canceled.\n" +
|
||||
"Do you want to cancel the Merge Process?");
|
||||
cancel = choice == OptionDialog.OPTION_ONE;
|
||||
}
|
||||
|
||||
if (cancel) {
|
||||
wasCanceled = true;
|
||||
MergeManager mergeManager = plugin.getMergeManager();
|
||||
if (mergeManager != null) {
|
||||
|
@ -231,22 +231,12 @@ class MergeManagerProvider extends ComponentProviderAdapter {
|
|||
|
||||
private JPanel createButtonPanel() {
|
||||
applyButton = new JButton("Apply");
|
||||
applyButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
applyCallback();
|
||||
}
|
||||
});
|
||||
applyButton.addActionListener(e -> applyCallback());
|
||||
applyButton.setEnabled(false);
|
||||
applyButton.setToolTipText("Apply conflict resolution");
|
||||
|
||||
cancelButton = new JButton("Cancel");
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
cancelCallback(false);
|
||||
}
|
||||
});
|
||||
cancelButton.addActionListener(e -> cancelCallback(false));
|
||||
|
||||
JPanel panel = ButtonPanelFactory.createButtonPanel(
|
||||
new JButton[] { applyButton, cancelButton }, ButtonPanelFactory.X_AXIS);
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package ghidra.app.plugin.core.analysis;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -37,7 +36,7 @@ import ghidra.program.model.lang.LanguageID;
|
|||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.program.util.GhidraProgramUtilities;
|
||||
import ghidra.util.HTMLUtilities;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.Swing;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.*;
|
||||
|
||||
|
@ -171,30 +170,17 @@ class AnalyzeAllOpenProgramsTask extends Task {
|
|||
}
|
||||
|
||||
private boolean setOptions(final Program program, AutoAnalysisManager mgr) {
|
||||
final AtomicBoolean analyze = new AtomicBoolean();
|
||||
AtomicBoolean analyze = new AtomicBoolean();
|
||||
int id = program.startTransaction("analysis");
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AnalysisOptionsDialog dialog =
|
||||
new AnalysisOptionsDialog(getValidProgramsByArchitecture());
|
||||
tool.showDialog(dialog);
|
||||
boolean shouldAnalyze = dialog.wasAnalyzeButtonSelected();
|
||||
analyze.set(shouldAnalyze);
|
||||
}
|
||||
Swing.runNow(() -> {
|
||||
AnalysisOptionsDialog dialog =
|
||||
new AnalysisOptionsDialog(getValidProgramsByArchitecture());
|
||||
tool.showDialog(dialog);
|
||||
boolean shouldAnalyze = dialog.wasAnalyzeButtonSelected();
|
||||
analyze.set(shouldAnalyze);
|
||||
});
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
// shouldn't happen
|
||||
Msg.debug(this, "Unexpected exception", e);
|
||||
return false;
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
// shouldn't happen
|
||||
Msg.debug(this, "Unexpected exception", e);
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
program.endTransaction(id, true);
|
||||
}
|
||||
|
@ -338,10 +324,10 @@ class AnalyzeAllOpenProgramsTask extends Task {
|
|||
|
||||
buffy.append("</TABLE>");
|
||||
|
||||
OptionDialog dialog = new ScrollingOptionDialog("Found Differing Architectures--Continue?",
|
||||
buffy.toString(), "Continue", OptionDialog.WARNING_MESSAGE);
|
||||
dialog.show(null);
|
||||
return dialog.getResult() == OptionDialog.OPTION_ONE;
|
||||
return Swing.runNow(() -> {
|
||||
ScrollingOptionDialog dialog = new ScrollingOptionDialog(buffy.toString());
|
||||
return dialog.shouldContinue();
|
||||
});
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
|
@ -495,9 +481,16 @@ class AnalyzeAllOpenProgramsTask extends Task {
|
|||
|
||||
private class ScrollingOptionDialog extends OptionDialog {
|
||||
|
||||
public ScrollingOptionDialog(String title, String message, String option1,
|
||||
int messageType) {
|
||||
super(title, message, option1, messageType, null);
|
||||
public ScrollingOptionDialog(String message) {
|
||||
super("Found Differing Architectures", message, "Continue",
|
||||
OptionDialog.WARNING_MESSAGE, null);
|
||||
}
|
||||
|
||||
boolean shouldContinue() {
|
||||
return Swing.runNow(() -> {
|
||||
show(null);
|
||||
return getResult() == OptionDialog.OPTION_ONE;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,6 @@ import ghidra.program.model.address.Address;
|
|||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.symbol.Reference;
|
||||
import ghidra.util.HelpLocation;
|
||||
import ghidra.util.SystemUtilities;
|
||||
|
||||
/**
|
||||
* <CODE>SetStackDepthChangeAction</CODE> allows the user to set a stack depth change value
|
||||
|
@ -172,14 +171,8 @@ class SetStackDepthChangeAction extends ListingContextAction {
|
|||
currentAddress.toString() + ".";
|
||||
// @formatter:on
|
||||
|
||||
final OptionDialog dialog = new OptionDialog("Stack Depth Change or Function Purge?",
|
||||
message, "Local", "Global", OptionDialog.QUESTION_MESSAGE,
|
||||
OptionDialog.getIconForMessageType(OptionDialog.QUESTION_MESSAGE), true);
|
||||
|
||||
dialog.setHelpLocation(new HelpLocation(funcPlugin.getName(), "Set_Stack_Depth_Change"));
|
||||
|
||||
Runnable r = () -> tool.showDialog(dialog);
|
||||
SystemUtilities.runSwingNow(r);
|
||||
StackChangeOptionDialog dialog = new StackChangeOptionDialog(message);
|
||||
dialog.show();
|
||||
return dialog.getResult();
|
||||
}
|
||||
|
||||
|
@ -198,4 +191,13 @@ class SetStackDepthChangeAction extends ListingContextAction {
|
|||
return true;
|
||||
}
|
||||
|
||||
private class StackChangeOptionDialog extends OptionDialog {
|
||||
|
||||
StackChangeOptionDialog(String message) {
|
||||
super("Stack Depth Change or Function Purge?", message, "Local", "Global",
|
||||
OptionDialog.QUESTION_MESSAGE, null, true);
|
||||
|
||||
setHelpLocation(new HelpLocation(funcPlugin.getName(), "Set_Stack_Depth_Change"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.awt.event.InputEvent;
|
|||
import java.awt.event.KeyEvent;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import org.jdom.Element;
|
||||
|
||||
import docking.ComponentProvider;
|
||||
|
@ -820,14 +822,11 @@ public class ReferencesPlugin extends Plugin {
|
|||
curType = "Memory reference(s)";
|
||||
}
|
||||
|
||||
OptionDialog confirmDlg = new OptionDialog("Reference Removal Confirmation",
|
||||
JComponent parent = editRefDialog.getComponent();
|
||||
int choice = OptionDialog.showOptionDialog(parent, "Reference Removal Confirmation",
|
||||
"Warning! existing " + curType + " will be removed.", "Continue",
|
||||
OptionDialog.WARNING_MESSAGE,
|
||||
OptionDialog.getIconForMessageType(OptionDialog.WARNING_MESSAGE));
|
||||
confirmDlg.setRememberLocation(false);
|
||||
confirmDlg.setRememberSize(false);
|
||||
tool.showDialog(confirmDlg, editRefDialog.getComponent());
|
||||
return (confirmDlg.getResult() != OptionDialog.CANCEL_OPTION);
|
||||
OptionDialog.WARNING_MESSAGE);
|
||||
return (choice != OptionDialog.CANCEL_OPTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,6 @@ package ghidra.app.util.task;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import docking.widgets.OptionDialog;
|
||||
import ghidra.app.util.dialog.CheckoutDialog;
|
||||
|
@ -259,16 +258,10 @@ public class OpenProgramTask extends Task {
|
|||
|
||||
private boolean askRecoverFile(final String filename) {
|
||||
|
||||
final AtomicBoolean result = new AtomicBoolean();
|
||||
|
||||
SystemUtilities.runSwingNow(() -> {
|
||||
int option = OptionDialog.showYesNoDialog(null, "Crash Recovery Data Found",
|
||||
"<html>" + HTMLUtilities.escapeHTML(filename) + " has crash data.<br>" +
|
||||
"Would you like to recover unsaved changes?");
|
||||
result.set(option == OptionDialog.OPTION_ONE);
|
||||
});
|
||||
|
||||
return result.get();
|
||||
int option = OptionDialog.showYesNoDialog(null, "Crash Recovery Data Found",
|
||||
"<html>" + HTMLUtilities.escapeHTML(filename) + " has crash data.<br>" +
|
||||
"Would you like to recover unsaved changes?");
|
||||
return option == OptionDialog.OPTION_ONE;
|
||||
}
|
||||
|
||||
private void performOptionalCheckout(DomainFile domainFile) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue