List of usage examples for com.intellij.openapi.ui.popup JBPopup show
void show(@NotNull Component owner);
From source file:com.android.tools.idea.editors.hprof.views.ViewBitmapAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { ClassInstance selectedClassInstance = e.getData(InstancesTreeView.SELECTED_CLASS_INSTANCE); if (selectedClassInstance == null) { return;/*from w w w . java 2 s. c o m*/ } try { BufferedImage img = BitmapDecoder.getBitmap(new HprofBitmapProvider(selectedClassInstance)); final JComponent comp; if (img != null) { comp = ImageEditorManagerImpl.createImageEditorUI(img); } else { String errorMessage = AndroidBundle.message("android.profiler.hprof.actions.view.bitmap.fail"); comp = new JLabel(errorMessage, Messages.getErrorIcon(), SwingConstants.CENTER); } Project project = e.getData(CommonDataKeys.PROJECT); JBPopup popup = DebuggerUIUtil.createValuePopup(project, comp, null); JFrame frame = WindowManager.getInstance().getFrame(project); Dimension frameSize = frame.getSize(); Dimension size = new Dimension(frameSize.width / 2, frameSize.height / 2); popup.setSize(size); popup.show(new RelativePoint(frame, new Point(size.width / 2, size.height / 2))); } catch (Exception ignored) { } }
From source file:com.android.tools.idea.editors.theme.attributes.ShowJavadocAction.java
License:Apache License
@Override public void actionPerformed(ActionEvent e) { EditedStyleItem item = myCurrentItem; if (item == null) { return;//from ww w . j a va2 s . c om } 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)); }
From source file:com.android.tools.idea.gradle.structure.configurables.ui.dependencies.AbstractDependenciesPanel.java
License:Apache License
@NotNull protected final JPanel createActionsPanel() { JPanel actionsPanel = new JPanel(new BorderLayout()); DefaultActionGroup actions = new DefaultActionGroup(); AnAction addDependencyAction = new DumbAwareAction("Add Dependency", "", IconUtil.getAddIcon()) { @Override//from w w w . j ava 2 s.c o m public void actionPerformed(AnActionEvent e) { JBPopup popup = JBPopupFactory.getInstance() .createListPopup(new BaseListPopupStep<AbstractPopupAction>(null, getPopupActions()) { @Override public Icon getIconFor(AbstractPopupAction action) { return action.icon; } @Override public boolean isMnemonicsNavigationEnabled() { return true; } @Override public PopupStep onChosen(AbstractPopupAction action, boolean finalChoice) { return doFinalStep(action::execute); } @Override @NotNull public String getTextFor(AbstractPopupAction action) { return "&" + action.index + " " + action.text; } }); popup.show(new RelativePoint(actionsPanel, new Point(0, actionsPanel.getHeight() - 1))); } }; actions.add(addDependencyAction); List<AnAction> extraToolbarActions = getExtraToolbarActions(); if (!extraToolbarActions.isEmpty()) { actions.addSeparator(); actions.addAll(extraToolbarActions); } ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("TOP", actions, true); JComponent toolbarComponent = toolbar.getComponent(); toolbarComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM)); actionsPanel.add(toolbarComponent, BorderLayout.CENTER); return actionsPanel; }
From source file:com.android.tools.idea.gradle.structure.editors.ModuleDependenciesPanel.java
License:Apache License
@NotNull private JComponent createTableWithButtons() { myEntryTable.getSelectionModel().addListSelectionListener(e -> { if (e.getValueIsAdjusting()) { return; }/*from www. j a v a 2 s .co m*/ updateButtons(); }); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myEntryTable); decorator.setAddAction(button -> { ImmutableList<PopupAction> popupActions = ImmutableList .of(new PopupAction(AndroidIcons.MavenLogo, 1, "Library dependency") { @Override public void run() { addExternalDependency(); } }, new PopupAction(PlatformIcons.LIBRARY_ICON, 2, "Jar dependency") { @Override public void run() { addFileDependency(); } }, new PopupAction(AllIcons.Nodes.Module, 3, "Module dependency") { @Override public void run() { addModuleDependency(); } }); final JBPopup popup = JBPopupFactory.getInstance() .createListPopup(new BaseListPopupStep<PopupAction>(null, popupActions) { @Override public Icon getIconFor(PopupAction value) { return value.myIcon; } @Override public boolean hasSubstep(PopupAction value) { return false; } @Override public boolean isMnemonicsNavigationEnabled() { return true; } @Override public PopupStep onChosen(final PopupAction value, final boolean finalChoice) { return doFinalStep(value); } @Override @NotNull public String getTextFor(PopupAction value) { return "&" + value.myIndex + " " + value.myTitle; } }); popup.show(button.getPreferredPopupPoint()); }); decorator.setRemoveAction(button -> removeSelectedItems()); decorator.setMoveUpAction(button -> moveSelectedRows(-1)); decorator.setMoveDownAction(button -> moveSelectedRows(+1)); final JPanel panel = decorator.createPanel(); myRemoveButton = ToolbarDecorator.findRemoveButton(panel); return panel; }
From source file:com.android.tools.idea.run.ViewBitmapAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { final DataContext actionContext = e.getDataContext(); final DebuggerTreeNodeImpl node = getSelectedNode(actionContext); if (node == null) { return;/*from www.ja v a 2 s . c om*/ } final Value bitmapValue = getValue(node); if (bitmapValue == null) { return; } final Project project = CommonDataKeys.PROJECT.getData(actionContext); if (project == null) { return; } final DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project); if (debuggerManager == null) { return; } final DebuggerContextImpl debuggerContext = debuggerManager.getContext(); if (debuggerContext == null || debuggerContext.getDebuggerSession() == null) { return; } final ProgressWindowWithNotification progressWindow = new ProgressWindowWithNotification(true, project); final String variableName = node.getText() == null ? "Bitmap" : node.getText().toString(); DownloadBitmapCommand.CompletionCallback onComplete = new DownloadBitmapCommand.CompletionCallback() { @Override public void bitmapDownloaded(@NotNull final BufferedImage image) { DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() { @Override public void run() { JComponent imageComponent = new JComponent() { @Override protected void paintComponent(Graphics g) { g.drawImage(image, 0, 0, null); } }; JBPopup popup = JBPopupFactory.getInstance() .createComponentPopupBuilder(imageComponent, null).setProject(project) .setTitle(variableName).setResizable(true).setMovable(true).setFocusable(true) .setMinSize(new Dimension(image.getWidth(), image.getHeight())).setShowBorder(true) .createPopup(); popup.show(JBPopupFactory.getInstance().guessBestPopupLocation(actionContext)); } }); } @Override public void error(@NotNull final String message) { DebuggerInvocationUtil.swingInvokeLater(project, new Runnable() { @Override public void run() { JBPopup popup = JBPopupFactory.getInstance().createMessage(message); popup.show(JBPopupFactory.getInstance().guessBestPopupLocation(actionContext)); } }); } }; DownloadBitmapCommand downloadBitmapCommand = new DownloadBitmapCommand(bitmapValue, debuggerContext, onComplete, progressWindow); progressWindow.setTitle("Retrieving Bitmap..."); debuggerContext.getDebugProcess().getManagerThread().startProgress(downloadBitmapCommand, progressWindow); }
From source file:com.android.tools.idea.structure.gradle.ModuleDependenciesPanel.java
License:Apache License
@NotNull private JComponent createTableWithButtons() { myEntryTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override//from w ww .ja v a2s .co m public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } updateButtons(); } }); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myEntryTable); decorator.setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { ImmutableList<PopupAction> popupActions = ImmutableList .of(new PopupAction(AndroidIcons.MavenLogo, 1, "Library dependency") { @Override public void run() { addExternalDependency(); } }, new PopupAction(PlatformIcons.LIBRARY_ICON, 2, "File dependency") { @Override public void run() { addFileDependency(); } }, new PopupAction(AllIcons.Nodes.Module, 3, "Module dependency") { @Override public void run() { addModuleDependency(); } }); final JBPopup popup = JBPopupFactory.getInstance() .createListPopup(new BaseListPopupStep<PopupAction>(null, popupActions) { @Override public Icon getIconFor(PopupAction value) { return value.myIcon; } @Override public boolean hasSubstep(PopupAction value) { return false; } @Override public boolean isMnemonicsNavigationEnabled() { return true; } @Override public PopupStep onChosen(final PopupAction value, final boolean finalChoice) { return doFinalStep(new Runnable() { @Override public void run() { value.run(); } }); } @Override @NotNull public String getTextFor(PopupAction value) { return "&" + value.myIndex + " " + value.myTitle; } }); popup.show(button.getPreferredPopupPoint()); } }); decorator.setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { removeSelectedItems(); } }); decorator.setMoveUpAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { moveSelectedRows(-1); } }); decorator.setMoveDownAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { moveSelectedRows(+1); } }); final JPanel panel = decorator.createPanel(); myRemoveButton = ToolbarDecorator.findRemoveButton(panel); return panel; }
From source file:com.android.tools.idea.uibuilder.handlers.constraint.WidgetNavigatorPanel.java
License:Apache License
public static JBPopup createPopup(DesignSurface surface) { WidgetNavigatorPanel navigatorPanel = new WidgetNavigatorPanel(surface); final Dimension minSize = new Dimension(navigatorPanel.getSize()); JBPopup builder = JBPopupFactory.getInstance().createComponentPopupBuilder(navigatorPanel, navigatorPanel) .setTitle(TITLE).setMinSize(minSize).setResizable(false).setMovable(true).setRequestFocus(true) .setLocateWithinScreenBounds(true).setCancelButton(CANCEL_BUTTON).setShowBorder(true) .setShowShadow(true).setCancelOnClickOutside(false).setCancelOnWindowDeactivation(false) .setCancelOnOtherWindowOpen(true).addListener(navigatorPanel).createPopup(); final int x = surface.getWidth() - PREFERRED_SIZE.width - surface.getScrollPane().getVerticalScrollBar().getWidth(); final int y = NlConstants.RULER_SIZE_PX; RelativePoint position = new RelativePoint(surface, new Point(x, y)); builder.show(position); return builder; }
From source file:com.antoine.ideaplugin.greenrobot.ShowUsagesAction.java
License:Apache License
private static boolean showPopupIfNeedTo(@NotNull JBPopup popup, @NotNull RelativePoint popupPosition) { if (!popup.isDisposed() && !popup.isVisible()) { popup.show(popupPosition); return true; } else {//from w w w .j av a2 s .c o m return false; } }
From source file:com.google.cloud.tools.intellij.login.ui.GoogleLoginAction.java
License:Apache License
/** * Opens up the Google Login panel as a popup. *///from ww w. ja va2 s.c om private static void showPopup(AnActionEvent event) { GoogleLoginUsersPanel usersPanel = new GoogleLoginUsersPanel(); JComponent source = (JComponent) event.getInputEvent().getSource(); ComponentPopupBuilder popupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(usersPanel, usersPanel.getList()); JBPopup popup = popupBuilder.createPopup(); JComponent component = popup.getContent(); int startingPoint = (int) (source.getWidth() - component.getPreferredSize().getWidth()); popup.show(new RelativePoint(source, new Point(startingPoint, source.getHeight() - 1))); }
From source file:com.google.gct.login.ui.GoogleLoginAction.java
License:Apache License
/** * Opens up the Google Login panel as a popup. *//*from ww w . j a v a2s. c o m*/ private static void showPopup(AnActionEvent e) { GoogleLoginUsersPanel usersPanel = new GoogleLoginUsersPanel(); JComponent source = (JComponent) e.getInputEvent().getSource(); ComponentPopupBuilder popupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(usersPanel, usersPanel.getList()); JBPopup popup = popupBuilder.createPopup(); JComponent component = popup.getContent(); int startingPoint = (int) (source.getWidth() - component.getPreferredSize().getWidth()); popup.show(new RelativePoint(source, new Point(startingPoint, source.getHeight() - 1))); }