List of usage examples for com.intellij.openapi.ui.popup ListPopup getContent
@NotNull JComponent getContent();
From source file:krasa.cpu.CpuUsagePanel.java
License:Apache License
public CpuUsagePanel(Project project) { refreshColors();// w ww . ja va2s.c om this.myProject = project; this.projectName = project.getName(); setOpaque(false); setFocusable(false); setToolTipText("IDE CPU usage / System CPU usage"); setBorder(StatusBarWidget.WidgetBorder.INSTANCE); updateUI(); new UiNotifyConnector(this, new Activatable() { @Override public void showNotify() { CpuUsageManager.register(CpuUsagePanel.this); } @Override public void hideNotify() { CpuUsageManager.unregister(CpuUsagePanel.this); } }); MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e)) { CpuUsageManager.update(); final DataContext context = DataManager.getInstance().getDataContext(CpuUsagePanel.this); ActionManager.getInstance().getAction("TakeThreadDump").actionPerformed(new AnActionEvent(e, context, ActionPlaces.UNKNOWN, new Presentation(""), ActionManager.getInstance(), 0)); } else if (SwingUtilities.isRightMouseButton(e)) { final DataContext context = DataManager.getInstance().getDataContext(CpuUsagePanel.this); ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, getActionGroup(), context, JBPopupFactory.ActionSelectionAid.MNEMONICS, false); Dimension dimension = popup.getContent().getPreferredSize(); Point at = new Point(0, -dimension.height); popup.show(new RelativePoint(e.getComponent(), at)); } } }; addMouseListener(mouseAdapter); }
From source file:net.groboclown.idea.p4ic.ui.P4MultipleConnectionWidget.java
License:Apache License
private void showPopup(@NotNull MouseEvent event) { // it isn't getting bubbled up to the parent DataContext dataContext = getContext(); final ListPopup popup = createListPopup(dataContext); if (popup.isVisible()) { popup.cancel();/*from w w w . j a v a2 s. com*/ return; } final Dimension dimension = popup.getContent().getPreferredSize(); final Point at = new Point(0, -dimension.height); popup.show(new RelativePoint(event.getComponent(), at)); Disposer.register(this, popup); // destroy popup on unexpected project close }
From source file:org.community.intellij.plugins.communitycase.history.wholeTree.BasePopupAction.java
License:Apache License
protected void doAction(MouseEvent e) { final DefaultActionGroup group = createActionGroup(); final DataContext parent = DataManager.getInstance().getDataContext((Component) myPanel.getParent()); final DataContext dataContext = SimpleDataContext.getSimpleContext(PlatformDataKeys.PROJECT.getName(), myProject, parent);/*from w ww. j a va 2s .c om*/ final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true, new Runnable() { @Override public void run() { // todo ? } }, 20); if (e != null) { popup.show(new RelativePoint(e)); } else { final Dimension dimension = popup.getContent().getPreferredSize(); final Point at = new Point(-dimension.width / 2, -dimension.height); popup.show(new RelativePoint(myLabel, at)); } }
From source file:org.intellij.xquery.runner.ui.datasources.DataSourceTypesListPopupGuiTest.java
License:Apache License
@Override protected PanelTestingFrame getPanelTestingFrame() { executor = mock(XQueryDataSourceTypeBasedActionExecutor.class); popup = new DataSourceTypesListPopup(executor); final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(popup); mainPanel = (JPanel) listPopup.getContent(); listPopup.show((Component) null); return new PanelTestingFrame(mainPanel); }
From source file:org.mustbe.consulo.vfs.backgroundTask.ui.widget.BackgroundTaskWidget.java
License:Apache License
@Nullable @Override/*www . j a v a 2 s . c o m*/ public Consumer<MouseEvent> getClickConsumer() { return new Consumer<MouseEvent>() { @Override public void consume(MouseEvent mouseEvent) { if (myVirtualFile == null) { return; } DefaultActionGroup group = new DefaultActionGroup(); group.add(new AnAction("Force Run", null, AllIcons.Actions.Resume) { @Override public void actionPerformed(AnActionEvent e) { BackgroundTaskByVfsChangeManager.getInstance(myProject).runTasks(myVirtualFile); } @Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(!BackgroundTaskByVfsChangeManager.getInstance(myProject) .findEnabledTasks(myVirtualFile).isEmpty()); } }); group.add(new AnAction("Manage", null, AllIcons.General.Settings) { @Override public void actionPerformed(AnActionEvent e) { BackgroundTaskByVfsChangeManager.getInstance(myProject).openManageDialog(myVirtualFile); } }); ListPopup choose = JBPopupFactory.getInstance().createActionGroupPopup(getTooltipText(), group, DataManager.getInstance().getDataContext(mouseEvent.getComponent()), null, true); Dimension dimension = choose.getContent().getPreferredSize(); Point at = new Point(0, -dimension.height); choose.show(new RelativePoint(mouseEvent.getComponent(), at)); } }; }