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);
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class ActionToolbarImpl method showAutoPopup.
private void showAutoPopup() {
if (isPopupShowing())
return;
final ActionGroup group;
if (myOrientation == SwingConstants.HORIZONTAL) {
group = myActionGroup;
} else {
final DefaultActionGroup outside = new DefaultActionGroup();
for (int i = myFirstOutsideIndex; i < myVisibleActions.size(); i++) {
outside.add(myVisibleActions.get(i));
}
group = outside;
}
PopupToolbar popupToolbar = new PopupToolbar(myPlace, group, true, myDataManager, myActionManager, myUpdater.getKeymapManager(), this) {
@Override
protected void onOtherActionPerformed() {
hidePopup();
}
@Override
protected DataContext getDataContext() {
return ActionToolbarImpl.this.getDataContext();
}
};
popupToolbar.setLayoutPolicy(NOWRAP_LAYOUT_POLICY);
popupToolbar.updateActionsImmediately();
Point location;
if (myOrientation == SwingConstants.HORIZONTAL) {
location = getLocationOnScreen();
} else {
location = getLocationOnScreen();
location.y = location.y + getHeight() - popupToolbar.getPreferredSize().height;
}
final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(popupToolbar, null);
builder.setResizable(false).setMovable(// fit the screen automatically
true).setRequestFocus(false).setTitle(null).setCancelOnClickOutside(true).setCancelOnOtherWindowOpen(true).setCancelCallback(() -> {
final boolean toClose = myActionManager.isActionPopupStackEmpty();
if (toClose) {
myUpdater.updateActions(false, true);
}
return toClose;
}).setCancelOnMouseOutCallback(new MouseChecker() {
@Override
public boolean check(final MouseEvent event) {
return myAutoPopupRec != null && myActionManager.isActionPopupStackEmpty() && !new RelativeRectangle(ActionToolbarImpl.this, myAutoPopupRec).contains(new RelativePoint(event));
}
});
builder.addListener(new JBPopupAdapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
processClosed();
}
});
myPopup = builder.createPopup();
final AnActionListener.Adapter listener = new AnActionListener.Adapter() {
@Override
public void afterActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) {
final JBPopup popup = myPopup;
if (popup != null && !popup.isDisposed() && popup.isVisible()) {
popup.cancel();
}
}
};
ActionManager.getInstance().addAnActionListener(listener);
Disposer.register(myPopup, popupToolbar);
Disposer.register(popupToolbar, new Disposable() {
@Override
public void dispose() {
ActionManager.getInstance().removeAnActionListener(listener);
}
});
myPopup.showInScreenCoordinates(this, location);
final Window window = SwingUtilities.getWindowAncestor(this);
if (window != null) {
final ComponentAdapter componentAdapter = new ComponentAdapter() {
@Override
public void componentResized(final ComponentEvent e) {
hidePopup();
}
@Override
public void componentMoved(final ComponentEvent e) {
hidePopup();
}
@Override
public void componentShown(final ComponentEvent e) {
hidePopup();
}
@Override
public void componentHidden(final ComponentEvent e) {
hidePopup();
}
};
window.addComponentListener(componentAdapter);
Disposer.register(popupToolbar, new Disposable() {
@Override
public void dispose() {
window.removeComponentListener(componentAdapter);
}
});
}
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class JBTabsImpl method processDropOver.
@Override
public void processDropOver(TabInfo over, RelativePoint point) {
int index = myLayout.getDropIndexFor(point.getPoint(this));
if (index != getDropInfoIndex()) {
setDropInfoIndex(index);
relayout(true, false);
}
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class JBTabsImpl method startDropOver.
@Override
public Image startDropOver(TabInfo tabInfo, RelativePoint point) {
myDropInfo = tabInfo;
int index = myLayout.getDropIndexFor(point.getPoint(this));
setDropInfoIndex(index);
addTab(myDropInfo, index, true, true);
TabLabel label = myInfo2Label.get(myDropInfo);
Dimension size = label.getPreferredSize();
label.setBounds(0, 0, size.width, size.height);
BufferedImage img = UIUtil.createImage(this, size.width, size.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = img.createGraphics();
label.paintOffscreen(g);
g.dispose();
relayout(true, false);
return img;
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class Callout method showTextBelow.
public static void showTextBelow(JComponent component, String text) {
final RelativePoint calloutPoint = RelativePoint.getSouthWestOf(component);
calloutPoint.getPoint().x += 5;
Callout.showText(calloutPoint, Callout.SOUTH_EAST, text);
}
Aggregations