Search in sources :

Example 6 with ReplaceConfiguration

use of com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration in project intellij-community by JetBrains.

the class SSBasedInspectionOptions method performEditAction.

private void performEditAction() {
    final Configuration configuration = (Configuration) myTemplatesList.getSelectedValue();
    if (configuration == null)
        return;
    SearchDialog dialog = createDialog(new SearchDialogFactory() {

        @Override
        public SearchDialog createDialog(SearchContext searchContext) {
            if (configuration instanceof SearchConfiguration) {
                return new SearchDialog(searchContext, false, false) {

                    @Override
                    public Configuration createConfiguration() {
                        SearchConfiguration newConfiguration = new SearchConfiguration();
                        copyConfiguration(configuration, newConfiguration);
                        return newConfiguration;
                    }
                };
            } else {
                return new ReplaceDialog(searchContext, false, false) {

                    @Override
                    public Configuration createConfiguration() {
                        ReplaceConfiguration newConfiguration = new ReplaceConfiguration();
                        copyConfiguration(configuration, newConfiguration);
                        return newConfiguration;
                    }
                };
            }
        }
    });
    dialog.setValuesFromConfig(configuration);
    dialog.setUseLastConfiguration(true);
    if (!dialog.showAndGet()) {
        return;
    }
    final Configuration newConfiguration = dialog.getConfiguration();
    final int index = myConfigurations.indexOf(configuration);
    myConfigurations.remove(index);
    myConfigurations.add(index, newConfiguration);
    final SearchContext context = dialog.getSearchContext();
    SSBasedInspectionCompiledPatternsCache.removeFromCache(configuration, context.getProject());
    configurationsChanged(context);
}
Also used : ReplaceDialog(com.intellij.structuralsearch.plugin.replace.ui.ReplaceDialog) ReplaceConfiguration(com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration) ReplaceConfiguration(com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration)

Aggregations

ReplaceConfiguration (com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration)6 MatchOptions (com.intellij.structuralsearch.MatchOptions)2 NotNull (org.jetbrains.annotations.NotNull)2 Project (com.intellij.openapi.project.Project)1 PsiElement (com.intellij.psi.PsiElement)1 ReplaceOptions (com.intellij.structuralsearch.plugin.replace.ReplaceOptions)1 ReplacementInfo (com.intellij.structuralsearch.plugin.replace.ReplacementInfo)1 Replacer (com.intellij.structuralsearch.plugin.replace.impl.Replacer)1 ReplaceDialog (com.intellij.structuralsearch.plugin.replace.ui.ReplaceDialog)1