diff --git a/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsAction.java b/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsAction.java index 5e485366c423..451bd183f4ad 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsAction.java @@ -39,8 +39,10 @@ import com.intellij.openapi.wm.ex.WindowManagerEx; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.ScrollingUtil; import com.intellij.ui.WindowMoveListener; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; import com.intellij.ui.components.breadcrumbs.Crumb; +import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.ui.speedSearch.ListWithFilter; import com.intellij.ui.speedSearch.NameFilteringListModel; import com.intellij.ui.speedSearch.SpeedSearch; @@ -49,11 +51,11 @@ import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.messages.Topic; import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.border.Border; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -106,7 +108,7 @@ public class RecentLocationsAction extends AnAction { ScrollingUtil.ensureSelectionExists(list); JLabel title = createTitle(showChanged); - JPanel topPanel = createTopPanel(createCheckbox(project, listWithFilter, e, showChanged), title); + JPanel topPanel = createHeaderPanel(title, createCheckbox(project, listWithFilter, e, showChanged)); JPanel mainPanel = createMainPanel(listWithFilter, topPanel); Ref navigationRef = Ref.create(false); @@ -123,7 +125,6 @@ public class RecentLocationsAction extends AnAction { }) .setResizable(true) .setMovable(true) - .setShowBorder(false) .setDimensionServiceKey(project, LOCATION_SETTINGS_KEY, true) .setMinSize(new Dimension(DEFAULT_POPUP_WIDTH, JBUI.scale(100))) .createPopup(); @@ -230,27 +231,18 @@ public class RecentLocationsAction extends AnAction { private static JPanel createMainPanel(@NotNull ListWithFilter listWithFilter, @NotNull JPanel topPanel) { JPanel mainPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false)); mainPanel.add(topPanel); - JLabel line = createLine(); - mainPanel.add(line); mainPanel.add(listWithFilter); mainPanel.setBorder(BorderFactory.createEmptyBorder()); return mainPanel; } @NotNull - private static JLabel createLine() { - JLabel line = new JLabel(); - Border bottom = JBUI.Borders.customLine(JBUI.CurrentTheme.Popup.separatorTextColor(), 0, 0, 1, 0); - line.setBorder(bottom); - return line; - } - - @NotNull - private static JPanel createTopPanel(@NotNull JComponent checkbox, @NotNull JLabel title) { - JPanel topPanel = new JPanel(new BorderLayout()); + private static JPanel createHeaderPanel(@NotNull JLabel title, @NotNull JComponent checkbox) { + JPanel topPanel = new NonOpaquePanel(new BorderLayout()); topPanel.add(title, BorderLayout.WEST); topPanel.add(checkbox, BorderLayout.EAST); - topPanel.setBorder(BorderFactory.createEmptyBorder(2, 5, 2, 5)); + topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + topPanel.setBackground(JBUI.CurrentTheme.Popup.headerBackground(true)); WindowMoveListener moveListener = new WindowMoveListener(topPanel); topPanel.addMouseListener(moveListener); @@ -275,14 +267,15 @@ public class RecentLocationsAction extends AnAction { action.getTemplatePresentation().putClientProperty(COMPONENT_KEY, checkbox); action.setSelected(event, changed); checkbox.setBorder(BorderFactory.createEmptyBorder()); + checkbox.setForeground(UIUtil.getContextHelpForeground()); return checkbox; } @NotNull private static JLabel createTitle(boolean showChanged) { - JLabel title = new JLabel(); - title.setBorder(BorderFactory.createEmptyBorder()); + JBLabel title = new JBLabel(); + title.setFont(title.getFont().deriveFont(Font.BOLD)); updateTitleText(title, showChanged); return title; } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsRenderer.java b/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsRenderer.java index 3560ae659000..915b807cbf9c 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsRenderer.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/RecentLocationsRenderer.java @@ -6,6 +6,7 @@ import com.intellij.openapi.editor.CaretState; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.actions.EditorActionUtil; import com.intellij.openapi.editor.ex.EditorEx; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.impl.IdeDocumentHistoryImpl; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.VerticalFlowLayout; @@ -23,9 +24,10 @@ import java.awt.*; import java.util.ArrayList; import java.util.Iterator; +import static com.intellij.ide.actions.RecentLocationsAction.getBreadcrumbs; + class RecentLocationsRenderer extends ColoredListCellRenderer { private static final JBColor BACKGROUND_COLOR = JBColor.namedColor("Table.lightSelectionBackground", new JBColor(0xE9EEF5, 0x464A4D)); - private static final Color TITLE_FOREGROUND_COLOR = UIUtil.getLabelForeground().darker(); @NotNull private final Project myProject; @NotNull private final SpeedSearch mySpeedSearch; @@ -46,47 +48,51 @@ class RecentLocationsRenderer extends ColoredListCellRenderer list, + @NotNull SpeedSearch speedSearch, + @NotNull String breadcrumb, + @NotNull IdeDocumentHistoryImpl.PlaceInfo placeInfo, + @NotNull Color background, + boolean selected) { + JComponent title = JBUI.Panels + .simplePanel() + .addToLeft(createTitleTextComponent(list, speedSearch, placeInfo, breadcrumb, selected)) + .addToCenter(createTitledSeparator(background)); + + title.setBorder(BorderFactory.createEmptyBorder(2, 0, 1, 0)); + title.setBackground(background); + + return title; + } + + @NotNull + private static TitledSeparator createTitledSeparator(@NotNull Color background) { + TitledSeparator titledSeparator = new TitledSeparator(); + titledSeparator.setBorder(BorderFactory.createEmptyBorder()); titledSeparator.setBackground(background); return titledSeparator; } - private static void addEditorComponent(@NotNull JPanel panel, - @NotNull EditorEx editor, - @NotNull String text, - @NotNull Color background, - @NotNull SpeedSearch speedSearch) { - editor.setBackgroundColor(background); + @NotNull + private static JComponent setupEditorComponent(@NotNull EditorEx editor, + @NotNull String text, + @NotNull SpeedSearch speedSearch, + @NotNull Color backgroundColor) { Iterable ranges = speedSearch.matchingFragments(text); - if (ranges != null) { selectSearchResultsInEditor(editor, ranges.iterator()); } @@ -94,49 +100,43 @@ class RecentLocationsRenderer extends ColoredListCellRenderer list, - @NotNull SpeedSearch speedSearch, - @NotNull String breadcrumb, - @NotNull Color background, - boolean selected) { - SimpleColoredComponent breadcrumbTextComponent = new SimpleColoredComponent(); - breadcrumbTextComponent.setForeground(TITLE_FOREGROUND_COLOR); - breadcrumbTextComponent.setBackground(background); - breadcrumbTextComponent.append(breadcrumb); - Iterable breadCrumbRanges = speedSearch.matchingFragments(breadcrumb); - if (breadCrumbRanges != null) { - SpeedSearchUtil.applySpeedSearchHighlighting(list, breadcrumbTextComponent, true, selected); + private static SimpleColoredComponent createTitleTextComponent(@NotNull JList list, + @NotNull SpeedSearch speedSearch, + @NotNull IdeDocumentHistoryImpl.PlaceInfo placeInfo, + @NotNull String breadcrumbText, + boolean selected) { + SimpleColoredComponent titleTextComponent = new SimpleColoredComponent(); + titleTextComponent.append(breadcrumbText); + + String text = breadcrumbText; + String fileName = placeInfo.getFile().getName(); + if (!StringUtil.equals(breadcrumbText, fileName)) { + text += " " + fileName; + titleTextComponent.append(" "); + titleTextComponent.append(fileName, createLabelDisabledForegroundAttributes()); } - return breadcrumbTextComponent; + if (speedSearch.matchingFragments(text) != null) { + SpeedSearchUtil.applySpeedSearchHighlighting(list, titleTextComponent, false, selected); + } + + titleTextComponent.setBorder(BorderFactory.createEmptyBorder()); + + return titleTextComponent; } @NotNull - private static SimpleColoredComponent createFileNameComponent(@NotNull JList list, - @NotNull SpeedSearch speedSearch, - @NotNull String breadcrumb, - @NotNull IdeDocumentHistoryImpl.PlaceInfo placeInfo, - boolean selected) { - SimpleColoredComponent fileNameComponent = new SimpleColoredComponent(); - fileNameComponent.setForeground(TITLE_FOREGROUND_COLOR); - if (!StringUtil.equals(breadcrumb, placeInfo.getFile().getName())) { - fileNameComponent.append(placeInfo.getFile().getName()); - fileNameComponent.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 2)); - Iterable fileNameRanges = speedSearch.matchingFragments(placeInfo.getFile().getName()); - if (fileNameRanges != null) { - SpeedSearchUtil.applySpeedSearchHighlighting(list, fileNameComponent, true, selected); - } - } - - return fileNameComponent; + private static SimpleTextAttributes createLabelDisabledForegroundAttributes() { + TextAttributes textAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES.toTextAttributes(); + textAttributes.setForegroundColor(UIUtil.getLabelDisabledForeground()); + return SimpleTextAttributes.fromTextAttributes(textAttributes); } @Override @@ -147,18 +147,6 @@ class RecentLocationsRenderer extends ColoredListCellRenderer resultIterator) { if (!editor.getCaretModel().supportsMultipleCarets()) { return; diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index 64c450a79f7b..a8a32d576f3e 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -472,10 +472,10 @@ command.select.all=Select All message.no.targets.available=No targets available in this context title.popup.select.target=Select In title.popup.recent.files=Recent Files -recent.locations.popup.title=Recent locations -recent.locations.changed.locations=Recent changed locations +recent.locations.popup.title=Recent Locations +recent.locations.changed.locations=Recent Changed Locations recent.locations.popup.empty.text=No recent locations found -recent.locations.title.text=Changed locations ({0}) +recent.locations.title.text=Show Changed Locations {0} action.split.vertically=Split _Vertically action.split.horizontally=Split Hori_zontally action.sync.completed.successfully={0} completed successfully.