use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class ShowUsagesAction method rebuildTable.
private void rebuildTable(@NotNull final UsageViewImpl usageView, @NotNull final List<Usage> usages, @NotNull List<UsageNode> nodes, @NotNull final JTable table, @Nullable final JBPopup popup, @NotNull final UsageViewPresentation presentation, @NotNull final RelativePoint popupPosition, boolean findUsagesInProgress, @NotNull AtomicInteger outOfScopeUsages, @NotNull SearchScope searchScope) {
ApplicationManager.getApplication().assertIsDispatchThread();
boolean shouldShowMoreSeparator = usages.contains(MORE_USAGES_SEPARATOR);
if (shouldShowMoreSeparator) {
nodes.add(MORE_USAGES_SEPARATOR_NODE);
}
boolean hasOutsideScopeUsages = usages.contains(USAGES_OUTSIDE_SCOPE_SEPARATOR);
if (hasOutsideScopeUsages && !shouldShowMoreSeparator) {
nodes.add(USAGES_OUTSIDE_SCOPE_NODE);
}
String title = presentation.getTabText();
String fullTitle = getFullTitle(usages, title, shouldShowMoreSeparator || hasOutsideScopeUsages, nodes.size() - (shouldShowMoreSeparator || hasOutsideScopeUsages ? 1 : 0), findUsagesInProgress);
if (popup != null) {
((AbstractPopup) popup).setCaption(fullTitle);
}
List<UsageNode> data = collectData(usages, nodes, usageView, presentation);
MyModel tableModel = setTableModel(table, usageView, data, outOfScopeUsages, searchScope);
List<UsageNode> existingData = tableModel.getItems();
int row = table.getSelectedRow();
int newSelection = updateModel(tableModel, existingData, data, row == -1 ? 0 : row);
if (newSelection < 0 || newSelection >= tableModel.getRowCount()) {
ScrollingUtil.ensureSelectionExists(table);
newSelection = table.getSelectedRow();
} else {
// do not pre-select the usage under caret by default
if (newSelection == 0 && table.getModel().getRowCount() > 1) {
Object valueInTopRow = table.getModel().getValueAt(0, 0);
if (valueInTopRow instanceof UsageNode && usageView.isOriginUsage(((UsageNode) valueInTopRow).getUsage())) {
newSelection++;
}
}
table.getSelectionModel().setSelectionInterval(newSelection, newSelection);
}
ScrollingUtil.ensureIndexIsVisible(table, newSelection, 0);
if (popup != null) {
setSizeAndDimensions(table, popup, popupPosition, data);
}
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class RunnerContentUi method getTabsAt.
@Nullable
private JBTabs getTabsAt(DockableContent content, RelativePoint point) {
if (content instanceof DockableGrid) {
final Point p = point.getPoint(getComponent());
Component c = SwingUtilities.getDeepestComponentAt(getComponent(), p.x, p.y);
while (c != null) {
if (c instanceof JBRunnerTabs) {
return (JBTabs) c;
}
c = c.getParent();
}
}
return null;
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class DirDiffTableModel method reportException.
private void reportException(final String htmlContent) {
Runnable balloonShower = () -> {
Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(htmlContent, MessageType.WARNING, null).setShowCallout(false).setHideOnClickOutside(true).setHideOnAction(true).setHideOnFrameResize(true).setHideOnKeyOutside(true).createBalloon();
final Rectangle rect = myPanel.getPanel().getBounds();
final Point p = new Point(rect.x + rect.width - 100, rect.y + 50);
final RelativePoint point = new RelativePoint(myPanel.getPanel(), p);
balloon.show(point, Balloon.Position.below);
Disposer.register(myProject != null ? myProject : ApplicationManager.getApplication(), balloon);
};
ApplicationManager.getApplication().invokeLater(balloonShower, o -> !(myProject == null || myProject.isDefault()) && ((!myProject.isOpen()) || myProject.isDisposed()));
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class NewColorAndFontPanel method notifyAtSchemePanel.
private void notifyAtSchemePanel(@NotNull String message) {
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
Balloon balloon = popupFactory.createHtmlTextBalloonBuilder(message, MessageType.INFO, null).setHideOnClickOutside(true).setHideOnKeyOutside(true).createBalloon();
Disposer.register(ApplicationManager.getApplication(), balloon);
balloon.show(new RelativePoint(mySchemesPanel, new Point(mySchemesPanel.getWidth() / 10, mySchemesPanel.getHeight())), Balloon.Position.below);
}
use of com.intellij.ui.awt.RelativePoint in project intellij-community by JetBrains.
the class MultipleFilesHyperlinkInfo method navigate.
@Override
public void navigate(@NotNull final Project project, @Nullable RelativePoint hyperlinkLocationPoint) {
List<PsiFile> currentFiles = new ArrayList<>();
AccessToken accessToken = ReadAction.start();
try {
for (VirtualFile file : myVirtualFiles) {
if (!file.isValid())
continue;
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile != null) {
// Sources may be downloaded.
PsiElement navigationElement = psiFile.getNavigationElement();
if (navigationElement instanceof PsiFile) {
currentFiles.add((PsiFile) navigationElement);
continue;
}
currentFiles.add(psiFile);
}
}
} finally {
accessToken.finish();
}
if (currentFiles.isEmpty())
return;
if (currentFiles.size() == 1) {
new OpenFileHyperlinkInfo(myProject, currentFiles.get(0).getVirtualFile(), myLineNumber).navigate(project);
} else {
final JBList list = new JBList(currentFiles);
int width = WindowManager.getInstance().getFrame(project).getSize().width;
list.setCellRenderer(new GotoFileCellRenderer(width));
JBPopup popup = JBPopupFactory.getInstance().createListPopupBuilder(list).setTitle("Choose Target File").setItemChoosenCallback(() -> {
VirtualFile file = ((PsiFile) list.getSelectedValue()).getVirtualFile();
new OpenFileHyperlinkInfo(myProject, file, myLineNumber).navigate(project);
}).createPopup();
if (hyperlinkLocationPoint != null) {
popup.show(hyperlinkLocationPoint);
} else {
popup.showInFocusCenter();
}
}
}
Aggregations