private @NotNull MyDialog createDialog(@NotNull Window owner) throws GlasspanePeerUnavailableException {
    Window active = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
    if (active instanceof JDialog || !(owner instanceof IdeFrame)) {
      throw new GlasspanePeerUnavailableException();
    }

    Component glassPane;
    // Not all successor of IdeFrame are frames
    if (owner instanceof JFrame) {
      glassPane = ((JFrame)owner).getGlassPane();
    }
    else if (owner instanceof JDialog) {
      glassPane = ((JDialog)owner).getGlassPane();
    }
    else {
      throw new IllegalStateException("Cannot find glass pane for " + owner.getClass().getName());
    }

    assert glassPane instanceof IdeGlassPaneEx : "GlassPane should be instance of IdeGlassPane!";
    return new MyDialog((IdeGlassPaneEx)glassPane, myWrapper);
  }
private @NotNull MyDialog createDialog(@NotNull Window owner)