Пример #1
0
  public void initAnswerPlaceholder(final TaskFile file, boolean isRestarted) {
    if (!isRestarted) {
      setInitialState(new MyInitialState(myOffset, length));
      myStatus = file.getTask().getStatus();
    }

    setTaskFile(file);
  }
 public void initAnswerPlaceholder(final TaskFile file, boolean isRestarted) {
   setTaskFile(file);
   if (!isRestarted) {
     setInitialState(new MyInitialState(myOffset, myLength));
     for (AnswerPlaceholderSubtaskInfo info : getSubtaskInfos().values()) {
       info.setStatus(file.getTask().getStatus());
     }
   }
 }
Пример #3
0
 @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
 public static VirtualFile flushWindows(TaskFile taskFile, VirtualFile file) {
   VirtualFile taskDir = file.getParent();
   VirtualFile fileWindows = null;
   final Document document = FileDocumentManager.getInstance().getDocument(file);
   if (document == null) {
     LOG.debug("Couldn't flush windows");
     return null;
   }
   if (taskDir != null) {
     String name = file.getNameWithoutExtension() + "_windows";
     PrintWriter printWriter = null;
     try {
       fileWindows = taskDir.createChildData(taskFile, name);
       printWriter = new PrintWriter(new FileOutputStream(fileWindows.getPath()));
       for (TaskWindow taskWindow : taskFile.getTaskWindows()) {
         if (!taskWindow.isValid(document)) {
           continue;
         }
         int start = taskWindow.getRealStartOffset(document);
         String windowDescription =
             document.getText(new TextRange(start, start + taskWindow.getLength()));
         printWriter.println("#study_plugin_window = " + windowDescription);
       }
       ApplicationManager.getApplication()
           .runWriteAction(
               new Runnable() {
                 @Override
                 public void run() {
                   FileDocumentManager.getInstance().saveDocument(document);
                 }
               });
     } catch (IOException e) {
       LOG.error(e);
     } finally {
       closeSilently(printWriter);
       synchronize();
     }
   }
   return fileWindows;
 }
Пример #4
0
 public void addTaskFile(@NotNull final String name, int index) {
   TaskFile taskFile = new TaskFile();
   taskFile.setIndex(index);
   task_files.put(name, taskFile);
 }
 public int getActiveSubtaskIndex() {
   if (myTaskFile == null || myTaskFile.getTask() == null) {
     return 0;
   }
   return myTaskFile.getTask().getActiveSubtaskIndex();
 }