Merge remote-tracking branch 'origin/Ghidra_9.2'

This commit is contained in:
ghidra1 2020-10-01 11:09:48 -04:00
commit 7d89da07cd
4 changed files with 35 additions and 21 deletions

View file

@ -22,7 +22,7 @@ dependencies {
runtime "org.slf4j:slf4j-nop:1.7.25"
// use this if you want slf4j log messages sent to log4j
// runtime "org.apache.logging.log4j:log4j-slf4j-impl:2.12.1"
runtime "org.jheaps:jheaps:0.11"
runtime "org.jheaps:jheaps:0.13"
helpPath project(path: ":Base", configuration: 'helpPath')

View file

@ -26,13 +26,25 @@ import docking.DialogComponentProvider;
import docking.DockingWindowManager;
import docking.tool.ToolConstants;
import docking.widgets.OptionDialog;
import ghidra.util.*;
import ghidra.util.HelpLocation;
import ghidra.util.Swing;
import ghidra.util.exception.CancelledException;
import ghidra.util.timer.GTimer;
/**
* Dialog that is displayed to show activity for a Task that is running outside of the
* Swing Thread.
*
* <p>Implementation note:
* if this class is constructed with a {@code hasProgrees} value of {@code false},
* then an activity component will be shown, not a progress monitor. Any calls to update
* progress will not affect the display. However, the display can be converted to use progress
* by first calling {@link #setIndeterminate(boolean)} with a {@code false} value and then calling
* {@link #initialize(long)}. Once this has happened, this dialog will no longer use the
* activity display--the progress bar is in effect for the duration of this dialog's usage.
*
* <p>This dialog can be toggled between indeterminate mode and progress mode via calls to
* {@link #setIndeterminate(boolean)}.
*/
public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
@ -50,6 +62,8 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
private Component centerOnComp;
private Runnable shouldCancelRunnable;
private boolean taskDone;
private boolean supportsProgress;
private JPanel mainPanel;
private JPanel activityPanel;
private TaskMonitorComponent monitorComponent;
@ -107,10 +121,11 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
boolean hasProgress) {
super(title, isModal, true, canCancel, true);
this.centerOnComp = centerOnComp;
setup(canCancel, hasProgress);
this.supportsProgress = hasProgress;
setup(canCancel);
}
private void setup(boolean canCancel, boolean hasProgress) {
private void setup(boolean canCancel) {
monitorComponent = new TaskMonitorComponent(false, false);
activityPanel = new ChompingBitsAnimationPanel();
@ -135,7 +150,7 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
mainPanel = new JPanel(new BorderLayout());
addWorkPanel(mainPanel);
if (hasProgress) {
if (supportsProgress) {
installProgressMonitor();
}
else {
@ -165,7 +180,7 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
* Adds the panel that contains the progress bar to the dialog
*/
private void installProgressMonitor() {
SystemUtilities.runIfSwingOrPostSwingLater(() -> {
Swing.runIfSwingOrRunLater(() -> {
mainPanel.removeAll();
mainPanel.add(monitorComponent, BorderLayout.CENTER);
repack();
@ -177,7 +192,7 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
* dialog. This should only be called if the dialog has no need to display progress.
*/
private void installActivityDisplay() {
SystemUtilities.runIfSwingOrPostSwingLater(() -> {
Swing.runIfSwingOrRunLater(() -> {
mainPanel.removeAll();
mainPanel.add(activityPanel, BorderLayout.CENTER);
repack();
@ -273,7 +288,7 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
}
protected void doShow() {
SystemUtilities.runIfSwingOrPostSwingLater(() -> {
Swing.runIfSwingOrRunLater(() -> {
DockingWindowManager.showDialog(centerOnComp, TaskDialog.this);
});
}
@ -302,7 +317,7 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
}
};
SystemUtilities.runSwingNow(disposeTask);
Swing.runNow(disposeTask);
}
//==================================================================================================
@ -332,9 +347,8 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
@Override
public void initialize(long max) {
if (monitorComponent.isIndeterminate()) {
// don't show the progress bar if we have already been marked as indeterminate (this
// allows us to prevent low-level algorithms from changing the display settings).
if (!supportsProgress) {
return;
}
@ -356,7 +370,8 @@ public class TaskDialog extends DialogComponentProvider implements TaskMonitor {
}
@Override
public void setIndeterminate(final boolean indeterminate) {
public void setIndeterminate(boolean indeterminate) {
supportsProgress = !indeterminate;
monitorComponent.setIndeterminate(indeterminate);
}

View file

@ -31,8 +31,6 @@ public abstract class Task implements MonitoredRunnable {
private boolean canCancel;
private boolean hasProgress;
private boolean isModal;
private boolean isInterruptible;
private boolean isForgettable;
protected boolean waitForTaskCompleted = false;
private Set<TaskListener> listeners = new HashSet<>();
protected TaskMonitor taskMonitor = TaskMonitor.DUMMY;
@ -164,10 +162,10 @@ public abstract class Task implements MonitoredRunnable {
};
if (waitForTaskCompleted) {
SystemUtilities.runSwingNow(r);
Swing.runNow(r);
}
else {
SystemUtilities.runSwingLater(r);
Swing.runLater(r);
}
}
@ -176,8 +174,8 @@ public abstract class Task implements MonitoredRunnable {
*
* <P>Note: The run(TaskMonitor) method should not make any calls directly
* on Swing components, as these calls are not thread safe. Place Swing
* calls in a Runnable, then call {@link SystemUtilities#runSwingLater(Runnable)} or
* {@link SystemUtilities#runSwingNow(Runnable)}to schedule the Runnable inside of
* calls in a Runnable, then call {@link Swing#runLater(Runnable)} or
* {@link Swing#runNow(Runnable)}to schedule the Runnable inside of
* the AWT Event Thread.
*
* @param monitor The TaskMonitor that will monitor the executing Task

View file

@ -33,6 +33,7 @@ import ghidra.GhidraApplicationLayout;
import ghidradev.EclipseMessageUtils;
import ghidradev.ghidraprojectcreator.utils.GhidraScriptUtils;
import ghidradev.ghidraprojectcreator.wizards.pages.*;
import utilities.util.FileUtilities;
/**
* Wizard to create a new Ghidra scripting project.
@ -147,8 +148,8 @@ public class CreateGhidraScriptProjectWizard extends Wizard implements INewWizar
* @return True if the data returned from the wizard pages are valid; otherwise, false
*/
private boolean validate() {
if (projectPage.getProjectDir().getAbsolutePath().startsWith(
ghidraInstallationPage.getGhidraInstallDir().getAbsolutePath())) {
if (FileUtilities.isPathContainedWithin(ghidraInstallationPage.getGhidraInstallDir(),
projectPage.getProjectDir())) {
EclipseMessageUtils.showErrorDialog("Invalid Project Root Directory",
"Project root directory cannot reside inside of the selected Ghidra installation directory.");
return false;