mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -22,7 +22,6 @@ import com.intellij.find.actions.ShowUsagesAction;
|
||||
import com.intellij.ide.util.scopeChooser.ScopeChooserCombo;
|
||||
import com.intellij.ide.util.scopeChooser.ScopeDescriptor;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
@@ -83,8 +82,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.text.JTextComponent;
|
||||
@@ -96,8 +93,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import static com.intellij.ui.SimpleTextAttributes.STYLE_PLAIN;
|
||||
|
||||
public class FindDialog extends DialogWrapper implements FindUI {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.find.impl.FindDialog");
|
||||
private final FindUIHelper myHelper;
|
||||
@@ -159,7 +154,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
@Override
|
||||
public void showUI() {
|
||||
if (haveResultsPreview()) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> scheduleResultsUpdate(), ModalityState.any());
|
||||
ApplicationManager.getApplication().invokeLater(this::scheduleResultsUpdate, ModalityState.any());
|
||||
}
|
||||
show();
|
||||
}
|
||||
@@ -270,12 +265,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
comboBox.setEditable(true);
|
||||
comboBox.setMaximumRowCount(8);
|
||||
|
||||
comboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
validateFindButton();
|
||||
}
|
||||
});
|
||||
comboBox.addActionListener(__ -> validateFindButton());
|
||||
|
||||
final Component editorComponent = comboBox.getEditor().getEditorComponent();
|
||||
|
||||
@@ -301,12 +291,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
}
|
||||
};
|
||||
document.addDocumentListener(documentAdapter);
|
||||
Disposer.register(myDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
document.removeDocumentListener(documentAdapter);
|
||||
}
|
||||
});
|
||||
Disposer.register(myDisposable, () -> document.removeDocumentListener(documentAdapter));
|
||||
} else {
|
||||
assert false;
|
||||
}
|
||||
@@ -624,21 +609,18 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
registerNavigateToSourceShortcutOnComponent(table, myUsagePreviewPanel);
|
||||
myResultsPreviewTable = table;
|
||||
new TableSpeedSearch(table, o -> ((UsageInfo2UsageAdapter)o).getFile().getName());
|
||||
myResultsPreviewTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (e.getValueIsAdjusting()) return;
|
||||
int index = myResultsPreviewTable.getSelectionModel().getLeadSelectionIndex();
|
||||
if (index != -1) {
|
||||
UsageInfo usageInfo = ((UsageInfo2UsageAdapter)myResultsPreviewTable.getModel().getValueAt(index, 0)).getUsageInfo();
|
||||
myUsagePreviewPanel.updateLayout(usageInfo.isValid() ? Collections.singletonList(usageInfo) : null);
|
||||
VirtualFile file = usageInfo.getVirtualFile();
|
||||
myUsagePreviewPanel.setBorder(IdeBorderFactory.createTitledBorder(file != null ? file.getPath() : "", false));
|
||||
}
|
||||
else {
|
||||
myUsagePreviewPanel.updateLayout(null);
|
||||
myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder());
|
||||
}
|
||||
myResultsPreviewTable.getSelectionModel().addListSelectionListener(e -> {
|
||||
if (e.getValueIsAdjusting()) return;
|
||||
int index = myResultsPreviewTable.getSelectionModel().getLeadSelectionIndex();
|
||||
if (index != -1) {
|
||||
UsageInfo usageInfo = ((UsageInfo2UsageAdapter)myResultsPreviewTable.getModel().getValueAt(index, 0)).getUsageInfo();
|
||||
myUsagePreviewPanel.updateLayout(usageInfo.isValid() ? Collections.singletonList(usageInfo) : null);
|
||||
VirtualFile file = usageInfo.getVirtualFile();
|
||||
myUsagePreviewPanel.setBorder(IdeBorderFactory.createTitledBorder(file != null ? file.getPath() : "", false));
|
||||
}
|
||||
else {
|
||||
myUsagePreviewPanel.updateLayout(null);
|
||||
myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder());
|
||||
}
|
||||
});
|
||||
mySearchRescheduleOnCancellationsAlarm = new Alarm();
|
||||
@@ -719,12 +701,9 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
filterPanel.add(myUseFileFilter = createCheckbox(FindBundle.message("find.filter.file.mask.checkbox")),BorderLayout.WEST);
|
||||
filterPanel.add(myFileFilter,BorderLayout.CENTER);
|
||||
initFileFilter(myFileFilter, myUseFileFilter);
|
||||
myUseFileFilter.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
scheduleResultsUpdate();
|
||||
validateFindButton();
|
||||
}
|
||||
myUseFileFilter.addActionListener(__ -> {
|
||||
scheduleResultsUpdate();
|
||||
validateFindButton();
|
||||
});
|
||||
return filterPanel;
|
||||
}
|
||||
@@ -738,17 +717,14 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
fileFilter.setEnabled(false);
|
||||
|
||||
useFileFilter.addActionListener(
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (useFileFilter.isSelected()) {
|
||||
fileFilter.setEnabled(true);
|
||||
fileFilter.getEditor().selectAll();
|
||||
fileFilter.getEditor().getEditorComponent().requestFocusInWindow();
|
||||
}
|
||||
else {
|
||||
fileFilter.setEnabled(false);
|
||||
}
|
||||
__ -> {
|
||||
if (useFileFilter.isSelected()) {
|
||||
fileFilter.setEnabled(true);
|
||||
fileFilter.getEditor().selectAll();
|
||||
fileFilter.getEditor().getEditorComponent().requestFocusInWindow();
|
||||
}
|
||||
else {
|
||||
fileFilter.setEnabled(false);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -864,12 +840,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
|
||||
myCbCaseSensitive = createCheckbox(FindBundle.message("find.options.case.sensitive"));
|
||||
findOptionsPanel.add(myCbCaseSensitive);
|
||||
ItemListener liveResultsPreviewUpdateListener = new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
scheduleResultsUpdate();
|
||||
}
|
||||
};
|
||||
ItemListener liveResultsPreviewUpdateListener = __ -> scheduleResultsUpdate();
|
||||
myCbCaseSensitive.addItemListener(liveResultsPreviewUpdateListener);
|
||||
|
||||
myCbPreserveCase = createCheckbox(FindBundle.message("find.options.replace.preserve.case"));
|
||||
@@ -899,12 +870,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
getPresentableName(FindModel.SearchContext.EXCEPT_COMMENTS),
|
||||
getPresentableName(FindModel.SearchContext.EXCEPT_STRING_LITERALS),
|
||||
getPresentableName(FindModel.SearchContext.EXCEPT_COMMENTS_AND_STRING_LITERALS)});
|
||||
mySearchContext.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
scheduleResultsUpdate();
|
||||
}
|
||||
});
|
||||
mySearchContext.addActionListener(__ -> scheduleResultsUpdate());
|
||||
final JPanel searchContextPanel = new JPanel(new BorderLayout());
|
||||
searchContextPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
|
||||
@@ -921,19 +887,9 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
|
||||
findOptionsPanel.add(searchContextPanel);
|
||||
|
||||
ActionListener actionListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateControls();
|
||||
}
|
||||
};
|
||||
ActionListener actionListener = __ -> updateControls();
|
||||
myCbRegularExpressions.addActionListener(actionListener);
|
||||
myCbRegularExpressions.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent e) {
|
||||
setupRegExpSetting();
|
||||
}
|
||||
});
|
||||
myCbRegularExpressions.addItemListener(__ -> setupRegExpSetting());
|
||||
|
||||
myCbCaseSensitive.addActionListener(actionListener);
|
||||
myCbPreserveCase.addActionListener(actionListener);
|
||||
@@ -960,7 +916,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FindModel.SearchContext parseSearchContext(String presentableName) {
|
||||
static FindModel.SearchContext parseSearchContext(String presentableName) {
|
||||
FindModel.SearchContext searchContext = FindModel.SearchContext.ANY;
|
||||
if (FindBundle.message("find.context.in.literals.scope.label").equals(presentableName)) {
|
||||
searchContext = FindModel.SearchContext.IN_STRING_LITERALS;
|
||||
@@ -980,7 +936,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getSearchContextName(FindModel model) {
|
||||
static String getSearchContextName(FindModel model) {
|
||||
String searchContext = FindBundle.message("find.context.anywhere.scope.label");
|
||||
if (model.isInCommentsOnly()) searchContext = FindBundle.message("find.context.in.comments.scope.label");
|
||||
else if (model.isInStringLiteralsOnly()) searchContext = FindBundle.message("find.context.in.literals.scope.label");
|
||||
@@ -1083,12 +1039,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
? FindBundle.message("find.scope.all.projects.radio")
|
||||
: FindBundle.message("find.scope.whole.project.radio"), true);
|
||||
scopePanel.add(myRbProject, gbConstraints);
|
||||
ItemListener resultsPreviewUpdateListener = new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
scheduleResultsUpdate();
|
||||
}
|
||||
};
|
||||
ItemListener resultsPreviewUpdateListener = __ -> scheduleResultsUpdate();
|
||||
myRbProject.addItemListener(resultsPreviewUpdateListener);
|
||||
|
||||
gbConstraints.gridx = 0;
|
||||
@@ -1112,12 +1063,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
|
||||
Arrays.sort(names,String.CASE_INSENSITIVE_ORDER);
|
||||
myModuleComboBox = new ComboBox(names);
|
||||
myModuleComboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
scheduleResultsUpdate();
|
||||
}
|
||||
});
|
||||
myModuleComboBox.addActionListener(__ -> scheduleResultsUpdate());
|
||||
scopePanel.add(myModuleComboBox, gbConstraints);
|
||||
|
||||
if (modules.length == 1) {
|
||||
@@ -1143,12 +1089,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
}
|
||||
initCombobox(myDirectoryComboBox);
|
||||
myDirectoryComboBox.setSwingPopup(false);
|
||||
myDirectoryComboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
scheduleResultsUpdate();
|
||||
}
|
||||
});
|
||||
myDirectoryComboBox.addActionListener(__ -> scheduleResultsUpdate());
|
||||
scopePanel.add(myDirectoryComboBox, gbConstraints);
|
||||
|
||||
gbConstraints.weightx = 0;
|
||||
@@ -1195,12 +1136,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
return /*!projectFilesScopeName.equals(display) &&*/ !display.startsWith(moduleFilesScopeName);
|
||||
}
|
||||
});
|
||||
myScopeCombo.getComboBox().addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
scheduleResultsUpdate();
|
||||
}
|
||||
});
|
||||
myScopeCombo.getComboBox().addActionListener(__ -> scheduleResultsUpdate());
|
||||
myRbCustomScope.addItemListener(resultsPreviewUpdateListener);
|
||||
|
||||
Disposer.register(myDisposable, myScopeCombo);
|
||||
@@ -1213,60 +1149,45 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
bgScope.add(myRbDirectory);
|
||||
bgScope.add(myRbCustomScope);
|
||||
|
||||
myRbProject.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
validateScopeControls();
|
||||
validateFindButton();
|
||||
}
|
||||
myRbProject.addActionListener(__ -> {
|
||||
validateScopeControls();
|
||||
validateFindButton();
|
||||
});
|
||||
myRbCustomScope.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
validateScopeControls();
|
||||
validateFindButton();
|
||||
myScopeCombo.getComboBox().requestFocusInWindow();
|
||||
}
|
||||
myRbCustomScope.addActionListener(__ -> {
|
||||
validateScopeControls();
|
||||
validateFindButton();
|
||||
myScopeCombo.getComboBox().requestFocusInWindow();
|
||||
});
|
||||
|
||||
myRbDirectory.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
validateScopeControls();
|
||||
validateFindButton();
|
||||
myDirectoryComboBox.getEditor().getEditorComponent().requestFocusInWindow();
|
||||
}
|
||||
myRbDirectory.addActionListener(__ -> {
|
||||
validateScopeControls();
|
||||
validateFindButton();
|
||||
myDirectoryComboBox.getEditor().getEditorComponent().requestFocusInWindow();
|
||||
});
|
||||
|
||||
myRbModule.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
validateScopeControls();
|
||||
validateFindButton();
|
||||
myModuleComboBox.requestFocusInWindow();
|
||||
}
|
||||
myRbModule.addActionListener(__ -> {
|
||||
validateScopeControls();
|
||||
validateFindButton();
|
||||
myModuleComboBox.requestFocusInWindow();
|
||||
});
|
||||
|
||||
mySelectDirectoryButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
|
||||
FileChooser.chooseFiles(descriptor, myProject, null, files -> myDirectoryComboBox.setSelectedItem(files.get(0).getPresentableUrl()));
|
||||
}
|
||||
mySelectDirectoryButton.addActionListener(__ -> {
|
||||
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
|
||||
FileChooser.chooseFiles(descriptor, myProject, null, files -> myDirectoryComboBox.setSelectedItem(files.get(0).getPresentableUrl()));
|
||||
});
|
||||
|
||||
return scopePanel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static StateRestoringCheckBox createCheckbox(@NotNull String message) {
|
||||
private static StateRestoringCheckBox createCheckbox(@NotNull String message) {
|
||||
final StateRestoringCheckBox cb = new StateRestoringCheckBox(message);
|
||||
cb.setFocusable(false);
|
||||
return cb;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static StateRestoringCheckBox createCheckbox(boolean selected, @NotNull String message) {
|
||||
private static StateRestoringCheckBox createCheckbox(boolean selected, @NotNull String message) {
|
||||
final StateRestoringCheckBox cb = new StateRestoringCheckBox(message, selected);
|
||||
cb.setFocusable(false);
|
||||
return cb;
|
||||
@@ -1300,12 +1221,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
bgScope.add(myRbGlobal);
|
||||
bgScope.add(myRbSelectedText);
|
||||
|
||||
ActionListener actionListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
updateControls();
|
||||
}
|
||||
};
|
||||
ActionListener actionListener = __ -> updateControls();
|
||||
myRbGlobal.addActionListener(actionListener);
|
||||
myRbSelectedText.addActionListener(actionListener);
|
||||
|
||||
@@ -1432,7 +1348,7 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
SearchScope selectedScope = myScopeCombo.getSelectedScope();
|
||||
String customScopeName = selectedScope == null ? null : selectedScope.getDisplayName();
|
||||
model.setCustomScopeName(customScopeName);
|
||||
model.setCustomScope(selectedScope == null ? null : selectedScope);
|
||||
model.setCustomScope(selectedScope);
|
||||
model.setCustomScope(true);
|
||||
}
|
||||
}
|
||||
@@ -1622,8 +1538,8 @@ public class FindDialog extends DialogWrapper implements FindUI {
|
||||
}
|
||||
};
|
||||
private final ColoredTableCellRenderer myFileAndLineNumber = new ColoredTableCellRenderer() {
|
||||
private final SimpleTextAttributes REPEATED_FILE_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, new JBColor(0xCCCCCC, 0x5E5E5E));
|
||||
private final SimpleTextAttributes ORDINAL_ATTRIBUTES = new SimpleTextAttributes(STYLE_PLAIN, new JBColor(0x999999, 0x999999));
|
||||
private final SimpleTextAttributes REPEATED_FILE_ATTRIBUTES = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new JBColor(0xCCCCCC, 0x5E5E5E));
|
||||
private final SimpleTextAttributes ORDINAL_ATTRIBUTES = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new JBColor(0x999999, 0x999999));
|
||||
|
||||
@Override
|
||||
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.intellij.notification.NotificationDisplayType;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.impl.NotificationsConfigurationImpl;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.IdeActions;
|
||||
@@ -91,14 +90,14 @@ public class FindManagerImpl extends FindManager {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.find.impl.FindManagerImpl");
|
||||
|
||||
private final FindUsagesManager myFindUsagesManager;
|
||||
private boolean isFindWasPerformed = false;
|
||||
private boolean isSelectNextOccurrenceWasPerformed = false;
|
||||
private boolean isFindWasPerformed;
|
||||
private boolean isSelectNextOccurrenceWasPerformed;
|
||||
private Point myReplaceInFilePromptPos = new Point(-1, -1);
|
||||
private Point myReplaceInProjectPromptPos = new Point(-1, -1);
|
||||
private final FindModel myFindInProjectModel = new FindModel();
|
||||
private final FindModel myFindInFileModel = new FindModel();
|
||||
private FindModel myFindNextModel = null;
|
||||
private FindModel myPreviousFindModel = null;
|
||||
private FindModel myFindNextModel;
|
||||
private FindModel myPreviousFindModel;
|
||||
private static final FindResultImpl NOT_FOUND_RESULT = new FindResultImpl();
|
||||
private final Project myProject;
|
||||
private final MessageBus myBus;
|
||||
@@ -120,12 +119,9 @@ public class FindManagerImpl extends FindManager {
|
||||
myFindInProjectModel.setMultipleFiles(true);
|
||||
|
||||
NotificationsConfigurationImpl.remove("FindInPath");
|
||||
Disposer.register(project, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (myHelper != null) {
|
||||
Disposer.dispose(myHelper);
|
||||
}
|
||||
Disposer.register(project, () -> {
|
||||
if (myHelper != null) {
|
||||
Disposer.dispose(myHelper);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -145,7 +141,9 @@ public class FindManagerImpl extends FindManager {
|
||||
}
|
||||
|
||||
@PromptResultValue
|
||||
public int showPromptDialogImpl(@NotNull final FindModel model, String title, @Nullable final MalformedReplacementStringException exception) {
|
||||
private int showPromptDialogImpl(@NotNull final FindModel model,
|
||||
String title,
|
||||
@Nullable final MalformedReplacementStringException exception) {
|
||||
ReplacePromptDialog replacePromptDialog = new ReplacePromptDialog(model.isMultipleFiles(), title, myProject, exception) {
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -195,12 +193,7 @@ public class FindManagerImpl extends FindManager {
|
||||
public void showFindDialog(@NotNull FindModel model, @NotNull Runnable okHandler) {
|
||||
if (myHelper == null || Disposer.isDisposed(myHelper)) {
|
||||
myHelper = new FindUIHelper(myProject, model, okHandler);
|
||||
Disposer.register(myHelper, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
myHelper = null;
|
||||
}
|
||||
});
|
||||
Disposer.register(myHelper, () -> myHelper = null);
|
||||
}
|
||||
else {
|
||||
myHelper.setModel(model);
|
||||
@@ -376,7 +369,7 @@ public class FindManagerImpl extends FindManager {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private static Key<FindExceptCommentsOrLiteralsData> ourExceptCommentsOrLiteralsDataKey = Key.create("except.comments.literals.search.data");
|
||||
private static final Key<FindExceptCommentsOrLiteralsData> ourExceptCommentsOrLiteralsDataKey = Key.create("except.comments.literals.search.data");
|
||||
|
||||
private Predicate<FindResult> getFindContextPredicate(@NotNull FindModel model, VirtualFile file, CharSequence text) {
|
||||
if (file == null) return null;
|
||||
@@ -505,7 +498,7 @@ public class FindManagerImpl extends FindManager {
|
||||
return new StringSearcher(model.getStringToFind(), model.isCaseSensitive(), model.isForward());
|
||||
}
|
||||
|
||||
public static void clearPreviousFindData(FindModel model) {
|
||||
static void clearPreviousFindData(FindModel model) {
|
||||
synchronized (model) {
|
||||
model.putUserData(ourCommentsLiteralsSearchDataKey, null);
|
||||
model.putUserData(ourExceptCommentsOrLiteralsDataKey, null);
|
||||
@@ -514,7 +507,7 @@ public class FindManagerImpl extends FindManager {
|
||||
|
||||
private static class CommentsLiteralsSearchData {
|
||||
final VirtualFile lastFile;
|
||||
int startOffset = 0;
|
||||
int startOffset;
|
||||
final SyntaxHighlighterOverEditorHighlighter highlighter;
|
||||
|
||||
TokenSet tokensOfInterest;
|
||||
@@ -523,9 +516,9 @@ public class FindManagerImpl extends FindManager {
|
||||
final Set<Language> relevantLanguages;
|
||||
final FindModel model;
|
||||
|
||||
public CommentsLiteralsSearchData(VirtualFile lastFile, Set<Language> relevantLanguages,
|
||||
SyntaxHighlighterOverEditorHighlighter highlighter, TokenSet tokensOfInterest,
|
||||
StringSearcher searcher, Matcher matcher, FindModel model) {
|
||||
CommentsLiteralsSearchData(VirtualFile lastFile, Set<Language> relevantLanguages,
|
||||
SyntaxHighlighterOverEditorHighlighter highlighter, TokenSet tokensOfInterest,
|
||||
StringSearcher searcher, Matcher matcher, FindModel model) {
|
||||
this.lastFile = lastFile;
|
||||
this.highlighter = highlighter;
|
||||
this.tokensOfInterest = tokensOfInterest;
|
||||
@@ -636,8 +629,8 @@ public class FindManagerImpl extends FindManager {
|
||||
final TextAttributesKey[] keys = data.highlighter.getTokenHighlights(tokenType);
|
||||
|
||||
if (tokens.contains(tokenType) ||
|
||||
(model.isInStringLiteralsOnly() && ChunkExtractor.isHighlightedAsString(keys)) ||
|
||||
(model.isInCommentsOnly() && ChunkExtractor.isHighlightedAsComment(keys))
|
||||
model.isInStringLiteralsOnly() && ChunkExtractor.isHighlightedAsString(keys) ||
|
||||
model.isInCommentsOnly() && ChunkExtractor.isHighlightedAsComment(keys)
|
||||
) {
|
||||
int start = lexer.getTokenStart();
|
||||
int end = lexer.getTokenEnd();
|
||||
@@ -727,7 +720,8 @@ public class FindManagerImpl extends FindManager {
|
||||
return tokensOfInterest;
|
||||
}
|
||||
|
||||
private static @Nullable SyntaxHighlighter getHighlighter(VirtualFile file, @Nullable Language lang) {
|
||||
@Nullable
|
||||
private static SyntaxHighlighter getHighlighter(VirtualFile file, @Nullable Language lang) {
|
||||
SyntaxHighlighter syntaxHighlighter = lang != null ? SyntaxHighlighterFactory.getSyntaxHighlighter(lang, null, file) : null;
|
||||
if (lang == null || syntaxHighlighter instanceof PlainSyntaxHighlighter) {
|
||||
syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(file.getFileType(), null, file);
|
||||
|
||||
@@ -40,19 +40,18 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.List;
|
||||
|
||||
public class FindPopupDirectoryChooser extends JPanel {
|
||||
class FindPopupDirectoryChooser extends JPanel {
|
||||
@NotNull private final FindUIHelper myHelper;
|
||||
@NotNull private final Project myProject;
|
||||
@NotNull private final FindPopupPanel myFindPopupPanel;
|
||||
@NotNull private final ComboBox<String> myDirectoryComboBox;
|
||||
|
||||
public FindPopupDirectoryChooser(@NotNull FindPopupPanel panel) {
|
||||
FindPopupDirectoryChooser(@NotNull FindPopupPanel panel) {
|
||||
super(new BorderLayout());
|
||||
|
||||
myHelper = panel.getHelper();
|
||||
@@ -75,33 +74,30 @@ public class FindPopupDirectoryChooser extends JPanel {
|
||||
TextFieldWithBrowseButton.MyDoClickAction.addTo(mySelectDirectoryButton, myDirectoryComboBox);
|
||||
mySelectDirectoryButton.setMargin(JBUI.emptyInsets());
|
||||
|
||||
mySelectDirectoryButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
|
||||
descriptor.setForcedToUseIdeaFileChooser(true);
|
||||
myFindPopupPanel.getCanClose().set(false);
|
||||
FileChooser.chooseFiles(descriptor, myProject, myFindPopupPanel, null,
|
||||
new FileChooser.FileChooserConsumer() {
|
||||
@Override
|
||||
public void consume(List<VirtualFile> files) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
myFindPopupPanel.getCanClose().set(true);
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(myDirectoryComboBox.getEditor().getEditorComponent(), true);
|
||||
myHelper.getModel().setDirectoryName(files.get(0).getPresentableUrl());
|
||||
myDirectoryComboBox.getEditor().setItem(files.get(0).getPresentableUrl());
|
||||
});
|
||||
}
|
||||
mySelectDirectoryButton.addActionListener(__ -> {
|
||||
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
|
||||
descriptor.setForcedToUseIdeaFileChooser(true);
|
||||
myFindPopupPanel.getCanClose().set(false);
|
||||
FileChooser.chooseFiles(descriptor, myProject, myFindPopupPanel, null,
|
||||
new FileChooser.FileChooserConsumer() {
|
||||
@Override
|
||||
public void consume(List<VirtualFile> files) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
myFindPopupPanel.getCanClose().set(true);
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(myDirectoryComboBox.getEditor().getEditorComponent(), true);
|
||||
myHelper.getModel().setDirectoryName(files.get(0).getPresentableUrl());
|
||||
myDirectoryComboBox.getEditor().setItem(files.get(0).getPresentableUrl());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelled() {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
myFindPopupPanel.getCanClose().set(true);
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(myDirectoryComboBox.getEditor().getEditorComponent(), true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void cancelled() {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
myFindPopupPanel.getCanClose().set(true);
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(myDirectoryComboBox.getEditor().getEditorComponent(), true);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
MyRecursiveDirectoryAction recursiveDirectoryAction = new MyRecursiveDirectoryAction();
|
||||
@@ -115,7 +111,7 @@ public class FindPopupDirectoryChooser extends JPanel {
|
||||
add(buttonsPanel, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
public void initByModel(@NotNull FindModel findModel) {
|
||||
void initByModel(@NotNull FindModel findModel) {
|
||||
final String directoryName = findModel.getDirectoryName();
|
||||
java.util.List<String> strings = FindInProjectSettings.getInstance(myProject).getRecentDirectories();
|
||||
|
||||
|
||||
@@ -80,13 +80,13 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -110,7 +110,7 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
private SearchTextArea mySearchTextArea;
|
||||
private SearchTextArea myReplaceTextArea;
|
||||
private ActionListener myOkActionListener;
|
||||
private AtomicBoolean myCanClose = new AtomicBoolean(true);
|
||||
private final AtomicBoolean myCanClose = new AtomicBoolean(true);
|
||||
private JBLabel myOKHintLabel;
|
||||
private Alarm mySearchRescheduleOnCancellationsAlarm;
|
||||
private volatile ProgressIndicatorBase myResultsPreviewSearchProgress;
|
||||
@@ -123,7 +123,7 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
private StateRestoringCheckBox myCbFileFilter;
|
||||
private ActionToolbarImpl myScopeSelectionToolbar;
|
||||
private TextFieldWithAutoCompletion<String> myFileMaskField;
|
||||
private ArrayList<String> myFileMasks = new ArrayList<>();
|
||||
private final ArrayList<String> myFileMasks = new ArrayList<>();
|
||||
private ActionButton myFilterContextButton;
|
||||
private ActionButton myTabResultsButton;
|
||||
private JButton myOKButton;
|
||||
@@ -146,21 +146,19 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
myDisposable = Disposer.newDisposable();
|
||||
myScopeUI = FindPopupScopeUIProvider.getInstance().create(this);
|
||||
|
||||
Disposer.register(myDisposable, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
FindPopupPanel.this.finishPreviousPreviewSearch();
|
||||
if (mySearchRescheduleOnCancellationsAlarm != null) Disposer.dispose(mySearchRescheduleOnCancellationsAlarm);
|
||||
if (myUsagePreviewPanel != null) Disposer.dispose(myUsagePreviewPanel);
|
||||
}
|
||||
Disposer.register(myDisposable, () -> {
|
||||
finishPreviousPreviewSearch();
|
||||
if (mySearchRescheduleOnCancellationsAlarm != null) Disposer.dispose(mySearchRescheduleOnCancellationsAlarm);
|
||||
if (myUsagePreviewPanel != null) Disposer.dispose(myUsagePreviewPanel);
|
||||
});
|
||||
|
||||
initComponents();
|
||||
initByModel();
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(() -> this.scheduleResultsUpdate(), ModalityState.any());
|
||||
ApplicationManager.getApplication().invokeLater(this::scheduleResultsUpdate, ModalityState.any());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUI() {
|
||||
if (myBalloon != null && myBalloon.isVisible()) {
|
||||
return;
|
||||
@@ -272,12 +270,7 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
myLoadingDecorator = new LoadingDecorator(new JLabel(EmptyIcon.ICON_16), getDisposable(), 250, true, new AsyncProcessIcon("FindInPathLoading"));
|
||||
myLoadingDecorator.setLoadingText("");
|
||||
myCbCaseSensitive = createCheckBox("find.popup.case.sensitive");
|
||||
ItemListener liveResultsPreviewUpdateListener = new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
scheduleResultsUpdate();
|
||||
}
|
||||
};
|
||||
ItemListener liveResultsPreviewUpdateListener = __ -> scheduleResultsUpdate();
|
||||
myCbCaseSensitive.addItemListener(liveResultsPreviewUpdateListener);
|
||||
myCbPreserveCase = createCheckBox("find.options.replace.preserve.case");
|
||||
myCbPreserveCase.addItemListener(liveResultsPreviewUpdateListener);
|
||||
@@ -287,21 +280,18 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
myCbRegularExpressions = createCheckBox("find.popup.regex");
|
||||
myCbRegularExpressions.addItemListener(liveResultsPreviewUpdateListener);
|
||||
myCbFileFilter = createCheckBox("find.popup.filemask");
|
||||
myCbFileFilter.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (myCbFileFilter.isSelected()) {
|
||||
myFileMaskField.setEnabled(true);
|
||||
if (myCbFileFilter.getClientProperty("dontRequestFocus") == null) {
|
||||
myFileMaskField.selectAll();
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(myFileMaskField, true);
|
||||
}
|
||||
myCbFileFilter.addItemListener(__ -> {
|
||||
if (myCbFileFilter.isSelected()) {
|
||||
myFileMaskField.setEnabled(true);
|
||||
if (myCbFileFilter.getClientProperty("dontRequestFocus") == null) {
|
||||
myFileMaskField.selectAll();
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(myFileMaskField, true);
|
||||
}
|
||||
else {
|
||||
myFileMaskField.setEnabled(false);
|
||||
if (myCbFileFilter.getClientProperty("dontRequestFocus") == null) {
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(mySearchComponent, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
myFileMaskField.setEnabled(false);
|
||||
if (myCbFileFilter.getClientProperty("dontRequestFocus") == null) {
|
||||
IdeFocusManager.getInstance(myProject).requestFocus(mySearchComponent, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -402,31 +392,28 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
}
|
||||
}.registerCustomShortcutSet(CustomShortcutSet.fromString("alt DOWN"), this);
|
||||
myOKButton = new JButton(FindBundle.message("find.popup.find.button"));
|
||||
myOkActionListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FindModel validateModel = myHelper.getModel().clone();
|
||||
applyTo(validateModel, false);
|
||||
myOkActionListener = __ -> {
|
||||
FindModel validateModel = myHelper.getModel().clone();
|
||||
applyTo(validateModel, false);
|
||||
|
||||
ValidationInfo validationInfo = getValidationInfo(validateModel);
|
||||
ValidationInfo validationInfo = getValidationInfo(validateModel);
|
||||
|
||||
if (validationInfo == null) {
|
||||
myHelper.getModel().copyFrom(validateModel);
|
||||
myHelper.updateFindSettings();
|
||||
myHelper.doOKAction();
|
||||
}
|
||||
else {
|
||||
String message = validationInfo.message;
|
||||
Messages.showMessageDialog(
|
||||
FindPopupPanel.this,
|
||||
message,
|
||||
CommonBundle.getErrorTitle(),
|
||||
Messages.getErrorIcon()
|
||||
);
|
||||
return;
|
||||
}
|
||||
Disposer.dispose(myBalloon);
|
||||
if (validationInfo == null) {
|
||||
myHelper.getModel().copyFrom(validateModel);
|
||||
myHelper.updateFindSettings();
|
||||
myHelper.doOKAction();
|
||||
}
|
||||
else {
|
||||
String message = validationInfo.message;
|
||||
Messages.showMessageDialog(
|
||||
this,
|
||||
message,
|
||||
CommonBundle.getErrorTitle(),
|
||||
Messages.getErrorIcon()
|
||||
);
|
||||
return;
|
||||
}
|
||||
Disposer.dispose(myBalloon);
|
||||
};
|
||||
myOKButton.addActionListener(myOkActionListener);
|
||||
boolean enterAsOK = Registry.is("ide.find.enter.as.ok", false);
|
||||
@@ -497,11 +484,11 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
myReplaceTextArea.setMultilineEnabled(false);
|
||||
|
||||
Pair<FindPopupScopeUI.ScopeType, JComponent>[] scopeComponents = myScopeUI.getComponents();
|
||||
List<AnAction> scopeActions = new LinkedList<>();
|
||||
|
||||
myScopeDetailsPanel = new JPanel(new CardLayout());
|
||||
myScopeDetailsPanel.setBorder(JBUI.Borders.emptyBottom(UIUtil.isUnderDefaultMacTheme() ? 0 : 3));
|
||||
|
||||
List<AnAction> scopeActions = new ArrayList<>(scopeComponents.length);
|
||||
for (Pair<FindPopupScopeUI.ScopeType, JComponent> scopeComponent : scopeComponents) {
|
||||
FindPopupScopeUI.ScopeType scopeType = scopeComponent.first;
|
||||
scopeActions.add(new MySelectScopeToggleAction(scopeType));
|
||||
@@ -542,11 +529,7 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
ScrollingUtil.installActions(myResultsPreviewTable, false, mySearchComponent);
|
||||
ScrollingUtil.installActions(myResultsPreviewTable, false, myReplaceComponent);
|
||||
|
||||
ActionListener helpAction = new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
HelpManager.getInstance().invokeHelp("reference.dialogs.findinpath");
|
||||
}
|
||||
};
|
||||
ActionListener helpAction = __ -> HelpManager.getInstance().invokeHelp("reference.dialogs.findinpath");
|
||||
registerKeyboardAction(helpAction,KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0),JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
registerKeyboardAction(helpAction,KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0),JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||
|
||||
@@ -557,29 +540,26 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
}
|
||||
};
|
||||
Disposer.register(myDisposable, myUsagePreviewPanel);
|
||||
myResultsPreviewTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (e.getValueIsAdjusting()) return;
|
||||
int index = myResultsPreviewTable.getSelectedRow();
|
||||
if (index != -1) {
|
||||
UsageInfo2UsageAdapter adapter = (UsageInfo2UsageAdapter)myResultsPreviewTable.getModel().getValueAt(index, 0);
|
||||
myUsagePreviewPanel.updateLayout(adapter.isValid() ? Arrays.asList(adapter.getMergedInfos()) : null);
|
||||
VirtualFile file = adapter.getFile();
|
||||
String path = "";
|
||||
if (file != null) {
|
||||
String relativePath = VfsUtilCore.getRelativePath(file, myProject.getBaseDir());
|
||||
if (relativePath == null) relativePath = file.getPath();
|
||||
path = "<html><body> " +
|
||||
relativePath
|
||||
.replace(file.getName(), "<b>" + file.getName() + "</b>") + "</body></html>";
|
||||
}
|
||||
myUsagePreviewPanel.setBorder(IdeBorderFactory.createTitledBorder(path, false, new JBInsets(8, 0, 0, 0)).setShowLine(false));
|
||||
}
|
||||
else {
|
||||
myUsagePreviewPanel.updateLayout(null);
|
||||
myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder());
|
||||
myResultsPreviewTable.getSelectionModel().addListSelectionListener(e -> {
|
||||
if (e.getValueIsAdjusting()) return;
|
||||
int index = myResultsPreviewTable.getSelectedRow();
|
||||
if (index != -1) {
|
||||
UsageInfo2UsageAdapter adapter = (UsageInfo2UsageAdapter)myResultsPreviewTable.getModel().getValueAt(index, 0);
|
||||
myUsagePreviewPanel.updateLayout(adapter.isValid() ? Arrays.asList(adapter.getMergedInfos()) : null);
|
||||
VirtualFile file = adapter.getFile();
|
||||
String path = "";
|
||||
if (file != null) {
|
||||
String relativePath = VfsUtilCore.getRelativePath(file, myProject.getBaseDir());
|
||||
if (relativePath == null) relativePath = file.getPath();
|
||||
path = "<html><body> " +
|
||||
relativePath
|
||||
.replace(file.getName(), "<b>" + file.getName() + "</b>") + "</body></html>";
|
||||
}
|
||||
myUsagePreviewPanel.setBorder(IdeBorderFactory.createTitledBorder(path, false, new JBInsets(8, 0, 0, 0)).setShowLine(false));
|
||||
}
|
||||
else {
|
||||
myUsagePreviewPanel.updateLayout(null);
|
||||
myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder());
|
||||
}
|
||||
});
|
||||
mySearchRescheduleOnCancellationsAlarm = new Alarm();
|
||||
@@ -639,7 +619,7 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
|
||||
@Override
|
||||
public Component getComponentAfter(Container container, Component c) {
|
||||
return (c == myResultsPreviewTable) ? mySearchComponent : super.getComponentAfter(container, c);
|
||||
return c == myResultsPreviewTable ? mySearchComponent : super.getComponentAfter(container, c);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -775,12 +755,12 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
}
|
||||
}
|
||||
|
||||
public void scheduleResultsUpdate() {
|
||||
void scheduleResultsUpdate() {
|
||||
if (myBalloon == null || !myBalloon.isVisible()) return;
|
||||
if (mySearchRescheduleOnCancellationsAlarm == null || mySearchRescheduleOnCancellationsAlarm.isDisposed()) return;
|
||||
updateControls();
|
||||
mySearchRescheduleOnCancellationsAlarm.cancelAllRequests();
|
||||
mySearchRescheduleOnCancellationsAlarm.addRequest(() -> findSettingsChanged(), 100);
|
||||
mySearchRescheduleOnCancellationsAlarm.addRequest(this::findSettingsChanged, 100);
|
||||
}
|
||||
|
||||
private void finishPreviousPreviewSearch() {
|
||||
@@ -888,16 +868,11 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
resultsFilesCount.incrementAndGet();
|
||||
lastUsageFileRef.set(usageFile);
|
||||
}
|
||||
final boolean merged;
|
||||
Usage recent = recentUsageRef.get();
|
||||
UsageInfo2UsageAdapter recentAdapter =
|
||||
recent != null && recent instanceof UsageInfo2UsageAdapter ? (UsageInfo2UsageAdapter)recent : null;
|
||||
recent instanceof UsageInfo2UsageAdapter ? (UsageInfo2UsageAdapter)recent : null;
|
||||
UsageInfo2UsageAdapter currentAdapter = usage instanceof UsageInfo2UsageAdapter ? (UsageInfo2UsageAdapter)usage : null;
|
||||
if (currentAdapter != null && recentAdapter != null) {
|
||||
merged = recentAdapter.merge(currentAdapter);
|
||||
} else {
|
||||
merged = false;
|
||||
}
|
||||
final boolean merged = currentAdapter != null && recentAdapter != null && recentAdapter.merge(currentAdapter);
|
||||
if (!merged) {
|
||||
recentUsageRef.set(usage);
|
||||
}
|
||||
@@ -977,11 +952,10 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
if (hash != myLoadingHash) {
|
||||
return;
|
||||
}
|
||||
UIUtil.invokeLaterIfNeeded(() -> {
|
||||
myLoadingDecorator.stopLoading();
|
||||
});
|
||||
UIUtil.invokeLaterIfNeeded(() -> myLoadingDecorator.stopLoading());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getFileTypeMask() {
|
||||
String mask = null;
|
||||
@@ -1041,6 +1015,7 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getStringToFind() {
|
||||
return mySearchComponent.getText();
|
||||
@@ -1132,15 +1107,10 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
}
|
||||
|
||||
private class MySwitchContextToggleAction extends ToggleAction {
|
||||
public MySwitchContextToggleAction(FindModel.SearchContext context) {
|
||||
MySwitchContextToggleAction(FindModel.SearchContext context) {
|
||||
super(FindDialog.getPresentableName(context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformedUpdate(@NotNull AnActionEvent e) {
|
||||
super.beforeActionPerformedUpdate(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelected(AnActionEvent e) {
|
||||
return Comparing.equal(mySelectedContextName, getTemplatePresentation().getText());
|
||||
@@ -1158,7 +1128,7 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
private class MySelectScopeToggleAction extends ToggleAction {
|
||||
private final FindPopupScopeUI.ScopeType myScope;
|
||||
|
||||
public MySelectScopeToggleAction(FindPopupScopeUI.ScopeType scope) {
|
||||
MySelectScopeToggleAction(FindPopupScopeUI.ScopeType scope) {
|
||||
super(scope.text, null, scope.icon);
|
||||
getTemplatePresentation().setHoveredIcon(scope.icon);
|
||||
getTemplatePresentation().setDisabledIcon(scope.icon);
|
||||
@@ -1189,7 +1159,7 @@ public class FindPopupPanel extends JBPanel implements FindUI {
|
||||
private class MyShowFilterPopupAction extends AnAction {
|
||||
private final DefaultActionGroup mySwitchContextGroup;
|
||||
|
||||
public MyShowFilterPopupAction() {
|
||||
MyShowFilterPopupAction() {
|
||||
super(FindBundle.message("find.popup.show.filter.popup"), null, AllIcons.General.Filter);
|
||||
LayeredIcon icon = JBUI.scale(new LayeredIcon(2));
|
||||
icon.setIcon(AllIcons.General.Filter, 0);
|
||||
|
||||
@@ -36,6 +36,9 @@ public interface FindPopupScopeUI {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if something was hidden
|
||||
*/
|
||||
boolean hideAllPopups();
|
||||
|
||||
class ScopeType {
|
||||
|
||||
@@ -44,8 +44,7 @@ import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FindPopupScopeUIImpl implements FindPopupScopeUI {
|
||||
|
||||
class FindPopupScopeUIImpl implements FindPopupScopeUI {
|
||||
private final ScopeType PROJECT = new ScopeType("Project", FindBundle.message("find.popup.scope.project"), EmptyIcon.ICON_0);
|
||||
private final ScopeType MODULE = new ScopeType("Module", FindBundle.message("find.popup.scope.module"), EmptyIcon.ICON_0);
|
||||
private final ScopeType DIRECTORY = new ScopeType("Directory", FindBundle.message("find.popup.scope.directory"), EmptyIcon.ICON_0);
|
||||
@@ -54,23 +53,24 @@ public class FindPopupScopeUIImpl implements FindPopupScopeUI {
|
||||
@NotNull private final FindUIHelper myHelper;
|
||||
@NotNull private final Project myProject;
|
||||
@NotNull private final FindPopupPanel myFindPopupPanel;
|
||||
@NotNull private final Pair[] myComponents;
|
||||
@NotNull private final Pair<ScopeType, JComponent>[] myComponents;
|
||||
|
||||
private ComboBox<String> myModuleComboBox;
|
||||
private FindPopupDirectoryChooser myDirectoryChooser;
|
||||
private ScopeChooserCombo myScopeCombo;
|
||||
|
||||
public FindPopupScopeUIImpl(@NotNull FindPopupPanel panel) {
|
||||
FindPopupScopeUIImpl(@NotNull FindPopupPanel panel) {
|
||||
myHelper = panel.getHelper();
|
||||
myProject = panel.getProject();
|
||||
myFindPopupPanel = panel;
|
||||
initComponents();
|
||||
|
||||
myComponents = new Pair[]{
|
||||
new Pair(PROJECT, new JLabel()),
|
||||
new Pair(MODULE, shrink(myModuleComboBox)),
|
||||
new Pair(DIRECTORY, myDirectoryChooser),
|
||||
new Pair(SCOPE, shrink(myScopeCombo)),
|
||||
//noinspection unchecked
|
||||
myComponents = (Pair<ScopeType, JComponent>[])new Pair[]{
|
||||
new Pair<>(PROJECT, new JLabel()),
|
||||
new Pair<>(MODULE, shrink(myModuleComboBox)),
|
||||
new Pair<>(DIRECTORY, myDirectoryChooser),
|
||||
new Pair<>(SCOPE, shrink(myScopeCombo)),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class FindPopupScopeUIImpl implements FindPopupScopeUI {
|
||||
}
|
||||
else if (selectedScope == DIRECTORY) {
|
||||
String directory = myDirectoryChooser.getDirectory();
|
||||
findModel.setDirectoryName(directory == null ? "" : directory);
|
||||
findModel.setDirectoryName(directory);
|
||||
}
|
||||
else if (selectedScope == MODULE) {
|
||||
findModel.setModuleName((String)myModuleComboBox.getSelectedItem());
|
||||
@@ -177,7 +177,7 @@ public class FindPopupScopeUIImpl implements FindPopupScopeUI {
|
||||
|
||||
@Override
|
||||
public boolean hideAllPopups() {
|
||||
final JComboBox[] candidates = new JComboBox[] { myModuleComboBox, myScopeCombo.getComboBox(), myDirectoryChooser.getComboBox() };
|
||||
final JComboBox[] candidates = { myModuleComboBox, myScopeCombo.getComboBox(), myDirectoryChooser.getComboBox() };
|
||||
for (JComboBox candidate : candidates) {
|
||||
if (candidate.isPopupVisible()) {
|
||||
candidate.hidePopup();
|
||||
@@ -224,13 +224,13 @@ public class FindPopupScopeUIImpl implements FindPopupScopeUI {
|
||||
private ScopeType getScope(FindModel model) {
|
||||
if (model.isCustomScope()) {
|
||||
return SCOPE;
|
||||
} else
|
||||
}
|
||||
if (model.isProjectScope()) {
|
||||
return PROJECT;
|
||||
} else
|
||||
}
|
||||
if (model.getDirectoryName() != null) {
|
||||
return DIRECTORY;
|
||||
} else
|
||||
}
|
||||
if (model.getModuleName() != null) {
|
||||
return MODULE;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.find.impl;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FindPopupScopeUIProvider {
|
||||
static FindPopupScopeUIProvider getInstance() {
|
||||
return ServiceManager.getService(FindPopupScopeUIProvider.class);
|
||||
|
||||
@@ -83,32 +83,32 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
SEARCH_OVERLOADED_METHODS = search;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean SEARCH_OVERLOADED_METHODS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean SEARCH_IN_LIBRARIES = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean SKIP_RESULTS_WHEN_ONE_USAGE = false;
|
||||
@SuppressWarnings("WeakerAccess") public boolean SEARCH_OVERLOADED_METHODS;
|
||||
@SuppressWarnings("WeakerAccess") public boolean SEARCH_IN_LIBRARIES;
|
||||
@SuppressWarnings("WeakerAccess") public boolean SKIP_RESULTS_WHEN_ONE_USAGE;
|
||||
|
||||
@SuppressWarnings({"WeakerAccess"}) public String FIND_DIRECTION = FIND_DIRECTION_FORWARD;
|
||||
@SuppressWarnings({"WeakerAccess"}) public String FIND_ORIGIN = FIND_ORIGIN_FROM_CURSOR;
|
||||
@SuppressWarnings({"WeakerAccess"}) public String FIND_SCOPE = FIND_SCOPE_GLOBAL;
|
||||
@SuppressWarnings({"WeakerAccess"}) public String FIND_CUSTOM_SCOPE = null;
|
||||
@SuppressWarnings("WeakerAccess") public String FIND_DIRECTION = FIND_DIRECTION_FORWARD;
|
||||
@SuppressWarnings("WeakerAccess") public String FIND_ORIGIN = FIND_ORIGIN_FROM_CURSOR;
|
||||
@SuppressWarnings("WeakerAccess") public String FIND_SCOPE = FIND_SCOPE_GLOBAL;
|
||||
@SuppressWarnings("WeakerAccess") public String FIND_CUSTOM_SCOPE;
|
||||
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean CASE_SENSITIVE_SEARCH = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean LOCAL_CASE_SENSITIVE_SEARCH = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean PRESERVE_CASE_REPLACE = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean WHOLE_WORDS_ONLY = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean COMMENTS_ONLY = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean STRING_LITERALS_ONLY = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_COMMENTS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_COMMENTS_AND_STRING_LITERALS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean EXCEPT_STRING_LITERALS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean LOCAL_WHOLE_WORDS_ONLY = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean REGULAR_EXPRESSIONS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean LOCAL_REGULAR_EXPRESSIONS = false;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean WITH_SUBDIRECTORIES = true;
|
||||
@SuppressWarnings({"WeakerAccess"}) public boolean SHOW_RESULTS_IN_SEPARATE_VIEW = false;
|
||||
@SuppressWarnings("WeakerAccess") public boolean CASE_SENSITIVE_SEARCH;
|
||||
@SuppressWarnings("WeakerAccess") public boolean LOCAL_CASE_SENSITIVE_SEARCH;
|
||||
@SuppressWarnings("WeakerAccess") public boolean PRESERVE_CASE_REPLACE;
|
||||
@SuppressWarnings("WeakerAccess") public boolean WHOLE_WORDS_ONLY;
|
||||
@SuppressWarnings("WeakerAccess") public boolean COMMENTS_ONLY;
|
||||
@SuppressWarnings("WeakerAccess") public boolean STRING_LITERALS_ONLY;
|
||||
@SuppressWarnings("WeakerAccess") public boolean EXCEPT_COMMENTS;
|
||||
@SuppressWarnings("WeakerAccess") public boolean EXCEPT_COMMENTS_AND_STRING_LITERALS;
|
||||
@SuppressWarnings("WeakerAccess") public boolean EXCEPT_STRING_LITERALS;
|
||||
@SuppressWarnings("WeakerAccess") public boolean LOCAL_WHOLE_WORDS_ONLY;
|
||||
@SuppressWarnings("WeakerAccess") public boolean REGULAR_EXPRESSIONS;
|
||||
@SuppressWarnings("WeakerAccess") public boolean LOCAL_REGULAR_EXPRESSIONS;
|
||||
@SuppressWarnings("WeakerAccess") public boolean WITH_SUBDIRECTORIES = true;
|
||||
@SuppressWarnings("WeakerAccess") public boolean SHOW_RESULTS_IN_SEPARATE_VIEW;
|
||||
|
||||
@SuppressWarnings({"WeakerAccess"}) public String SEARCH_SCOPE = DEFAULT_SEARCH_SCOPE;
|
||||
@SuppressWarnings({"WeakerAccess"}) public String FILE_MASK;
|
||||
@SuppressWarnings("WeakerAccess") public String SEARCH_SCOPE = DEFAULT_SEARCH_SCOPE;
|
||||
@SuppressWarnings("WeakerAccess") public String FILE_MASK;
|
||||
|
||||
@Tag("recentFileMasks")
|
||||
@Property(surroundWithTag = false)
|
||||
@@ -403,10 +403,7 @@ public class FindSettingsImpl extends FindSettings implements PersistentStateCom
|
||||
EXCEPT_STRING_LITERALS = selected;
|
||||
}
|
||||
|
||||
@State(
|
||||
name = "FindRecents",
|
||||
storages = {@Storage(value = "find.recents.xml", roamingType = RoamingType.DISABLED)}
|
||||
)
|
||||
@State(name = "FindRecents", storages = @Storage(value = "find.recents.xml", roamingType = RoamingType.DISABLED))
|
||||
static final class FindRecents extends FindInProjectSettingsBase {
|
||||
public static FindRecents getInstance() {
|
||||
return ServiceManager.getService(FindRecents.class);
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class FindUIHelper implements Disposable {
|
||||
class FindUIHelper implements Disposable {
|
||||
@NotNull private final Project myProject;
|
||||
@NotNull private FindModel myModel;
|
||||
FindModel myPreviousModel;
|
||||
@@ -39,7 +39,7 @@ public class FindUIHelper implements Disposable {
|
||||
|
||||
FindUI myUI;
|
||||
|
||||
public FindUIHelper(@NotNull Project project, @NotNull FindModel model, @NotNull Runnable okHandler) {
|
||||
FindUIHelper(@NotNull Project project, @NotNull FindModel model, @NotNull Runnable okHandler) {
|
||||
myProject = project;
|
||||
myModel = model;
|
||||
myOkHandler = okHandler;
|
||||
@@ -47,10 +47,10 @@ public class FindUIHelper implements Disposable {
|
||||
myUI.initByModel();
|
||||
}
|
||||
|
||||
protected FindUI getOrCreateUI() {
|
||||
boolean newInstanceRequired = (myUI instanceof FindPopupPanel && !Registry.is("ide.find.as.popup")) ||
|
||||
(myUI instanceof FindDialog && Registry.is("ide.find.as.popup")) ||
|
||||
(myUI == null);
|
||||
private FindUI getOrCreateUI() {
|
||||
boolean newInstanceRequired = myUI instanceof FindPopupPanel && !Registry.is("ide.find.as.popup") ||
|
||||
myUI instanceof FindDialog && Registry.is("ide.find.as.popup") ||
|
||||
myUI == null;
|
||||
if (newInstanceRequired) {
|
||||
if (Registry.is("ide.find.as.popup")) {
|
||||
myUI = new FindPopupPanel(this);
|
||||
@@ -68,7 +68,7 @@ public class FindUIHelper implements Disposable {
|
||||
|
||||
private void registerAction(String actionName, boolean replace, FindDialog findDialog) {
|
||||
AnAction action = ActionManager.getInstance().getAction(actionName);
|
||||
JRootPane findDialogRootComponent = ((JDialog)(findDialog.getWindow())).getRootPane();
|
||||
JRootPane findDialogRootComponent = ((JDialog)findDialog.getWindow()).getRootPane();
|
||||
new AnAction() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
@@ -193,21 +193,13 @@ public class FindUIHelper implements Disposable {
|
||||
|
||||
String getTitle() {
|
||||
if (myModel.isReplaceState()){
|
||||
if (myModel.isMultipleFiles()){
|
||||
return FindBundle.message("find.replace.in.project.dialog.title");
|
||||
}
|
||||
else{
|
||||
return FindBundle.message("find.replace.text.dialog.title");
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (myModel.isMultipleFiles()){
|
||||
return FindBundle.message("find.in.path.dialog.title");
|
||||
}
|
||||
else{
|
||||
return FindBundle.message("find.text.dialog.title");
|
||||
}
|
||||
return myModel.isMultipleFiles()
|
||||
? FindBundle.message("find.replace.in.project.dialog.title")
|
||||
: FindBundle.message("find.replace.text.dialog.title");
|
||||
}
|
||||
return myModel.isMultipleFiles() ?
|
||||
FindBundle.message("find.in.path.dialog.title") :
|
||||
FindBundle.message("find.text.dialog.title");
|
||||
}
|
||||
|
||||
public boolean isReplaceState() {
|
||||
|
||||
Reference in New Issue
Block a user