mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GT-2886 - fixed NPE when trying to beep
This commit is contained in:
parent
146a83f953
commit
2f58ec7b47
8 changed files with 53 additions and 39 deletions
|
@ -173,8 +173,7 @@ public class CodeBrowserClipboardProvider extends ByteCopier
|
||||||
return pasteByteString(string);
|
return pasteByteString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
tool.setStatusInfo("Paste failed: unsupported data type");
|
tool.setStatusInfo("Paste failed: unsupported data type", true);
|
||||||
tool.getToolFrame().getToolkit().beep();
|
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
String msg = e.getMessage();
|
String msg = e.getMessage();
|
||||||
|
@ -182,8 +181,7 @@ public class CodeBrowserClipboardProvider extends ByteCopier
|
||||||
msg = e.toString();
|
msg = e.toString();
|
||||||
Msg.error(this, "Unexpected Exception: " + e.getMessage(), e);
|
Msg.error(this, "Unexpected Exception: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
tool.setStatusInfo("Paste failed: " + msg);
|
tool.setStatusInfo("Paste failed: " + msg, true);
|
||||||
tool.getToolFrame().getToolkit().beep();
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -405,8 +403,7 @@ public class CodeBrowserClipboardProvider extends ByteCopier
|
||||||
|
|
||||||
String message = "Copy failed: " + msg;
|
String message = "Copy failed: " + msg;
|
||||||
Msg.error(this, message, e);
|
Msg.error(this, message, e);
|
||||||
tool.setStatusInfo(message);
|
tool.setStatusInfo(message, true);
|
||||||
tool.getToolFrame().getToolkit().beep();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -440,8 +437,7 @@ public class CodeBrowserClipboardProvider extends ByteCopier
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
msg = e.toString();
|
msg = e.toString();
|
||||||
}
|
}
|
||||||
tool.setStatusInfo("Paste failed: " + msg);
|
tool.setStatusInfo("Paste failed: " + msg, true);
|
||||||
tool.getToolFrame().getToolkit().beep();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -125,8 +125,7 @@ public abstract class ByteCopier {
|
||||||
String string = (String) object;
|
String string = (String) object;
|
||||||
if (!isOnlyAsciiBytes(string)) {
|
if (!isOnlyAsciiBytes(string)) {
|
||||||
tool.setStatusInfo("Paste string contains non-text ascii bytes. " +
|
tool.setStatusInfo("Paste string contains non-text ascii bytes. " +
|
||||||
"Only the ascii text will be pasted.");
|
"Only the ascii text will be pasted.", true);
|
||||||
tool.getToolFrame().getToolkit().beep();
|
|
||||||
|
|
||||||
string = keepOnlyAsciiBytes(string);
|
string = keepOnlyAsciiBytes(string);
|
||||||
}
|
}
|
||||||
|
@ -219,8 +218,7 @@ public abstract class ByteCopier {
|
||||||
protected boolean pasteBytes(Transferable pasteData)
|
protected boolean pasteBytes(Transferable pasteData)
|
||||||
throws UnsupportedFlavorException, IOException {
|
throws UnsupportedFlavorException, IOException {
|
||||||
if (!supportsPasteTransferable(pasteData)) {
|
if (!supportsPasteTransferable(pasteData)) {
|
||||||
tool.setStatusInfo("Paste failed: No valid data on clipboard");
|
tool.setStatusInfo("Paste failed: No valid data on clipboard", true);
|
||||||
tool.getToolFrame().getToolkit().beep();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,8 +247,7 @@ public abstract class ByteCopier {
|
||||||
String validString = string;
|
String validString = string;
|
||||||
if (!isOnlyAsciiBytes(string)) {
|
if (!isOnlyAsciiBytes(string)) {
|
||||||
tool.setStatusInfo("Pasted string contained non-text ascii bytes. " +
|
tool.setStatusInfo("Pasted string contained non-text ascii bytes. " +
|
||||||
"Only the ascii text was pasted.");
|
"Only the ascii text was pasted.", true);
|
||||||
tool.getToolFrame().getToolkit().beep();
|
|
||||||
|
|
||||||
validString = keepOnlyAsciiBytes(string);
|
validString = keepOnlyAsciiBytes(string);
|
||||||
}
|
}
|
||||||
|
@ -258,7 +255,7 @@ public abstract class ByteCopier {
|
||||||
byte[] bytes = getBytes(validString);
|
byte[] bytes = getBytes(validString);
|
||||||
if (bytes == null) {
|
if (bytes == null) {
|
||||||
status = "Improper data format (expected sequence of hex bytes)";
|
status = "Improper data format (expected sequence of hex bytes)";
|
||||||
tool.getToolFrame().getToolkit().beep();
|
tool.beep();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,13 +267,13 @@ public abstract class ByteCopier {
|
||||||
for (int i = 0; i < byteCount;) {
|
for (int i = 0; i < byteCount;) {
|
||||||
if (curAddr == null) {
|
if (curAddr == null) {
|
||||||
status = "Not enough addresses to paste bytes";
|
status = "Not enough addresses to paste bytes";
|
||||||
tool.getToolFrame().getToolkit().beep();
|
tool.beep();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CodeUnit curCodeUnit = listing.getCodeUnitContaining(curAddr);
|
CodeUnit curCodeUnit = listing.getCodeUnitContaining(curAddr);
|
||||||
if (!(curCodeUnit instanceof Data) || ((Data) curCodeUnit).isDefined()) {
|
if (!(curCodeUnit instanceof Data) || ((Data) curCodeUnit).isDefined()) {
|
||||||
status = "Cannot paste on top of defined instructions/data";
|
status = "Cannot paste on top of defined instructions/data";
|
||||||
tool.getToolFrame().getToolkit().beep();
|
tool.beep();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int length = curCodeUnit.getLength();
|
int length = curCodeUnit.getLength();
|
||||||
|
|
|
@ -86,8 +86,7 @@ public class ByteViewerClipboardProvider extends ByteCopier
|
||||||
@Override
|
@Override
|
||||||
public boolean paste(Transferable pasteData) {
|
public boolean paste(Transferable pasteData) {
|
||||||
if (!supportsPasteTransferable(pasteData)) {
|
if (!supportsPasteTransferable(pasteData)) {
|
||||||
tool.setStatusInfo("Paste failed: No valid data on clipboard");
|
tool.setStatusInfo("Paste failed: No valid data on clipboard", true);
|
||||||
tool.getToolFrame().getToolkit().beep();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +95,7 @@ public class ByteViewerClipboardProvider extends ByteCopier
|
||||||
return pasteBytes(pasteData);
|
return pasteBytes(pasteData);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
tool.setStatusInfo("Paste failed: " + e.getMessage());
|
tool.setStatusInfo("Paste failed: " + e.getMessage(), true);
|
||||||
tool.getToolFrame().getToolkit().beep();
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,8 +86,7 @@ public class FGClipboardProvider extends CodeBrowserClipboardProvider {
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
msg = e.toString();
|
msg = e.toString();
|
||||||
}
|
}
|
||||||
tool.setStatusInfo("Copy failed: " + msg);
|
tool.setStatusInfo("Copy failed: " + msg, true);
|
||||||
tool.getToolFrame().getToolkit().beep();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -159,8 +159,7 @@ public class VTPlugin extends Plugin {
|
||||||
Preferences.setProperty(SHOW_HELP_PREFERENCE, "No");
|
Preferences.setProperty(SHOW_HELP_PREFERENCE, "No");
|
||||||
Preferences.store();
|
Preferences.store();
|
||||||
|
|
||||||
URL url =
|
URL url = ResourceManager.getResource("help/topics/VersionTrackingPlugin/VT_Workflow.html");
|
||||||
ResourceManager.getResource("help/topics/VersionTrackingPlugin/VT_Workflow.html");
|
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
Msg.showError(this, null, "Help Not Found",
|
Msg.showError(this, null, "Help Not Found",
|
||||||
"Unable to find the Version Tracking workflow help");
|
"Unable to find the Version Tracking workflow help");
|
||||||
|
@ -396,7 +395,7 @@ public class VTPlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
static void showBusyToolMessage(PluginTool tool) {
|
static void showBusyToolMessage(PluginTool tool) {
|
||||||
JFrame toolFrame = tool.getToolFrame();
|
JFrame toolFrame = tool.getToolFrame();
|
||||||
toolFrame.getToolkit().beep();
|
tool.beep();
|
||||||
Msg.showInfo(VTPlugin.class, toolFrame, "Tool \"" + tool.getName() + "\" Busy",
|
Msg.showInfo(VTPlugin.class, toolFrame, "Tool \"" + tool.getName() + "\" Busy",
|
||||||
"You must stop all background tasks before exiting.");
|
"You must stop all background tasks before exiting.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1909,7 +1909,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the status text in the active component window.
|
* Set the status text in the active component window
|
||||||
* @param text status text
|
* @param text status text
|
||||||
*/
|
*/
|
||||||
public void setStatusText(String text) {
|
public void setStatusText(String text) {
|
||||||
|
@ -1918,6 +1918,30 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the status text in the active component window
|
||||||
|
*
|
||||||
|
* @param text string to be displayed in the Status display area
|
||||||
|
* @param beep whether to beep or not
|
||||||
|
*/
|
||||||
|
public void setStatusText(String text, boolean beep) {
|
||||||
|
if (root == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setStatusText(text);
|
||||||
|
if (beep) {
|
||||||
|
Toolkit.getDefaultToolkit().beep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience method to make an attention-grabbing noise to the user
|
||||||
|
*/
|
||||||
|
public static void beep() {
|
||||||
|
Toolkit.getDefaultToolkit().beep();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the menu group associated with a cascaded submenu. This allows
|
* Set the menu group associated with a cascaded submenu. This allows
|
||||||
* a cascading menu item to be grouped with a specific set of actions.
|
* a cascading menu item to be grouped with a specific set of actions.
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.*;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
import docking.*;
|
import docking.*;
|
||||||
import ghidra.util.SystemUtilities;
|
import ghidra.util.Swing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action that manages multiple PluginActions mapped to this action's key binding.
|
* Action that manages multiple PluginActions mapped to this action's key binding.
|
||||||
|
@ -146,7 +146,6 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If more than one action, prompt user for selection
|
// If more than one action, prompt user for selection
|
||||||
JFrame rootFrame = winMgr.getRootFrame();
|
|
||||||
if (list.size() > 1) {
|
if (list.size() > 1) {
|
||||||
// popup dialog to show multiple actions
|
// popup dialog to show multiple actions
|
||||||
if (dialog == null) {
|
if (dialog == null) {
|
||||||
|
@ -159,7 +158,7 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
|
||||||
// doing the show in an invoke later seems to fix a strange swing bug that lock up
|
// doing the show in an invoke later seems to fix a strange swing bug that lock up
|
||||||
// the program if you tried to invoke a new action too quickly after invoking
|
// the program if you tried to invoke a new action too quickly after invoking
|
||||||
// it the first time
|
// it the first time
|
||||||
SystemUtilities.runSwingLater(() -> winMgr.showDialog(dialog));
|
Swing.runLater(() -> DockingWindowManager.showDialog(dialog));
|
||||||
}
|
}
|
||||||
else if (list.size() == 1) {
|
else if (list.size() == 1) {
|
||||||
final ExecutableKeyActionAdapter actionProxy = list.get(0);
|
final ExecutableKeyActionAdapter actionProxy = list.get(0);
|
||||||
|
@ -168,8 +167,7 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String name = (String) getValue(Action.NAME);
|
String name = (String) getValue(Action.NAME);
|
||||||
winMgr.setStatusText("Action (" + name + ") not valid in this context!");
|
winMgr.setStatusText("Action (" + name + ") not valid in this context!", true);
|
||||||
rootFrame.getToolkit().beep();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -492,14 +492,10 @@ public abstract class PluginTool extends AbstractDockingTool
|
||||||
/**
|
/**
|
||||||
* Set the status information.
|
* Set the status information.
|
||||||
* @param text string to be displayed in the Status display area
|
* @param text string to be displayed in the Status display area
|
||||||
* @param beep whether to be or not
|
* @param beep whether to beep or not
|
||||||
*/
|
*/
|
||||||
public void setStatusInfo(String text, boolean beep) {
|
public void setStatusInfo(String text, boolean beep) {
|
||||||
winMgr.setStatusText(text);
|
winMgr.setStatusText(text, beep);
|
||||||
if (beep) {
|
|
||||||
Toolkit tk = getToolFrame().getToolkit();
|
|
||||||
tk.beep();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -514,6 +510,13 @@ public abstract class PluginTool extends AbstractDockingTool
|
||||||
winMgr.setStatusText("");
|
winMgr.setStatusText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience method to make an attention-grabbing noise to the user
|
||||||
|
*/
|
||||||
|
public void beep() {
|
||||||
|
DockingWindowManager.beep();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the provider that should get the default focus when no component has focus.
|
* Sets the provider that should get the default focus when no component has focus.
|
||||||
* @param provider the provider that should get the default focus when no component has focus.
|
* @param provider the provider that should get the default focus when no component has focus.
|
||||||
|
@ -1357,7 +1360,7 @@ public abstract class PluginTool extends AbstractDockingTool
|
||||||
taskMgr.stop(false);
|
taskMgr.stop(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
getToolFrame().getToolkit().beep();
|
beep();
|
||||||
Msg.showInfo(getClass(), getToolFrame(), "Tool Busy",
|
Msg.showInfo(getClass(), getToolFrame(), "Tool Busy",
|
||||||
"You must stop all background tasks before exiting.");
|
"You must stop all background tasks before exiting.");
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue