Java 类com.intellij.openapi.ui.popup.JBPopupListener 实例源码

项目:intellij-ce-playground    文件:ChooseByNameFilter.java   
/**
 * Create and show popup
 */
private void createPopup() {
  if (myPopup != null) {
    return;
  }
  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(myChooserPanel, myChooser).setModalContext(false).setFocusable(false)
      .setResizable(true).setCancelOnClickOutside(false).setMinSize(new Dimension(200, 200))
      .setDimensionServiceKey(myProject, "GotoFile_FileTypePopup", false).createPopup();
  myPopup.addListener(new JBPopupListener.Adapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      myPopup = null;
    }
  });
  myPopup.showUnderneathOf(myToolbar.getComponent());
}
项目:tools-idea    文件:ChooseByNameFilter.java   
/**
 * Create and show popup
 */
private void createPopup() {
  if (myPopup != null) {
    return;
  }
  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(myChooserPanel, myChooser).setModalContext(false).setFocusable(false)
      .setResizable(true).setCancelOnClickOutside(false).setMinSize(new Dimension(200, 200))
      .setDimensionServiceKey(myProject, "GotoFile_FileTypePopup", false).createPopup();
  myPopup.addListener(new JBPopupListener.Adapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      myPopup = null;
    }
  });
  myPopup.showUnderneathOf(myToolbar.getComponent());
}
项目:consulo    文件:ChooseByNameFilter.java   
/**
 * Create and show popup
 */
private void createPopup() {
  if (myPopup != null) {
    return;
  }
  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(myChooserPanel, myChooser).setModalContext(false).setFocusable(false)
          .setResizable(true).setCancelOnClickOutside(false).setMinSize(new Dimension(200, 200))
          .setDimensionServiceKey(myProject, "GotoFile_FileTypePopup", false).createPopup();
  myPopup.addListener(new JBPopupListener.Adapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      myPopup = null;
    }
  });
  myPopup.showUnderneathOf(myToolbar.getComponent());
}
项目:intellij-ce-playground    文件:BalloonImpl.java   
private void hideAndDispose(final boolean ok) {
  if (myDisposed) return;
  myDisposed = true;
  hideComboBoxPopups();

  final Runnable disposeRunnable = new Runnable() {
    @Override
    public void run() {
      myFadedOut = true;

      for (JBPopupListener each : myListeners) {
        each.onClosed(new LightweightWindowEvent(BalloonImpl.this, ok));
      }

      Disposer.dispose(BalloonImpl.this);
      onDisposed();
    }
  };

  Toolkit.getDefaultToolkit().removeAWTEventListener(myAwtActivityListener);
  if (myLayeredPane != null) {
    myLayeredPane.removeComponentListener(myComponentListener);
    Disposer.register(ApplicationManager.getApplication(), this); // to be safe if Application suddenly exits and animation wouldn't have a chance to complete

    runAnimation(false, myLayeredPane, new Runnable() {
      @Override
      public void run() {
        disposeRunnable.run();
      }
    });
  }
  else {
    disposeRunnable.run();
  }

  myVisible = false;
  myTracker = null;
}
项目:tools-idea    文件:BalloonImpl.java   
private void hideAndDispose(final boolean ok) {
  if (myDisposed) return;

  myDisposed = true;


  final Runnable disposeRunnable = new Runnable() {
    public void run() {
      myFadedOut = true;

      for (JBPopupListener each : myListeners) {
        each.onClosed(new LightweightWindowEvent(BalloonImpl.this, ok));
      }

      Disposer.dispose(BalloonImpl.this);
      onDisposed();
    }
  };

  Toolkit.getDefaultToolkit().removeAWTEventListener(myAwtActivityListener);
  if (myLayeredPane != null) {
    myLayeredPane.removeComponentListener(myComponentListener);
    runAnimation(false, myLayeredPane, new Runnable() {
      @Override
      public void run() {
        disposeRunnable.run();
      }
    });
  } else {
    disposeRunnable.run();
  }

  myVisible = false;
  myTracker = null;
}
项目:intellij-ce-playground    文件:FindPopupWithProgress.java   
public FindPopupWithProgress(@NotNull final Project project,
                             @NotNull Collection<String> variants,
                             @NotNull Function<String, Future> function) {
  myFunction = function;
  myTextField = new TextFieldWithProgress(project, variants) {
    @Override
    public void onOk() {
      if (myFuture == null) {
        final Future future = myFunction.fun(getText().trim());
        myFuture = future;
        showProgress();
        ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
          @Override
          public void run() {
            try {
              future.get();
              okPopup();
            }
            catch (CancellationException ex) {
              cancelPopup();
            }
            catch (InterruptedException ex) {
              cancelPopup();
            }
            catch (ExecutionException ex) {
              LOG.error(ex);
              cancelPopup();
            }
          }
        });
      }
    }
  };

  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(myTextField, myTextField.getPreferableFocusComponent())
    .setCancelOnClickOutside(true).setCancelOnWindowDeactivation(true).setCancelKeyEnabled(true).setRequestFocus(true).createPopup();
  myPopup.addListener(new JBPopupListener.Adapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (!event.isOk()) {
        if (myFuture != null) {
          myFuture.cancel(true);
        }
      }
      myFuture = null;
      myTextField.hideProgress();
    }
  });

  final JBTextField field = new JBTextField(20);
  final Dimension size = field.getPreferredSize();
  final Insets insets = myTextField.getBorder().getBorderInsets(myTextField);
  size.height += 6 + insets.top + insets.bottom;
  size.width += 4 + insets.left + insets.right;
  myPopup.setSize(size);
}
项目:intellij-ce-playground    文件:BalloonImpl.java   
@Override
public void addListener(@NotNull JBPopupListener listener) {
  myListeners.add(listener);
}
项目:intellij-ce-playground    文件:NotificationPopup.java   
public void addListener(JBPopupListener listener) {
}
项目:intellij-ce-playground    文件:SuggestionList.java   
/**
 * @param listener popup listener (will be called back when popup closed)
 */
public SuggestionList(@SuppressWarnings("NullableProblems") @NotNull final JBPopupListener listener) {
  myListener = listener;
}
项目:tools-idea    文件:BalloonImpl.java   
public void addListener(JBPopupListener listener) {
  myListeners.add(listener);
}
项目:tools-idea    文件:NotificationPopup.java   
public void addListener(JBPopupListener listener) {
}
项目:consulo    文件:GoToHashOrRefPopup.java   
public GoToHashOrRefPopup(@Nonnull final Project project,
                          @Nonnull VcsLogRefs variants,
                          Collection<VirtualFile> roots,
                          @Nonnull Function<String, Future> onSelectedHash,
                          @Nonnull Function<VcsRef, Future> onSelectedRef,
                          @Nonnull VcsLogColorManager colorManager,
                          @Nonnull Comparator<VcsRef> comparator) {
  myOnSelectedHash = onSelectedHash;
  myOnSelectedRef = onSelectedRef;
  myTextField =
    new TextFieldWithProgress(project, new VcsRefCompletionProvider(project, variants, roots, colorManager, comparator)) {
      @Override
      public void onOk() {
        if (myFuture == null) {
          final Future future = ((mySelectedRef == null || (!mySelectedRef.getName().equals(getText().trim())))
                                 ? myOnSelectedHash.fun(getText().trim())
                                 : myOnSelectedRef.fun(mySelectedRef));
          myFuture = future;
          showProgress();
          ApplicationManager.getApplication().executeOnPooledThread(() -> {
            try {
              future.get();
              okPopup();
            }
            catch (CancellationException ex) {
              cancelPopup();
            }
            catch (InterruptedException ex) {
              cancelPopup();
            }
            catch (ExecutionException ex) {
              LOG.error(ex);
              cancelPopup();
            }
          });
        }
      }
    };
  myTextField.setAlignmentX(Component.LEFT_ALIGNMENT);

  JBLabel label = new JBLabel("Enter hash or branch/tag name:");
  label.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
  label.setAlignmentX(Component.LEFT_ALIGNMENT);

  JPanel panel = new JPanel();
  BoxLayout layout = new BoxLayout(panel, BoxLayout.PAGE_AXIS);
  panel.setLayout(layout);
  panel.add(label);
  panel.add(myTextField);
  panel.setBorder(new EmptyBorder(2, 2, 2, 2));

  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, myTextField.getPreferableFocusComponent())
    .setCancelOnClickOutside(true).setCancelOnWindowDeactivation(true).setCancelKeyEnabled(true).setRequestFocus(true).createPopup();
  myPopup.addListener(new JBPopupListener.Adapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (!event.isOk()) {
        if (myFuture != null) {
          myFuture.cancel(true);
        }
      }
      myFuture = null;
      myTextField.hideProgress();
    }
  });
}
项目:consulo    文件:BalloonImpl.java   
private void hideAndDispose(final boolean ok) {
  if (myDisposed) return;

  if (mySmartFadeoutPaused) {
    mySmartFadeoutPaused = false;
    return;
  }

  if (myTraceDispose) {
    Logger.getInstance("#com.intellij.ui.BalloonImpl").error("Dispose balloon before showing", new Throwable());
  }

  myDisposed = true;
  hideComboBoxPopups();

  final Runnable disposeRunnable = () -> {
    myFadedOut = true;
    if (myRequestFocus) {
      if (myOriginalFocusOwner != null) {
        myFocusManager.requestFocus(myOriginalFocusOwner, false);
      }
    }

    for (JBPopupListener each : myListeners) {
      each.onClosed(new LightweightWindowEvent(this, ok));
    }

    Disposer.dispose(this);
    onDisposed();
  };

  Toolkit.getDefaultToolkit().removeAWTEventListener(myAwtActivityListener);
  if (myLayeredPane != null) {
    myLayeredPane.removeComponentListener(myComponentListener);

    runAnimation(false, myLayeredPane, disposeRunnable);
  }
  else {
    disposeRunnable.run();
  }

  myVisible = false;
  myTracker = null;
}
项目:consulo    文件:BalloonImpl.java   
@Override
public void addListener(@Nonnull JBPopupListener listener) {
  myListeners.add(listener);
}
项目:consulo    文件:NotificationPopup.java   
public void addListener(JBPopupListener listener) {
}
项目:intellij-ce-playground    文件:NotificationPopup.java   
void addListener(JBPopupListener listener);
项目:tools-idea    文件:NotificationPopup.java   
void addListener(JBPopupListener listener);
项目:consulo    文件:NotificationPopup.java   
void addListener(JBPopupListener listener);