mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
The extension point for a project creator
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
<extensionPoint qualifiedName="Edu.optionsProvider" beanClass="com.jetbrains.edu.learning.settings.StudyOptionsProviderEP">
|
||||
<with attribute="instance" implements="com.jetbrains.edu.learning.settings.StudyOptionsProvider"/>
|
||||
</extensionPoint>
|
||||
<extensionPoint qualifiedName="Edu.eduProjectCreator" interface="com.jetbrains.edu.learning.builtInServer.EduProjectCreator"/>
|
||||
</extensionPoints>
|
||||
|
||||
<actions>
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.jetbrains.edu.learning.courseFormat.Course;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author meanmail
|
||||
*/
|
||||
public class EduProjectCreator {
|
||||
public static final ExtensionPointName<EduProjectCreator> EP_NAME = ExtensionPointName.create("Edu.eduProjectCreator");
|
||||
|
||||
public static boolean createProject(@NotNull Course course) {
|
||||
EduProjectCreator[] extensions = Extensions.getExtensions(EP_NAME);
|
||||
|
||||
for (EduProjectCreator projectCreator : extensions) {
|
||||
if (projectCreator.canCreateProject(course)) {
|
||||
return projectCreator.createCourseProject(course);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean createCourseProject(@NotNull Course course) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canCreateProject(@NotNull Course course) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+15
@@ -28,6 +28,7 @@ import com.intellij.openapi.wm.WindowManager;
|
||||
import com.jetbrains.edu.learning.StudyTaskManager;
|
||||
import com.jetbrains.edu.learning.courseFormat.Course;
|
||||
import com.jetbrains.edu.learning.courseFormat.RemoteCourse;
|
||||
import com.jetbrains.edu.learning.intellij.generation.EduProjectGenerator;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpMethod;
|
||||
@@ -44,6 +45,7 @@ import org.jetbrains.ide.RestService;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -197,6 +199,19 @@ public class StepikRestService extends RestService {
|
||||
}
|
||||
|
||||
private static boolean createProjectAndOpen(int courseId) {
|
||||
EduProjectGenerator generator = new EduProjectGenerator();
|
||||
Project defaultProject = ProjectManager.getInstance().getDefaultProject();
|
||||
String title = "Getting Available Courses";
|
||||
List<Course> availableCourses = new ArrayList<>();
|
||||
ApplicationManager.getApplication().invokeAndWait(() -> {
|
||||
List<Course> courses = generator.getCoursesUnderProgress(true, title, defaultProject);
|
||||
availableCourses.addAll(courses);
|
||||
});
|
||||
for (Course course : availableCourses) {
|
||||
if (course instanceof RemoteCourse && ((RemoteCourse)course).getId() == courseId) {
|
||||
return EduProjectCreator.createProject(course);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user