EDU-210 set course name as course archive name
authorLiana Bakradze <liana.bakradze@jetbrains.com>
Mon, 27 Jul 2015 09:58:27 +0000 (12:58 +0300)
committerLiana Bakradze <liana.bakradze@jetbrains.com>
Mon, 27 Jul 2015 09:58:27 +0000 (12:58 +0300)
python/educational/course-creator/src/com/jetbrains/edu/coursecreator/ui/CreateCourseArchiveDialog.java
python/educational/course-creator/src/com/jetbrains/edu/coursecreator/ui/CreateCourseArchivePanel.java

index 6412f30b99e0b514b30cd6249a36408cd82cd320..0707be045e75c8fedb6bd021cecf96852a3fb80e 100644 (file)
@@ -2,6 +2,8 @@ package com.jetbrains.edu.coursecreator.ui;
 
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.DialogWrapper;
+import com.jetbrains.edu.courseFormat.Course;
+import com.jetbrains.edu.coursecreator.CCProjectService;
 import com.jetbrains.edu.coursecreator.actions.CCCreateCourseArchive;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -15,8 +17,10 @@ public class CreateCourseArchiveDialog extends DialogWrapper {
 
   public CreateCourseArchiveDialog(@NotNull final  Project project, CCCreateCourseArchive action) {
     super(project);
+    Course course = CCProjectService.getInstance(project).getCourse();
+    assert course != null;
     setTitle("Create Course Archive");
-    myPanel = new CreateCourseArchivePanel(project, this);
+    myPanel = new CreateCourseArchivePanel(project, this, course.getName());
     myAction = action;
     init();
   }
index 1d0cc01dfcd3d8865bd4c8b2621873249a089086..3f22f5950dd54ac5bbc8b39473577ddcfb21aa10 100644 (file)
@@ -5,6 +5,7 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.TextFieldWithBrowseButton;
+import com.intellij.openapi.util.io.FileUtil;
 import com.jetbrains.edu.EduNames;
 import org.jetbrains.annotations.NotNull;
 
@@ -22,13 +23,14 @@ public class CreateCourseArchivePanel extends JPanel {
   private JLabel myErrorLabel;
   private CreateCourseArchiveDialog myDlg;
 
-  public CreateCourseArchivePanel(@NotNull final Project project, CreateCourseArchiveDialog dlg) {
+  public CreateCourseArchivePanel(@NotNull final Project project, CreateCourseArchiveDialog dlg, String name) {
     setLayout(new BorderLayout());
     add(myPanel, BorderLayout.CENTER);
     myErrorIcon.setIcon(AllIcons.Actions.Lightning);
     setState(false);
     myDlg = dlg;
-    myNameField.setText(EduNames.COURSE);
+    String sanitizedName = FileUtil.sanitizeFileName(name);
+    myNameField.setText(sanitizedName.startsWith("_") ? EduNames.COURSE : sanitizedName);
     myLocationField.setText(project.getBasePath());
     FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
     myLocationField.addBrowseFolderListener("Choose location folder", null, project, descriptor);