SSR: remove unneeded static Project field hack

This commit is contained in:
Bas Leijdekkers
2017-06-08 16:50:01 +02:00
parent 6805bb4379
commit 7c754f675c
2 changed files with 11 additions and 21 deletions
@@ -109,11 +109,11 @@ class EditVarConstraintsDialog extends DialogWrapper {
private JButton myOneInfinityButton;
private JButton myZeroOneButton;
private static Project myProject;
private final Project myProject;
EditVarConstraintsDialog(final Project project, Configuration configuration, List<Variable> _variables, final FileType fileType) {
super(project, true);
myProject = project;
variables = _variables;
myConfiguration = configuration;
@@ -543,21 +543,21 @@ class EditVarConstraintsDialog extends DialogWrapper {
myRegExHelpLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
}
private static EditorTextField createRegexComponent() {
private EditorTextField createRegexComponent() {
@NonNls final String fileName = "1.regexp";
final FileType fileType = getFileType(fileName);
final Document doc = createDocument(fileName, fileType, "");
return new EditorTextField(doc, myProject, fileType);
}
private static EditorTextField createScriptComponent() {
private EditorTextField createScriptComponent() {
@NonNls final String fileName = "1.groovy";
final FileType fileType = getFileType(fileName);
final Document doc = createDocument(fileName, fileType, "");
return new EditorTextField(doc, myProject, fileType);
}
private static Document createDocument(final String fileName, final FileType fileType, String text) {
private Document createDocument(final String fileName, final FileType fileType, String text) {
final PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText(fileName, fileType, text, -1, true);
return PsiDocumentManager.getInstance(myProject).getDocument(file);
@@ -569,10 +569,6 @@ class EditVarConstraintsDialog extends DialogWrapper {
return fileType;
}
public static void setProject(final Project project) {
myProject = project;
}
private static class MyChangeListener implements ChangeListener {
private final JComponent component;
private final boolean inverted;
@@ -605,7 +601,7 @@ class EditVarConstraintsDialog extends DialogWrapper {
}
}
static Editor createEditor(final Project project, final String text, final String fileName) {
Editor createEditor(final Project project, final String text, final String fileName) {
final FileType fileType = getFileType(fileName);
final Document doc = createDocument(fileName, fileType, text);
final Editor editor = EditorFactory.getInstance().createEditor(doc, project);
@@ -622,11 +618,11 @@ class EditVarConstraintsDialog extends DialogWrapper {
return editor;
}
private static class EditScriptDialog extends DialogWrapper {
private class EditScriptDialog extends DialogWrapper {
private final Editor editor;
private final String title;
public EditScriptDialog(Project project, String text, Collection<String> names) {
EditScriptDialog(Project project, String text, Collection<String> names) {
super(project, true);
setTitle(SSRBundle.message("edit.groovy.script.constraint.title"));
editor = createEditor(project, text, "1.groovy");
@@ -177,7 +177,7 @@ public class SearchDialog extends DialogWrapper {
return editor;
}
private void initiateValidation() {
void initiateValidation() {
myAlarm.cancelAllRequests();
myAlarm.addRequest(() -> {
try {
@@ -613,22 +613,18 @@ public class SearchDialog extends DialogWrapper {
@Override
public void actionPerformed(ActionEvent e) {
EditVarConstraintsDialog.setProject(searchContext.getProject());
new EditVarConstraintsDialog(
searchContext.getProject(),
model.getConfig(), getVariablesFromListeners(),
(FileType)fileTypes.getSelectedItem()
).show();
initiateValidation();
EditVarConstraintsDialog.setProject(null);
}
}
)
);
panel.add(
Box.createHorizontalStrut(8)
);
panel.add(Box.createHorizontalStrut(8));
panel.add(
createJButtonForAction(
@@ -652,9 +648,7 @@ public class SearchDialog extends DialogWrapper {
)
);
panel.add(
Box.createHorizontalStrut(8)
);
panel.add(Box.createHorizontalStrut(8));
panel.add(
createJButtonForAction(