mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix EDU-577 Set switch task panel action invisible in non-edu projects, save in TaskManager what panel to show after switch
This commit is contained in:
-12
@@ -52,9 +52,6 @@ public class StudyProjectComponent implements ProjectComponent {
|
||||
private static final Logger LOG = Logger.getInstance(StudyProjectComponent.class.getName());
|
||||
private final Project myProject;
|
||||
private FileCreatedByUserListener myListener;
|
||||
|
||||
// Shows could we use JavaFX Task Description panel or should use Swing
|
||||
private boolean useJavaFx = false;
|
||||
private Map<Keymap, List<Pair<String, String>>> myDeletedShortcuts = new HashMap<Keymap, List<Pair<String, String>>>();
|
||||
private StudyProjectComponent(@NotNull final Project project) {
|
||||
myProject = project;
|
||||
@@ -66,7 +63,6 @@ public class StudyProjectComponent implements ProjectComponent {
|
||||
// Check if user has javafx lib in his JDK. Now bundled JDK doesn't have this lib inside.
|
||||
if (StudyUtils.hasJavaFx()) {
|
||||
Platform.setImplicitExit(false);
|
||||
useJavaFx = true;
|
||||
}
|
||||
|
||||
if (course != null && !course.isUpToDate()) {
|
||||
@@ -284,14 +280,6 @@ public class StudyProjectComponent implements ProjectComponent {
|
||||
return module.getComponent(StudyProjectComponent.class);
|
||||
}
|
||||
|
||||
public boolean useJavaFx() {
|
||||
return useJavaFx;
|
||||
}
|
||||
|
||||
public void setUseJavaFx(boolean useJavaFx) {
|
||||
this.useJavaFx = useJavaFx;
|
||||
}
|
||||
|
||||
private class FileCreatedByUserListener extends VirtualFileAdapter {
|
||||
@Override
|
||||
public void fileCreated(@NotNull VirtualFileEvent event) {
|
||||
|
||||
+11
-1
@@ -37,6 +37,7 @@ public class StudyTaskManager implements PersistentStateComponent<Element>, Dumb
|
||||
public Map<TaskFile, StudyStatus> myTaskStatusMap = new HashMap<>();
|
||||
public Map<Task, List<UserTest>> myUserTests = new HashMap<>();
|
||||
public List<String> myInvisibleFiles = new ArrayList<>();
|
||||
public boolean myShouldUseJavaFx = StudyUtils.hasJavaFx();
|
||||
|
||||
private StudyTaskManager() {
|
||||
}
|
||||
@@ -70,7 +71,7 @@ public class StudyTaskManager implements PersistentStateComponent<Element>, Dumb
|
||||
@NotNull
|
||||
public List<UserTest> getUserTests(@NotNull final Task task) {
|
||||
final List<UserTest> userTests = myUserTests.get(task);
|
||||
return userTests != null ? userTests : Collections.<UserTest>emptyList();
|
||||
return userTests != null ? userTests : Collections.emptyList();
|
||||
}
|
||||
|
||||
public void removeUserTest(@NotNull final Task task, @NotNull final UserTest userTest) {
|
||||
@@ -207,6 +208,7 @@ public class StudyTaskManager implements PersistentStateComponent<Element>, Dumb
|
||||
myInvisibleFiles = taskManager.myInvisibleFiles;
|
||||
myTaskStatusMap = taskManager.myTaskStatusMap;
|
||||
myStudyStatusMap = taskManager.myStudyStatusMap;
|
||||
myShouldUseJavaFx = taskManager.myShouldUseJavaFx;
|
||||
}
|
||||
}
|
||||
final Element oldCourseElement = state.getChild(COURSE_ELEMENT);
|
||||
@@ -250,4 +252,12 @@ public class StudyTaskManager implements PersistentStateComponent<Element>, Dumb
|
||||
public boolean isInvisibleFile(String path) {
|
||||
return myInvisibleFiles.contains(path);
|
||||
}
|
||||
|
||||
public boolean shouldUseJavaFx() {
|
||||
return myShouldUseJavaFx;
|
||||
}
|
||||
|
||||
public void setShouldUseJavaFx(boolean shouldUseJavaFx) {
|
||||
this.myShouldUseJavaFx = shouldUseJavaFx;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-3
@@ -5,7 +5,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.ComboBox
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.jetbrains.edu.learning.StudyProjectComponent
|
||||
import com.jetbrains.edu.learning.StudyTaskManager
|
||||
import com.jetbrains.edu.learning.StudyUtils
|
||||
import javax.swing.DefaultComboBoxModel
|
||||
import javax.swing.JComponent
|
||||
@@ -45,7 +45,8 @@ class StudySwitchTaskPanelAction: AnAction() {
|
||||
}
|
||||
comboBoxModel.addElement(SWING_ITEM)
|
||||
|
||||
comboBoxModel.selectedItem = if (StudyProjectComponent.getInstance(project).useJavaFx()) JAVAFX_ITEM else SWING_ITEM
|
||||
comboBoxModel.selectedItem =
|
||||
if (StudyUtils.hasJavaFx() && StudyTaskManager.getInstance(project).shouldUseJavaFx()) JAVAFX_ITEM else SWING_ITEM
|
||||
myComboBox.model = comboBoxModel
|
||||
title = "Switch Task Description Panel"
|
||||
myComboBox.setMinimumAndPreferredWidth(250)
|
||||
@@ -67,7 +68,13 @@ class StudySwitchTaskPanelAction: AnAction() {
|
||||
|
||||
override fun doOKAction() {
|
||||
super.doOKAction()
|
||||
StudyProjectComponent.getInstance(myProject).setUseJavaFx(myComboBox.selectedItem == JAVAFX_ITEM)
|
||||
StudyTaskManager.getInstance(myProject).setShouldUseJavaFx(myComboBox.selectedItem == JAVAFX_ITEM)
|
||||
}
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent?) {
|
||||
if (e != null) {
|
||||
StudyUtils.updateAction(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -7,9 +7,9 @@ import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowFactory;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.jetbrains.edu.learning.courseFormat.Course;
|
||||
import com.jetbrains.edu.learning.StudyProjectComponent;
|
||||
import com.jetbrains.edu.learning.StudyTaskManager;
|
||||
import com.jetbrains.edu.learning.StudyUtils;
|
||||
import com.jetbrains.edu.learning.courseFormat.Course;
|
||||
import icons.InteractiveLearningIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class StudyToolWindowFactory implements ToolWindowFactory, DumbAware {
|
||||
if (course != null) {
|
||||
|
||||
final StudyToolWindow studyToolWindow;
|
||||
if (StudyProjectComponent.getInstance(project).useJavaFx()) {
|
||||
if (StudyUtils.hasJavaFx() && StudyTaskManager.getInstance(project).shouldUseJavaFx()) {
|
||||
studyToolWindow = new StudyJavaFxToolWindow();
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user