import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
-import com.intellij.openapi.fileEditor.UniqueVFilePathBuilder;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.fileTypes.PlainTextFileType;
import com.intellij.usages.impl.UsagePreviewPanel;
import com.intellij.util.*;
import com.intellij.util.containers.Convertor;
+import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
return;
}
- myResultsPreviewTable.getColumnModel().getColumn(0).setCellRenderer(new UsageTableCellRenderer());
+ myResultsPreviewTable.getColumnModel().getColumn(0).setCellRenderer(new UsageTableCellRenderer(false, true));
myResultsPreviewTable.getEmptyText().setText("Searching...");
myContent.setTitleAt(RESULTS_PREVIEW_TAB_INDEX, PREVIEW_TITLE);
};
table.setShowColumns(false);
table.setShowGrid(false);
+ table.setIntercellSpacing(JBUI.emptySize());
new NavigateToSourceListener().installOn(table);
Splitter previewSplitter = new Splitter(true, 0.5f, 0.1f, 0.9f);
// skip line number / file info
for (int i = 1; i < text.length; ++i) {
TextChunk textChunk = text[i];
- myUsageRenderer.append(textChunk.getText(), textChunk.getSimpleAttributesIgnoreBackground());
+ SimpleTextAttributes attributes = getAttributes(textChunk);
+ myUsageRenderer.append(textChunk.getText(), attributes);
}
}
setBorder(null);
}
+
+ @NotNull
+ private SimpleTextAttributes getAttributes(@NotNull TextChunk textChunk) {
+ SimpleTextAttributes at = textChunk.getSimpleAttributesIgnoreBackground();
+ if (myUseBold) return at;
+ boolean highlighted = textChunk.getType() != null || at.getFontStyle() == Font.BOLD;
+ return highlighted
+ ? new SimpleTextAttributes(null, at.getFgColor(), at.getWaveColor(),
+ (at.getStyle() & ~SimpleTextAttributes.STYLE_BOLD) |
+ SimpleTextAttributes.STYLE_SEARCH_MATCH)
+ : at;
+ }
};
private final ColoredTableCellRenderer myFileAndLineNumber = new ColoredTableCellRenderer() {
@Override
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
if (value instanceof UsageInfo2UsageAdapter) {
- final UsageInfo2UsageAdapter usageAdapter = (UsageInfo2UsageAdapter)value;
+ UsageInfo2UsageAdapter usageAdapter = (UsageInfo2UsageAdapter)value;
TextChunk[] text = usageAdapter.getPresentation().getText();
- final String uniqueVirtualFilePath =
- UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(usageAdapter.getUsageInfo().getProject(), usageAdapter.getFile());
// line number / file info
+ VirtualFile file = usageAdapter.getFile();
+ String uniqueVirtualFilePath = myOmitFileExtension ? file.getNameWithoutExtension() : file.getName();
append(uniqueVirtualFilePath + " " + text[0].getText(), SimpleTextAttributes.GRAYED_ATTRIBUTES);
}
setBorder(null);
}
};
+ private static final int MARGIN = 2;
+ private final boolean myOmitFileExtension;
+ private final boolean myUseBold;
- UsageTableCellRenderer() {
+ UsageTableCellRenderer(boolean omitFileExtension, boolean useBold) {
+ myOmitFileExtension = omitFileExtension;
+ myUseBold = useBold;
setLayout(new BorderLayout());
-
add(myUsageRenderer, BorderLayout.WEST);
add(myFileAndLineNumber, BorderLayout.EAST);
+ setBorder(IdeBorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, 0));
}
@Override
myUsageRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
myFileAndLineNumber.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setBackground(myUsageRenderer.getBackground());
+ if (!isSelected && value instanceof UsageInfo2UsageAdapter) {
+ UsageInfo2UsageAdapter usageAdapter = (UsageInfo2UsageAdapter)value;
+ Color color = FileColorManager.getInstance(usageAdapter.getUsageInfo().getProject()).getFileColor(usageAdapter.getFile());
+ setBackground(color);
+ myUsageRenderer.setBackground(color);
+ myFileAndLineNumber.setBackground(color);
+ }
return this;
}
}
import static com.intellij.find.impl.FindDialog.createCheckbox;
public class FindPopupPanel extends JBPanel {
- private static final Logger LOG = Logger.getInstance("#com.intellij.find.impl.FindPopupPanel");
- private static final KeyStroke OK_KEYSTROKE = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK);
+ private static final Logger LOG = Logger.getInstance(FindPopupPanel.class);
+ // unify with CommonShortcuts.CTRL_ENTER
+ private static final KeyStroke OK_KEYSTROKE = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, SystemInfo.isMac
+ ? InputEvent.META_DOWN_MASK
+ : InputEvent.CTRL_DOWN_MASK);
private static final KeyStroke MOVE_CARET_DOWN = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0);
private static final KeyStroke MOVE_CARET_UP = KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0);
}
};
myFileMaskField.setPreferredWidth(JBUI.scale(100));
+ myFileMaskField.addDocumentListener(new com.intellij.openapi.editor.event.DocumentAdapter() {
+ @Override
+ public void documentChanged(com.intellij.openapi.editor.event.DocumentEvent e) {
+ scheduleResultsUpdate();
+ }
+ });
myCbFileFilter.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
(ActionToolbarImpl)ActionManager.getInstance().createActionToolbar(ActionPlaces.EDITOR_TOOLBAR, scopeActionGroup, true);
myScopeSelectionToolbar.setForceMinimumSize(true);
myScopeSelectionToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
- myScopeSelectionToolbar.setBorder(new RoundedLineBorder(JBColor.border(), JBUI.scale(5)));
-
Module[] modules = ModuleManager.getInstance(myProject).getModules();
String[] names = new String[modules.length];
myResultsPreviewTable.setShowColumns(false);
myResultsPreviewTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
myResultsPreviewTable.setShowGrid(false);
+ myResultsPreviewTable.setIntercellSpacing(JBUI.emptySize());
new NavigateToSourceListener().installOn(myResultsPreviewTable);
applyFont(JBUI.Fonts.label(), myCbCaseSensitive, myCbPreserveCase, myCbWholeWordsOnly, myCbRegularExpressions,
myResultsPreviewTable);
applyTo(myModel, false);
FindManager.getInstance(myProject).getFindInProjectModel().copyFrom(myModel);
((FindManagerImpl)FindManager.getInstance(myProject)).changeGlobalSettings(myModel);
- FindSettings.getInstance().setDefaultScopeName(myScopeCombo.getSelectedScopeName());
-
+ FindSettings findSettings = FindSettings.getInstance();
+ findSettings.setDefaultScopeName(myScopeCombo.getSelectedScopeName());
+ findSettings.setFileMask(myModel.getFileFilter());
- ValidationInfo result = getValidationInfo(/*findModel*/myModel);
+ ValidationInfo result = getValidationInfo(myModel);
final ProgressIndicatorBase progressIndicatorWhenSearchStarted = new ProgressIndicatorBase();
myResultsPreviewSearchProgress = progressIndicatorWhenSearchStarted;
return;
}
- myResultsPreviewTable.getColumnModel().getColumn(0).setCellRenderer(new FindDialog.UsageTableCellRenderer());
+ myResultsPreviewTable.getColumnModel().getColumn(0).setCellRenderer(new FindDialog.UsageTableCellRenderer(myCbFileFilter.isSelected(), false));
myResultsPreviewTable.getEmptyText().setText("Searching...");
final AtomicInteger resultsCount = new AtomicInteger();
@Override
public void computeInReadAction(@NotNull ProgressIndicator indicator) {
final UsageViewPresentation presentation =
- FindInProjectUtil.setupViewPresentation(FindSettings.getInstance().isShowResultsInSeparateView(), /*findModel*/myModel.clone());
- final boolean showPanelIfOnlyOneUsage = !FindSettings.getInstance().isSkipResultsWithOneUsage();
+ FindInProjectUtil.setupViewPresentation(findSettings.isShowResultsInSeparateView(), /*findModel*/myModel.clone());
+ final boolean showPanelIfOnlyOneUsage = !findSettings.isSkipResultsWithOneUsage();
final FindUsagesProcessPresentation processPresentation =
FindInProjectUtil.setupProcessPresentation(myProject, showPanelIfOnlyOneUsage, presentation);
public void run() {
JPanel popupContent = new JPanel(new BorderLayout());
popupContent.setName("PopupContent!!!");
- Splitter splitter = new JBSplitter(true, .33F, .1F, .5F);
+ Splitter splitter = new JBSplitter(true, .33F);
splitter.setDividerWidth(1);
- splitter.setFirstComponent(new JBScrollPane(myResultsPreviewTable) {
+ splitter.getDivider().setBackground(OnePixelDivider.BACKGROUND);
+ JBScrollPane scrollPane = new JBScrollPane(myResultsPreviewTable) {
@Override
public Dimension getMinimumSize() {
Dimension size = super.getMinimumSize();
size.height = Math.max(size.height, myResultsPreviewTable.getPreferredScrollableViewportSize().height);
return size;
}
- });
+ };
+ scrollPane.setBorder(IdeBorderFactory.createEmptyBorder());
+ splitter.setFirstComponent(scrollPane);
popupContent.add(splitter, BorderLayout.CENTER);
JPanel bottomPanel = new JPanel(new MigLayout("flowx, ins 4, fillx, hidemode 3, gap 0"));
bottomPanel.add(myTabResultsButton);
bottomPanel.add(Box.createHorizontalGlue(), "growx, pushx");
- JBLabel label = new JBLabel("Ctrl+Enter");
+ JBLabel label = new JBLabel(KeymapUtil.getShortcutsText(new Shortcut[]{new KeyboardShortcut(OK_KEYSTROKE, null)}));
label.setEnabled(false);
bottomPanel.add(label, "gapright 10");
bottomPanel.add(myOKButton);
popupContent.registerKeyboardAction(myOkActionListener, OK_KEYSTROKE, WHEN_IN_FOCUSED_WINDOW);
-
myCodePreviewComponent = myUsagePreviewPanel.createComponent();
+ myCodePreviewComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
splitter.setSecondComponent(myCodePreviewComponent);
AtomicBoolean canClose = new AtomicBoolean();