/hg/icedtea-web: PolicyEditor EDT Runnables invoked immediately ...
aazores at icedtea.classpath.org
aazores at icedtea.classpath.org
Mon Jun 30 15:34:23 UTC 2014
changeset b18d50d9e32e in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=b18d50d9e32e
author: Andrew Azores <aazores at redhat.com>
date: Mon Jun 30 11:34:15 2014 -0400
PolicyEditor EDT Runnables invoked immediately if the current thread is EDT
2014-06-30 Andrew Azores <aazores at redhat.com>
Runnables to be invoked on the EDT are invoked immediately if the current
thread is already the EDT, rather than being queued for invocation later.
invokeRunnableOrEnqueueLater replaces SwingUtilities.invokeLater to
achieve this.
* netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
(updateCheckboxes): uses invokeRunnableOrEnqueueAndWait
(updateCheckboxesInvokeAndWait): removed
(invokeRunnableOrEnqueueAndWait, invokeRunnableOrEnqueueLater): new
methods
diffstat:
ChangeLog | 12 ++
netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java | 53 +++++----
2 files changed, 42 insertions(+), 23 deletions(-)
diffs (151 lines):
diff -r 1c5922c7b7b0 -r b18d50d9e32e ChangeLog
--- a/ChangeLog Thu Jun 26 17:22:11 2014 +0200
+++ b/ChangeLog Mon Jun 30 11:34:15 2014 -0400
@@ -1,3 +1,15 @@
+2014-06-30 Andrew Azores <aazores at redhat.com>
+
+ Runnables to be invoked on the EDT are invoked immediately if the current
+ thread is already the EDT, rather than being queued for invocation later.
+ invokeRunnableOrEnqueueLater replaces SwingUtilities.invokeLater to
+ achieve this.
+ * netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
+ (updateCheckboxes): uses invokeRunnableOrEnqueueAndWait
+ (updateCheckboxesInvokeAndWait): removed
+ (invokeRunnableOrEnqueueAndWait, invokeRunnableOrEnqueueLater): new
+ methods
+
2014-06-26 Jacob Wisor <gitne at gmx.de>
* netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPane.java: Formatting
diff -r 1c5922c7b7b0 -r b18d50d9e32e netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java
--- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java Thu Jun 26 17:22:11 2014 +0200
+++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java Mon Jun 30 11:34:15 2014 -0400
@@ -377,7 +377,7 @@
viewCustomButtonAction = new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
- SwingUtilities.invokeLater(new Runnable() {
+ invokeRunnableOrEnqueueLater(new Runnable() {
@Override
public void run() {
String codebase = getSelectedCodebase();
@@ -732,7 +732,7 @@
model = codebase;
}
policyEditorController.addCodebase(codebase);
- SwingUtilities.invokeLater(new Runnable() {
+ invokeRunnableOrEnqueueLater(new Runnable() {
@Override
public void run() {
if (!listModel.contains(model)) {
@@ -761,7 +761,7 @@
* policy file model.
*/
public void addNewCodebaseInteractive() {
- SwingUtilities.invokeLater(new Runnable() {
+ invokeRunnableOrEnqueueLater(new Runnable() {
@Override
public void run() {
String codebase = "";
@@ -790,7 +790,7 @@
}
policyEditorController.removeCodebase(codebase);
final int fIndex = previousIndex;
- SwingUtilities.invokeLater(new Runnable() {
+ invokeRunnableOrEnqueueLater(new Runnable() {
@Override
public void run() {
listModel.removeElement(codebase);
@@ -876,17 +876,34 @@
policyEditorController.clearCustomCodebase(codebase);
}
+ private void invokeRunnableOrEnqueueLater(final Runnable runnable) {
+ if (SwingUtilities.isEventDispatchThread()) {
+ runnable.run();
+ } else {
+ SwingUtilities.invokeLater(runnable);
+ }
+ }
+
+ private void invokeRunnableOrEnqueueAndWait(final Runnable runnable) throws InvocationTargetException, InterruptedException {
+ if (SwingUtilities.isEventDispatchThread()) {
+ runnable.run();
+ } else {
+ SwingUtilities.invokeAndWait(runnable);
+ }
+ }
+
/**
* Update the checkboxes to show the permissions granted to the specified codebase
* @param codebase whose permissions to display
*/
private void updateCheckboxes(final String codebase) {
try {
- if (SwingUtilities.isEventDispatchThread()) {
- updateCheckboxesImpl(codebase);
- } else {
- updateCheckboxesInvokeAndWait(codebase);
- }
+ invokeRunnableOrEnqueueAndWait(new Runnable() {
+ @Override
+ public void run() {
+ updateCheckboxesImpl(codebase);
+ }
+ });
} catch (InterruptedException ex) {
OutputController.getLogger().log(ex);
} catch (InvocationTargetException ex) {
@@ -894,16 +911,6 @@
}
}
- private void updateCheckboxesInvokeAndWait(final String codebase) throws InterruptedException, InvocationTargetException {
- SwingUtilities.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- updateCheckboxesImpl(codebase);
- }
- });
-
- }
-
private void updateCheckboxesImpl(final String codebase) {
for (final PolicyEditorPermissions perm : PolicyEditorPermissions.values()) {
final JCheckBox box = checkboxMap.get(perm);
@@ -1233,7 +1240,7 @@
protected Void doInBackground() throws Exception {
try {
if (parentWindow != null) {
- SwingUtilities.invokeLater(new Runnable() {
+ invokeRunnableOrEnqueueLater(new Runnable() {
@Override
public void run() {
progressIndicator.setLocationRelativeTo(parentWindow);
@@ -1298,7 +1305,7 @@
public Void doInBackground() throws Exception {
try {
if (parentWindow != null) {
- SwingUtilities.invokeLater(new Runnable() {
+ invokeRunnableOrEnqueueLater(new Runnable() {
@Override
public void run() {
progressIndicator.setLocationRelativeTo(parentWindow);
@@ -1331,7 +1338,7 @@
// This dialog is often displayed when closing the editor, and so PolicyEditor
// may already be disposed when this dialog appears. Give a weak reference so
// that this dialog doesn't prevent the JVM from exiting
- SwingUtilities.invokeLater(new Runnable() {
+ invokeRunnableOrEnqueueLater(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(parentPolicyEditor.get(), R("PEChangesSaved"));
@@ -1346,7 +1353,7 @@
// This dialog is often displayed when closing the editor, and so PolicyEditor
// may already be disposed when this dialog appears. Give a weak reference so
// that this dialog doesn't prevent the JVM from exiting
- SwingUtilities.invokeLater(new Runnable() {
+ invokeRunnableOrEnqueueLater(new Runnable() {
@Override
public void run() {
JOptionPane.showMessageDialog(parentPolicyEditor.get(), R("PECouldNotSave"), R("Error"), JOptionPane.ERROR_MESSAGE);
More information about the distro-pkg-dev
mailing list