blob: 33e7ac5b4d4d9bbe2926b638dbf4b26f64e5feec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package com.intellij.structuralsearch.plugin;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.Project;
import com.intellij.structuralsearch.SSRBundle;
import com.intellij.structuralsearch.plugin.replace.ui.ReplaceDialog;
import com.intellij.structuralsearch.plugin.ui.Configuration;
import com.intellij.structuralsearch.plugin.ui.SearchContext;
/**
* Search and replace structural java code patterns action.
*/
public class StructuralReplaceAction extends AnAction {
public StructuralReplaceAction() {
super(SSRBundle.message("structuralreplace.action"));
}
/** Handles IDEA action event
* @param event the event of action
*/
public void actionPerformed(AnActionEvent event) {
triggerAction(null, SearchContext.buildFromDataContext(event.getDataContext()));
}
public static void triggerAction(Configuration config, SearchContext searchContext) {
ReplaceDialog replaceDialog = new ReplaceDialog(searchContext);
if (config!=null) {
replaceDialog.setUseLastConfiguration(true);
replaceDialog.setValuesFromConfig(config);
}
replaceDialog.show();
}
/** Updates the state of the action
* @param event the action event
*/
public void update(AnActionEvent event) {
final Presentation presentation = event.getPresentation();
final DataContext context = event.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(context);
final StructuralSearchPlugin plugin = (project == null)? null:StructuralSearchPlugin.getInstance( project );
if (plugin== null || plugin.isSearchInProgress() || plugin.isReplaceInProgress() || plugin.isDialogVisible()) {
presentation.setEnabled( false );
} else {
presentation.setEnabled( true );
}
super.update(event);
}
}
|