Search in sources :

Example 26 with RelativePoint

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

the class JBRunnerTabs method processDropOver.

@Override
public void processDropOver(TabInfo over, RelativePoint relativePoint) {
    final Point point = relativePoint.getPoint(getComponent());
    myShowDropLocation = shouldAddToGlobal(point);
    super.processDropOver(over, relativePoint);
    for (Map.Entry<TabInfo, TabLabel> entry : myInfo2Label.entrySet()) {
        final TabLabel label = entry.getValue();
        if (label.getBounds().contains(point) && myDropInfo != entry.getKey()) {
            select(entry.getKey(), false);
            break;
        }
    }
}
Also used : TabLabel(com.intellij.ui.tabs.impl.TabLabel) TabInfo(com.intellij.ui.tabs.TabInfo) RelativePoint(com.intellij.ui.awt.RelativePoint) Map(java.util.Map)

Example 27 with RelativePoint

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

the class RunnerContentUi method detachTo.

@Override
public ActionCallback detachTo(int window, GridCell cell) {
    if (myOriginal != null) {
        return myOriginal.detachTo(window, cell);
    }
    RunnerContentUi target = null;
    if (window > 0) {
        for (RunnerContentUi child : myChildren) {
            if (child.myWindow == window) {
                target = child;
                break;
            }
        }
    }
    final GridCellImpl gridCell = (GridCellImpl) cell;
    final Content[] contents = gridCell.getContents();
    storeDefaultIndices(contents);
    for (Content content : contents) {
        content.putUserData(RunnerLayout.DROP_INDEX, getStateFor(content).getTab().getIndex());
    }
    Dimension size = gridCell.getSize();
    if (size == null) {
        size = JBUI.size(200, 200);
    }
    final DockableGrid content = new DockableGrid(null, null, size, Arrays.asList(contents), window);
    if (target != null) {
        target.add(content, null);
    } else {
        Point location = gridCell.getLocation();
        if (location == null) {
            location = getComponent().getLocationOnScreen();
        }
        location.translate(size.width / 2, size.height / 2);
        getDockManager().createNewDockContainerFor(content, new RelativePoint(location));
    }
    return ActionCallback.DONE;
}
Also used : DockableContent(com.intellij.ui.docking.DockableContent) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 28 with RelativePoint

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

the class RunnerContentUi method add.

@Override
public void add(@NotNull DockableContent dockable, RelativePoint dropTarget) {
    final DockableGrid dockableGrid = (DockableGrid) dockable;
    final RunnerContentUi prev = dockableGrid.getRunnerUi();
    saveUiState();
    final List<Content> contents = dockableGrid.getContents();
    final boolean wasRestoring = myOriginal != null && myOriginal.isStateBeingRestored();
    setStateIsBeingRestored(true, this);
    try {
        final Point point = dropTarget != null ? dropTarget.getPoint(myComponent) : null;
        boolean hadGrid = !myTabs.shouldAddToGlobal(point);
        for (Content content : contents) {
            final View view = getStateFor(content);
            if (view.isMinimizedInGrid())
                continue;
            prev.myManager.removeContent(content, false);
            myManager.removeContent(content, false);
            if (hadGrid && !wasRestoring) {
                view.assignTab(getTabFor(getSelectedGrid()));
                view.setPlaceInGrid(calcPlaceInGrid(point, myComponent.getSize()));
            } else if (contents.size() == 1 && !wasRestoring) {
                view.assignTab(null);
                view.setPlaceInGrid(myLayoutSettings.getDefaultGridPlace(content));
            }
            view.setWindow(myWindow);
            myManager.addContent(content);
        }
    } finally {
        setStateIsBeingRestored(false, this);
    }
    saveUiState();
    updateTabsUI(true);
}
Also used : DockableContent(com.intellij.ui.docking.DockableContent) RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 29 with RelativePoint

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

the class VcsCommitInfoBalloon method showCommitDetails.

public void showCommitDetails() {
    if (myBalloon == null || !myBalloon.isVisible()) {
        createNewCommitInfoBalloon();
        myBalloon.show(new RelativePoint(calculateBestPopupLocation()));
    }
    updateCommitDetails();
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint)

Example 30 with RelativePoint

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

the class AnActionButton method getPreferredPopupPoint.

public final RelativePoint getPreferredPopupPoint() {
    Container c = myContextComponent;
    ActionToolbar toolbar = null;
    while ((c = c.getParent()) != null) {
        if (c instanceof JComponent && (toolbar = (ActionToolbar) ((JComponent) c).getClientProperty(ActionToolbar.ACTION_TOOLBAR_PROPERTY_KEY)) != null) {
            break;
        }
    }
    if (toolbar instanceof JComponent) {
        for (Component comp : ((JComponent) toolbar).getComponents()) {
            if (comp instanceof ActionButtonComponent) {
                if (comp instanceof AnActionHolder) {
                    if (((AnActionHolder) comp).getAction() == this) {
                        return new RelativePoint(comp.getParent(), new Point(comp.getX(), comp.getY() + comp.getHeight()));
                    }
                }
            }
        }
    }
    return null;
}
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