Java 类com.intellij.openapi.application.RuntimeInterruptedException 实例源码

项目:eddy    文件:EddyPlugin.java   
private static void checkLogging() {
  // if no logging preference saved, make the user select one
  final PropertiesComponent props = PropertiesComponent.getInstance();
  final String name = "com.eddysystems.Props.checkedLogging";
  String checked = props.getValue(name);

  log("logging state: " + checked);

  if (checked == null || !checked.equals("true")) {

    // we haven't checked before, check now and save to Preferences
    final Object done = new Object();
    final Runnable showRunner = new Runnable() {
        @Override
        public void run() {
          final TOSDialog d = new TOSDialog();
          d.showAndGet();
          Preferences.getData().setLogPreference(d.logging());
          Preferences.save();
          synchronized (done) {
            done.notifyAll();
          }
        }
    };

    // go to dispatch to show dialog
    if (!ApplicationManager.getApplication().isDispatchThread()) {
      // we have to wait manually, because getting the current modality isn't a thing that 13 lets us do outside of
      // dispatch
      ApplicationManager.getApplication().invokeLater(showRunner);
      try {
        synchronized (done) {
          done.wait();
        }
      } catch (InterruptedException e) {
        throw new RuntimeInterruptedException(e);
      }
    } else {
      showRunner.run();
    }
    props.setValue(name, "true");
  }
}