Skip to content

Ghidra is a software reverse engineering (SRE) framework

Merge remote-tracking branch 'origin/GT-2853_dev747368_remove_tooltipmanager'

ghidra17da1abe3eae2
diff --cc Ghidra/Framework/Docking/src/main/java/ghidra/util/task/TaskMonitorComponent.java
index 4aba7f8b8b,033e28731e..47af51d076
--- a/Ghidra/Framework/Docking/src/main/java/ghidra/util/task/TaskMonitorComponent.java
+++ b/Ghidra/Framework/Docking/src/main/java/ghidra/util/task/TaskMonitorComponent.java
@@@ -23,7 -23,7 +23,6 @@@ import java.util.concurrent.atomic.Atom
import javax.swing.*;
- import docking.ToolTipManager;
-import docking.util.AnimatedIcon;
import docking.widgets.EmptyBorderButton;
import docking.widgets.OptionDialog;
import docking.widgets.label.GDHtmlLabel;
@@@ -44,27 -46,22 +43,27 @@@ public class TaskMonitorComponent exten
private WeakSet<CancelledListener> listeners =
WeakDataStructureFactory.createCopyOnReadWeakSet();
-
- private WeakSet<IssueListener> issueListeners;
- private JButton cancelButton;
- private JPanel eastButtonPanel;
++
private JProgressBar progressBar;
+ private JButton cancelButton;
-
++
+ private JPanel cancelPanel;
+ private JPanel progressBarPanel;
+ private JPanel mainContentPanel;
private JPanel progressPanel;
- private JPanel activeProgressPanel;
- private JLabel imageLabel;
+ private String progressMessage;
private String taskName;
-
++
+ private JLabel messageLabel;
-
++
private volatile boolean isCancelled;
-
- private String message;
+
private long lastProgress = -1;
private long progress;
- private long lastMax = -1;
- private long max;
+ private long lastMaxProgress = -1;
+ private long maxProgress;
+ private long scaleFactor = 1;
private Runnable updateProgressPanelRunnable;
private Runnable updateCancelButtonRunnable;
@@@ -75,18 -72,22 +74,18 @@@
private boolean showingIcon = true;
private boolean showingCancelButton = true;
private boolean cancelEnabled = true;
+ private boolean paintProgressValue = true;
-
++
private AtomicBoolean isIndeterminate = new AtomicBoolean(false);
private AtomicInteger taskID = new AtomicInteger();
private Timer updateTimer;
-
- private Runnable shouldCancelRunnable;
+
- private boolean paintProgressValue = true;
private NumberFormat percentFormat = NumberFormat.getPercentInstance();
-
- private long scaleFactor = 1;
+
/**
- * Construct a new TaskMonitorComponent.
- * @param l listener that is notified when the task completes or the
- * user cancels the task
+ * Constructor
*/
-
public TaskMonitorComponent() {
this(true, true);
}
@@@ -117,25 -112,13 +116,25 @@@
buildProgressPanel(includeTextField, includeCancelButton);
}
-
+
- /**
- * Reset this monitor so that it can be reused.
- */
- public synchronized void reset() {
- isCancelled = false;
- taskID.incrementAndGet();
+ @Override
+ public void addCancelledListener(CancelledListener mcl) {
+ listeners.add(mcl);
+ }
+
+ @Override
+ public void removeCancelledListener(CancelledListener mcl) {
+ listeners.remove(mcl);
+ }
-
++
+ @Override
+ public void incrementProgress(long incrementAmount) {
+ setProgress(progress + incrementAmount);
+ }
+
+ @Override
+ public long getProgress() {
+ return progress;
}
@Override
@@@ -164,7 -147,13 +163,7 @@@
progress = value;
startUpdateTimer();
}
-
+
- private synchronized void startUpdateTimer() {
- if (!updateTimer.isRunning()) {
- updateTimer.start();
- }
- }
-
@Override
public void initialize(long maxValue) {
setMaximum(maxValue);
@@@ -242,46 -242,14 +241,46 @@@
isCancelled = false;
}
}
-
+
+ @Override
+ public void setShowProgressValue(boolean showProgressValue) {
+ this.paintProgressValue = showProgressValue;
+ startUpdateTimer();
+ }
+
+ @Override
+ public long getMaximum() {
+ return maxProgress;
+ }
-
++
+ /**
+ * Reset this monitor so that it can be reused
+ */
+ @Override
+ public synchronized void reset() {
+ isCancelled = false;
+ taskID.incrementAndGet();
+ }
-
++
/**
- * Set whether the progress bar should be visible.
- * @param b true if the progress bar should be visible
+ * Returns true if {@link #setIndeterminate(boolean)} with a value of <tt>true</tt> has
+ * been called.
+ *
+ * @return true if {@link #setIndeterminate(boolean)} with a value of <tt>true</tt> has
+ * been called.
*/
- public synchronized void showProgress(boolean b) {
- if (b != showingProgress) {
- showingProgress = b;
+ public boolean isIndeterminate() {
+ return isIndeterminate.get();
+ }
+
+ /**
+ * Set whether the progress bar should be visible
+ *
+ * @param show true if the progress bar should be visible
+ */
+ public synchronized void showProgress(boolean show) {
+ if (show != showingProgress) {
+ showingProgress = show;
SystemUtilities.runSwingLater(updateProgressPanelRunnable);
}
}
@@@ -308,15 -273,13 +307,15 @@@
return;
}
- if (showCancel) {
- add(eastButtonPanel, BorderLayout.EAST);
+ if (visible) {
+ add(cancelPanel, BorderLayout.EAST);
}
else {
- remove(eastButtonPanel);
+ remove(cancelPanel);
}
-
- showingCancelButton = showCancel;
++
+ repaint();
- showingCancelButton = visible;
++ showingCancelButton = visible;
}
/**
@@@ -340,20 -302,16 +339,20 @@@
SystemUtilities.runSwingNow(r);
}
-
+
- @Override
- public void setShowProgressValue(boolean showProgressValue) {
- this.paintProgressValue = showProgressValue;
- startUpdateTimer();
+ protected void notifyChangeListeners() {
+ Runnable r = () -> {
+ for (CancelledListener mcl : listeners) {
+ mcl.cancelled();
+ }
+ };
+ SwingUtilities.invokeLater(r);
}
-
+
- @Override
- public long getMaximum() {
- return max;
+ private synchronized void startUpdateTimer() {
+ if (!updateTimer.isRunning()) {
+ updateTimer.start();
+ }
}
private synchronized void update() {