Search in sources :

Example 1 with RelativePoint

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

the class SvnAuthenticationNotifier method showAlreadyChecking.

private boolean showAlreadyChecking() {
    final IdeFrame frameFor = WindowManagerEx.getInstanceEx().findFrameFor(myProject);
    if (frameFor != null) {
        final JComponent component = frameFor.getComponent();
        Point point = component.getMousePosition();
        if (point == null) {
            point = new Point((int) (component.getWidth() * 0.7), 0);
        }
        SwingUtilities.convertPointToScreen(point, component);
        JBPopupFactory.getInstance().createHtmlTextBalloonBuilder("Already checking...", MessageType.WARNING, null).createBalloon().show(new RelativePoint(point), Balloon.Position.below);
    }
    return false;
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 2 with RelativePoint

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

the class SuggestionList method showSuggestions.

/**
   * @param values          suggestions in format [group1[suggestions]]. See class doc for info about groups.
   *                        We recommend you <strong>not to use</strong> this method.
   *                        Use {@link #showSuggestions(SuggestionsBuilder, com.intellij.ui.awt.RelativePoint, String)} instead.
   *                        {@link com.jetbrains.python.suggestionList.SuggestionsBuilder} is easier to use
   * @param displayPoint    point on screen to display suggestions
   * @param elementToSelect element in list to be selected (if any)
   */
public void showSuggestions(@NotNull final List<List<Suggestion>> values, @NotNull final RelativePoint displayPoint, @Nullable final String elementToSelect) {
    close();
    myList.setCellRenderer(new MyCellRenderer());
    myListModel.clear();
    if (values.isEmpty()) {
        return;
    }
    // Fill and select
    // Record to select
    int record = 0;
    // Iterate through groups adding suggestions. Odd groups should be marked differently.
    for (int groupId = 0; groupId < values.size(); groupId++) {
        final List<Suggestion> suggestions = values.get(groupId);
        for (int suggestionId = 0; suggestionId < suggestions.size(); suggestionId++) {
            final Suggestion suggestion = suggestions.get(suggestionId);
            myListModel.addElement(new SuggestionListElement((groupId % 2) == 0, suggestion));
            if (suggestion.getText().equals(elementToSelect)) {
                myList.setSelectedIndex(record);
            }
            record++;
        }
    }
    if ((myList.getSelectedIndex() == -1) && (!myListModel.isEmpty())) {
        // Select first element
        myList.setSelectedIndex(0);
    }
    // Use scroll bars
    final JScrollPane content = new JScrollPane(myList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    myListPopUp = JBPopupFactory.getInstance().createComponentPopupBuilder(content, null).createPopup();
    if (myListener != null) {
        myListPopUp.addListener(myListener);
    }
    myListPopUp.show(displayPoint);
    // Scrolls to selected
    myList.ensureIndexIsVisible(myList.getSelectedIndex());
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 3 with RelativePoint

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

the class ShowJavadoc method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null) {
        return;
    }
    DocumentationManager documentationManager = DocumentationManager.getInstance(project);
    final DocumentationComponent component = new DocumentationComponent(documentationManager);
    final Property property = myTable.getSelectionProperty();
    if (property == null) {
        return;
    }
    PsiElement javadocElement = property.getJavadocElement();
    ActionCallback callback;
    if (javadocElement == null) {
        callback = new ActionCallback();
        component.setText(property.getJavadocText(), null, true);
    } else {
        callback = documentationManager.queueFetchDocInfo(javadocElement, component);
    }
    callback.doWhenProcessed(() -> {
        JBPopup hint = JBPopupFactory.getInstance().createComponentPopupBuilder(component, component).setProject(project).setDimensionServiceKey(project, DocumentationManager.JAVADOC_LOCATION_AND_SIZE, false).setResizable(true).setMovable(true).setRequestFocus(true).setTitle(DesignerBundle.message("designer.properties.javadoc.title", property.getName())).setCancelCallback(() -> {
            Disposer.dispose(component);
            return Boolean.TRUE;
        }).createPopup();
        component.setHint(hint);
        Disposer.register(hint, component);
        hint.show(new RelativePoint(myTable.getParent(), new Point(0, 0)));
    });
    if (javadocElement == null) {
        callback.setDone();
    }
}
Also used : Project(com.intellij.openapi.project.Project) DocumentationManager(com.intellij.codeInsight.documentation.DocumentationManager) DocumentationComponent(com.intellij.codeInsight.documentation.DocumentationComponent) ActionCallback(com.intellij.openapi.util.ActionCallback) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) JBPopup(com.intellij.openapi.ui.popup.JBPopup) Property(com.intellij.designer.model.Property) PsiElement(com.intellij.psi.PsiElement)

Example 4 with RelativePoint

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

the class FormEditingUtil method showPopupUnderComponent.

public static void showPopupUnderComponent(final JBPopup popup, final RadComponent selectedComponent) {
    // popup.showUnderneathOf() doesn't work on invisible components
    Rectangle rc = selectedComponent.getBounds();
    Point pnt = new Point(rc.x, rc.y + rc.height);
    popup.show(new RelativePoint(selectedComponent.getDelegee().getParent(), pnt));
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 5 with RelativePoint

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

the class StudyUtils method computeLocation.

public static RelativePoint computeLocation(Editor editor) {
    final Rectangle visibleRect = editor.getComponent().getVisibleRect();
    Point point = new Point(visibleRect.x + visibleRect.width + 10, visibleRect.y + 10);
    return new RelativePoint(editor.getComponent(), point);
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint) 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