use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class ExternalSystemUiUtil method showBalloon.
/**
* Asks to show balloon that contains information related to the given component.
*
* @param component component for which we want to show information
* @param messageType balloon message type
* @param message message to show
*/
public static void showBalloon(@NotNull JComponent component, @NotNull MessageType messageType, @NotNull String message) {
final BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType, null).setDisposable(ApplicationManager.getApplication()).setFadeoutTime(BALLOON_FADEOUT_TIME);
Balloon balloon = builder.createBalloon();
Dimension size = component.getSize();
Balloon.Position position;
int x;
int y;
if (size == null) {
x = y = 0;
position = Balloon.Position.above;
} else {
x = Math.min(10, size.width / 2);
y = size.height;
position = Balloon.Position.below;
}
balloon.show(new RelativePoint(component, new Point(x, y)), position);
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class GeneralCodeStylePanel method showError.
private static void showError(final JTextField field, final String message) {
BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, MessageType.ERROR.getDefaultIcon(), MessageType.ERROR.getPopupBackground(), null);
balloonBuilder.setFadeoutTime(1500);
final Balloon balloon = balloonBuilder.createBalloon();
final Rectangle rect = field.getBounds();
final Point p = new Point(0, rect.height);
final RelativePoint point = new RelativePoint(field, p);
balloon.show(point, Balloon.Position.below);
Disposer.register(ProjectManager.getInstance().getDefaultProject(), balloon);
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class DaemonEditorPopup method invokePopup.
@Override
public void invokePopup(final Component comp, final int x, final int y) {
if (ApplicationManager.getApplication() == null)
return;
final JRadioButtonMenuItem errorsFirst = createRadioButtonMenuItem(EditorBundle.message("errors.panel.go.to.errors.first.radio"));
errorsFirst.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DaemonCodeAnalyzerSettings.getInstance().NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST = errorsFirst.isSelected();
}
});
final JPopupMenu popupMenu = new JBPopupMenu();
popupMenu.add(errorsFirst);
final JRadioButtonMenuItem next = createRadioButtonMenuItem(EditorBundle.message("errors.panel.go.to.next.error.warning.radio"));
next.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DaemonCodeAnalyzerSettings.getInstance().NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST = !next.isSelected();
}
});
popupMenu.add(next);
ButtonGroup group = new ButtonGroup();
group.add(errorsFirst);
group.add(next);
popupMenu.addSeparator();
final JMenuItem hLevel = new JBMenuItem(EditorBundle.message("customize.highlighting.level.menu.item"));
popupMenu.add(hLevel);
final boolean isErrorsFirst = DaemonCodeAnalyzerSettings.getInstance().NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST;
errorsFirst.setSelected(isErrorsFirst);
next.setSelected(!isErrorsFirst);
hLevel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final PsiFile psiFile = myPsiFile;
if (psiFile == null)
return;
final HectorComponent component = new HectorComponent(psiFile);
final Dimension dimension = component.getPreferredSize();
Point point = new Point(x, y);
component.showComponent(new RelativePoint(comp, new Point(point.x - dimension.width, point.y)));
}
});
final JBCheckboxMenuItem previewCheckbox = new JBCheckboxMenuItem(IdeBundle.message("checkbox.show.editor.preview.popup"), UISettings.getInstance().getShowEditorToolTip());
popupMenu.addSeparator();
popupMenu.add(previewCheckbox);
previewCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UISettings.getInstance().setShowToolWindowsNumbers(previewCheckbox.isSelected());
UISettings.getInstance().fireUISettingsChanged();
}
});
PsiFile file = myPsiFile;
if (file != null && DaemonCodeAnalyzer.getInstance(myPsiFile.getProject()).isHighlightingAvailable(file)) {
popupMenu.show(comp, x, y);
}
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class PsiElementListNavigator method openTargets.
public static void openTargets(MouseEvent e, NavigatablePsiElement[] targets, String title, final String findUsagesTitle, ListCellRenderer listRenderer, @Nullable ListBackgroundUpdaterTask listUpdaterTask) {
JBPopup popup = navigateOrCreatePopup(targets, title, findUsagesTitle, listRenderer, listUpdaterTask);
if (popup != null) {
if (listUpdaterTask != null) {
Alarm alarm = new Alarm(popup);
alarm.addRequest(() -> popup.show(new RelativePoint(e)), 300);
ProgressManager.getInstance().run(listUpdaterTask);
} else {
popup.show(new RelativePoint(e));
}
}
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class IntentionHintComponent method showPopup.
private void showPopup(boolean mouseClick) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (myPopup == null || myPopup.isDisposed())
return;
if (mouseClick && myPanel.isShowing()) {
final RelativePoint swCorner = RelativePoint.getSouthWestOf(myPanel);
final int yOffset = canPlaceBulbOnTheSameLine(myEditor) ? 0 : myEditor.getLineHeight() - (myEditor.isOneLineMode() ? SMALL_BORDER_SIZE : NORMAL_BORDER_SIZE);
myPopup.show(new RelativePoint(swCorner.getComponent(), new Point(swCorner.getPoint().x, swCorner.getPoint().y + yOffset)));
} else {
myPopup.showInBestPositionFor(myEditor);
}
myPopupShown = true;
}
Aggregations