You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by sk...@apache.org on 2022/05/23 15:50:51 UTC
[netbeans] branch delivery updated: Don't call isDispatchThread in a headless environment
This is an automated email from the ASF dual-hosted git repository.
skygo pushed a commit to branch delivery
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/delivery by this push:
new 739a923d81 Don't call isDispatchThread in a headless environment
new 81a902fd17 Merge pull request #4134 from jtulach/jtulach/DontCallSwing
739a923d81 is described below
commit 739a923d81d01032e5afad65ce7e1dd67c89dbef
Author: Jaroslav Tulach <ja...@apidesign.org>
AuthorDate: Mon May 23 15:19:47 2022 +0200
Don't call isDispatchThread in a headless environment
---
.../src/org/netbeans/modules/sampler/InternalSampler.java | 12 ++++++++----
.../sampler/src/org/netbeans/modules/sampler/Sampler.java | 7 +++++--
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/platform/sampler/src/org/netbeans/modules/sampler/InternalSampler.java b/platform/sampler/src/org/netbeans/modules/sampler/InternalSampler.java
index 9391891ce8..5c055bdd35 100644
--- a/platform/sampler/src/org/netbeans/modules/sampler/InternalSampler.java
+++ b/platform/sampler/src/org/netbeans/modules/sampler/InternalSampler.java
@@ -171,7 +171,7 @@ final class InternalSampler extends Sampler {
@Override
@Messages("Save_Progress=Saving snapshot")
void openProgress(final int steps) {
- if (EventQueue.isDispatchThread()) {
+ if (isDispatchThread()) {
// log warnining
return;
}
@@ -180,7 +180,7 @@ final class InternalSampler extends Sampler {
@Override
void closeProgress() {
- if (EventQueue.isDispatchThread()) {
+ if (isDispatchThread()) {
return;
}
progress.finish();
@@ -189,12 +189,16 @@ final class InternalSampler extends Sampler {
@Override
void progress(int i) {
- if (EventQueue.isDispatchThread()) {
+ if (isDispatchThread()) {
return;
}
if (progress != null) {
progress.progress(i);
}
}
-
+
+ @Override
+ boolean isDispatchThread() {
+ return EventQueue.isDispatchThread();
+ }
}
diff --git a/platform/sampler/src/org/netbeans/modules/sampler/Sampler.java b/platform/sampler/src/org/netbeans/modules/sampler/Sampler.java
index 7902c12238..94bd7a70ee 100644
--- a/platform/sampler/src/org/netbeans/modules/sampler/Sampler.java
+++ b/platform/sampler/src/org/netbeans/modules/sampler/Sampler.java
@@ -27,7 +27,6 @@ import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.swing.SwingUtilities;
import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.annotations.common.NonNull;
@@ -227,7 +226,7 @@ public abstract class Sampler {
if (cancel || samples < 1) {
return;
}
- if (SwingUtilities.isEventDispatchThread()) throw new IllegalStateException("sampling cannot be stopped from EDT"); //NOI18N
+ if (isDispatchThread()) throw new IllegalStateException("sampling cannot be stopped from EDT"); //NOI18N
double average = sum / samples;
double std_deviation = Math.sqrt(devSquaresSum / samples);
boolean writeCommand = dos != null;
@@ -255,4 +254,8 @@ public abstract class Sampler {
samplesStream = null;
}
}
+
+ boolean isDispatchThread() {
+ return false;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists