mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Implementation for a project creator
This commit is contained in:
@@ -15,5 +15,6 @@
|
||||
<orderEntry type="module" module-name="python-community-configure" />
|
||||
<orderEntry type="module" module-name="course-creator" />
|
||||
<orderEntry type="module" module-name="educational-core" />
|
||||
<orderEntry type="module" module-name="python-community-ide" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -37,6 +37,7 @@
|
||||
<extensions defaultExtensionNs="Edu">
|
||||
<StudyExecutor implementationClass="com.jetbrains.edu.learning.PyStudyExecutor" language="Python"/>
|
||||
<pluginConfigurator implementationClass="com.jetbrains.edu.learning.PyEduPluginConfigurator" language="Python"/>
|
||||
<eduProjectCreator implementation="com.jetbrains.edu.learning.builtInServer.EduPythonProjectCreator"/>
|
||||
</extensions>
|
||||
<actions>
|
||||
<action id="WelcomeScreen.PythonIntro" class="com.jetbrains.edu.learning.actions.PyStudyIntroductionCourseAction"
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.edu.learning.builtInServer;
|
||||
|
||||
import com.intellij.platform.DirectoryProjectGenerator;
|
||||
import com.jetbrains.edu.learning.PyStudyDirectoryProjectGenerator;
|
||||
import com.jetbrains.edu.learning.courseFormat.Course;
|
||||
import com.jetbrains.edu.learning.courseGeneration.StudyProjectGenerator;
|
||||
import com.jetbrains.python.newProject.steps.PyCharmNewProjectStep;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author meanmail
|
||||
*/
|
||||
public class BuiltInServerNewProjectStep extends PyCharmNewProjectStep {
|
||||
public BuiltInServerNewProjectStep(@NotNull Course course) {
|
||||
super(new BuiltInServerNewProjectStep.MyCustomization(course));
|
||||
}
|
||||
|
||||
protected static class MyCustomization extends PyCharmNewProjectStep.Customization {
|
||||
private final Course myCourse;
|
||||
private final PyStudyDirectoryProjectGenerator myGenerator;
|
||||
|
||||
public MyCustomization(@NotNull Course course) {
|
||||
myCourse = course;
|
||||
myGenerator = new PyStudyDirectoryProjectGenerator(true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected DirectoryProjectGenerator[] getProjectGenerators() {
|
||||
return new DirectoryProjectGenerator[] {};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected DirectoryProjectGenerator createEmptyProjectGenerator() {
|
||||
StudyProjectGenerator generator = myGenerator.getGenerator();
|
||||
ArrayList<Course> courses = new ArrayList<>();
|
||||
courses.add(myCourse);
|
||||
generator.setCourses(courses);
|
||||
generator.setSelectedCourse(myCourse);
|
||||
return myGenerator;
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.edu.learning.builtInServer;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.AbstractNewProjectDialog;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.jetbrains.edu.learning.courseFormat.Course;
|
||||
import com.jetbrains.python.PythonLanguage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author meanmail
|
||||
*/
|
||||
public class EduPythonProjectCreator extends EduProjectCreator {
|
||||
@Override
|
||||
public boolean canCreateProject(@NotNull Course course) {
|
||||
return course.getLanguageById() == PythonLanguage.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createCourseProject(@NotNull Course course) {
|
||||
ApplicationManager.getApplication().invokeAndWait(() -> {
|
||||
AbstractNewProjectDialog dlg = new AbstractNewProjectDialog() {
|
||||
@Override
|
||||
protected DefaultActionGroup createRootStep() {
|
||||
return new BuiltInServerNewProjectStep(course);
|
||||
}
|
||||
};
|
||||
dlg.show();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user