use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class DetectionExcludesConfigurable method doAddAction.
private void doAddAction(AnActionButton button) {
final List<FrameworkType> types = new ArrayList<>();
for (FrameworkType type : FrameworkDetectorRegistry.getInstance().getFrameworkTypes()) {
if (!isExcluded(type)) {
types.add(type);
}
}
Collections.sort(types, (o1, o2) -> o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName()));
types.add(0, null);
final ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<FrameworkType>("Framework to Exclude", types) {
@Override
public Icon getIconFor(FrameworkType value) {
return value != null ? value.getIcon() : null;
}
@NotNull
@Override
public String getTextFor(FrameworkType value) {
return value != null ? value.getPresentableName() : "All Frameworks...";
}
@Override
public boolean hasSubstep(FrameworkType selectedValue) {
return selectedValue != null;
}
@Override
public PopupStep onChosen(final FrameworkType frameworkType, boolean finalChoice) {
if (frameworkType == null) {
return doFinalStep(() -> chooseDirectoryAndAdd(null));
} else {
return addExcludedFramework(frameworkType);
}
}
});
final RelativePoint popupPoint = button.getPreferredPopupPoint();
if (popupPoint != null) {
popup.show(popupPoint);
} else {
popup.showInCenterOf(myMainPanel);
}
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class GotoDeclarationAction method startFindUsages.
private static boolean startFindUsages(@NotNull Editor editor, PsiElement element) {
if (element != null) {
ShowUsagesAction showUsages = (ShowUsagesAction) ActionManager.getInstance().getAction(ShowUsagesAction.ID);
RelativePoint popupPosition = JBPopupFactory.getInstance().guessBestPopupLocation(editor);
showUsages.startFindUsages(element, popupPosition, editor, ShowUsagesAction.USAGES_PAGE_SIZE);
return true;
}
return false;
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class BaseRunConfigurationAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
final RunnerAndConfigurationSettings existing = context.findExisting();
if (existing == null) {
final List<ConfigurationFromContext> producers = getConfigurationsFromContext(context);
if (producers.isEmpty())
return;
if (producers.size() > 1) {
final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
Collections.sort(producers, ConfigurationFromContext.NAME_COMPARATOR);
final ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationFromContext>(ExecutionBundle.message("configuration.action.chooser.title"), producers) {
@Override
@NotNull
public String getTextFor(final ConfigurationFromContext producer) {
return childActionName(producer.getConfigurationType(), producer.getConfiguration());
}
@Override
public Icon getIconFor(final ConfigurationFromContext producer) {
return producer.getConfigurationType().getIcon();
}
@Override
public PopupStep onChosen(final ConfigurationFromContext producer, final boolean finalChoice) {
perform(producer, context);
return FINAL_CHOICE;
}
});
final InputEvent event = e.getInputEvent();
if (event instanceof MouseEvent) {
popup.show(new RelativePoint((MouseEvent) event));
} else if (editor != null) {
popup.showInBestPositionFor(editor);
} else {
popup.showInBestPositionFor(dataContext);
}
} else {
perform(producers.get(0), context);
}
return;
}
perform(context);
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class ConsoleGutterComponent method mouseMoved.
@Override
public void mouseMoved(MouseEvent e) {
int line = EditorUtil.yPositionToLogicalLine(editor, e.getPoint());
if (line == lastGutterToolTipLine) {
return;
}
TooltipController controller = TooltipController.getInstance();
if (lastGutterToolTipLine != -1) {
controller.cancelTooltip(TOOLTIP_GROUP, e, true);
}
String toolTip = gutterContentProvider.getToolTip(line, editor);
setCursor(toolTip == null ? Cursor.getDefaultCursor() : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
if (toolTip == null) {
lastGutterToolTipLine = -1;
controller.cancelTooltip(TOOLTIP_GROUP, e, false);
} else {
lastGutterToolTipLine = line;
RelativePoint showPoint = new RelativePoint(this, e.getPoint());
controller.showTooltipByMouseMove(editor, showPoint, ((EditorMarkupModel) editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(toolTip), false, TOOLTIP_GROUP, new HintHint(this, e.getPoint()).setAwtTooltip(true));
}
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class FindPopupPanel method showUI.
public void showUI() {
if (myBalloon != null && myBalloon.isVisible()) {
return;
}
if (myBalloon != null && !myBalloon.isDisposed()) {
myBalloon.cancel();
}
if (myBalloon == null || myBalloon.isDisposed()) {
final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(this, mySearchComponent);
myBalloon = builder.setProject(myHelper.getProject()).setMovable(true).setResizable(true).setMayBeParent(true).setCancelOnClickOutside(true).setModalContext(false).setRequestFocus(true).setCancelCallback(() -> {
if (!myCanClose.get())
return false;
if (!ApplicationManager.getApplication().isActive())
return false;
List<JBPopup> popups = JBPopupFactory.getInstance().getChildPopups(this);
if (!popups.isEmpty()) {
for (JBPopup popup : popups) {
popup.cancel();
}
return false;
}
if (myScopeUI.hideAllPopups()) {
return false;
}
DimensionService.getInstance().setSize(SERVICE_KEY, myBalloon.getSize(), myHelper.getProject());
DimensionService.getInstance().setLocation(SERVICE_KEY, myBalloon.getLocationOnScreen(), myHelper.getProject());
return true;
}).createPopup();
Disposer.register(myBalloon, myDisposable);
registerCloseAction(myBalloon);
final Window window = WindowManager.getInstance().suggestParentWindow(myProject);
Component parent = UIUtil.findUltimateParent(window);
RelativePoint showPoint = null;
Point screenPoint = DimensionService.getInstance().getLocation(SERVICE_KEY);
if (screenPoint != null) {
showPoint = new RelativePoint(screenPoint);
}
if (parent != null && showPoint == null) {
int height = UISettings.getInstance().getShowNavigationBar() ? 135 : 115;
if (parent instanceof IdeFrameImpl && ((IdeFrameImpl) parent).isInFullScreen()) {
height -= 20;
}
showPoint = new RelativePoint(parent, new Point((parent.getSize().width - getPreferredSize().width) / 2, height));
}
mySearchComponent.selectAll();
WindowMoveListener windowListener = new WindowMoveListener(this);
myTitleLabel.addMouseListener(windowListener);
myTitleLabel.addMouseMotionListener(windowListener);
Dimension panelSize = getPreferredSize();
Dimension prev = DimensionService.getInstance().getSize(SERVICE_KEY);
if (!myCbPreserveCase.isVisible()) {
panelSize.width += myCbPreserveCase.getPreferredSize().width + 8;
}
panelSize.height *= 2;
if (prev != null && prev.height < panelSize.height)
prev.height = panelSize.height;
myBalloon.setMinimumSize(panelSize);
if (prev == null)
panelSize.height = panelSize.height * 3 / 2;
myBalloon.setSize(prev != null ? prev : panelSize);
if (showPoint != null && showPoint.getComponent() != null) {
myBalloon.show(showPoint);
} else {
myBalloon.showCenteredInCurrentWindow(myProject);
}
}
}
Aggregations