use of com.intellij.openapi.ui.popup.JBPopup in project android by JetBrains.
the class AndroidAddLibraryDependencyAction method invoke.
@Override
public void invoke(@NotNull final Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
final GradleBuildModel buildModel = getGradleBuildModel(project, file);
if (buildModel == null) {
return;
}
ImmutableCollection<String> dependencies = findAllDependencies(buildModel);
if (dependencies.isEmpty()) {
return;
}
final JList list = new JBList(dependencies);
JBPopup popup = new PopupChooserBuilder(list).setItemChoosenCallback(new Runnable() {
@Override
public void run() {
for (Object selectedValue : list.getSelectedValues()) {
if (selectedValue == null) {
return;
}
addDependency(project, buildModel, (String) selectedValue);
}
}
}).createPopup();
popup.showInBestPositionFor(editor);
}
use of com.intellij.openapi.ui.popup.JBPopup in project android by JetBrains.
the class ShowCustomIssueExplanationFix method apply.
@Override
public void apply(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull AndroidQuickfixContexts.Context context) {
Project project = myElement.getProject();
DocumentationManager manager = DocumentationManager.getInstance(project);
DocumentationComponent component = new DocumentationComponent(manager);
component.setText("<html>" + myIssue.getExplanation(TextFormat.HTML) + "</html>", myElement, false);
JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(component, component).setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false).setResizable(true).setMovable(true).setRequestFocus(true).createPopup();
component.setHint(popup);
if (context.getType() == AndroidQuickfixContexts.EditorContext.TYPE) {
popup.showInBestPositionFor(((AndroidQuickfixContexts.EditorContext) context).getEditor());
} else {
popup.showCenteredInCurrentWindow(project);
}
Disposer.dispose(component);
}
use of com.intellij.openapi.ui.popup.JBPopup in project android by JetBrains.
the class ShowJavadocAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
EditedStyleItem item = myCurrentItem;
if (item == null) {
return;
}
Project project = myContext.getProject();
DocumentationManager documentationManager = DocumentationManager.getInstance(project);
final DocumentationComponent docComponent = new DocumentationComponent(documentationManager);
String tooltip = ThemeEditorUtils.generateToolTipText(item.getSelectedValue(), myContext.getCurrentContextModule(), myContext.getConfiguration());
// images will not work unless we pass a valid PsiElement {@link DocumentationComponent#myImageProvider}
docComponent.setText(tooltip, new FakePsiElement() {
@Override
public boolean isValid() {
// this needs to return true for the DocumentationComponent to accept this PsiElement {@link DocumentationComponent#setData(PsiElement, String, boolean, String, String)}
return true;
}
@NotNull
@Override
public Project getProject() {
// superclass implementation throws an exception
return myContext.getProject();
}
@Override
public PsiElement getParent() {
return null;
}
@Override
public PsiFile getContainingFile() {
// superclass implementation throws an exception
return null;
}
}, true);
JBPopup hint = JBPopupFactory.getInstance().createComponentPopupBuilder(docComponent, docComponent).setProject(project).setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false).setResizable(true).setMovable(true).setRequestFocus(true).setTitle(item.getName()).setCancelCallback(new Computable<Boolean>() {
@Override
public Boolean compute() {
Disposer.dispose(docComponent);
return Boolean.TRUE;
}
}).createPopup();
docComponent.setHint(hint);
Disposer.register(hint, docComponent);
hint.show(new RelativePoint(myAttributesTable.getParent(), ORIGIN));
}
use of com.intellij.openapi.ui.popup.JBPopup in project intellij-plugins by JetBrains.
the class DependenciesConfigurable method addItem.
private void addItem(AnActionButton button) {
initPopupActions();
final JBPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<AddItemPopupAction>(FlexBundle.message("add.dependency.popup.title"), myPopupActions) {
@Override
public Icon getIconFor(AddItemPopupAction aValue) {
return aValue.getIcon();
}
@Override
public boolean hasSubstep(AddItemPopupAction selectedValue) {
return selectedValue.hasSubStep();
}
public boolean isMnemonicsNavigationEnabled() {
return true;
}
public PopupStep onChosen(final AddItemPopupAction selectedValue, final boolean finalChoice) {
if (selectedValue.hasSubStep()) {
return selectedValue.createSubStep();
}
return doFinalStep(() -> selectedValue.run());
}
@NotNull
public String getTextFor(AddItemPopupAction value) {
return "&" + value.getIndex() + " " + value.getTitle();
}
});
popup.show(button.getPreferredPopupPoint());
}
use of com.intellij.openapi.ui.popup.JBPopup in project intellij-community by JetBrains.
the class CompareWithSelectedRevisionAction method showListPopup.
public static void showListPopup(final List<VcsFileRevision> revisions, final Project project, final Consumer<VcsFileRevision> selectedRevisionConsumer, final boolean showComments) {
ColumnInfo[] columns = new ColumnInfo[] { REVISION_TABLE_COLUMN, DATE_TABLE_COLUMN, AUTHOR_TABLE_COLUMN };
for (VcsFileRevision revision : revisions) {
if (revision.getBranchName() != null) {
columns = new ColumnInfo[] { REVISION_TABLE_COLUMN, BRANCH_TABLE_COLUMN, DATE_TABLE_COLUMN, AUTHOR_TABLE_COLUMN };
break;
}
}
final TableView<VcsFileRevision> table = new TableView<>(new ListTableModel<>(columns, revisions, 0));
table.setShowHorizontalLines(false);
table.setTableHeader(null);
Runnable runnable = new Runnable() {
@Override
public void run() {
VcsFileRevision revision = table.getSelectedObject();
if (revision != null) {
selectedRevisionConsumer.consume(revision);
}
}
};
if (table.getModel().getRowCount() == 0) {
table.clearSelection();
}
new SpeedSearchBase<TableView>(table) {
@Override
protected int getSelectedIndex() {
return table.getSelectedRow();
}
@Override
protected int convertIndexToModel(int viewIndex) {
return table.convertRowIndexToModel(viewIndex);
}
@Override
protected Object[] getAllElements() {
return revisions.toArray();
}
@Override
protected String getElementText(Object element) {
VcsFileRevision revision = (VcsFileRevision) element;
return revision.getRevisionNumber().asString() + " " + revision.getBranchName() + " " + revision.getAuthor();
}
@Override
protected void selectElement(Object element, String selectedText) {
VcsFileRevision revision = (VcsFileRevision) element;
TableUtil.selectRows(myComponent, new int[] { myComponent.convertRowIndexToView(revisions.indexOf(revision)) });
TableUtil.scrollSelectionToVisible(myComponent);
}
};
table.setMinimumSize(new Dimension(300, 50));
final PopupChooserBuilder builder = new PopupChooserBuilder(table);
if (showComments) {
builder.setSouthComponent(createCommentsPanel(table));
}
builder.setTitle(VcsBundle.message("lookup.title.vcs.file.revisions")).setItemChoosenCallback(runnable).setResizable(true).setDimensionServiceKey("Vcs.CompareWithSelectedRevision.Popup").setMinSize(new Dimension(300, 300));
final JBPopup popup = builder.createPopup();
popup.showCenteredInCurrentWindow(project);
}
Aggregations