Object columnItem = rowVector.get(column);
String itemName = "";
if (columnItem instanceof UsageInfo2UsageAdapter)
{
UsageInfo2UsageAdapter usageAdapter = (UsageInfo2UsageAdapter) columnItem;
itemName = usageAdapter.getElement().getContainingFile().getName();
}
if (columnItem instanceof PsiNamedElement)
{
PsiNamedElement psiElement = (PsiNamedElement) columnItem;
itemName = psiElement.getName();
}
else if (columnItem instanceof PsiElement)
{
PsiElement psiElement = (PsiElement) columnItem;
itemName = psiElement.getText();
}
if (itemName.equals(selectionName))
{
itemUnderMouse = columnItem;
break;
}
}
}
if (SwingUtilities.isLeftMouseButton(e))
{
if (itemUnderMouse instanceof PsiElement)
{
PsiElement psiElement = (PsiElement) itemUnderMouse;
VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
FileEditorManager.getInstance(project).openFile(virtualFile, true);
Editor selectedTextEditor = FileEditorManager.getInstance(project).getSelectedTextEditor();
selectedTextEditor.getCaretModel().moveToOffset(psiElement.getTextOffset());
selectedTextEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
if (itemUnderMouse instanceof UsageInfo2UsageAdapter)
{
UsageInfo2UsageAdapter usageAdapter = (UsageInfo2UsageAdapter) itemUnderMouse;
VirtualFile virtualFile = usageAdapter.getFile();
FileEditorManager.getInstance(project).openFile(virtualFile, true);
Editor selectedTextEditor = FileEditorManager.getInstance(project).getSelectedTextEditor();
selectedTextEditor.getCaretModel().moveToOffset(usageAdapter.getUsageInfo().getNavigationOffset());
selectedTextEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
}
}