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;
}
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());
}
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();
}
}
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));
}
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);
}
Aggregations