private boolean confirmed = false;
@Override
public void run() {
if (context.getServiceReference(PersistenceProvider.class.getName()) == null) {
WindowManager windowManager = getWindowManager();
Map<String, Object> hints = new HashMap<String, Object>();
if (!confirmed) {
logger.warn("unable to obtain persistence provider");
hints.put(WindowManagerImpl.OPTION_TYPE, OptionBox.YES_NO_OPTION);
String[] options = {
BUNDLE.getString("persistence_warning_ok"),
BUNDLE.getString("persistence_warning_cancel")
};
String result = windowManager.showInputDialog(
BUNDLE.getString("persistence_warning_title"),
BUNDLE.getString("persistence_warning_message"),
options,
options[0],
hints);
if (result.equals(options[1])) {
System.exit(0);
} else {
confirmed = true;
}
} else {
logger.error("unable to obtain persistence provider");
hints.put(WindowManagerImpl.OPTION_TYPE, OptionBox.YES_OPTION);
String[] options = {
BUNDLE.getString("persistence_error_ok"),
};
windowManager.showInputDialog(
BUNDLE.getString("persistence_error_title"),
BUNDLE.getString("persistence_error_message"),
options,
options[0],
hints);
System.exit(0);
}
}
}
private WindowManager getWindowManager() {
// Try to use the Platform's version, in case something other
// than WindowManagerImpl has been injected somewhere.
Platform platform = PlatformAccess.getPlatform();
if (platform != null) {
WindowManager windowManager = platform.getWindowManager();
if (windowManager != null) {
return windowManager;
}
}
// Otherwise, fall back to this bundle's version.