Example usage for com.intellij.openapi.ui.popup ComponentPopupBuilder setTitle

List of usage examples for com.intellij.openapi.ui.popup ComponentPopupBuilder setTitle

Introduction

In this page you can find the example usage for com.intellij.openapi.ui.popup ComponentPopupBuilder setTitle.

Prototype

@NotNull
    ComponentPopupBuilder setTitle(String title);

Source Link

Usage

From source file:com.intellij.ide.bookmarks.actions.ToggleBookmarkWithMnemonicAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent e) {
    super.actionPerformed(e);

    DataContext dataContext = e.getDataContext();
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null)
        return;//from w  ww.j  a  va  2  s.c  o m
    final BookmarkInContextInfo info = new BookmarkInContextInfo(dataContext, project).invoke();
    final Bookmark bookmark = info.getBookmarkAtPlace();
    final BookmarkManager bookmarks = BookmarkManager.getInstance(project);
    if (bookmark != null) {
        final JBPopup[] popup = new JBPopup[1];
        MnemonicChooser mc = new MnemonicChooser() {
            @Override
            protected void onMnemonicChosen(char c) {
                popup[0].cancel();
                bookmarks.setMnemonic(bookmark, c);
            }

            @Override
            protected void onCancelled() {
                popup[0].cancel();
                bookmarks.removeBookmark(bookmark);
            }

            @Override
            protected boolean isOccupied(char c) {
                return bookmarks.findBookmarkForMnemonic(c) != null;
            }
        };

        final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(mc, mc);
        popup[0] = builder.setTitle("Bookmark Mnemonic").setFocusable(true).setRequestFocus(true)
                .setMovable(false).setCancelKeyEnabled(false)
                .setAdText(bookmarks.hasBookmarksWithMnemonics()
                        ? (UIUtil.isUnderDarcula() ? "Brown" : "Yellow") + " cells are in use"
                        : null)
                .setResizable(false).createPopup();

        popup[0].showInBestPositionFor(dataContext);
    }
}

From source file:com.urswolfer.intellij.plugin.gerrit.ui.diff.CommentBalloonBuilder.java

License:Apache License

public JBPopup getNewCommentBalloon(final CommentForm balloonContent, @NotNull final String title) {
    final ComponentPopupBuilder builder = jbPopupFactory.createComponentPopupBuilder(balloonContent,
            balloonContent);//from ww  w . jav  a 2  s .  c  o m
    builder.setAdText("Hit Ctrl+Enter to create comment. It will be published once you post your review.");
    builder.setTitle(title);
    builder.setResizable(true);
    builder.setMovable(true);
    builder.setRequestFocus(true);
    builder.setCancelOnClickOutside(false);
    builder.setCancelOnWindowDeactivation(false);
    return builder.createPopup();
}