new renderer

This commit is contained in:
Konstantin Bulenkov
2013-08-26 14:32:09 +02:00
parent 9ea47a52fc
commit e36607b4bf
@@ -24,6 +24,7 @@ import com.intellij.ide.ui.LafManagerListener;
import com.intellij.ide.ui.search.BooleanOptionDescription;
import com.intellij.ide.ui.search.OptionDescription;
import com.intellij.ide.ui.search.SearchableOptionsRegistrarImpl;
import com.intellij.ide.util.DefaultPsiElementCellRenderer;
import com.intellij.ide.util.gotoByName.*;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
@@ -56,6 +57,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.codeStyle.MinusculeMatcher;
import com.intellij.psi.codeStyle.NameUtil;
import com.intellij.psi.util.PsiUtilCore;
@@ -302,6 +304,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
final Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(field.getTextEditor()));
assert project != null;
myRenderer.myProject = project;
myCalcThread = new CalcThread(project, pattern);
myCalcThread.start();
}
@@ -350,7 +353,9 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
}
};
private String myLocationString;
private DefaultPsiElementCellRenderer myPsiRenderer = new DefaultPsiElementCellRenderer();
private Icon myLocationIcon;
private Project myProject;
private JPanel myMainPanel = new JPanel(new BorderLayout());
private JLabel myTitle = new JLabel();
private JPanel myLeftPanel = new JPanel(new BorderLayout()) {
@@ -383,7 +388,16 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component cmp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
Component cmp;
PsiFile file;
myLocationString = null;
if (value instanceof VirtualFile && myProject != null && (file = PsiManager.getInstance(myProject).findFile((VirtualFile)value)) != null) {
cmp = new GotoFileCellRenderer(list.getWidth()).getListCellRendererComponent(list, file, index, isSelected, cellHasFocus);
} else if (value instanceof PsiElement) {
cmp = myPsiRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
} else {
cmp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
}
if (myLocationString != null || value instanceof BooleanOptionDescription) {
final JPanel panel = new JPanel(new BorderLayout());
panel.add(cmp, BorderLayout.CENTER);
@@ -490,7 +504,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
index++;
}
myLeftWidth += 10;
//myLeftWidth += 10;
myTitle.setForeground(Gray._122);
myTitle.setAlignmentY(BOTTOM_ALIGNMENT);
myLeftPanel.setBorder(new CompoundBorder(new CustomLineBorder(getSeparatorColor(), 0, 0, 0, 1), new EmptyBorder(0, 0, 0, 5)));
@@ -863,9 +877,11 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
@SuppressWarnings("SSBasedInspection")
private void updatePopup() {
myProgressIndicator.checkCanceled();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
myProgressIndicator.checkCanceled();
myListModel.update();
myList.revalidate();
myList.repaint();
@@ -911,8 +927,8 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
sz.width++;
sz.width++;
}
sz.width = 600;
sz.height = 800;
sz.width = Math.max(600, sz.width);
sz.height = Math.max(800, sz.height);
myPopup.setSize(sz);
final Point screen = field.getLocationOnScreen();
final int x = screen.x + field.getWidth() - myPopup.getSize().width;