EDU-950 Exception on first open when creating a project

This commit is contained in:
Ekaterina Tuzova
2017-05-18 12:20:02 +03:00
parent ce0c8252a8
commit 683d92686a
5 changed files with 16 additions and 20 deletions
@@ -1,17 +1,18 @@
package com.jetbrains.edu.coursecreator.actions;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.jetbrains.edu.learning.StudySettings;
public class CCPluginToggleAction extends ToggleAction {
public static final String COURSE_CREATOR_ENABLED = "Edu.CourseCreator.Enabled";
@Override
public boolean isSelected(AnActionEvent e) {
return StudySettings.getInstance().isCourseCreatorEnabled();
return PropertiesComponent.getInstance().getBoolean(COURSE_CREATOR_ENABLED);
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
StudySettings.getInstance().setCourseCreatorEnabled(state);
PropertiesComponent.getInstance().setValue(COURSE_CREATOR_ENABLED, state);
}
}
@@ -1,13 +1,15 @@
package com.jetbrains.edu.coursecreator.settings;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.wm.IdeFocusManager;
import com.jetbrains.edu.learning.StudySettings;
import com.jetbrains.edu.learning.settings.StudyOptionsProvider;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import static com.jetbrains.edu.coursecreator.actions.CCPluginToggleAction.COURSE_CREATOR_ENABLED;
public class CCOptions implements StudyOptionsProvider {
private JRadioButton myHtmlRadioButton;
private JRadioButton myMarkdownRadioButton;
@@ -16,7 +18,7 @@ public class CCOptions implements StudyOptionsProvider {
@Nullable
@Override
public JComponent createComponent() {
if (!StudySettings.getInstance().isCourseCreatorEnabled()) return null;
if (!PropertiesComponent.getInstance().getBoolean(COURSE_CREATOR_ENABLED)) return null;
if (CCSettings.getInstance().useHtmlAsDefaultTaskFormat()) {
myHtmlRadioButton.setSelected(true);
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(
@@ -17,7 +17,6 @@ public class StudySettings implements PersistentStateComponent<StudySettings> {
private StepicUser myUser;
public long LAST_TIME_CHECKED = 0;
private boolean myEnableTestingFromSamples = false;
private boolean isCourseCreatorEnabled = false;
public StudySettings() {
}
@@ -72,15 +71,6 @@ public class StudySettings implements PersistentStateComponent<StudySettings> {
ApplicationManager.getApplication().getMessageBus().syncPublisher(SETTINGS_CHANGED).settingsChanged();
}
public boolean isCourseCreatorEnabled() {
return isCourseCreatorEnabled;
}
public void setCourseCreatorEnabled(boolean courseCreatorEnabled) {
isCourseCreatorEnabled = courseCreatorEnabled;
ApplicationManager.getApplication().getMessageBus().syncPublisher(SETTINGS_CHANGED).settingsChanged();
}
@FunctionalInterface
public interface StudySettingsListener {
void settingsChanged();
@@ -1,13 +1,15 @@
package com.jetbrains.edu.coursecreator;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.ide.util.projectWizard.AbstractNewProjectDialog;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.Presentation;
import com.jetbrains.edu.learning.StudySettings;
import icons.EducationalCoreIcons;
import static com.jetbrains.edu.coursecreator.actions.CCPluginToggleAction.COURSE_CREATOR_ENABLED;
public class PyCCCreateCourseAction extends AnAction {
public PyCCCreateCourseAction() {
super("Create New Course", "Create New Course", EducationalCoreIcons.EducationalProjectType);
@@ -27,6 +29,6 @@ public class PyCCCreateCourseAction extends AnAction {
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
presentation.setEnabledAndVisible(StudySettings.getInstance().isCourseCreatorEnabled());
presentation.setEnabledAndVisible(PropertiesComponent.getInstance().getBoolean(COURSE_CREATOR_ENABLED));
}
}
@@ -1,8 +1,8 @@
package com.jetbrains.python.edu;
import com.intellij.ide.customize.AbstractCustomizeWizardStep;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.ui.VerticalFlowLayout;
import com.jetbrains.edu.learning.StudySettings;
import icons.PythonEducationalIcons;
import javax.swing.*;
@@ -11,6 +11,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class CustomizeEduStepPanel extends AbstractCustomizeWizardStep {
static final String COURSE_CREATOR_ENABLED = "Edu.CourseCreator.Enabled";
public CustomizeEduStepPanel() {
int iconSize = 180;
@@ -20,7 +21,7 @@ public class CustomizeEduStepPanel extends AbstractCustomizeWizardStep {
student.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
StudySettings.getInstance().setCourseCreatorEnabled(false);
PropertiesComponent.getInstance().setValue(COURSE_CREATOR_ENABLED, false);
}
});
studentPanel.add(student);
@@ -35,7 +36,7 @@ public class CustomizeEduStepPanel extends AbstractCustomizeWizardStep {
teacher.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
StudySettings.getInstance().setCourseCreatorEnabled(true);
PropertiesComponent.getInstance().setValue(COURSE_CREATOR_ENABLED, true);
}
});
add(teacherPanel);