Search in sources :

Example 81 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class ShowUsagesAction method rebuildTable.

private void rebuildTable(@NotNull final UsageViewImpl usageView, @NotNull final List<Usage> usages, @NotNull List<UsageNode> nodes, @NotNull final JTable table, @Nullable final JBPopup popup, @NotNull final UsageViewPresentation presentation, @NotNull final RelativePoint popupPosition, boolean findUsagesInProgress, @NotNull AtomicInteger outOfScopeUsages, @NotNull SearchScope searchScope) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    boolean shouldShowMoreSeparator = usages.contains(MORE_USAGES_SEPARATOR);
    if (shouldShowMoreSeparator) {
        nodes.add(MORE_USAGES_SEPARATOR_NODE);
    }
    boolean hasOutsideScopeUsages = usages.contains(USAGES_OUTSIDE_SCOPE_SEPARATOR);
    if (hasOutsideScopeUsages && !shouldShowMoreSeparator) {
        nodes.add(USAGES_OUTSIDE_SCOPE_NODE);
    }
    String title = presentation.getTabText();
    String fullTitle = getFullTitle(usages, title, shouldShowMoreSeparator || hasOutsideScopeUsages, nodes.size() - (shouldShowMoreSeparator || hasOutsideScopeUsages ? 1 : 0), findUsagesInProgress);
    if (popup != null) {
        ((AbstractPopup) popup).setCaption(fullTitle);
    }
    List<UsageNode> data = collectData(usages, nodes, usageView, presentation);
    MyModel tableModel = setTableModel(table, usageView, data, outOfScopeUsages, searchScope);
    List<UsageNode> existingData = tableModel.getItems();
    int row = table.getSelectedRow();
    int newSelection = updateModel(tableModel, existingData, data, row == -1 ? 0 : row);
    if (newSelection < 0 || newSelection >= tableModel.getRowCount()) {
        ScrollingUtil.ensureSelectionExists(table);
        newSelection = table.getSelectedRow();
    } else {
        // do not pre-select the usage under caret by default
        if (newSelection == 0 && table.getModel().getRowCount() > 1) {
            Object valueInTopRow = table.getModel().getValueAt(0, 0);
            if (valueInTopRow instanceof UsageNode && usageView.isOriginUsage(((UsageNode) valueInTopRow).getUsage())) {
                newSelection++;
            }
        }
        table.getSelectionModel().setSelectionInterval(newSelection, newSelection);
    }
    ScrollingUtil.ensureIndexIsVisible(table, newSelection, 0);
    if (popup != null) {
        setSizeAndDimensions(table, popup, popupPosition, data);
    }
}
Also used : AbstractPopup(com.intellij.ui.popup.AbstractPopup) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 82 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class RunnerContentUi method getTabsAt.

@Nullable
private JBTabs getTabsAt(DockableContent content, RelativePoint point) {
    if (content instanceof DockableGrid) {
        final Point p = point.getPoint(getComponent());
        Component c = SwingUtilities.getDeepestComponentAt(getComponent(), p.x, p.y);
        while (c != null) {
            if (c instanceof JBRunnerTabs) {
                return (JBTabs) c;
            }
            c = c.getParent();
        }
    }
    return null;
}
Also used : JBTabs(com.intellij.ui.tabs.JBTabs) RelativePoint(com.intellij.ui.awt.RelativePoint) Nullable(org.jetbrains.annotations.Nullable)

Example 83 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class DirDiffTableModel method reportException.

private void reportException(final String htmlContent) {
    Runnable balloonShower = () -> {
        Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(htmlContent, MessageType.WARNING, null).setShowCallout(false).setHideOnClickOutside(true).setHideOnAction(true).setHideOnFrameResize(true).setHideOnKeyOutside(true).createBalloon();
        final Rectangle rect = myPanel.getPanel().getBounds();
        final Point p = new Point(rect.x + rect.width - 100, rect.y + 50);
        final RelativePoint point = new RelativePoint(myPanel.getPanel(), p);
        balloon.show(point, Balloon.Position.below);
        Disposer.register(myProject != null ? myProject : ApplicationManager.getApplication(), balloon);
    };
    ApplicationManager.getApplication().invokeLater(balloonShower, o -> !(myProject == null || myProject.isDefault()) && ((!myProject.isOpen()) || myProject.isDisposed()));
}
Also used : Balloon(com.intellij.openapi.ui.popup.Balloon) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 84 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class NewColorAndFontPanel method notifyAtSchemePanel.

private void notifyAtSchemePanel(@NotNull String message) {
    final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
    Balloon balloon = popupFactory.createHtmlTextBalloonBuilder(message, MessageType.INFO, null).setHideOnClickOutside(true).setHideOnKeyOutside(true).createBalloon();
    Disposer.register(ApplicationManager.getApplication(), balloon);
    balloon.show(new RelativePoint(mySchemesPanel, new Point(mySchemesPanel.getWidth() / 10, mySchemesPanel.getHeight())), Balloon.Position.below);
}
Also used : JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) Balloon(com.intellij.openapi.ui.popup.Balloon) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 85 with RelativePoint

use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.

the class MultipleFilesHyperlinkInfo method navigate.

@Override
public void navigate(@NotNull final Project project, @Nullable RelativePoint hyperlinkLocationPoint) {
    List<PsiFile> currentFiles = new ArrayList<>();
    AccessToken accessToken = ReadAction.start();
    try {
        for (VirtualFile file : myVirtualFiles) {
            if (!file.isValid())
                continue;
            PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
            if (psiFile != null) {
                // Sources may be downloaded.
                PsiElement navigationElement = psiFile.getNavigationElement();
                if (navigationElement instanceof PsiFile) {
                    currentFiles.add((PsiFile) navigationElement);
                    continue;
                }
                currentFiles.add(psiFile);
            }
        }
    } finally {
        accessToken.finish();
    }
    if (currentFiles.isEmpty())
        return;
    if (currentFiles.size() == 1) {
        new OpenFileHyperlinkInfo(myProject, currentFiles.get(0).getVirtualFile(), myLineNumber).navigate(project);
    } else {
        final JBList list = new JBList(currentFiles);
        int width = WindowManager.getInstance().getFrame(project).getSize().width;
        list.setCellRenderer(new GotoFileCellRenderer(width));
        JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list).setTitle("Choose Target File").setItemChoosenCallback(() -> {
            VirtualFile file = ((PsiFile) list.getSelectedValue()).getVirtualFile();
            new OpenFileHyperlinkInfo(myProject, file, myLineNumber).navigate(project);
        }).createPopup();
        if (hyperlinkLocationPoint != null) {
            popup.show(hyperlinkLocationPoint);
        } else {
            popup.showInFocusCenter();
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) GotoFileCellRenderer(com.intellij.ide.util.gotoByName.GotoFileCellRenderer) AccessToken(com.intellij.openapi.application.AccessToken) ArrayList(java.util.ArrayList) PsiFile(com.intellij.psi.PsiFile) JBList(com.intellij.ui.components.JBList) JBPopup(com.intellij.openapi.ui.popup.JBPopup) PsiElement(com.intellij.psi.PsiElement) RelativePoint(com.intellij.ui.awt.RelativePoint)

Aggregations

RelativePoint (com.intellij.ui.awt.RelativePoint)127 Project (com.intellij.openapi.project.Project)16 Balloon (com.intellij.openapi.ui.popup.Balloon)15 JBPopup (com.intellij.openapi.ui.popup.JBPopup)15 NotNull (org.jetbrains.annotations.NotNull)15 MouseEvent (java.awt.event.MouseEvent)12 Nullable (org.jetbrains.annotations.Nullable)10 Editor (com.intellij.openapi.editor.Editor)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 PsiElement (com.intellij.psi.PsiElement)8 JBList (com.intellij.ui.components.JBList)8 Disposable (com.intellij.openapi.Disposable)7 BalloonBuilder (com.intellij.openapi.ui.popup.BalloonBuilder)7 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)7 ArrayList (java.util.ArrayList)7 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)6 ListPopup (com.intellij.openapi.ui.popup.ListPopup)6 PsiFile (com.intellij.psi.PsiFile)5 HintHint (com.intellij.ui.HintHint)5 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)4