Added TIMEOUT property to adjust how long to wait for the event

dispatch queue to complete.
This commit is contained in:
nathan 2016-04-05 14:19:13 +02:00
parent 6fdbe8ac83
commit 62740a0d5a
2 changed files with 60 additions and 16 deletions

View File

@ -53,6 +53,10 @@ GnomeShellExtension.SHELL_RESTART_COMMAND (type String, default value 'gnome-s
- Command to restart the gnome-shell. It is recommended to start it in the background (hence '&')
SystemTray.TIMEOUT (type int, default value '2')
- How long to wait when updating menu entries before the request times-out
SystemTray.TRAY_SIZE (type int, default value '22')
- Size of the tray, so that the icon can properly scale based on OS. (if it's not exact)
@ -147,7 +151,7 @@ This project is **kept in sync** with the utilities library, so "jar hell" is no
<dependency>
<groupId>com.dorkbox</groupId>
<artifactId>SystemTray</artifactId>
<version>2.14</version>
<version>2.15</version>
</dependency>
```

View File

@ -54,6 +54,10 @@ public abstract
class SystemTray {
protected static final Logger logger = LoggerFactory.getLogger(SystemTray.class);
@Property
/** How long to wait when updating menu entries before the request times-out */
public static final int TIMEOUT = 2;
@Property
/** Size of the tray, so that the icon can properly scale based on OS. (if it's not exact) */
public static int TRAY_SIZE = 22;
@ -255,10 +259,6 @@ class SystemTray {
//noinspection unused
final AppIndicator instance = AppIndicator.INSTANCE;
trayType = AppIndicatorTray.class;
if (AppIndicator.IS_VERSION_3) {
}
} catch (Throwable e) {
logger.error("AppIndicator support detected, but unable to load the library. Falling back to GTK");
e.printStackTrace();
@ -267,7 +267,10 @@ class SystemTray {
}
} finally {
if (bin != null) {
bin.close();
try {
bin.close();
} catch (Exception ignored) {
}
bin = null;
}
}
@ -411,7 +414,7 @@ class SystemTray {
*/
public static
String getVersion() {
return "2.14";
return "2.15";
}
/**
@ -531,6 +534,7 @@ class SystemTray {
@Deprecated
public
void setIcon(InputStream imageStream) {
@SuppressWarnings("deprecation")
final String fullPath = ImageUtil.iconPathNoCache(imageStream);
setIcon_(fullPath);
}
@ -625,7 +629,11 @@ class SystemTray {
});
try {
final boolean await = countDownLatch.await(2, TimeUnit.SECONDS);
if (!countDownLatch.await(TIMEOUT, TimeUnit.SECONDS)) {
throw new RuntimeException("Event dispatch queue took longer than " + TIMEOUT + " seconds to complete. Please adjust " +
"`SystemTray.TIMEOUT` to a value which better suites your environment.");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
@ -666,7 +674,11 @@ class SystemTray {
});
try {
final boolean await = countDownLatch.await(2, TimeUnit.SECONDS);
if (!countDownLatch.await(TIMEOUT, TimeUnit.SECONDS)) {
throw new RuntimeException("Event dispatch queue took longer than " + TIMEOUT + " seconds to complete. Please adjust " +
"`SystemTray.TIMEOUT` to a value which better suites your environment.");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
@ -708,7 +720,11 @@ class SystemTray {
});
try {
final boolean await = countDownLatch.await(2, TimeUnit.SECONDS);
if (!countDownLatch.await(TIMEOUT, TimeUnit.SECONDS)) {
throw new RuntimeException("Event dispatch queue took longer than " + TIMEOUT + " seconds to complete. Please adjust " +
"`SystemTray.TIMEOUT` to a value which better suites your environment.");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
@ -749,7 +765,11 @@ class SystemTray {
});
try {
final boolean await = countDownLatch.await(2, TimeUnit.SECONDS);
if (!countDownLatch.await(TIMEOUT, TimeUnit.SECONDS)) {
throw new RuntimeException("Event dispatch queue took longer than " + TIMEOUT + " seconds to complete. Please adjust " +
"`SystemTray.TIMEOUT` to a value which better suites your environment.");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
@ -794,7 +814,11 @@ class SystemTray {
});
try {
final boolean await = countDownLatch.await(2, TimeUnit.SECONDS);
if (!countDownLatch.await(TIMEOUT, TimeUnit.SECONDS)) {
throw new RuntimeException("Event dispatch queue took longer than " + TIMEOUT + " seconds to complete. Please adjust " +
"`SystemTray.TIMEOUT` to a value which better suites your environment.");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
@ -835,7 +859,11 @@ class SystemTray {
});
try {
final boolean await = countDownLatch.await(2, TimeUnit.SECONDS);
if (!countDownLatch.await(TIMEOUT, TimeUnit.SECONDS)) {
throw new RuntimeException("Event dispatch queue took longer than " + TIMEOUT + " seconds to complete. Please adjust " +
"`SystemTray.TIMEOUT` to a value which better suites your environment.");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
@ -879,7 +907,11 @@ class SystemTray {
});
try {
final boolean await = countDownLatch.await(2, TimeUnit.SECONDS);
if (!countDownLatch.await(TIMEOUT, TimeUnit.SECONDS)) {
throw new RuntimeException("Event dispatch queue took longer than " + TIMEOUT + " seconds to complete. Please adjust " +
"`SystemTray.TIMEOUT` to a value which better suites your environment.");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
@ -931,7 +963,11 @@ class SystemTray {
});
try {
final boolean await = countDownLatch.await(2, TimeUnit.SECONDS);
if (!countDownLatch.await(TIMEOUT, TimeUnit.SECONDS)) {
throw new RuntimeException("Event dispatch queue took longer than " + TIMEOUT + " seconds to complete. Please adjust " +
"`SystemTray.TIMEOUT` to a value which better suites your environment.");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
@ -978,7 +1014,11 @@ class SystemTray {
});
try {
final boolean await = countDownLatch.await(2, TimeUnit.SECONDS);
if (!countDownLatch.await(TIMEOUT, TimeUnit.SECONDS)) {
throw new RuntimeException("Event dispatch queue took longer than " + TIMEOUT + " seconds to complete. Please adjust " +
"`SystemTray.TIMEOUT` to a value which better suites your environment.");
}
} catch (InterruptedException e) {
e.printStackTrace();
}