From 4307fbefedb004ea9401c09acf3d4ed523823255 Mon Sep 17 00:00:00 2001 From: meanmail Date: Sat, 8 Apr 2017 04:36:41 +0700 Subject: [PATCH] Implementation for a project creator --- .../builtInServer/EduProjectCreator.java | 4 +- .../Edu-Python/Edu-Python.iml | 1 + .../Edu-Python/resources/META-INF/plugin.xml | 1 + .../BuiltInServerNewProjectStep.java | 61 +++++++++++++++++++ .../EduPythonProjectCreator.java | 47 ++++++++++++++ 5 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 python/educational-python/Edu-Python/src/com/jetbrains/edu/learning/builtInServer/BuiltInServerNewProjectStep.java create mode 100644 python/educational-python/Edu-Python/src/com/jetbrains/edu/learning/builtInServer/EduPythonProjectCreator.java diff --git a/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduProjectCreator.java b/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduProjectCreator.java index b1d5fe692292..224ff03ef6f2 100644 --- a/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduProjectCreator.java +++ b/python/educational-core/src/com/jetbrains/edu/learning/builtInServer/EduProjectCreator.java @@ -38,11 +38,11 @@ public class EduProjectCreator { return false; } - private boolean createCourseProject(@NotNull Course course) { + public boolean createCourseProject(@NotNull Course course) { return false; } - private boolean canCreateProject(@NotNull Course course) { + public boolean canCreateProject(@NotNull Course course) { return false; } } diff --git a/python/educational-python/Edu-Python/Edu-Python.iml b/python/educational-python/Edu-Python/Edu-Python.iml index 815befd49b4b..3460c943ef69 100644 --- a/python/educational-python/Edu-Python/Edu-Python.iml +++ b/python/educational-python/Edu-Python/Edu-Python.iml @@ -15,5 +15,6 @@ + \ No newline at end of file diff --git a/python/educational-python/Edu-Python/resources/META-INF/plugin.xml b/python/educational-python/Edu-Python/resources/META-INF/plugin.xml index 35419980703f..b7a8fb0120f6 100644 --- a/python/educational-python/Edu-Python/resources/META-INF/plugin.xml +++ b/python/educational-python/Edu-Python/resources/META-INF/plugin.xml @@ -37,6 +37,7 @@ + courses = new ArrayList<>(); + courses.add(myCourse); + generator.setCourses(courses); + generator.setSelectedCourse(myCourse); + return myGenerator; + } + } +} diff --git a/python/educational-python/Edu-Python/src/com/jetbrains/edu/learning/builtInServer/EduPythonProjectCreator.java b/python/educational-python/Edu-Python/src/com/jetbrains/edu/learning/builtInServer/EduPythonProjectCreator.java new file mode 100644 index 000000000000..cac9d2333c32 --- /dev/null +++ b/python/educational-python/Edu-Python/src/com/jetbrains/edu/learning/builtInServer/EduPythonProjectCreator.java @@ -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; + } +}