mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Minor refactoring
This commit is contained in:
+9
-5
@@ -57,7 +57,7 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator<PyN
|
||||
private static final Logger LOG = Logger.getInstance(PyStudyDirectoryProjectGenerator.class.getName());
|
||||
private final StudyProjectGenerator myGenerator;
|
||||
private static final String NO_PYTHON_INTERPRETER = "<html><u>Add</u> python interpreter.</html>";
|
||||
private final Consumer<Project> myCallback;
|
||||
private final Consumer<Project> myOnCreated;
|
||||
public ValidationResult myValidationResult = new ValidationResult("selected course is not valid");
|
||||
private final StudyNewProjectPanel mySettingsPanel;
|
||||
|
||||
@@ -66,8 +66,8 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator<PyN
|
||||
this(false);
|
||||
}
|
||||
|
||||
public PyStudyDirectoryProjectGenerator(boolean isLocal, @Nullable Consumer<Project> callback) {
|
||||
myCallback = callback;
|
||||
public PyStudyDirectoryProjectGenerator(boolean isLocal, @Nullable Consumer<Project> onCreated) {
|
||||
myOnCreated = onCreated;
|
||||
myGenerator = new StudyProjectGenerator();
|
||||
myGenerator.addSettingsStateListener(new StudyProjectGenerator.SettingsListener() {
|
||||
@Override
|
||||
@@ -150,8 +150,12 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator<PyN
|
||||
LOG.error("Can't copy test_helper.py " + exception.getMessage());
|
||||
}
|
||||
|
||||
if (myCallback != null) {
|
||||
myCallback.consume(project);
|
||||
doCreated(project);
|
||||
}
|
||||
|
||||
protected void doCreated(@NotNull Project project) {
|
||||
if (myOnCreated != null) {
|
||||
myOnCreated.consume(project);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -31,17 +31,17 @@ import java.util.ArrayList;
|
||||
* @author meanmail
|
||||
*/
|
||||
public class BuiltInServerNewProjectStep extends PyCharmNewProjectStep {
|
||||
public BuiltInServerNewProjectStep(@NotNull Course course, @Nullable Consumer<Project> callback) {
|
||||
super(new BuiltInServerNewProjectStep.MyCustomization(course, callback));
|
||||
public BuiltInServerNewProjectStep(@NotNull Course course, @Nullable Consumer<Project> onCreated) {
|
||||
super(new BuiltInServerNewProjectStep.MyCustomization(course, onCreated));
|
||||
}
|
||||
|
||||
protected static class MyCustomization extends PyCharmNewProjectStep.Customization {
|
||||
private final Course myCourse;
|
||||
private final PyStudyDirectoryProjectGenerator myGenerator;
|
||||
|
||||
public MyCustomization(@NotNull Course course, @Nullable Consumer<Project> callback) {
|
||||
public MyCustomization(@NotNull Course course, @Nullable Consumer<Project> onCreated) {
|
||||
myCourse = course;
|
||||
myGenerator = new PyStudyDirectoryProjectGenerator(true, callback);
|
||||
myGenerator = new PyStudyDirectoryProjectGenerator(true, onCreated);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -35,12 +35,12 @@ public class EduPythonProjectCreator extends EduProjectCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createCourseProject(@NotNull Course course, @Nullable Consumer<Project> callback) {
|
||||
public boolean createCourseProject(@NotNull Course course, @Nullable Consumer<Project> onCreated) {
|
||||
ApplicationManager.getApplication().invokeAndWait(() -> {
|
||||
AbstractNewProjectDialog dlg = new AbstractNewProjectDialog() {
|
||||
@Override
|
||||
protected DefaultActionGroup createRootStep() {
|
||||
return new BuiltInServerNewProjectStep(course, callback);
|
||||
return new BuiltInServerNewProjectStep(course, onCreated);
|
||||
}
|
||||
};
|
||||
dlg.show();
|
||||
|
||||
Reference in New Issue
Block a user